2007-08-27 [colin] 2.10.0cvs179
[claws.git] / src / quote_fmt_parse.y
blob35afce7b4f004c015a13fe764d590bfa0cbca743
1 /*
2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "defs.h"
24 #include <glib.h>
25 #include <glib/gi18n.h>
27 #include <ctype.h>
29 #include "procmsg.h"
30 #include "procmime.h"
31 #include "utils.h"
32 #include "codeconv.h"
33 #include "procheader.h"
34 #include "addr_compl.h"
35 #include "gtk/inputdialog.h"
37 #include "quote_fmt.h"
38 #include "quote_fmt_lex.h"
40 /* decl */
42 flex quote_fmt.l
43 bison -p quote_fmt quote_fmt.y
46 int yylex(void);
48 static MsgInfo *msginfo = NULL;
49 static PrefsAccount *account = NULL;
50 #ifdef USE_ASPELL
51 static gchar default_dictionary[BUFFSIZE];
52 #endif
53 static gboolean *visible = NULL;
54 static gboolean dry_run = FALSE;
55 static gint maxsize = 0;
56 static gint stacksize = 0;
57 static GHashTable *var_table = NULL;
59 typedef struct st_buffer
61 gchar *buffer;
62 gint bufsize;
63 gint bufmax;
64 } st_buffer;
66 static struct st_buffer main_expr = { NULL, 0, 0 };
67 static struct st_buffer sub_expr = { NULL, 0, 0 };
68 static struct st_buffer* current = NULL;
70 static const gchar *quote_str = NULL;
71 static const gchar *body = NULL;
72 static gint error = 0;
74 static gint cursor_pos = -1;
76 extern int quote_fmt_firsttime;
77 extern int line;
79 static void add_visibility(gboolean val)
81 stacksize++;
82 if (maxsize < stacksize) {
83 maxsize += 128;
84 visible = g_realloc(visible, maxsize * sizeof(gboolean));
85 if (visible == NULL)
86 maxsize = 0;
89 visible[stacksize - 1] = val;
92 static void remove_visibility(void)
94 stacksize--;
95 if (stacksize < 0) {
96 g_warning("Error: visibility stack underflow\n");
97 stacksize = 0;
101 static void add_buffer(const gchar *s)
103 gint len;
105 if (s == NULL)
106 return;
108 len = strlen(s);
109 if (current->bufsize + len + 1 > current->bufmax) {
110 if (current->bufmax == 0)
111 current->bufmax = 128;
112 while (current->bufsize + len + 1 > current->bufmax)
113 current->bufmax *= 2;
114 current->buffer = g_realloc(current->buffer, current->bufmax);
116 strcpy(current->buffer + current->bufsize, s);
117 current->bufsize += len;
120 static void clear_buffer(void)
122 if (current->buffer)
123 *current->buffer = '\0';
124 else
125 /* force to an empty string, as buffer should not be left unallocated */
126 add_buffer("");
127 current->bufsize = 0;
130 gchar *quote_fmt_get_buffer(void)
132 if (current != &main_expr)
133 g_warning("Error: parser still in sub-expr mode\n");
135 if (error != 0)
136 return NULL;
137 else
138 return current->buffer;
141 gint quote_fmt_get_line(void)
143 return line;
146 gint quote_fmt_get_cursor_pos(void)
148 return cursor_pos;
151 #define INSERT(buf) \
152 if (stacksize != 0 && visible[stacksize - 1])\
153 add_buffer(buf); \
155 #define INSERT_CHARACTER(chr) \
156 if (stacksize != 0 && visible[stacksize - 1]) { \
157 gchar tmp[2]; \
158 tmp[0] = (chr); \
159 tmp[1] = '\0'; \
160 add_buffer(tmp); \
163 void quote_fmt_reset_vartable(void)
165 if (var_table) {
166 g_hash_table_destroy(var_table);
167 var_table = NULL;
171 #ifdef USE_ASPELL
172 void quote_fmt_init(MsgInfo *info, const gchar *my_quote_str,
173 const gchar *my_body, gboolean my_dry_run,
174 PrefsAccount *compose_account,
175 GtkAspell *compose_gtkaspell)
176 #else
177 void quote_fmt_init(MsgInfo *info, const gchar *my_quote_str,
178 const gchar *my_body, gboolean my_dry_run,
179 PrefsAccount *compose_account)
180 #endif
182 quote_str = my_quote_str;
183 body = my_body;
184 msginfo = info;
185 account = compose_account;
186 #ifdef USE_ASPELL
187 gchar *dict = gtkaspell_get_default_dictionary(compose_gtkaspell);
188 if (dict)
189 strncpy2(default_dictionary, dict, sizeof(default_dictionary));
190 else
191 *default_dictionary = '\0';
192 #endif
193 dry_run = my_dry_run;
194 stacksize = 0;
195 add_visibility(TRUE);
196 main_expr.bufmax = 0;
197 sub_expr.bufmax = 0;
198 current = &main_expr;
199 clear_buffer();
200 error = 0;
201 line = 1;
203 if (!var_table)
204 var_table = g_hash_table_new_full(g_str_hash, g_str_equal,
205 g_free, g_free);
208 * force LEX initialization
210 quote_fmt_firsttime = 1;
211 cursor_pos = -1;
214 void quote_fmterror(char *str)
216 g_warning("Error: %s at line %d\n", str, line);
217 error = 1;
220 int quote_fmtwrap(void)
222 return 1;
225 static int isseparator(int ch)
227 return g_ascii_isspace(ch) || ch == '.' || ch == '-';
230 static void quote_fmt_show_date(const MsgInfo *msginfo, const gchar *format)
232 char result[100];
233 char *rptr;
234 char zone[6];
235 struct tm lt;
236 const char *fptr;
237 const char *zptr;
239 if (!msginfo->date)
240 return;
243 * ALF - GNU C's strftime() has a nice format specifier
244 * for time zone offset (%z). Non-standard however, so
245 * emulate it.
248 #define RLEFT (sizeof result) - (rptr - result)
249 #define STR_SIZE(x) (sizeof (x) - 1)
251 zone[0] = 0;
253 if (procheader_date_parse_to_tm(msginfo->date, &lt, zone)) {
255 * break up format string in tiny bits delimited by valid %z's and
256 * feed it to strftime(). don't forget that '%%z' mean literal '%z'.
258 for (rptr = result, fptr = format; fptr && *fptr && rptr < &result[sizeof result - 1];) {
259 int perc;
260 const char *p;
261 char *tmp;
263 if (NULL != (zptr = strstr(fptr, "%z"))) {
265 * count nr. of prepended percent chars
267 for (perc = 0, p = zptr; p && p >= format && *p == '%'; p--, perc++)
270 * feed to strftime()
272 tmp = g_strndup(fptr, zptr - fptr + (perc % 2 ? 0 : STR_SIZE("%z")));
273 if (tmp) {
274 rptr += strftime(rptr, RLEFT, tmp, &lt);
275 g_free(tmp);
278 * append time zone offset
280 if (zone[0] && perc % 2)
281 rptr += g_snprintf(rptr, RLEFT, "%s", zone);
282 fptr = zptr + STR_SIZE("%z");
283 } else {
284 rptr += strftime(rptr, RLEFT, fptr, &lt);
285 fptr = NULL;
289 if (g_utf8_validate(result, -1, NULL)) {
290 INSERT(result);
291 } else {
292 gchar *utf = conv_codeset_strdup(result,
293 conv_get_locale_charset_str_no_utf8(),
294 CS_INTERNAL);
295 if (utf == NULL ||
296 !g_utf8_validate(utf, -1, NULL)) {
297 g_free(utf);
298 utf = g_malloc(strlen(result)*2+1);
299 conv_localetodisp(utf,
300 strlen(result)*2+1, result);
302 if (g_utf8_validate(utf, -1, NULL)) {
303 INSERT(utf);
305 g_free(utf);
308 #undef STR_SIZE
309 #undef RLEFT
312 static void quote_fmt_show_first_name(const MsgInfo *msginfo)
314 guchar *p;
315 gchar *str;
317 if (!msginfo->fromname)
318 return;
320 p = (guchar*)strchr(msginfo->fromname, ',');
321 if (p != NULL) {
322 /* fromname is like "Duck, Donald" */
323 p++;
324 while (*p && isspace(*p)) p++;
325 str = alloca(strlen((char *)p) + 1);
326 if (str != NULL) {
327 strcpy(str, (char *)p);
328 INSERT(str);
330 } else {
331 /* fromname is like "Donald Duck" */
332 str = alloca(strlen(msginfo->fromname) + 1);
333 if (str != NULL) {
334 strcpy(str, msginfo->fromname);
335 p = (guchar *)str;
336 while (*p && !isspace(*p)) p++;
337 *p = '\0';
338 INSERT(str);
343 static void quote_fmt_show_last_name(const MsgInfo *msginfo)
345 gchar *p;
346 gchar *str;
348 /* This probably won't work together very well with Middle
349 names and the like - thth */
350 if (!msginfo->fromname)
351 return;
353 str = alloca(strlen(msginfo->fromname) + 1);
354 if (str != NULL) {
355 strcpy(str, msginfo->fromname);
356 p = strchr(str, ',');
357 if (p != NULL) {
358 /* fromname is like "Duck, Donald" */
359 *p = '\0';
360 INSERT(str);
361 } else {
362 /* fromname is like "Donald Duck" */
363 p = str;
364 while (*p && !isspace(*p)) p++;
365 if (*p) {
366 /* We found a space. Get first
367 none-space char and insert
368 rest of string from there. */
369 while (*p && isspace(*p)) p++;
370 if (*p) {
371 INSERT(p);
372 } else {
373 /* If there is no none-space
374 char, just insert whole
375 fromname. */
376 INSERT(str);
378 } else {
379 /* If there is no space, just
380 insert whole fromname. */
381 INSERT(str);
387 static void quote_fmt_show_sender_initial(const MsgInfo *msginfo)
389 #define MAX_SENDER_INITIAL 20
390 gchar tmp[MAX_SENDER_INITIAL];
391 guchar *p;
392 gchar *cur;
393 gint len = 0;
395 if (!msginfo->fromname)
396 return;
398 p = (guchar *)msginfo->fromname;
399 cur = tmp;
400 while (*p) {
401 if (*p && g_utf8_validate((gchar *)p, 1, NULL)) {
402 *cur = toupper(*p);
403 cur++;
404 len++;
405 if (len >= MAX_SENDER_INITIAL - 1)
406 break;
407 } else
408 break;
409 while (*p && !isseparator(*p)) p++;
410 while (*p && isseparator(*p)) p++;
412 *cur = '\0';
413 INSERT(tmp);
416 static void quote_fmt_show_msg(MsgInfo *msginfo, const gchar *body,
417 gboolean quoted, gboolean signature,
418 const gchar *quote_str)
420 gchar buf[BUFFSIZE];
421 FILE *fp;
423 if (!(msginfo->folder || body))
424 return;
426 if (body)
427 fp = str_open_as_stream(body);
428 else {
429 if (MSG_IS_ENCRYPTED(msginfo->flags))
430 fp = procmime_get_first_encrypted_text_content(msginfo);
431 else
432 fp = procmime_get_first_text_content(msginfo);
435 if (fp == NULL)
436 g_warning("Can't get text part\n");
437 else {
438 while (fgets(buf, sizeof(buf), fp) != NULL) {
439 strcrchomp(buf);
441 if (!signature && strncmp(buf, "-- \n", 4) == 0)
442 break;
444 if (quoted && quote_str)
445 INSERT(quote_str);
447 INSERT(buf);
449 fclose(fp);
453 static void quote_fmt_insert_file(const gchar *filename)
455 FILE *file;
456 char buffer[256];
458 if ((file = g_fopen(filename, "rb")) != NULL) {
459 while (fgets(buffer, sizeof(buffer), file)) {
460 INSERT(buffer);
462 fclose(file);
467 static void quote_fmt_insert_program_output(const gchar *progname)
469 FILE *file;
470 char buffer[256];
472 if ((file = popen(progname, "r")) != NULL) {
473 while (fgets(buffer, sizeof(buffer), file)) {
474 INSERT(buffer);
476 pclose(file);
480 static void quote_fmt_insert_user_input(const gchar *varname)
482 gchar *buf = NULL;
483 gchar *text = NULL;
485 if (dry_run)
486 return;
488 if ((text = g_hash_table_lookup(var_table, varname)) == NULL) {
489 buf = g_strdup_printf(_("Enter text to replace '%s'"), varname);
490 text = input_dialog(_("Enter variable"), buf, "");
491 g_free(buf);
492 if (!text)
493 return;
494 g_hash_table_insert(var_table, g_strdup(varname), g_strdup(text));
495 } else {
496 /* don't free the one in hashtable at the end */
497 text = g_strdup(text);
500 if (!text)
501 return;
502 INSERT(text);
503 g_free(text);
506 static gchar *quote_fmt_complete_address(const gchar *addr)
508 gint count;
509 gchar *res, *tmp, *email_addr;
510 gchar **split;
512 debug_print("quote_fmt_complete_address: %s\n", addr);
513 if (addr == NULL)
514 return NULL;
516 /* if addr is a list of message, try the 1st element only */
517 split = g_strsplit(addr, ",", -1);
518 if (!split || !split[0] || *split[0] == '\0') {
519 g_strfreev(split);
520 return NULL;
523 Xstrdup_a(email_addr, split[0], return NULL);
524 extract_address(email_addr);
525 if (!*email_addr) {
526 g_strfreev(split);
527 return NULL;
530 res = NULL;
531 start_address_completion(NULL);
532 if (1 < (count = complete_address(email_addr))) {
533 tmp = get_complete_address(1);
534 res = procheader_get_fromname(tmp);
535 g_free(tmp);
537 end_address_completion();
538 g_strfreev(split);
540 debug_print("quote_fmt_complete_address: matched %s\n", res);
541 return res;
546 %union {
547 char chr;
548 char str[256];
551 /* tokens SHOW */
552 %token SHOW_NEWSGROUPS
553 %token SHOW_DATE SHOW_FROM SHOW_FULLNAME SHOW_FIRST_NAME SHOW_LAST_NAME
554 %token SHOW_SENDER_INITIAL SHOW_SUBJECT SHOW_TO SHOW_MESSAGEID
555 %token SHOW_PERCENT SHOW_CC SHOW_REFERENCES SHOW_MESSAGE
556 %token SHOW_QUOTED_MESSAGE SHOW_BACKSLASH SHOW_TAB SHOW_MAIL_ADDRESS
557 %token SHOW_QUOTED_MESSAGE_NO_SIGNATURE SHOW_MESSAGE_NO_SIGNATURE
558 %token SHOW_EOL SHOW_QUESTION_MARK SHOW_EXCLAMATION_MARK SHOW_PIPE SHOW_OPARENT SHOW_CPARENT
559 %token SHOW_ACCOUNT_FULL_NAME SHOW_ACCOUNT_MAIL_ADDRESS SHOW_ACCOUNT_NAME SHOW_ACCOUNT_ORGANIZATION
560 %token SHOW_ACCOUNT_DICT
561 %token SHOW_DICT SHOW_TAGS
562 %token SHOW_ADDRESSBOOK_COMPLETION_FOR_CC
563 %token SHOW_ADDRESSBOOK_COMPLETION_FOR_FROM
564 %token SHOW_ADDRESSBOOK_COMPLETION_FOR_TO
565 /* tokens QUERY */
566 %token QUERY_DATE QUERY_FROM
567 %token QUERY_FULLNAME QUERY_SUBJECT QUERY_TO QUERY_NEWSGROUPS
568 %token QUERY_MESSAGEID QUERY_CC QUERY_REFERENCES
569 %token QUERY_ACCOUNT_FULL_NAME QUERY_ACCOUNT_ORGANIZATION QUERY_ACCOUNT_DICT
570 %token QUERY_DICT
571 %token QUERY_CC_FOUND_IN_ADDRESSBOOK
572 %token QUERY_FROM_FOUND_IN_ADDRESSBOOK
573 %token QUERY_TO_FOUND_IN_ADDRESSBOOK
574 /* tokens QUERY_NOT */
575 %token QUERY_NOT_DATE QUERY_NOT_FROM
576 %token QUERY_NOT_FULLNAME QUERY_NOT_SUBJECT QUERY_NOT_TO QUERY_NOT_NEWSGROUPS
577 %token QUERY_NOT_MESSAGEID QUERY_NOT_CC QUERY_NOT_REFERENCES
578 %token QUERY_NOT_ACCOUNT_FULL_NAME QUERY_NOT_ACCOUNT_ORGANIZATION QUERY_NOT_ACCOUNT_DICT
579 %token QUERY_NOT_DICT
580 %token QUERY_NOT_CC_FOUND_IN_ADDRESSBOOK
581 %token QUERY_NOT_FROM_FOUND_IN_ADDRESSBOOK
582 %token QUERY_NOT_TO_FOUND_IN_ADDRESSBOOK
583 /* other tokens */
584 %token INSERT_FILE INSERT_PROGRAMOUTPUT INSERT_USERINPUT
585 %token OPARENT CPARENT
586 %token CHARACTER
587 %token SHOW_DATE_EXPR
588 %token SET_CURSOR_POS
590 %start quote_fmt
592 %token <chr> CHARACTER
593 %type <chr> character
594 %type <str> string
598 quote_fmt:
599 character_or_special_or_insert_or_query_list ;
601 sub_expr:
602 character_or_special_list ;
604 character_or_special_or_insert_or_query_list:
605 character_or_special_or_insert_or_query character_or_special_or_insert_or_query_list
606 | character_or_special_or_insert_or_query ;
608 character_or_special_list:
609 character_or_special character_or_special_list
610 | character_or_special ;
612 character_or_special_or_insert_or_query:
613 character_or_special
614 | query
615 | query_not
616 | insert ;
618 character_or_special:
619 special
620 | character
622 INSERT_CHARACTER($1);
625 character:
626 CHARACTER
629 string:
630 CHARACTER
632 $$[0] = $1;
633 $$[1] = '\0';
635 | string CHARACTER
637 int len;
639 strncpy($$, $1, sizeof($$));
640 $$[sizeof($$) - 1] = '\0';
641 len = strlen($$);
642 if (len + 1 < sizeof($$)) {
643 $$[len + 1] = '\0';
644 $$[len] = $2;
648 special:
649 SHOW_NEWSGROUPS
651 if (msginfo->newsgroups)
652 INSERT(msginfo->newsgroups);
654 | SHOW_DATE_EXPR OPARENT string CPARENT
656 quote_fmt_show_date(msginfo, $3);
658 | SHOW_DATE
660 if (msginfo->date)
661 INSERT(msginfo->date);
663 | SHOW_FROM
665 if (msginfo->from)
666 INSERT(msginfo->from);
668 | SHOW_MAIL_ADDRESS
670 if (msginfo->from) {
671 gchar *stripped_address = g_strdup(msginfo->from);
672 extract_address(stripped_address);
673 INSERT(stripped_address);
674 g_free(stripped_address);
677 | SHOW_FULLNAME
679 if (msginfo->fromname)
680 INSERT(msginfo->fromname);
682 | SHOW_FIRST_NAME
684 quote_fmt_show_first_name(msginfo);
686 | SHOW_LAST_NAME
688 quote_fmt_show_last_name(msginfo);
690 | SHOW_SENDER_INITIAL
692 quote_fmt_show_sender_initial(msginfo);
694 | SHOW_SUBJECT
696 if (msginfo->subject)
697 INSERT(msginfo->subject);
699 | SHOW_TO
701 if (msginfo->to)
702 INSERT(msginfo->to);
704 | SHOW_MESSAGEID
706 if (msginfo->msgid)
707 INSERT(msginfo->msgid);
709 | SHOW_PERCENT
711 INSERT("%");
713 | SHOW_CC
715 if (msginfo->cc)
716 INSERT(msginfo->cc);
718 | SHOW_REFERENCES
720 GSList *item;
722 INSERT(msginfo->inreplyto);
723 for (item = msginfo->references; item != NULL; item = g_slist_next(item))
724 if (item->data)
725 INSERT(item->data);
727 | SHOW_MESSAGE
729 quote_fmt_show_msg(msginfo, body, FALSE, TRUE, quote_str);
731 | SHOW_QUOTED_MESSAGE
733 quote_fmt_show_msg(msginfo, body, TRUE, TRUE, quote_str);
735 | SHOW_MESSAGE_NO_SIGNATURE
737 quote_fmt_show_msg(msginfo, body, FALSE, FALSE, quote_str);
739 | SHOW_QUOTED_MESSAGE_NO_SIGNATURE
741 quote_fmt_show_msg(msginfo, body, TRUE, FALSE, quote_str);
743 | SHOW_ACCOUNT_FULL_NAME
745 if (account && account->name)
746 INSERT(account->name);
748 | SHOW_ACCOUNT_MAIL_ADDRESS
750 if (account && account->address)
751 INSERT(account->address);
753 | SHOW_ACCOUNT_NAME
755 if (account && account->account_name)
756 INSERT(account->account_name);
758 | SHOW_ACCOUNT_ORGANIZATION
760 if (account && account->organization)
761 INSERT(account->organization);
763 | SHOW_ACCOUNT_DICT
765 #ifdef USE_ASPELL
766 if (account && account->enable_default_dictionary) {
767 gchar *dictname = g_path_get_basename(account->default_dictionary);
768 INSERT(dictname);
769 g_free(dictname);
771 #endif
773 | SHOW_DICT
775 #ifdef USE_ASPELL
776 INSERT(default_dictionary);
777 #endif
779 | SHOW_TAGS
781 gchar *tags = procmsg_msginfo_get_tags_str(msginfo);
782 if (tags) {
783 INSERT(tags);
785 g_free(tags);
787 | SHOW_BACKSLASH
789 INSERT("\\");
791 | SHOW_TAB
793 INSERT("\t");
795 | SHOW_EOL
797 INSERT("\n");
799 | SHOW_QUESTION_MARK
801 INSERT("?");
803 | SHOW_EXCLAMATION_MARK
805 INSERT("!");
807 | SHOW_PIPE
809 INSERT("|");
811 | SHOW_OPARENT
813 INSERT("{");
815 | SHOW_CPARENT
817 INSERT("}");
819 | SET_CURSOR_POS
821 cursor_pos = current->bufsize;
823 | SHOW_ADDRESSBOOK_COMPLETION_FOR_CC
825 gchar *tmp = quote_fmt_complete_address(msginfo->cc);
826 if (tmp) {
827 INSERT(tmp);
828 g_free(tmp);
831 | SHOW_ADDRESSBOOK_COMPLETION_FOR_FROM
833 gchar *tmp = quote_fmt_complete_address(msginfo->from);
834 if (tmp) {
835 INSERT(tmp);
836 g_free(tmp);
839 | SHOW_ADDRESSBOOK_COMPLETION_FOR_TO
841 gchar *tmp = quote_fmt_complete_address(msginfo->to);
842 if (tmp) {
843 INSERT(tmp);
844 g_free(tmp);
848 query:
849 QUERY_DATE
851 add_visibility(msginfo->date != NULL);
853 OPARENT quote_fmt CPARENT
855 remove_visibility();
857 | QUERY_FROM
859 add_visibility(msginfo->from != NULL);
861 OPARENT quote_fmt CPARENT
863 remove_visibility();
865 | QUERY_FULLNAME
867 add_visibility(msginfo->fromname != NULL);
869 OPARENT quote_fmt CPARENT
871 remove_visibility();
873 | QUERY_SUBJECT
875 add_visibility(msginfo->subject != NULL);
877 OPARENT quote_fmt CPARENT
879 remove_visibility();
881 | QUERY_TO
883 add_visibility(msginfo->to != NULL);
885 OPARENT quote_fmt CPARENT
887 remove_visibility();
889 | QUERY_NEWSGROUPS
891 add_visibility(msginfo->newsgroups != NULL);
893 OPARENT quote_fmt CPARENT
895 remove_visibility();
897 | QUERY_MESSAGEID
899 add_visibility(msginfo->msgid != NULL);
901 OPARENT quote_fmt CPARENT
903 remove_visibility();
905 | QUERY_CC
907 add_visibility(msginfo->cc != NULL);
909 OPARENT quote_fmt CPARENT
911 remove_visibility();
913 | QUERY_REFERENCES
915 gboolean found;
916 GSList *item;
918 found = (msginfo->inreplyto != NULL);
919 for (item = msginfo->references; found == FALSE && item != NULL; item = g_slist_next(item))
920 if (item->data)
921 found = TRUE;
922 add_visibility(found == TRUE);
924 OPARENT quote_fmt CPARENT
926 remove_visibility();
928 | QUERY_ACCOUNT_FULL_NAME
930 add_visibility(account != NULL && account->name != NULL);
932 OPARENT quote_fmt CPARENT
934 remove_visibility();
936 | QUERY_ACCOUNT_ORGANIZATION
938 add_visibility(account != NULL && account->organization != NULL);
940 OPARENT quote_fmt CPARENT
942 remove_visibility();
944 | QUERY_ACCOUNT_DICT
946 #ifdef USE_ASPELL
947 add_visibility(account != NULL && account->enable_default_dictionary == TRUE &&
948 account->default_dictionary != NULL && *account->default_dictionary != '\0');
949 #else
950 add_visibility(FALSE);
951 #endif
953 OPARENT quote_fmt CPARENT
955 remove_visibility();
957 | QUERY_DICT
959 #ifdef USE_ASPELL
960 add_visibility(*default_dictionary != '\0');
961 #else
962 add_visibility(FALSE);
963 #endif
965 OPARENT quote_fmt CPARENT
967 remove_visibility();
969 | QUERY_CC_FOUND_IN_ADDRESSBOOK
971 gchar *tmp = quote_fmt_complete_address(msginfo->cc);
972 add_visibility(tmp != NULL && *tmp != '\0');
973 g_free(tmp);
975 OPARENT quote_fmt CPARENT
977 remove_visibility();
979 | QUERY_FROM_FOUND_IN_ADDRESSBOOK
981 gchar *tmp = quote_fmt_complete_address(msginfo->from);
982 add_visibility(tmp != NULL && *tmp != '\0');
983 g_free(tmp);
985 OPARENT quote_fmt CPARENT
987 remove_visibility();
989 | QUERY_TO_FOUND_IN_ADDRESSBOOK
991 gchar *tmp = quote_fmt_complete_address(msginfo->to);
992 add_visibility(tmp != NULL && *tmp != '\0');
993 g_free(tmp);
995 OPARENT quote_fmt CPARENT
997 remove_visibility();
1000 query_not:
1001 QUERY_NOT_DATE
1003 add_visibility(msginfo->date == NULL);
1005 OPARENT quote_fmt CPARENT
1007 remove_visibility();
1009 | QUERY_NOT_FROM
1011 add_visibility(msginfo->from == NULL);
1013 OPARENT quote_fmt CPARENT
1015 remove_visibility();
1017 | QUERY_NOT_FULLNAME
1019 add_visibility(msginfo->fromname == NULL);
1021 OPARENT quote_fmt CPARENT
1023 remove_visibility();
1025 | QUERY_NOT_SUBJECT
1027 add_visibility(msginfo->subject == NULL);
1029 OPARENT quote_fmt CPARENT
1031 remove_visibility();
1033 | QUERY_NOT_TO
1035 add_visibility(msginfo->to == NULL);
1037 OPARENT quote_fmt CPARENT
1039 remove_visibility();
1041 | QUERY_NOT_NEWSGROUPS
1043 add_visibility(msginfo->newsgroups == NULL);
1045 OPARENT quote_fmt CPARENT
1047 remove_visibility();
1049 | QUERY_NOT_MESSAGEID
1051 add_visibility(msginfo->msgid == NULL);
1053 OPARENT quote_fmt CPARENT
1055 remove_visibility();
1057 | QUERY_NOT_CC
1059 add_visibility(msginfo->cc == NULL);
1061 OPARENT quote_fmt CPARENT
1063 remove_visibility();
1065 | QUERY_NOT_REFERENCES
1067 gboolean found;
1068 GSList *item;
1070 found = (msginfo->inreplyto != NULL);
1071 for (item = msginfo->references; found == FALSE && item != NULL; item = g_slist_next(item))
1072 if (item->data)
1073 found = TRUE;
1074 add_visibility(found == FALSE);
1076 OPARENT quote_fmt CPARENT
1078 remove_visibility();
1080 | QUERY_NOT_ACCOUNT_FULL_NAME
1082 add_visibility(account == NULL || account->name == NULL);
1084 OPARENT quote_fmt CPARENT
1086 remove_visibility();
1088 | QUERY_NOT_ACCOUNT_ORGANIZATION
1090 add_visibility(account == NULL || account->organization == NULL);
1092 OPARENT quote_fmt CPARENT
1094 remove_visibility();
1096 | QUERY_NOT_ACCOUNT_DICT
1098 #ifdef USE_ASPELL
1099 add_visibility(account == NULL || account->enable_default_dictionary == FALSE
1100 || *account->default_dictionary == '\0');
1101 #else
1102 add_visibility(FALSE);
1103 #endif
1105 OPARENT quote_fmt CPARENT
1107 remove_visibility();
1109 | QUERY_NOT_DICT
1111 #ifdef USE_ASPELL
1112 add_visibility(*default_dictionary == '\0');
1113 #else
1114 add_visibility(FALSE);
1115 #endif
1117 OPARENT quote_fmt CPARENT
1119 remove_visibility();
1121 | QUERY_NOT_CC_FOUND_IN_ADDRESSBOOK
1123 gchar *tmp = quote_fmt_complete_address(msginfo->cc);
1124 add_visibility(tmp == NULL || *tmp == '\0');
1125 g_free(tmp);
1127 OPARENT quote_fmt CPARENT
1129 remove_visibility();
1131 | QUERY_NOT_FROM_FOUND_IN_ADDRESSBOOK
1133 gchar *tmp = quote_fmt_complete_address(msginfo->from);
1134 add_visibility(tmp == NULL || *tmp == '\0');
1135 g_free(tmp);
1137 OPARENT quote_fmt CPARENT
1139 remove_visibility();
1141 | QUERY_NOT_TO_FOUND_IN_ADDRESSBOOK
1143 gchar *tmp = quote_fmt_complete_address(msginfo->to);
1144 add_visibility(tmp == NULL || *tmp == '\0');
1145 g_free(tmp);
1147 OPARENT quote_fmt CPARENT
1149 remove_visibility();
1152 insert:
1153 INSERT_FILE
1155 current = &sub_expr;
1156 clear_buffer();
1158 OPARENT sub_expr CPARENT
1160 current = &main_expr;
1161 if (!dry_run) {
1162 quote_fmt_insert_file(sub_expr.buffer);
1165 | INSERT_PROGRAMOUTPUT
1167 current = &sub_expr;
1168 clear_buffer();
1170 OPARENT sub_expr CPARENT
1172 current = &main_expr;
1173 if (!dry_run) {
1174 quote_fmt_insert_program_output(sub_expr.buffer);
1177 | INSERT_USERINPUT
1179 current = &sub_expr;
1180 clear_buffer();
1182 OPARENT sub_expr CPARENT
1184 current = &main_expr;
1185 if (!dry_run) {
1186 quote_fmt_insert_user_input(sub_expr.buffer);