2008-09-16 [wwp] 3.5.0cvs106
authorTristan Chabredier <wwp@claws-mail.org>
Tue, 16 Sep 2008 12:22:12 +0000 (12:22 +0000)
committerTristan Chabredier <wwp@claws-mail.org>
Tue, 16 Sep 2008 12:22:12 +0000 (12:22 +0000)
* 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.

ChangeLog
PATCHSETS
configure.ac
src/account.c
src/account.h
src/compose.c
src/quote_fmt.c
src/quote_fmt_lex.l
src/quote_fmt_parse.y

index 9abc8bf8bfab70262a6dfd25f30761b754263dea..3811caf5eb56c0d45a97f43da9c1444531dc737b 100644 (file)
--- 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
index 70bdcd67edd6333ee48c4924529bb20a96a30458..f40292cc9d8cbf69693ec04b8eeb9eee5d1405f2 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( 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
index a69378ae033ce1c61f8c0c1628c19b369137a176..e4abdcfcc116e266459ce2cc394289ad0d186f33 100644 (file)
@@ -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=
 
index 4a35a3de3a7aa89b475909e168750ddfa6ed948c..2ab5ae103efb4f969dd456730b0240a0efd15ff6 100644 (file)
@@ -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;
+}
index 8c8e6508bebc51a4c4ba3ea39c61df090d0c0eaf..416b5cd3056c5d7122b6475c4b626d76c010b8f1 100644 (file)
@@ -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__ */
index 22ca6682fff97b1f9884a4ff6cc993de76ff5244..e1e6039939426e8e00257571c2c5cd60e71a378a 100644 (file)
@@ -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);
 
index 3ea117d86ddc4421f0fc184d3051a2107d8cb89c..1baaf651249bf831f6c6cdac5fa92c2660c0fe6d 100644 (file)
@@ -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 <span style=\"oblique\">completion</span>: Cc"), /* completion of 'Cc' from address book */
        "%addrbook_from (%ABf)",        N_("address book <span style=\"oblique\">completion</span>: From"), /* completion of 'From' from address book */
@@ -84,8 +86,8 @@ static gchar *quote_desc_strings[] = {
        "\\n",                          N_("new line"),
        "",                                     NULL,
        N_("<span weight=\"bold\">commands:</span>"),           NULL,
-       "?x{<span style=\"oblique\">expr</span>}\n\n",          N_("insert <span style=\"oblique\">expr</span> if x is set, where x is one of\nthe [dfNFLIstcnriT, ad, af, ao, aT, ABc, ABf, ABt]\nsymbols (or their long equivalent)"),
-       "!x{<span style=\"oblique\">expr</span>}\n\n",          N_("insert <span style=\"oblique\">expr</span> 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{<span style=\"oblique\">expr</span>}\n\n",          N_("insert <span style=\"oblique\">expr</span> 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{<span style=\"oblique\">expr</span>}\n\n",          N_("insert <span style=\"oblique\">expr</span> 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{<span style=\"oblique\">sub_expr</span>}\n(|f{<span style=\"oblique\">sub_expr</span>})",                N_("insert file:\n<span style=\"oblique\">sub_expr</span> is evaluated as the path of the file to insert"), /* insert file */
        "|program{<span style=\"oblique\">sub_expr</span>}\n(|p{<span style=\"oblique\">sub_expr</span>})\n",   N_("insert program output:\n<span style=\"oblique\">sub_expr</span> is evaluated as a command-line to get\nthe output from"), /* insert program output */
        "|input{<span style=\"oblique\">sub_expr</span>}\n(|i{<span style=\"oblique\">sub_expr</span>})\n",             N_("insert user input:\n<span style=\"oblique\">sub_expr</span> is a variable to be replaced by\nuser-entered text"), /* insert user input */
index 92983634c65cc5869dae2a7015fc96db4a2d8671..46c295f5022e75652ca526b13959fbb88b300384 100644 (file)
@@ -96,6 +96,8 @@ int escaped_string = 0;
 <S_NORMAL>("%am"|"%account_email") /* mail address in compose account */ return SHOW_ACCOUNT_MAIL_ADDRESS;
 <S_NORMAL>("%an"|"%account_name") /* compose account name itself */ return SHOW_ACCOUNT_NAME;
 <S_NORMAL>("%ao"|"%account_org") /* organization in compose account */ return SHOW_ACCOUNT_ORGANIZATION;
+<S_NORMAL>("%as"|"%account_sig") /* signature in compose account */ return SHOW_ACCOUNT_SIG;
+<S_NORMAL>("%asp"|"%account_sigpath") /* signature path in compose account */ return SHOW_ACCOUNT_SIGPATH;
 <S_NORMAL>("%aT"|"%account_dict") /* main dict (if enabled) in compose account */ return SHOW_ACCOUNT_DICT;
 <S_NORMAL>("%ABc"|"%addrbook_cc") /* completion of 'Cc' from the address book */ return SHOW_ADDRESSBOOK_COMPLETION_FOR_CC;
 <S_NORMAL>("%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;
index 762120c23ed0a5add218ea81ac3775a09041d50a..3567ffa60d2acf8e24db7d9829c32f5e86e63673 100644 (file)
@@ -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