{
OssoABookAccount *account = NULL;
GtkWidget *dialog = NULL;
+ gchar *email_address = NULL;
contact_model = osso_abook_contact_model_new ();
if (!open_addressbook ()) {
}
return;
}
+
+ email_address = modest_text_utils_get_email_address (address);
- account = osso_abook_account_get (EVC_EMAIL, NULL, address);
+ account = osso_abook_account_get (EVC_EMAIL, NULL, email_address);
+ g_free (email_address);
if (account)
{
dialog = osso_abook_add_to_contacts_dialog_new (contact_model, account);
return address;
}
+gchar *
+modest_text_utils_get_email_address (const gchar *full_address)
+{
+ const gchar *left, *right;
+
+ if (!full_address)
+ return NULL;
+
+ g_return_val_if_fail (g_utf8_validate (full_address, -1, NULL), NULL);
+
+ left = g_strrstr_len (full_address, strlen(full_address), "<");
+ if (left == NULL)
+ return g_strdup (full_address);
+ right = g_strstr_len (left, strlen(left), ">");
+ if (right == NULL)
+ return g_strdup (full_address);
+
+ return g_strndup (left + 1, right - left - 1);
+}
gint
modest_text_utils_get_subject_prefix_len (const gchar *sub)
/**
- * modest_text_utils_get_display_addres:
+ * modest_text_utils_get_display_address:
* @address: original address (UTF8 string)
*
* make a 'display address' from an address:
*/
gchar* modest_text_utils_get_display_address (gchar *address);
+/**
+ * modest_text_utils_get_email_address:
+ * @full_address: original address (UTF8 string)
+ *
+ * make a 'foo@bar.cx' from an address:
+ * "Foo Bar <foo@bar.cx> (Bla)" --> "foo@bar.cx"
+ * If no "<...>" is found, then it returns the full
+ * strings.
+ *
+ * Returns: a newly allocated string with the copy.
+ *
+ * NULL in case of error or if address == NULL
+ */
+gchar* modest_text_utils_get_email_address (const gchar *email_address);
+
/**
* modest_text_utils_get_subject_prefix_len: