commit aaf6267787e78b070f5d5d6909044c2c2109b490
parent a1d8a425780cd917ba5dff506d29fd712b158674
Author: Paweł Pękala <c0rn@gazeta.pl>
Date: Wed, 2 Dec 2009 15:20:55 +0000
2009-12-02 [pawel] 3.7.3cvs27
* src/compose.c
* src/compose.h
Fix Bug 1850 "Reply All" duplicates "To" user in "CC" if original
email had user in "From" and "CC"
Don't allow duplicate addresses in compose window headers
Diffstat:
5 files changed, 48 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,11 @@
+2009-12-02 [pawel] 3.7.3cvs27
+
+ * src/compose.c
+ * src/compose.h
+ Fix Bug 1850 "Reply All" duplicates "To" user in "CC" if original
+ email had user in "From" and "CC"
+ Don't allow duplicate addresses in compose window headers
+
2009-12-02 [mones] 3.7.3cvs26
* manual/intro.xml
diff --git a/PATCHSETS b/PATCHSETS
@@ -3900,3 +3900,4 @@
( cvs diff -u -r 1.382.2.525 -r 1.382.2.526 src/compose.c; ) > 3.7.3cvs24.patchset
( cvs diff -u -r 1.395.2.415 -r 1.395.2.416 src/summaryview.c; cvs diff -u -r 1.68.2.52 -r 1.68.2.53 src/summaryview.h; ) > 3.7.3cvs25.patchset
( cvs diff -u -r 1.1.2.9 -r 1.1.2.10 manual/intro.xml; cvs diff -u -r 1.1.2.3 -r 1.1.2.4 manual/es/intro.xml; cvs diff -u -r 1.1.2.5 -r 1.1.2.6 manual/fr/intro.xml; cvs diff -u -r 1.1.2.1 -r 1.1.2.2 manual/it/intro.xml; cvs diff -u -r 1.1.2.3 -r 1.1.2.4 manual/pl/intro.xml; ) > 3.7.3cvs26.patchset
+( cvs diff -u -r 1.382.2.526 -r 1.382.2.527 src/compose.c; cvs diff -u -r 1.50.2.56 -r 1.50.2.57 src/compose.h; ) > 3.7.3cvs27.patchset
diff --git a/configure.ac b/configure.ac
@@ -12,7 +12,7 @@ MINOR_VERSION=7
MICRO_VERSION=3
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=26
+EXTRA_VERSION=27
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=
diff --git a/src/compose.c b/src/compose.c
@@ -6545,17 +6545,41 @@ static void compose_create_header_entry(Compose *compose)
static void compose_add_header_entry(Compose *compose, const gchar *header,
gchar *text, ComposePrefType pref_type)
{
- ComposeHeaderEntry *last_header;
+ ComposeHeaderEntry *last_header = compose->header_last;
+ gchar *tmp = g_strdup(text), *email;
+
+ extract_address(tmp);
+ email = g_utf8_strdown(tmp, -1);
+
+ if (g_hash_table_lookup(compose->email_hashtable, email) != NULL) {
+ debug_print("Ignoring duplicate address - %s %s, pref_type: %d\n",
+ header, text, (gint) pref_type);
+ g_free(email);
+ g_free(tmp);
+ return;
+ }
- last_header = compose->header_last;
-
combobox_select_by_text(GTK_COMBO_BOX(last_header->combo), header);
gtk_entry_set_text(GTK_ENTRY(last_header->entry), text);
last_header->type = pref_type;
+
+ g_hash_table_insert(compose->email_hashtable, email,
+ GUINT_TO_POINTER(1));
+ g_free(tmp);
}
-static void compose_destroy_headerentry(ComposeHeaderEntry *headerentry)
+static void compose_destroy_headerentry(Compose *compose,
+ ComposeHeaderEntry *headerentry)
{
+ gchar *text = gtk_editable_get_chars(GTK_EDITABLE(headerentry->entry), 0, -1);
+ gchar *email;
+
+ extract_address(text);
+ email = g_utf8_strdown(text, -1);
+ g_hash_table_remove(compose->email_hashtable, email);
+ g_free(text);
+ g_free(email);
+
gtk_widget_destroy(headerentry->combo);
gtk_widget_destroy(headerentry->entry);
gtk_widget_destroy(headerentry->button);
@@ -6567,7 +6591,7 @@ static void compose_remove_header_entries(Compose *compose)
{
GSList *list;
for (list = compose->header_list; list; list = list->next)
- compose_destroy_headerentry((ComposeHeaderEntry *)list->data);
+ compose_destroy_headerentry(compose, (ComposeHeaderEntry *)list->data);
compose->header_last = NULL;
g_slist_free(compose->header_list);
@@ -7447,6 +7471,9 @@ static Compose *compose_create(PrefsAccount *account,
compose->replyinfo = NULL;
compose->fwdinfo = NULL;
+ compose->email_hashtable = g_hash_table_new_full(g_str_hash,
+ g_str_equal, (GDestroyNotify) g_free, NULL);
+
compose->replyto = NULL;
compose->cc = NULL;
compose->bcc = NULL;
@@ -8227,6 +8254,8 @@ static void compose_destroy(Compose *compose)
slist_free_strings(compose->header_list);
g_slist_free(compose->header_list);
+ g_hash_table_destroy(compose->email_hashtable);
+
procmsg_msginfo_free(compose->targetinfo);
procmsg_msginfo_free(compose->replyinfo);
procmsg_msginfo_free(compose->fwdinfo);
@@ -9037,7 +9066,7 @@ static void account_activated(GtkComboBox *optmenu, gpointer data)
ComposeHeaderEntry *hentry=(ComposeHeaderEntry *)list->data;
if (hentry->type == PREF_ACCOUNT || !list->next) {
- compose_destroy_headerentry(hentry);
+ compose_destroy_headerentry(compose, hentry);
continue;
}
@@ -9060,7 +9089,7 @@ static void account_activated(GtkComboBox *optmenu, gpointer data)
&style->base[GTK_STATE_NORMAL]);
saved_list = g_slist_append(saved_list, state);
- compose_destroy_headerentry(hentry);
+ compose_destroy_headerentry(compose, hentry);
}
compose->header_last = NULL;
diff --git a/src/compose.h b/src/compose.h
@@ -156,6 +156,8 @@ struct _Compose
guint header_nextrow;
ComposeHeaderEntry *header_last;
+ GHashTable *email_hashtable;
+
gchar *replyto;
gchar *cc;
gchar *bcc;