From 6db981fa566574d16f4664687d26147acde7ad80 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 20 Jan 2010 19:14:46 -0500 Subject: Bug 607520 - 'Add to Address Book' fails when address has space --- .../gui/contact-editor/e-contact-quick-add.c | 25 ++++++++++++++++++++++ .../gui/contact-editor/e-contact-quick-add.h | 2 ++ 2 files changed, 27 insertions(+) (limited to 'addressbook/gui/contact-editor') 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 @@ -588,6 +588,31 @@ e_contact_quick_add_free_form (const gchar *text, EContactQuickAddCallback cb, g g_free (email); } +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 ". 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) { 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__ */ -- cgit v1.2.3