From e66024d664a1d346d6246b4e8b7c682bafcf4dda Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Thu, 28 May 2009 15:00:16 +0200 Subject: Bug #583441 - bbdb plugin is getting information from composer now It used to ask composer for a message, a generated one, which asks for a password to the signing twice, once here and once when composer itself generates message for sending. bbdb crashed when user canceled password prompt for a key, as it didn't check for NULL returned. --- plugins/bbdb/bbdb.c | 56 ++++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 26 deletions(-) (limited to 'plugins/bbdb') diff --git a/plugins/bbdb/bbdb.c b/plugins/bbdb/bbdb.c index 2ec008dbfb..8cd8535a73 100644 --- a/plugins/bbdb/bbdb.c +++ b/plugins/bbdb/bbdb.c @@ -227,43 +227,47 @@ bbdb_do_thread (const gchar *name, const gchar *email) G_UNLOCK (todo); } +static void +walk_destinations_and_free (EDestination **dests) +{ + gint i; + + if (!dests) + return; + + for (i = 0; dests[i] != NULL; i++) { + const char *name, *addr; + + name = e_destination_get_name (dests[i]); + addr = e_destination_get_email (dests[i]); + + if (name || addr) + bbdb_do_thread (name, addr); + } + + e_destination_freev (dests); +} + void bbdb_handle_send (EPlugin *ep, EMEventTargetComposer *target) { + EComposerHeaderTable *table; GConfClient *gconf; - CamelMimeMessage *message = NULL; - const CamelInternetAddress *to, *cc; - gint i, len, enable; - gconf = gconf_client_get_default (); + gboolean enable; + gconf = gconf_client_get_default (); enable = gconf_client_get_bool (gconf, GCONF_KEY_ENABLE, NULL); - g_object_unref (G_OBJECT (gconf)); + g_object_unref (gconf); if (!enable) return; - message = e_msg_composer_get_message(target->composer, 1); - - to = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO); - - len = CAMEL_ADDRESS (to)->addresses->len; - for (i = 0; i < len; i++) { - const gchar *name, *addr; - if (!(camel_internet_address_get (to, i, &name, &addr))) - continue; - bbdb_do_thread (name, addr); - } - - - cc = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_CC); + table = e_msg_composer_get_header_table (target->composer); + g_return_if_fail (table); - len = CAMEL_ADDRESS (cc)->addresses->len; - for (i = 0; i < len; i++) { - const gchar *name, *addr; - if (!(camel_internet_address_get (cc, i, &name, &addr))) - continue; - bbdb_do_thread (name, addr); - } + /* read information from the composer, not from a generated message */ + walk_destinations_and_free (e_composer_header_table_get_destinations_to (table)); + walk_destinations_and_free (e_composer_header_table_get_destinations_cc (table)); } static void -- cgit v1.2.3