From: Tristan Chabredier Date: Wed, 17 Oct 2007 14:57:18 +0000 (+0000) Subject: 2007-10-17 [wwp] 3.0.2cvs79 X-Git-Tag: rel_3_1_0~73 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=f9a3eda0555b410b96b393a1f443a78850715948 2007-10-17 [wwp] 3.0.2cvs79 * src/compose.c * src/quote_fmt.c * src/quote_fmt.h * src/quote_fmt_lex.l * src/quote_fmt_parse.y Templates can now attach files using |attach{filename}. --- diff --git a/ChangeLog b/ChangeLog index f50504eb3..5180858ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-10-17 [wwp] 3.0.2cvs79 + + * src/compose.c + * src/quote_fmt.c + * src/quote_fmt.h + * src/quote_fmt_lex.l + * src/quote_fmt_parse.y + Templates can now attach files using |attach{filename}. + 2007-10-17 [wwp] 3.0.2cvs78 * src/prefs_customheader.c diff --git a/PATCHSETS b/PATCHSETS index 248482bf1..9a0a3d153 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -2991,3 +2991,4 @@ ( cvs diff -u -r 1.1.2.6 -r 1.1.2.7 src/edittags.c; cvs diff -u -r 1.1.2.3 -r 1.1.2.4 src/edittags.h; cvs diff -u -r 1.60.2.39 -r 1.60.2.40 src/filtering.c; cvs diff -u -r 1.21.2.15 -r 1.21.2.16 src/filtering.h; cvs diff -u -r 1.4.12.17 -r 1.4.12.18 src/importmutt.c; cvs diff -u -r 1.1.14.17 -r 1.1.14.18 src/importpine.c; cvs diff -u -r 1.115.2.172 -r 1.115.2.173 src/main.c; cvs diff -u -r 1.94.2.161 -r 1.94.2.162 src/messageview.c; cvs diff -u -r 1.19.2.17 -r 1.19.2.18 src/messageview.h; cvs diff -u -r 1.83.2.119 -r 1.83.2.120 src/mimeview.c; cvs diff -u -r 1.20.2.22 -r 1.20.2.23 src/mimeview.h; cvs diff -u -r 1.56.2.58 -r 1.56.2.59 src/pop.c; cvs diff -u -r 1.17.2.19 -r 1.17.2.20 src/pop.h; cvs diff -u -r 1.204.2.149 -r 1.204.2.150 src/prefs_common.c; cvs diff -u -r 1.103.2.95 -r 1.103.2.96 src/prefs_common.h; cvs diff -u -r 1.16.2.29 -r 1.16.2.30 src/prefs_customheader.c; cvs diff -u -r 1.2.16.5 -r 1.2.16.6 src/prefs_customheader.h; cvs diff -u -r 1.16.2.31 -r 1.16.2.32 src/prefs_display_header.c; cvs diff -u -r 1.1.16.5 -r 1.1.16.6 src/prefs_display_header.h; cvs diff -u -r 1.1.4.41 -r 1.1.4.42 src/prefs_filtering_action.c; cvs diff -u -r 1.1.4.4 -r 1.1.4.5 src/prefs_filtering_action.h; cvs diff -u -r 1.1.2.12 -r 1.1.2.13 src/prefs_folder_column.c; cvs diff -u -r 1.1.2.6 -r 1.1.2.7 src/prefs_folder_column.h; cvs diff -u -r 1.52.2.52 -r 1.52.2.53 src/prefs_folder_item.c; cvs diff -u -r 1.17.2.5 -r 1.17.2.6 src/prefs_folder_item.h; cvs diff -u -r 1.10.2.35 -r 1.10.2.36 src/prefs_gtk.c; cvs diff -u -r 1.5.2.15 -r 1.5.2.16 src/prefs_gtk.h; cvs diff -u -r 1.1.2.3 -r 1.1.2.4 src/prefs_logging.h; cvs diff -u -r 1.43.2.62 -r 1.43.2.63 src/prefs_matcher.c; cvs diff -u -r 1.4.2.7 -r 1.4.2.8 src/prefs_matcher.h; cvs diff -u -r 1.10.2.21 -r 1.10.2.22 src/prefs_summary_column.c; cvs diff -u -r 1.1.16.5 -r 1.1.16.6 src/prefs_summary_column.h; cvs diff -u -r 1.1.2.2 -r 1.1.2.3 src/prefs_summary_open.c; cvs diff -u -r 1.47.2.45 -r 1.47.2.46 src/procheader.c; cvs diff -u -r 1.11.2.9 -r 1.11.2.10 src/procheader.h; cvs diff -u -r 1.49.2.100 -r 1.49.2.101 src/procmime.c; cvs diff -u -r 1.17.2.20 -r 1.17.2.21 src/procmime.h; cvs diff -u -r 1.17.2.12 -r 1.17.2.13 src/recv.c; cvs diff -u -r 1.6.12.6 -r 1.6.12.7 src/recv.h; cvs diff -u -r 1.9.2.21 -r 1.9.2.22 src/sourcewindow.c; cvs diff -u -r 1.1.1.1.16.6 -r 1.1.1.1.16.7 src/sourcewindow.h; cvs diff -u -r 1.395.2.331 -r 1.395.2.332 src/summaryview.c; cvs diff -u -r 1.68.2.40 -r 1.68.2.41 src/summaryview.h; cvs diff -u -r 1.96.2.187 -r 1.96.2.188 src/textview.c; cvs diff -u -r 1.12.2.21 -r 1.12.2.22 src/textview.h; cvs diff -u -r 1.43.2.89 -r 1.43.2.90 src/toolbar.c; cvs diff -u -r 1.19.2.24 -r 1.19.2.25 src/toolbar.h; cvs diff -u -r 1.1.4.9 -r 1.1.4.10 src/common/mgutils.c; cvs diff -u -r 1.1.4.5 -r 1.1.4.6 src/common/mgutils.h; cvs diff -u -r 1.6.2.14 -r 1.6.2.15 src/common/nntp.c; cvs diff -u -r 1.4.2.5 -r 1.4.2.6 src/common/nntp.h; cvs diff -u -r 1.5.2.9 -r 1.5.2.10 src/common/prefs.c; cvs diff -u -r 1.3.2.5 -r 1.3.2.6 src/common/prefs.h; cvs diff -u -r 1.13.2.35 -r 1.13.2.36 src/common/socket.c; cvs diff -u -r 1.13.2.15 -r 1.13.2.16 src/common/socket.h; cvs diff -u -r 1.2.2.6 -r 1.2.2.7 src/common/stringtable.c; cvs diff -u -r 1.1.4.5 -r 1.1.4.6 src/common/stringtable.h; cvs diff -u -r 1.2.4.22 -r 1.2.4.23 src/common/template.c; cvs diff -u -r 1.1.4.6 -r 1.1.4.7 src/common/template.h; cvs diff -u -r 1.1.4.2 -r 1.1.4.3 src/common/uuencode.c; cvs diff -u -r 1.1.4.2 -r 1.1.4.3 src/common/uuencode.h; cvs diff -u -r 1.1.4.8 -r 1.1.4.9 src/gtk/gtkshruler.c; cvs diff -u -r 1.1.4.4 -r 1.1.4.5 src/gtk/gtkshruler.h; cvs diff -u -r 1.5.2.25 -r 1.5.2.26 src/gtk/menu.c; cvs diff -u -r 1.4.2.11 -r 1.4.2.12 src/gtk/menu.h; cvs diff -u -r 1.1.4.21 -r 1.1.4.22 src/gtk/progressdialog.c; cvs diff -u -r 1.1.4.11 -r 1.1.4.12 src/gtk/progressdialog.h; ) > 3.0.2cvs76.patchset ( cvs diff -u -r 1.5.2.50 -r 1.5.2.51 src/gtk/pluginwindow.c; ) > 3.0.2cvs77.patchset ( cvs diff -u -r 1.16.2.30 -r 1.16.2.31 src/prefs_customheader.c; cvs diff -u -r 1.3.2.17 -r 1.3.2.18 src/prefs_ext_prog.c; cvs diff -u -r 1.1.4.42 -r 1.1.4.43 src/prefs_filtering_action.c; cvs diff -u -r 1.43.2.63 -r 1.43.2.64 src/prefs_matcher.c; cvs diff -u -r 1.1.2.24 -r 1.1.2.25 src/prefs_other.c; cvs diff -u -r 1.30.2.45 -r 1.30.2.46 src/prefs_toolbar.c; cvs diff -u -r 1.1.2.11 -r 1.1.2.12 src/gtk/combobox.c; cvs diff -u -r 1.1.2.9 -r 1.1.2.10 src/gtk/combobox.h; cvs diff -u -r 1.5.2.69 -r 1.5.2.70 src/gtk/gtkutils.c; cvs diff -u -r 1.4.2.38 -r 1.4.2.39 src/gtk/gtkutils.h; cvs diff -u -r 1.1.2.26 -r 1.1.2.27 src/plugins/bogofilter/bogofilter_gtk.c; cvs diff -u -r 1.23.2.42 -r 1.23.2.43 src/plugins/spamassassin/spamassassin_gtk.c; ) > 3.0.2cvs78.patchset +( cvs diff -u -r 1.382.2.417 -r 1.382.2.418 src/compose.c; cvs diff -u -r 1.8.2.25 -r 1.8.2.26 src/quote_fmt.c; cvs diff -u -r 1.5.12.12 -r 1.5.12.13 src/quote_fmt.h; cvs diff -u -r 1.8.2.15 -r 1.8.2.16 src/quote_fmt_lex.l; cvs diff -u -r 1.22.2.36 -r 1.22.2.37 src/quote_fmt_parse.y; ) > 3.0.2cvs79.patchset diff --git a/configure.ac b/configure.ac index 41753054c..92b8412e5 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=0 MICRO_VERSION=2 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=78 +EXTRA_VERSION=79 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/compose.c b/src/compose.c index e0909325b..7866bbdf3 100644 --- a/src/compose.c +++ b/src/compose.c @@ -548,6 +548,8 @@ static void compose_set_dictionaries_from_folder_prefs(Compose *compose, #endif static void compose_attach_update_label(Compose *compose); +static void compose_attach_from_list(Compose *compose, GList *file_list, gboolean free_data); + static GtkItemFactoryEntry compose_popup_entries[] = { {N_("/_Add..."), NULL, compose_attach_cb, 0, NULL}, @@ -1096,6 +1098,7 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI alertpanel_error(_("New message subject format error.")); else gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), buf); + compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE); quote_fmt_reset_vartable(); g_free(subject); @@ -1123,6 +1126,7 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI body_format, NULL, tmp, FALSE, TRUE, _("New message body format error at line %d.")); + compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE); quote_fmt_reset_vartable(); g_free(tmp); @@ -1504,6 +1508,7 @@ static Compose *compose_generic_reply(MsgInfo *msginfo, compose_quote_fmt(compose, compose->replyinfo, body_fmt, qmark, body, FALSE, TRUE, _("Message reply format error at line %d.")); + compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE); quote_fmt_reset_vartable(); } @@ -1639,6 +1644,7 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo, compose_quote_fmt(compose, full_msginfo, body_fmt, qmark, body, FALSE, TRUE, _("Message forward format error at line %d.")); + compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE); quote_fmt_reset_vartable(); compose_attach_parts(compose, msginfo); @@ -7419,6 +7425,7 @@ static void compose_template_apply(Compose *compose, Template *tmpl, /* process the other fields */ compose_template_apply_fields(compose, tmpl); + compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE); quote_fmt_reset_vartable(); compose_changed_cb(NULL, compose); } @@ -8741,17 +8748,9 @@ static void compose_draft_cb(gpointer data, guint action, GtkWidget *widget) compose_draft(data, action); } -static void compose_attach_cb(gpointer data, guint action, GtkWidget *widget) +static void compose_attach_from_list(Compose *compose, GList *file_list, gboolean free_data) { - Compose *compose = (Compose *)data; - GList *file_list; - - if (compose->redirect_filename != NULL) - return; - - file_list = filesel_select_multiple_files_open(_("Select file")); - - if (file_list) { + if (compose && file_list) { GList *tmp; for ( tmp = file_list; tmp; tmp = tmp->next) { @@ -8759,9 +8758,27 @@ static void compose_attach_cb(gpointer data, guint action, GtkWidget *widget) gchar *utf8_filename = conv_filename_to_utf8(file); compose_attach_append(compose, file, utf8_filename, NULL); compose_changed_cb(NULL, compose); + if (free_data) { g_free(file); + tmp->data = NULL; + } g_free(utf8_filename); } + } +} + +static void compose_attach_cb(gpointer data, guint action, GtkWidget *widget) +{ + Compose *compose = (Compose *)data; + GList *file_list; + + if (compose->redirect_filename != NULL) + return; + + file_list = filesel_select_multiple_files_open(_("Select file")); + + if (file_list) { + compose_attach_from_list(compose, file_list, TRUE); g_list_free(file_list); } } diff --git a/src/quote_fmt.c b/src/quote_fmt.c index 1c42131f3..299ce7c82 100644 --- a/src/quote_fmt.c +++ b/src/quote_fmt.c @@ -89,6 +89,7 @@ static gchar *quote_desc_strings[] = { "|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 */ + "|attach{sub_expr}\n(|a{sub_expr})", N_("attach file:\nsub_expr is evaluated as the path of the file to attach"), /* attach file */ "", NULL, N_("definition of terms:"), NULL, "expr\n", N_("text that can contain any of the symbols or\ncommands above"), diff --git a/src/quote_fmt.h b/src/quote_fmt.h index c8f8ada12..5428478f1 100644 --- a/src/quote_fmt.h +++ b/src/quote_fmt.h @@ -11,6 +11,7 @@ void quote_fmt_quote_description(GtkWidget *widget, GtkWidget *pref_window); gchar *quote_fmt_get_buffer(void); +GList *quote_fmt_get_attachments_list(void); gint quote_fmt_get_line(void); #ifdef USE_ASPELL void quote_fmt_init(MsgInfo *info, const gchar *my_quote_str, diff --git a/src/quote_fmt_lex.l b/src/quote_fmt_lex.l index 54dd876e1..22d102a29 100644 --- a/src/quote_fmt_lex.l +++ b/src/quote_fmt_lex.l @@ -143,6 +143,7 @@ int line = -1; ("|f"|"|file") /* insert file */ return INSERT_FILE; ("|p"|"|program") /* insert program output */ return INSERT_PROGRAMOUTPUT; ("|i"|"|input") /* insert user input */ return INSERT_USERINPUT; +("|a"|"|attach") /* attach file */ return ATTACH_FILE; "{" return OPARENT; "}" { BEGIN S_NORMAL; return CPARENT; } "{" return OPARENT; diff --git a/src/quote_fmt_parse.y b/src/quote_fmt_parse.y index 6e29c2725..06ec182c7 100644 --- a/src/quote_fmt_parse.y +++ b/src/quote_fmt_parse.y @@ -55,6 +55,7 @@ static gboolean dry_run = FALSE; static gint maxsize = 0; static gint stacksize = 0; static GHashTable *var_table = NULL; +static GList *attachments = NULL; typedef struct st_buffer { @@ -138,6 +139,12 @@ gchar *quote_fmt_get_buffer(void) return current->buffer; } +GList *quote_fmt_get_attachments_list(void) +{ + fprintf(stderr, "+ get attachment list %p\n", attachments); + return attachments; +} + gint quote_fmt_get_line(void) { return line; @@ -166,6 +173,17 @@ void quote_fmt_reset_vartable(void) g_hash_table_destroy(var_table); var_table = NULL; } + if (attachments) { + fprintf(stderr, "+ freeing attachment list\n"); + GList *cur = attachments; + while (cur) { + fprintf(stderr, "-> %s\n", (gchar*)cur->data); + g_free(cur->data); + cur = g_list_next(cur); + } + g_list_free(attachments); + attachments = NULL; + } } #ifdef USE_ASPELL @@ -503,6 +521,12 @@ static void quote_fmt_insert_user_input(const gchar *varname) g_free(text); } +static void quote_fmt_attach_file(const gchar *filename) +{ + fprintf(stderr, "+ adding attachment %s\n", filename); + attachments = g_list_append(attachments, g_strdup(filename)); +} + static gchar *quote_fmt_complete_address(const gchar *addr) { gint count; @@ -582,6 +606,7 @@ static gchar *quote_fmt_complete_address(const gchar *addr) %token QUERY_NOT_TO_FOUND_IN_ADDRESSBOOK /* other tokens */ %token INSERT_FILE INSERT_PROGRAMOUTPUT INSERT_USERINPUT +%token ATTACH_FILE %token OPARENT CPARENT %token CHARACTER %token SHOW_DATE_EXPR @@ -613,7 +638,8 @@ character_or_special_or_insert_or_query: character_or_special | query | query_not - | insert ; + | insert + | attach ; character_or_special: special @@ -1189,3 +1215,17 @@ insert: quote_fmt_insert_user_input(sub_expr.buffer); } }; + +attach: + ATTACH_FILE + { + current = &sub_expr; + clear_buffer(); + } + OPARENT sub_expr CPARENT + { + current = &main_expr; + if (!dry_run) { + quote_fmt_attach_file(sub_expr.buffer); + } + };