diff options
author | Milan Crha <mcrha@redhat.com> | 2009-05-28 21:00:16 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2009-05-28 21:00:16 +0800 |
commit | e61e5e2325f8bb84fbb550d602aed000ae805a4e (patch) | |
tree | d28b9a1adc42888f50267590daa4b0c08ab89186 /plugins | |
parent | b33ce8f2a6dfab4a17eacd15e296035b4e2cfa49 (diff) | |
download | gsoc2013-evolution-e61e5e2325f8bb84fbb550d602aed000ae805a4e.tar gsoc2013-evolution-e61e5e2325f8bb84fbb550d602aed000ae805a4e.tar.gz gsoc2013-evolution-e61e5e2325f8bb84fbb550d602aed000ae805a4e.tar.bz2 gsoc2013-evolution-e61e5e2325f8bb84fbb550d602aed000ae805a4e.tar.lz gsoc2013-evolution-e61e5e2325f8bb84fbb550d602aed000ae805a4e.tar.xz gsoc2013-evolution-e61e5e2325f8bb84fbb550d602aed000ae805a4e.tar.zst gsoc2013-evolution-e61e5e2325f8bb84fbb550d602aed000ae805a4e.zip |
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.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/bbdb/bbdb.c | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/plugins/bbdb/bbdb.c b/plugins/bbdb/bbdb.c index a2499dfa98..679f30466d 100644 --- a/plugins/bbdb/bbdb.c +++ b/plugins/bbdb/bbdb.c @@ -227,43 +227,47 @@ bbdb_do_thread (const char *name, const char *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) + 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 |