ECompEditor: Extract plain email address from backend property
The code expects the property to be a plain email address, without the name and the other things, thus, in case the backend returns email address with the name, extract only the plain address out of it.
This commit is contained in:
@@ -2936,6 +2936,27 @@ e_comp_editor_get_managed_widget (ECompEditor *comp_editor,
|
||||
return widget;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
e_comp_editor_extract_email_address (const gchar *email_address)
|
||||
{
|
||||
CamelInternetAddress *addr;
|
||||
const gchar *str_addr;
|
||||
gchar *address;
|
||||
|
||||
if (!email_address || !*email_address)
|
||||
return NULL;
|
||||
|
||||
addr = camel_internet_address_new ();
|
||||
if (camel_address_unformat (CAMEL_ADDRESS (addr), email_address) == 1 &&
|
||||
camel_internet_address_get (addr, 0, NULL, &str_addr)) {
|
||||
address = g_strdup (str_addr);
|
||||
} else {
|
||||
address = g_strdup (email_address);
|
||||
}
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
e_comp_editor_get_alarm_email_address (ECompEditor *comp_editor)
|
||||
{
|
||||
@@ -2954,7 +2975,7 @@ e_comp_editor_set_alarm_email_address (ECompEditor *comp_editor,
|
||||
return;
|
||||
|
||||
g_free (comp_editor->priv->alarm_email_address);
|
||||
comp_editor->priv->alarm_email_address = g_strdup (alarm_email_address);
|
||||
comp_editor->priv->alarm_email_address = e_comp_editor_extract_email_address (alarm_email_address);
|
||||
|
||||
g_object_notify (G_OBJECT (comp_editor), "alarm-email-address");
|
||||
}
|
||||
@@ -2977,7 +2998,7 @@ e_comp_editor_set_cal_email_address (ECompEditor *comp_editor,
|
||||
return;
|
||||
|
||||
g_free (comp_editor->priv->cal_email_address);
|
||||
comp_editor->priv->cal_email_address = g_strdup (cal_email_address);
|
||||
comp_editor->priv->cal_email_address = e_comp_editor_extract_email_address (cal_email_address);
|
||||
|
||||
g_object_notify (G_OBJECT (comp_editor), "cal-email-address");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user