From 48a5427593a51404bebf706e1c4d9ff572fe2583 Mon Sep 17 00:00:00 2001 From: Tristan Chabredier Date: Tue, 10 Oct 2006 09:50:33 +0000 Subject: [PATCH] 2006-10-10 [wwp] 2.5.3cvs29 * src/compose.c * src/prefs_template.c * src/quote_fmt.c * src/quote_fmt.h * src/quote_fmt_lex.l * src/quote_fmt_parse.y Extend the quote parser a bit: allow to get access to basic (composing) account info. --- ChangeLog | 11 ++++++++ PATCHSETS | 1 + configure.ac | 2 +- src/compose.c | 12 ++++---- src/prefs_template.c | 2 +- src/quote_fmt.c | 8 ++++-- src/quote_fmt.h | 3 +- src/quote_fmt_lex.l | 8 ++++++ src/quote_fmt_parse.y | 64 ++++++++++++++++++++++++++++++++++++++++++- 9 files changed, 99 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 491ecf047..576f0e62a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2006-10-10 [wwp] 2.5.3cvs29 + + * src/compose.c + * src/prefs_template.c + * src/quote_fmt.c + * src/quote_fmt.h + * src/quote_fmt_lex.l + * src/quote_fmt_parse.y + Extend the quote parser a bit: allow to get access to + basic (composing) account info. + 2006-10-10 [colin] 2.5.3cvs28 * src/procheader.c diff --git a/PATCHSETS b/PATCHSETS index 7bd38318d..5fb4e64e5 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -1983,3 +1983,4 @@ ( cvs diff -u -r 1.654.2.2031 -r 1.654.2.2032 configure.ac; cvs diff -u -r 1.16.2.45 -r 1.16.2.46 src/msgcache.c; cvs diff -u -r 1.10.2.23 -r 1.10.2.24 src/prefs_gtk.c; ) > 2.5.3cvs26.patchset ( cvs diff -u -r 1.115.2.109 -r 1.115.2.110 src/main.c; cvs diff -u -r 1.10.2.24 -r 1.10.2.25 src/prefs_gtk.c; cvs diff -u -r 1.1.2.3 -r 1.1.2.4 src/plugins/pgpcore/pgp_viewer.c; cvs diff -u -r 1.1.2.29 -r 1.1.2.30 src/plugins/pgpcore/sgpgme.c; ) > 2.5.3cvs27.patchset ( cvs diff -u -r 1.47.2.34 -r 1.47.2.35 src/procheader.c; ) > 2.5.3cvs28.patchset +( cvs diff -u -r 1.382.2.313 -r 1.382.2.314 src/compose.c; cvs diff -u -r 1.12.2.31 -r 1.12.2.32 src/prefs_template.c; cvs diff -u -r 1.8.2.9 -r 1.8.2.10 src/quote_fmt.c; cvs diff -u -r 1.5.12.5 -r 1.5.12.6 src/quote_fmt.h; cvs diff -u -r 1.8.2.5 -r 1.8.2.6 src/quote_fmt_lex.l; cvs diff -u -r 1.22.2.23 -r 1.22.2.24 src/quote_fmt_parse.y; ) > 2.5.3cvs29.patchset diff --git a/configure.ac b/configure.ac index 21c21fad1..c24077b21 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=5 MICRO_VERSION=3 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=28 +EXTRA_VERSION=29 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/compose.c b/src/compose.c index b37aca554..68928ee2b 100644 --- a/src/compose.c +++ b/src/compose.c @@ -2371,7 +2371,7 @@ static gchar *compose_quote_fmt(Compose *compose, MsgInfo *msginfo, msginfo = &dummyinfo; if (qmark != NULL) { - quote_fmt_init(msginfo, NULL, NULL, FALSE); + quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account); quote_fmt_scan_string(qmark); quote_fmt_parse(); @@ -2387,7 +2387,7 @@ static gchar *compose_quote_fmt(Compose *compose, MsgInfo *msginfo, && trimmed_body[0]=='\n') *trimmed_body++; - quote_fmt_init(msginfo, quote_str, trimmed_body, FALSE); + quote_fmt_init(msginfo, quote_str, trimmed_body, FALSE, compose->account); quote_fmt_scan_string(fmt); quote_fmt_parse(); @@ -6643,7 +6643,7 @@ void compose_template_apply_fields(Compose *compose, Template *tmpl) msginfo = &dummyinfo; if (tmpl->to && *tmpl->to != '\0') { - quote_fmt_init(msginfo, NULL, NULL, FALSE); + quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account); quote_fmt_scan_string(tmpl->to); quote_fmt_parse(); @@ -6656,7 +6656,7 @@ void compose_template_apply_fields(Compose *compose, Template *tmpl) } if (tmpl->cc && *tmpl->cc != '\0') { - quote_fmt_init(msginfo, NULL, NULL, FALSE); + quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account); quote_fmt_scan_string(tmpl->cc); quote_fmt_parse(); @@ -6669,7 +6669,7 @@ void compose_template_apply_fields(Compose *compose, Template *tmpl) } if (tmpl->bcc && *tmpl->bcc != '\0') { - quote_fmt_init(msginfo, NULL, NULL, FALSE); + quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account); quote_fmt_scan_string(tmpl->bcc); quote_fmt_parse(); @@ -6683,7 +6683,7 @@ void compose_template_apply_fields(Compose *compose, Template *tmpl) /* process the subject */ if (tmpl->subject && *tmpl->subject != '\0') { - quote_fmt_init(msginfo, NULL, NULL, FALSE); + quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account); quote_fmt_scan_string(tmpl->subject); quote_fmt_parse(); diff --git a/src/prefs_template.c b/src/prefs_template.c index d792fc3fb..7953f55b1 100644 --- a/src/prefs_template.c +++ b/src/prefs_template.c @@ -508,7 +508,7 @@ static gboolean prefs_template_list_view_set_row(GtkTreeIter *row) MsgInfo dummyinfo; memset(&dummyinfo, 0, sizeof(MsgInfo)); - quote_fmt_init(&dummyinfo, NULL, NULL, TRUE); + quote_fmt_init(&dummyinfo, NULL, NULL, TRUE, NULL); quote_fmt_scan_string(value); quote_fmt_parse(); parsed_buf = quote_fmt_get_buffer(); diff --git a/src/quote_fmt.c b/src/quote_fmt.c index 6a2df4d46..99ba8f587 100644 --- a/src/quote_fmt.c +++ b/src/quote_fmt.c @@ -55,6 +55,10 @@ static gchar *quote_desc_strings[] = { "%m", N_("message body without signature"), /* message with no signature */ "%q", N_("quoted message body without signature"), /* quoted message with no signature */ "%X", N_("cursor position"), /* X marks the cursor spot */ + "%af", N_("compose account: full name"), /* full name in compose account */ + "%am", N_("compose account: mail address"), /* mail address in compose account */ + "%an", N_("compose account name itself"), /* compose account name itself */ + "%ao", N_("compose account: organization"), /* organization in compose account */ "\\%", N_("literal %"), "\\\\", N_("literal backslash"), "\\?", N_("literal question mark"), @@ -65,8 +69,8 @@ static gchar *quote_desc_strings[] = { "\\t", N_("tab"), "\\n", N_("linefeed"), "", NULL, - "?x{expr}\n", N_("insert expr if x is set\n(where x is one of the dfNFLIstcnri characters)"), - "!x{expr}\n", N_("insert expr if x is not set\n(where x is one of the dfNFLIstcnri characters)"), + "?x{expr}\n", N_("insert expr if x is set\n(where x is one of the dfNFLIstcnri characters or af, ao"), + "!x{expr}\n", N_("insert expr if x is not set\n(where x is one of the dfNFLIstcnri characters or af, ao)"), "|f{sub_expr}\n", N_("insert file:\nsub_expr is evaluated as a filename to insert"), /* insert file */ "|p{sub_expr}\n\n", N_("insert program output:\nsub_expr is evaluated as a command-line to get\nthe output from"), /* insert program output */ "|i{sub_expr}\n\n", N_("insert user input:\nsub_expr is a variable to be replaced by\nuser-entered text"), /* insert user input */ diff --git a/src/quote_fmt.h b/src/quote_fmt.h index 31a747b83..26d9b6a38 100644 --- a/src/quote_fmt.h +++ b/src/quote_fmt.h @@ -8,7 +8,8 @@ void quote_fmt_quote_description(void); gchar *quote_fmt_get_buffer(void); void quote_fmt_init(MsgInfo *info, const gchar *my_quote_str, - const gchar *my_body, gboolean my_dry_run); + const gchar *my_body, gboolean my_dry_run, + PrefsAccount *account); gint quote_fmtparse(void); void quote_fmt_scan_string(const gchar *str); void quote_fmt_reset_vartable(void); diff --git a/src/quote_fmt_lex.l b/src/quote_fmt_lex.l index cabf1f929..4631f40a8 100644 --- a/src/quote_fmt_lex.l +++ b/src/quote_fmt_lex.l @@ -67,6 +67,10 @@ int quote_fmt_firsttime = 1; "%t" /* to */ return SHOW_TO; "%Q" /* quoted message */ return SHOW_QUOTED_MESSAGE; "%q" /* quoted message with no signature */ return SHOW_QUOTED_MESSAGE_NO_SIGNATURE; +"%af" /* full name in compose account */ return SHOW_ACCOUNT_FULL_NAME; +"%am" /* mail address in compose account */ return SHOW_ACCOUNT_MAIL_ADDRESS; +"%an" /* compose account name itself */ return SHOW_ACCOUNT_NAME; +"%ao" /* organization in compose account */ return SHOW_ACCOUNT_ORGANIZATION; "\\\%" /* % */ return SHOW_PERCENT; "\\\\" /* \ */ return SHOW_BACKSLASH; "\\t"|"\t" /* tab */ return SHOW_TAB; @@ -85,6 +89,8 @@ int quote_fmt_firsttime = 1; "?n" /* query newsgroups */ return QUERY_NEWSGROUPS; "?i" /* query message-id */ return QUERY_MESSAGEID; "?r" /* query references */ return QUERY_REFERENCES; +"?af" /* query full name in compose account */ return QUERY_ACCOUNT_FULL_NAME; +"?ao" /* query organization in compose account */ return QUERY_ACCOUNT_ORGANIZATION; "|f" /* insert file */ return INSERT_FILE; "|p" /* insert program output */ return INSERT_PROGRAMOUTPUT; "|i" /* insert user input */ return INSERT_USERINPUT; @@ -97,6 +103,8 @@ int quote_fmt_firsttime = 1; "!n" /* query not(newsgroups) */ return QUERY_NOT_NEWSGROUPS; "!i" /* query not(message-id) */ return QUERY_NOT_MESSAGEID; "!r" /* query not(references) */ return QUERY_NOT_REFERENCES; +"!af" /* query not(full name in compose account) */ return QUERY_NOT_ACCOUNT_FULL_NAME; +"!ao" /* query not(organization in compose account) */ return QUERY_NOT_ACCOUNT_ORGANIZATION; "{" return OPARENT; "}" { BEGIN S_NORMAL; return CPARENT; } "{" return OPARENT; diff --git a/src/quote_fmt_parse.y b/src/quote_fmt_parse.y index 2fdc01937..b0c479706 100644 --- a/src/quote_fmt_parse.y +++ b/src/quote_fmt_parse.y @@ -45,6 +45,7 @@ bison -p quote_fmt quote_fmt.y int yylex(void); static MsgInfo *msginfo = NULL; +static PrefsAccount *account = NULL; static gboolean *visible = NULL; static gboolean dry_run = FALSE; static gint maxsize = 0; @@ -155,11 +156,13 @@ void quote_fmt_reset_vartable(void) } void quote_fmt_init(MsgInfo *info, const gchar *my_quote_str, - const gchar *my_body, gboolean my_dry_run) + const gchar *my_body, gboolean my_dry_run, + PrefsAccount *compose_account) { quote_str = my_quote_str; body = my_body; msginfo = info; + account = compose_account; dry_run = my_dry_run; stacksize = 0; add_visibility(TRUE); @@ -479,6 +482,7 @@ static void quote_fmt_insert_user_input(const gchar *varname) char str[256]; } +/* tokens SHOW */ %token SHOW_NEWSGROUPS %token SHOW_DATE SHOW_FROM SHOW_FULLNAME SHOW_FIRST_NAME SHOW_LAST_NAME %token SHOW_SENDER_INITIAL SHOW_SUBJECT SHOW_TO SHOW_MESSAGEID @@ -486,12 +490,18 @@ static void quote_fmt_insert_user_input(const gchar *varname) %token SHOW_QUOTED_MESSAGE SHOW_BACKSLASH SHOW_TAB %token SHOW_QUOTED_MESSAGE_NO_SIGNATURE SHOW_MESSAGE_NO_SIGNATURE %token SHOW_EOL SHOW_QUESTION_MARK SHOW_EXCLAMATION_MARK SHOW_PIPE SHOW_OPARENT SHOW_CPARENT +%token SHOW_ACCOUNT_FULL_NAME SHOW_ACCOUNT_MAIL_ADDRESS SHOW_ACCOUNT_NAME SHOW_ACCOUNT_ORGANIZATION +/* tokens QUERY */ %token QUERY_DATE QUERY_FROM %token QUERY_FULLNAME QUERY_SUBJECT QUERY_TO QUERY_NEWSGROUPS %token QUERY_MESSAGEID QUERY_CC QUERY_REFERENCES +%token QUERY_ACCOUNT_FULL_NAME QUERY_ACCOUNT_ORGANIZATION +/* tokens QUERY_NOT */ %token QUERY_NOT_DATE QUERY_NOT_FROM %token QUERY_NOT_FULLNAME QUERY_NOT_SUBJECT QUERY_NOT_TO QUERY_NOT_NEWSGROUPS %token QUERY_NOT_MESSAGEID QUERY_NOT_CC QUERY_NOT_REFERENCES +%token QUERY_NOT_ACCOUNT_FULL_NAME QUERY_NOT_ACCOUNT_ORGANIZATION +/* other tokens */ %token INSERT_FILE INSERT_PROGRAMOUTPUT INSERT_USERINPUT %token OPARENT CPARENT %token CHARACTER @@ -642,6 +652,26 @@ special: { quote_fmt_show_msg(msginfo, body, TRUE, FALSE, quote_str); } + | SHOW_ACCOUNT_FULL_NAME + { + if (account && account->name) + INSERT(account->name); + } + | SHOW_ACCOUNT_MAIL_ADDRESS + { + if (account && account->address) + INSERT(account->address); + } + | SHOW_ACCOUNT_NAME + { + if (account && account->account_name) + INSERT(account->account_name); + } + | SHOW_ACCOUNT_ORGANIZATION + { + if (account && account->organization) + INSERT(account->organization); + } | SHOW_BACKSLASH { INSERT("\\"); @@ -756,6 +786,22 @@ query: add_visibility(found == TRUE); } OPARENT quote_fmt CPARENT + { + remove_visibility(); + } + | QUERY_ACCOUNT_FULL_NAME + { + add_visibility(account != NULL && account->name != NULL); + } + OPARENT quote_fmt CPARENT + { + remove_visibility(); + } + | QUERY_ACCOUNT_ORGANIZATION + { + add_visibility(account != NULL && account->organization != NULL); + } + OPARENT quote_fmt CPARENT { remove_visibility(); }; @@ -837,6 +883,22 @@ query_not: add_visibility(found == FALSE); } OPARENT quote_fmt CPARENT + { + remove_visibility(); + } + | QUERY_NOT_ACCOUNT_FULL_NAME + { + add_visibility(account == NULL || account->name == NULL); + } + OPARENT quote_fmt CPARENT + { + remove_visibility(); + } + | QUERY_NOT_ACCOUNT_ORGANIZATION + { + add_visibility(account == NULL || account->organization == NULL); + } + OPARENT quote_fmt CPARENT { remove_visibility(); };