diff options
author | Milan Crha <mcrha@redhat.com> | 2009-05-28 21:00:16 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2009-05-29 00:17:57 +0800 |
commit | e66024d664a1d346d6246b4e8b7c682bafcf4dda (patch) | |
tree | 1d362f3d5c943a0fc76e8a51ede803b2e0466717 | |
parent | 3f395fce0fe950a5fb6959f01469e512ce81f377 (diff) | |
download | gsoc2013-evolution-e66024d664a1d346d6246b4e8b7c682bafcf4dda.tar gsoc2013-evolution-e66024d664a1d346d6246b4e8b7c682bafcf4dda.tar.gz gsoc2013-evolution-e66024d664a1d346d6246b4e8b7c682bafcf4dda.tar.bz2 gsoc2013-evolution-e66024d664a1d346d6246b4e8b7c682bafcf4dda.tar.lz gsoc2013-evolution-e66024d664a1d346d6246b4e8b7c682bafcf4dda.tar.xz gsoc2013-evolution-e66024d664a1d346d6246b4e8b7c682bafcf4dda.tar.zst gsoc2013-evolution-e66024d664a1d346d6246b4e8b7c682bafcf4dda.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.
-rw-r--r-- | plugins/bbdb/bbdb.c | 56 |
1 files changed, 30 insertions, 26 deletions
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 |