From: Paul Date: Wed, 3 Sep 2014 10:49:17 +0000 (+0100) Subject: add Reply-To to template config X-Git-Tag: 3.11.0~26 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=8c7418e621902913b0f1ecfce19eecc8557de6a3 add Reply-To to template config --- diff --git a/src/common/template.c b/src/common/template.c index b49b7d934..683f26362 100644 --- a/src/common/template.c +++ b/src/common/template.c @@ -51,7 +51,8 @@ static Template *template_load(gchar *filename) tmpl->from = NULL; tmpl->to = NULL; tmpl->cc = NULL; - tmpl->bcc = NULL; + tmpl->bcc = NULL; + tmpl->replyto = NULL; tmpl->value = NULL; while (fgets(buf, sizeof(buf), fp) != NULL) { @@ -67,6 +68,8 @@ static Template *template_load(gchar *filename) tmpl->cc = g_strdup(g_strstrip(buf + 3)); else if (!g_ascii_strncasecmp(buf, "Bcc:", 4)) tmpl->bcc = g_strdup(g_strstrip(buf + 4)); + else if (!g_ascii_strncasecmp(buf, "Reply-To:", 9)) + tmpl->replyto = g_strdup(g_strstrip(buf + 9)); else if (!g_ascii_strncasecmp(buf, "Subject:", 8)) tmpl->subject = g_strdup(g_strstrip(buf + 8)); } @@ -101,6 +104,7 @@ void template_free(Template *tmpl) g_free(tmpl->to); g_free(tmpl->cc); g_free(tmpl->bcc); + g_free(tmpl->replyto); g_free(tmpl->value); g_free(tmpl); } @@ -269,6 +273,8 @@ static void template_write_config(GSList *tmpl_list) TRY(fprintf(fp, "Cc: %s\n", tmpl->cc) > 0); if (tmpl->bcc && *tmpl->bcc != '\0') TRY(fprintf(fp, "Bcc: %s\n", tmpl->bcc) > 0); + if (tmpl->replyto && *tmpl->replyto != '\0') + TRY(fprintf(fp, "Reply-To: %s\n", tmpl->replyto) > 0); TRY(fputs("\n", fp) != EOF); diff --git a/src/common/template.h b/src/common/template.h index c74e4cfa5..2a3780662 100644 --- a/src/common/template.h +++ b/src/common/template.h @@ -32,7 +32,8 @@ struct _Template { gchar *from; gchar *to; gchar *cc; - gchar *bcc; + gchar *bcc; + gchar *replyto; gchar *value; }; diff --git a/src/compose.c b/src/compose.c index d41d221af..c3ea943de 100644 --- a/src/compose.c +++ b/src/compose.c @@ -8659,6 +8659,24 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl) } } + if (tmpl->replyto && *tmpl->replyto != '\0') { +#ifdef USE_ENCHANT + quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE, + compose->gtkaspell); +#else + quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE); +#endif + quote_fmt_scan_string(tmpl->replyto); + quote_fmt_parse(); + + buf = quote_fmt_get_buffer(); + if (buf == NULL) { + alertpanel_error(_("Template Reply-To format error.")); + } else { + compose_entry_append(compose, buf, COMPOSE_REPLYTO, PREF_TEMPLATE); + } + } + /* process the subject */ if (tmpl->subject && *tmpl->subject != '\0') { #ifdef USE_ENCHANT diff --git a/src/prefs_template.c b/src/prefs_template.c index 68173cbd7..bafd768af 100644 --- a/src/prefs_template.c +++ b/src/prefs_template.c @@ -62,6 +62,7 @@ static struct Templates { GtkWidget *entry_to; GtkWidget *entry_cc; GtkWidget *entry_bcc; + GtkWidget *entry_replyto; GtkWidget *text_value; } templates; @@ -82,6 +83,7 @@ static struct {"To", &templates.entry_to, TRUE, NULL}, {"Cc", &templates.entry_cc, TRUE, NULL}, {"Bcc", &templates.entry_bcc, TRUE, NULL}, + {"Reply-To", &templates.entry_replyto, TRUE, NULL}, {"Subject", &templates.entry_subject, FALSE, NULL}, {NULL, NULL, FALSE, NULL} }; @@ -158,7 +160,7 @@ static void prefs_template_window_create(void) GtkWidget *scrolled_window; GtkWidget *vpaned; GtkWidget *vbox1; - GtkWidget *table; /* including : entry_[name|from|to|cc|bcc|subject] */ + GtkWidget *table; /* including : entry_[name|from|to|cc|bcc|replyto|subject] */ GtkWidget *scroll2; GtkWidget *text_value; GtkWidget *vbox2; @@ -451,6 +453,7 @@ static void prefs_template_reset_dialog(void) gtk_entry_set_text(GTK_ENTRY(templates.entry_to), ""); gtk_entry_set_text(GTK_ENTRY(templates.entry_cc), ""); gtk_entry_set_text(GTK_ENTRY(templates.entry_bcc), ""); + gtk_entry_set_text(GTK_ENTRY(templates.entry_replyto), ""); gtk_entry_set_text(GTK_ENTRY(templates.entry_subject), ""); buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(templates.text_value)); @@ -657,6 +660,9 @@ static GSList *prefs_template_get_list(void) ntmpl->bcc = tmpl->bcc && *(tmpl->bcc) ? g_strdup(tmpl->bcc) : NULL; + ntmpl->replyto = tmpl->replyto && *(tmpl->replyto) + ? g_strdup(tmpl->replyto) + : NULL; ntmpl->value = tmpl->value && *(tmpl->value) ? g_strdup(tmpl->value) : NULL; @@ -734,7 +740,8 @@ static gboolean prefs_template_list_view_set_row(gint row) gchar *from; gchar *to; gchar *cc; - gchar *bcc; + gchar *bcc; + gchar *replyto; gchar *value; GtkTextBuffer *buffer; GtkTextIter start, end; @@ -770,6 +777,8 @@ static gboolean prefs_template_list_view_set_row(gint row) 0, -1); bcc = gtk_editable_get_chars(GTK_EDITABLE(templates.entry_bcc), 0, -1); + replyto = gtk_editable_get_chars(GTK_EDITABLE(templates.entry_replyto), + 0, -1); subject = gtk_editable_get_chars(GTK_EDITABLE(templates.entry_subject), 0, -1); @@ -789,6 +798,10 @@ static gboolean prefs_template_list_view_set_row(gint row) g_free(bcc); bcc = NULL; } + if (replyto && *replyto == '\0') { + g_free(replyto); + replyto = NULL; + } if (subject && *subject == '\0') { g_free(subject); subject = NULL; @@ -818,6 +831,12 @@ static gboolean prefs_template_list_view_set_row(gint row) g_free(value); return FALSE; } + if (!prefs_template_string_is_valid(replyto, NULL, TRUE, TRUE)) { + alertpanel_error(_("The \"Replyt-To\" field of the template contains an invalid email address.")); + g_free(replyto); + g_free(value); + return FALSE; + } if (!prefs_template_string_is_valid(subject, NULL, TRUE, FALSE)) { alertpanel_error(_("The \"Subject\" field of the template is invalid.")); g_free(subject); @@ -833,6 +852,7 @@ static gboolean prefs_template_list_view_set_row(gint row) tmpl->to = to; tmpl->cc = cc; tmpl->bcc = bcc; + tmpl->replyto = replyto; tmpl->value = value; prefs_template_list_view_insert_template(templates.list_view, @@ -1252,6 +1272,7 @@ static void prefs_template_select_row(GtkTreeView *list_view, GtkTreePath *path) tmpl_def.to = ""; tmpl_def.cc = ""; tmpl_def.bcc = ""; + tmpl_def.replyto = ""; tmpl_def.value = ""; gtk_tree_model_get(model, &titer, TEMPL_DATA, &tmpl, -1); @@ -1267,6 +1288,8 @@ static void prefs_template_select_row(GtkTreeView *list_view, GtkTreePath *path) tmpl->cc ? tmpl->cc : ""); gtk_entry_set_text(GTK_ENTRY(templates.entry_bcc), tmpl->bcc ? tmpl->bcc : ""); + gtk_entry_set_text(GTK_ENTRY(templates.entry_replyto), + tmpl->replyto ? tmpl->replyto : ""); gtk_entry_set_text(GTK_ENTRY(templates.entry_subject), tmpl->subject ? tmpl->subject : "");