aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addressbook/gui/contact-editor/e-contact-quick-add.c25
-rw-r--r--addressbook/gui/contact-editor/e-contact-quick-add.h2
-rw-r--r--mail/e-mail-reader.c16
-rw-r--r--modules/addressbook/e-book-shell-backend.c2
4 files changed, 43 insertions, 2 deletions
diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.c b/addressbook/gui/contact-editor/e-contact-quick-add.c
index 6525738fed..36bd4ed948 100644
--- a/addressbook/gui/contact-editor/e-contact-quick-add.c
+++ b/addressbook/gui/contact-editor/e-contact-quick-add.c
@@ -589,6 +589,31 @@ e_contact_quick_add_free_form (const gchar *text, EContactQuickAddCallback cb, g
}
void
+e_contact_quick_add_email (const gchar *email, EContactQuickAddCallback cb, gpointer closure)
+{
+ gchar *name = NULL;
+ gchar *addr = NULL;
+ gchar *lt, *gt;
+
+ /* Handle something of the form "Foo <foo@bar.com>". This is more
+ * more forgiving than the free-form parser, allowing for unquoted
+ * whitespace since we know the whole string is an email address. */
+
+ lt = (email != NULL) ? strchr (email, '<') : NULL;
+ gt = (lt != NULL) ? strchr (email, '>') : NULL;
+
+ if (lt != NULL && gt != NULL && (gt - lt) > 0) {
+ name = g_strndup (email, lt - email);
+ addr = g_strndup (lt + 1, gt - lt - 1);
+ }
+
+ e_contact_quick_add (name, addr, cb, closure);
+
+ g_free (name);
+ g_free (addr);
+}
+
+void
e_contact_quick_add_vcard (const gchar *vcard, EContactQuickAddCallback cb, gpointer closure)
{
QuickAdd *qa;
diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.h b/addressbook/gui/contact-editor/e-contact-quick-add.h
index e58722b4a2..a4d06ef12a 100644
--- a/addressbook/gui/contact-editor/e-contact-quick-add.h
+++ b/addressbook/gui/contact-editor/e-contact-quick-add.h
@@ -32,6 +32,8 @@ void e_contact_quick_add (const gchar *name, const gchar *email,
void e_contact_quick_add_free_form (const gchar *text, EContactQuickAddCallback cb, gpointer closure);
+void e_contact_quick_add_email (const gchar *email, EContactQuickAddCallback cb, gpointer closure);
+
void e_contact_quick_add_vcard (const gchar *vcard, EContactQuickAddCallback cb, gpointer closure);
#endif /* __E_CONTACT_QUICK_ADD_H__ */
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index c94749b5a5..c5106b6c23 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -105,9 +105,11 @@ action_add_to_address_book_cb (GtkAction *action,
EShell *shell;
EShellBackend *shell_backend;
EMFormatHTMLDisplay *html_display;
+ CamelInternetAddress *cia;
EWebView *web_view;
CamelURL *curl;
const gchar *uri;
+ gchar *email;
/* This action is defined in EMailDisplay. */
@@ -125,11 +127,23 @@ action_add_to_address_book_cb (GtkAction *action,
if (curl->path == NULL || *curl->path == '\0')
goto exit;
+ cia = camel_internet_address_new ();
+ if (camel_address_decode (CAMEL_ADDRESS (cia), curl->path) < 0) {
+ camel_object_unref (cia);
+ goto exit;
+ }
+
+ email = camel_address_format (CAMEL_ADDRESS (cia));
+
/* XXX EBookShellBackend should be listening for this
* event. Kind of kludgey, but works for now. */
shell = e_shell_backend_get_shell (shell_backend);
- e_shell_event (shell, "contact-quick-add-email", curl->path);
+ e_shell_event (shell, "contact-quick-add-email", email);
emu_remove_from_mail_cache_1 (curl->path);
+
+ camel_object_unref (cia);
+ g_free (email);
+
exit:
camel_url_free (curl);
}
diff --git a/modules/addressbook/e-book-shell-backend.c b/modules/addressbook/e-book-shell-backend.c
index 11ff1e3553..1166cd61c3 100644
--- a/modules/addressbook/e-book-shell-backend.c
+++ b/modules/addressbook/e-book-shell-backend.c
@@ -387,7 +387,7 @@ book_shell_backend_quick_add_email_cb (EShell *shell,
/* XXX This is an ugly hack but it's the only way I could think
* of to integrate this feature with other shell modules. */
- e_contact_quick_add_free_form (email, NULL, NULL);
+ e_contact_quick_add_email (email, NULL, NULL);
}
static void