From: Tristan Chabredier Date: Tue, 16 Sep 2008 12:22:12 +0000 (+0000) Subject: 2008-09-16 [wwp] 3.5.0cvs106 X-Git-Tag: rel_3_6_0~46 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=a54f0cb49ac5ee596cbb19ce30b036bf56757975 2008-09-16 [wwp] 3.5.0cvs106 * src/account.c * src/account.h * src/compose.c * src/quote_fmt.c * src/quote_fmt_lex.l * src/quote_fmt_parse.y Add account signature (path and value string) manipulation keywords to the template processor. It's now possible in all templates to insert the account signature to an arbitrary location or to pass it to a external script for further editing. --- diff --git a/ChangeLog b/ChangeLog index 9abc8bf8b..3811caf5e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2008-09-16 [wwp] 3.5.0cvs106 + + * src/account.c + * src/account.h + * src/compose.c + * src/quote_fmt.c + * src/quote_fmt_lex.l + * src/quote_fmt_parse.y + Add account signature (path and value string) manipulation + keywords to the template processor. It's now possible in + all templates to insert the account signature to an + arbitrary location or to pass it to a external script for + further editing. + + 2008-09-16 [mones] 3.5.0cvs105 * src/imap.c diff --git a/PATCHSETS b/PATCHSETS index 70bdcd67e..f40292cc9 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -3517,3 +3517,4 @@ ( cvs diff -u -r 1.1.2.1 -r 1.1.2.2 claws-mail.pc.in; cvs diff -u -r 1.155.2.90 -r 1.155.2.91 src/Makefile.am; cvs diff -u -r 1.382.2.474 -r 1.382.2.475 src/compose.c; cvs diff -u -r 1.50.2.50 -r 1.50.2.51 src/compose.h; cvs diff -u -r 1.23.2.29 -r 1.23.2.30 src/crash.c; cvs diff -u -r 1.2.2.30 -r 1.2.2.31 src/folder_item_prefs.c; cvs diff -u -r 1.2.2.17 -r 1.2.2.18 src/folder_item_prefs.h; cvs diff -u -r 1.115.2.204 -r 1.115.2.205 src/main.c; cvs diff -u -r 1.105.2.144 -r 1.105.2.145 src/prefs_account.c; cvs diff -u -r 1.204.2.177 -r 1.204.2.178 src/prefs_common.c; cvs diff -u -r 1.103.2.112 -r 1.103.2.113 src/prefs_common.h; cvs diff -u -r 1.52.2.66 -r 1.52.2.67 src/prefs_folder_item.c; cvs diff -u -r 1.5.2.36 -r 1.5.2.37 src/prefs_spelling.c; cvs diff -u -r 1.12.2.66 -r 1.12.2.67 src/prefs_template.c; cvs diff -u -r 1.5.12.18 -r 1.5.12.19 src/quote_fmt.h; cvs diff -u -r 1.22.2.39 -r 1.22.2.40 src/quote_fmt_parse.y; cvs diff -u -r 1.43.2.104 -r 1.43.2.105 src/toolbar.c; cvs diff -u -r 1.19.2.28 -r 1.19.2.29 src/toolbar.h; cvs diff -u -r 1.20.2.17 -r 1.20.2.18 src/gtk/Makefile.am; cvs diff -u -r 1.4.2.66 -r 1.4.2.67 src/gtk/about.c; cvs diff -u -r 1.2.2.37 -r 1.2.2.38 src/gtk/filesel.c; cvs diff -u -r 1.9.2.60 -r 1.9.2.61 src/gtk/gtkaspell.c; cvs diff -u -r 1.5.2.15 -r 1.5.2.16 src/gtk/gtkaspell.h; cvs diff -u -r 1.1.2.5 -r 1.1.2.6 src/plugins/bogofilter/Makefile.am; cvs diff -u -r 1.4.2.7 -r 1.4.2.8 src/plugins/dillo_viewer/Makefile.am; cvs diff -u -r 1.5.2.8 -r 1.5.2.9 src/plugins/spamassassin/Makefile.am; cvs diff -u -r 1.4.2.11 -r 1.4.2.12 src/plugins/trayicon/Makefile.am; ) > 3.5.0cvs103.patchset ( cvs diff -u -r 1.65.2.59 -r 1.65.2.60 src/codeconv.c; cvs diff -u -r 1.15.2.20 -r 1.15.2.21 src/codeconv.h; ) > 3.5.0cvs104.patchset ( cvs diff -u -r 1.179.2.227 -r 1.179.2.228 src/imap.c; cvs diff -u -r 1.149.2.94 -r 1.149.2.95 src/inc.c; cvs diff -u -r 1.274.2.271 -r 1.274.2.272 src/mainwindow.c; cvs diff -u -r 1.39.2.50 -r 1.39.2.51 src/mainwindow.h; cvs diff -u -r 1.101.2.53 -r 1.101.2.54 src/news.c; cvs diff -u -r 1.49.2.39 -r 1.49.2.40 src/prefs_account.h; cvs diff -u -r 1.204.2.178 -r 1.204.2.179 src/prefs_common.c; cvs diff -u -r 1.103.2.113 -r 1.103.2.114 src/prefs_common.h; cvs diff -u -r 1.1.2.30 -r 1.1.2.31 src/prefs_other.c; cvs diff -u -r 1.17.2.49 -r 1.17.2.50 src/send_message.c; cvs diff -u -r 1.2.2.32 -r 1.2.2.33 src/gtk/inputdialog.c; cvs diff -u -r 1.1.2.9 -r 1.1.2.10 src/gtk/inputdialog.h; ) > 3.5.0cvs105.patchset +( cvs diff -u -r 1.61.2.84 -r 1.61.2.85 src/account.c; cvs diff -u -r 1.11.2.11 -r 1.11.2.12 src/account.h; cvs diff -u -r 1.382.2.475 -r 1.382.2.476 src/compose.c; cvs diff -u -r 1.8.2.36 -r 1.8.2.37 src/quote_fmt.c; cvs diff -u -r 1.8.2.17 -r 1.8.2.18 src/quote_fmt_lex.l; cvs diff -u -r 1.22.2.40 -r 1.22.2.41 src/quote_fmt_parse.y; ) > 3.5.0cvs106.patchset diff --git a/configure.ac b/configure.ac index a69378ae0..e4abdcfcc 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=5 MICRO_VERSION=0 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=105 +EXTRA_VERSION=106 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/account.c b/src/account.c index 4a35a3de3..2ab5ae103 100644 --- a/src/account.c +++ b/src/account.c @@ -1788,3 +1788,55 @@ static void account_row_changed_while_drag_drop(GtkTreeModel *model, { account_list_set(); } + +gchar *account_get_signature_str(PrefsAccount *account) +{ + gchar *sig_body = NULL; + gchar *sig_str = NULL; + gchar *utf8_sig_str = NULL; + + g_return_val_if_fail(account != NULL, NULL); + + if (!account->sig_path) + return NULL; + + if (account->sig_type == SIG_FILE) { + if (!is_file_or_fifo_exist(account->sig_path)) { + g_warning("can't open signature file: %s\n", + account->sig_path); + return NULL; + } + } + + if (account->sig_type == SIG_COMMAND) + sig_body = get_command_output(account->sig_path); + else { + gchar *tmp; + + tmp = file_read_to_str(account->sig_path); + if (!tmp) + return NULL; + sig_body = normalize_newlines(tmp); + g_free(tmp); + } + + if (account->sig_sep) { + sig_str = g_strconcat("\n", account->sig_sep, "\n", sig_body, + NULL); + g_free(sig_body); + } else + sig_str = g_strconcat("\n", sig_body, NULL); + + if (sig_str) { + if (g_utf8_validate(sig_str, -1, NULL) == TRUE) + utf8_sig_str = sig_str; + else { + utf8_sig_str = conv_codeset_strdup + (sig_str, conv_get_locale_charset_str_no_utf8(), + CS_INTERNAL); + g_free(sig_str); + } + } + + return utf8_sig_str; +} diff --git a/src/account.h b/src/account.h index 8c8e6508b..416b5cd30 100644 --- a/src/account.h +++ b/src/account.h @@ -60,5 +60,6 @@ PrefsAccount *account_get_reply_account (MsgInfo *msginfo, gboolean reply_autosel); void account_rename_path (const gchar *old_id, const gchar *new_id); +gchar *account_get_signature_str(PrefsAccount *account); #endif /* __ACCOUNT_H__ */ diff --git a/src/compose.c b/src/compose.c index 22ca6682f..e1e603993 100644 --- a/src/compose.c +++ b/src/compose.c @@ -2200,7 +2200,7 @@ Compose *compose_reedit(MsgInfo *msginfo, gboolean batch) return NULL; } - compose->sig_str = compose_get_signature_str(compose); + compose->sig_str = account_get_signature_str(compose->account); return compose; } @@ -3200,7 +3200,7 @@ static void compose_insert_sig(Compose *compose, gboolean replace) } g_free(compose->sig_str); - compose->sig_str = compose_get_signature_str(compose); + compose->sig_str = account_get_signature_str(compose->account); cur_pos = gtk_text_iter_get_offset(&iter); diff --git a/src/quote_fmt.c b/src/quote_fmt.c index 3ea117d86..1baaf6512 100644 --- a/src/quote_fmt.c +++ b/src/quote_fmt.c @@ -69,6 +69,8 @@ static gchar *quote_desc_strings[] = { "%account_email (%am)", N_("account property: your email address"), /* mail address in compose account */ "%account_name (%an)", N_("account property: account name"), /* compose account name itself */ "%account_org (%ao)", N_("account property: organization"), /* organization in compose account */ + "%account_sig (%as)", N_("account property: signature"), /* signature set in account prefs */ + "%account_sigpath (%asp)", N_("account property: signature path"), /* signature path set in account prefs */ "%account_dict (%aT)", N_("account property: default dictionary"), /* main dict (if enabled) in account */ "%addrbook_cc (%ABc)", N_("address book completion: Cc"), /* completion of 'Cc' from address book */ "%addrbook_from (%ABf)", N_("address book completion: From"), /* completion of 'From' from address book */ @@ -84,8 +86,8 @@ static gchar *quote_desc_strings[] = { "\\n", N_("new line"), "", NULL, N_("commands:"), NULL, - "?x{expr}\n\n", N_("insert expr if x is set, where x is one of\nthe [dfNFLIstcnriT, ad, af, ao, aT, ABc, ABf, ABt]\nsymbols (or their long equivalent)"), - "!x{expr}\n\n", N_("insert expr if x is not set, where x is one of\nthe [dfNFLIstcnriT, ad, af, ao, aT, ABc, ABf, ABt]\nsymbols (or their long equivalent)"), + "?x{expr}\n\n", N_("insert expr if x is set, where x is one of\nthe [dfNFLIstcnriT, ad, af, ao, as, asp, aT, ABc, ABf, ABt]\nsymbols (or their long equivalent)"), + "!x{expr}\n\n", N_("insert expr if x is not set, where x is one of\nthe [dfNFLIstcnriT, ad, af, ao, as, asp, aT, ABc, ABf, ABt]\nsymbols (or their long equivalent)"), "|file{sub_expr}\n(|f{sub_expr})", N_("insert file:\nsub_expr is evaluated as the path of the file to insert"), /* insert file */ "|program{sub_expr}\n(|p{sub_expr})\n", N_("insert program output:\nsub_expr is evaluated as a command-line to get\nthe output from"), /* insert program output */ "|input{sub_expr}\n(|i{sub_expr})\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_lex.l b/src/quote_fmt_lex.l index 92983634c..46c295f50 100644 --- a/src/quote_fmt_lex.l +++ b/src/quote_fmt_lex.l @@ -96,6 +96,8 @@ int escaped_string = 0; ("%am"|"%account_email") /* mail address in compose account */ return SHOW_ACCOUNT_MAIL_ADDRESS; ("%an"|"%account_name") /* compose account name itself */ return SHOW_ACCOUNT_NAME; ("%ao"|"%account_org") /* organization in compose account */ return SHOW_ACCOUNT_ORGANIZATION; +("%as"|"%account_sig") /* signature in compose account */ return SHOW_ACCOUNT_SIG; +("%asp"|"%account_sigpath") /* signature path in compose account */ return SHOW_ACCOUNT_SIGPATH; ("%aT"|"%account_dict") /* main dict (if enabled) in compose account */ return SHOW_ACCOUNT_DICT; ("%ABc"|"%addrbook_cc") /* completion of 'Cc' from the address book */ return SHOW_ADDRESSBOOK_COMPLETION_FOR_CC; ("%ABf"|"%addrbook_from") /* completion of 'From' from the address book */ return SHOW_ADDRESSBOOK_COMPLETION_FOR_FROM; @@ -122,6 +124,8 @@ int escaped_string = 0; ("?r"|"?references") /* query references */ return QUERY_REFERENCES; ("?af"|"?account_fullname") /* query full name in compose account */ return QUERY_ACCOUNT_FULL_NAME; ("?ao"|"?account_org") /* query organization in compose account */ return QUERY_ACCOUNT_ORGANIZATION; +("?as"|"?account_sig") /* query signature */ return QUERY_ACCOUNT_SIG; +("?asp"|"?account_sigpath") /* query signature path */ return QUERY_ACCOUNT_SIGPATH; ("?aT"|"?account_dict") /* query account main dict enabled */ return QUERY_ACCOUNT_DICT; ("?ABc"|"?addrbook_cc") /* query completion for 'Cc' in address book */ return QUERY_CC_FOUND_IN_ADDRESSBOOK; ("?ABf"|"?addrbook_from") /* query completion for 'From' in address book */ return QUERY_FROM_FOUND_IN_ADDRESSBOOK; @@ -138,6 +142,8 @@ int escaped_string = 0; ("!r"|"!references") /* query not(references) */ return QUERY_NOT_REFERENCES; ("!af"|"!account_fullname") /* query not(full name in compose account) */ return QUERY_NOT_ACCOUNT_FULL_NAME; ("!ao"|"!account_org") /* query not(organization in compose account) */ return QUERY_NOT_ACCOUNT_ORGANIZATION; +("!as"|"!account_sig") /* query not(signature) */ return QUERY_NOT_ACCOUNT_SIG; +("!asp"|"!account_sigpath") /* query not(signature path) */ return QUERY_NOT_ACCOUNT_SIGPATH; ("!aT"|"!account_dict") /* query not(account main dict enabled and set) */ return QUERY_NOT_ACCOUNT_DICT; ("!ABc"|"!addrbook_cc") /* query not(completion for 'Cc' in address book) */ return QUERY_NOT_CC_FOUND_IN_ADDRESSBOOK; ("!ABf"|"!addrbook_from") /* query not(completion for 'From' in address book) */ return QUERY_NOT_FROM_FOUND_IN_ADDRESSBOOK; diff --git a/src/quote_fmt_parse.y b/src/quote_fmt_parse.y index 762120c23..3567ffa60 100644 --- a/src/quote_fmt_parse.y +++ b/src/quote_fmt_parse.y @@ -36,6 +36,7 @@ #include "quote_fmt.h" #include "quote_fmt_lex.h" +#include "account.h" /* decl */ /* @@ -581,7 +582,7 @@ static gchar *quote_fmt_complete_address(const gchar *addr) %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 -%token SHOW_ACCOUNT_DICT +%token SHOW_ACCOUNT_DICT SHOW_ACCOUNT_SIG SHOW_ACCOUNT_SIGPATH %token SHOW_DICT SHOW_TAGS %token SHOW_ADDRESSBOOK_COMPLETION_FOR_CC %token SHOW_ADDRESSBOOK_COMPLETION_FOR_FROM @@ -591,6 +592,7 @@ static gchar *quote_fmt_complete_address(const gchar *addr) %token QUERY_FULLNAME QUERY_SUBJECT QUERY_TO QUERY_NEWSGROUPS %token QUERY_MESSAGEID QUERY_CC QUERY_REFERENCES %token QUERY_ACCOUNT_FULL_NAME QUERY_ACCOUNT_ORGANIZATION QUERY_ACCOUNT_DICT +%token QUERY_ACCOUNT_SIG QUERY_ACCOUNT_SIGPATH %token QUERY_DICT %token QUERY_CC_FOUND_IN_ADDRESSBOOK %token QUERY_FROM_FOUND_IN_ADDRESSBOOK @@ -600,6 +602,7 @@ static gchar *quote_fmt_complete_address(const gchar *addr) %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 QUERY_NOT_ACCOUNT_DICT +%token QUERY_NOT_ACCOUNT_SIG QUERY_NOT_ACCOUNT_SIGPATH %token QUERY_NOT_DICT %token QUERY_NOT_CC_FOUND_IN_ADDRESSBOOK %token QUERY_NOT_FROM_FOUND_IN_ADDRESSBOOK @@ -786,6 +789,17 @@ special: if (account && account->organization) INSERT(account->organization); } + | SHOW_ACCOUNT_SIG + { + gchar *str = account_get_signature_str(account); + INSERT(str); + g_free(str); + } + | SHOW_ACCOUNT_SIGPATH + { + if (account && account->sig_path) + INSERT(account->sig_path); + } | SHOW_ACCOUNT_DICT { #ifdef USE_ENCHANT @@ -970,6 +984,25 @@ query: { remove_visibility(); } + | QUERY_ACCOUNT_SIG + { + gchar *str = account_get_signature_str(account); + add_visibility(str != NULL && * str != '\0'); + g_free(str); + } + OPARENT quote_fmt CPARENT + { + remove_visibility(); + } + | QUERY_ACCOUNT_SIGPATH + { + add_visibility(account != NULL && account->sig_path != NULL + && *account->sig_path != '\0'); + } + OPARENT quote_fmt CPARENT + { + remove_visibility(); + } | QUERY_ACCOUNT_DICT { #ifdef USE_ENCHANT @@ -1122,6 +1155,25 @@ query_not: { remove_visibility(); } + | QUERY_NOT_ACCOUNT_SIG + { + gchar *str = account_get_signature_str(account); + add_visibility(str == NULL || *str == '\0'); + g_free(str); + } + OPARENT quote_fmt CPARENT + { + remove_visibility(); + } + | QUERY_NOT_ACCOUNT_SIGPATH + { + add_visibility(account == NULL || account->sig_path == NULL + || *account->sig_path == '\0'); + } + OPARENT quote_fmt CPARENT + { + remove_visibility(); + } | QUERY_NOT_ACCOUNT_DICT { #ifdef USE_ENCHANT