static const gchar * get_email (EContact *contact, EContactField field_id, gchar **to_free) { gchar *name = NULL, *mail = NULL; const gchar *value = e_contact_get_const (contact, field_id); *to_free = NULL; if (eab_parse_qp_email (value, &name, &mail)) { *to_free = g_strdup_printf ("%s <%s>", name, mail); value = *to_free; } g_free (name); g_free (mail); return value; }
/* This is only wrapper to parse_qp_mail, it decodes string and if returned TRUE, * then makes one string and returns it, otherwise returns NULL. * Returned string is usable to place directly into GtkHtml stream. * Returned value should be freed with g_free. */ gchar * eab_parse_qp_email_to_html (const gchar *string) { gchar *name = NULL, *mail = NULL; gchar *html_name, *html_mail; gchar *value; if (!eab_parse_qp_email (string, &name, &mail)) return NULL; html_name = e_text_to_html (name, 0); html_mail = e_text_to_html (mail, E_TEXT_TO_HTML_CONVERT_ADDRESSES); value = g_strdup_printf ("%s <%s>", html_name, html_mail); g_free (html_name); g_free (html_mail); g_free (name); g_free (mail); return value; }
static void render_contact_column (EABContactFormatter *formatter, EContact *contact, GString *buffer) { GString *accum, *email; GList *email_list, *l, *email_attr_list, *al; gint email_num = 0; const gchar *nl; guint32 sip_flags = 0; if (formatter->priv->supports_sip) sip_flags = E_TEXT_TO_HTML_CONVERT_URLS | E_TEXT_TO_HTML_HIDE_URL_SCHEME | E_TEXT_TO_HTML_URL_IS_WHOLE_TEXT | E_CREATE_SIP_URL; email = g_string_new (""); nl = ""; email_list = e_contact_get (contact, E_CONTACT_EMAIL); email_attr_list = e_contact_get_attributes (contact, E_CONTACT_EMAIL); for (l = email_list, al = email_attr_list; l && al; l = l->next, al = al->next) { gchar *name = NULL, *mail = NULL; gchar *attr_str = (gchar *) get_email_location ((EVCardAttribute *) al->data); if (!eab_parse_qp_email (l->data, &name, &mail)) mail = e_text_to_html (l->data, 0); g_string_append_printf ( email, "%s%s%s<a href=\"internal-mailto:%d\">%s</a>%s " "<span class=\"header\">(%s)</span>", nl, name ? name : "", name ? " <" : "", email_num, mail, name ? ">" : "", attr_str ? attr_str : ""); email_num++; nl = "<br>"; g_free (name); g_free (mail); } g_list_foreach (email_list, (GFunc) g_free, NULL); g_list_foreach (email_attr_list, (GFunc) e_vcard_attribute_free, NULL); g_list_free (email_list); g_list_free (email_attr_list); accum = g_string_new (""); if (email->len) render_table_row (accum, _("Email"), email->str, NULL, 0); accum_sip (accum, contact, EAB_CONTACT_FORMATTER_SIP_TYPE_OTHER, NULL, sip_flags); accum_attribute (accum, contact, _("Nickname"), E_CONTACT_NICKNAME, NULL, 0); accum_attribute_multival (accum, contact, _("AIM"), E_CONTACT_IM_AIM, AIM_ICON, 0); accum_attribute_multival (accum, contact, _("GroupWise"), E_CONTACT_IM_GROUPWISE, GROUPWISE_ICON, 0); accum_attribute_multival (accum, contact, _("ICQ"), E_CONTACT_IM_ICQ, ICQ_ICON, 0); accum_attribute_multival (accum, contact, _("Jabber"), E_CONTACT_IM_JABBER, JABBER_ICON, 0); accum_attribute_multival (accum, contact, _("MSN"), E_CONTACT_IM_MSN, MSN_ICON, 0); accum_attribute_multival (accum, contact, _("Yahoo"), E_CONTACT_IM_YAHOO, YAHOO_ICON, 0); accum_attribute_multival (accum, contact, _("Gadu-Gadu"), E_CONTACT_IM_GADUGADU, GADUGADU_ICON, 0); accum_attribute_multival (accum, contact, _("Skype"), E_CONTACT_IM_SKYPE, SKYPE_ICON, 0); accum_attribute_multival (accum, contact, _("Twitter"), E_CONTACT_IM_TWITTER, TWITTER_ICON, 0); if (accum->len) g_string_append_printf ( buffer, "<div class=\"column\" id=\"contact-internet\">" "<table border=\"0\" cellspacing=\"5\">%s</table>" "</div>", accum->str); g_string_free (accum, TRUE); g_string_free (email, TRUE); }
static void render_contact_list_row (EABContactFormatter *formatter, EDestination *destination, GString *buffer) { gchar *evolution_imagesdir; gboolean list_collapsed = FALSE; const gchar *textrep; gchar *name = NULL, *email_addr = NULL; evolution_imagesdir = g_filename_to_uri (EVOLUTION_IMAGESDIR, NULL, NULL); textrep = e_destination_get_textrep (destination, TRUE); if (!eab_parse_qp_email (textrep, &name, &email_addr)) email_addr = g_strdup (textrep); g_string_append (buffer, "<tr>"); if (e_destination_is_evolution_list (destination)) { g_string_append_printf ( buffer, "<td width=" IMAGE_COL_WIDTH " valign=\"top\" align=\"left\">" "<img src=\"evo-file://%s/minus.png\" " "id=\"%s\" " "class=\"navigable _evo_collapse_button\">" "</td><td width=\"100%%\" align=\"left\">%s", evolution_imagesdir, e_destination_get_contact_uid (destination), name ? name : email_addr); if (!list_collapsed) { const GList *dest, *dests; g_string_append_printf ( buffer, "<br><table cellspacing=\"1\" id=\"list-%s\">", e_destination_get_contact_uid (destination)); dests = e_destination_list_get_root_dests (destination); for (dest = dests; dest; dest = dest->next) { render_contact_list_row ( formatter, dest->data, buffer); } g_string_append (buffer, "</table>"); } g_string_append (buffer, "</td>"); } else { if (name && *name) { g_string_append_printf ( buffer, "<td colspan=\"2\">%s <" "<a href=\"mailto:%s\">%s</a>>" "</td>", name, email_addr, email_addr); } else { g_string_append_printf ( buffer, "<td colspan=\"2\">" "<a href=\"mailto:%s\">%s</a>" "</td>", email_addr, email_addr); } } g_string_append (buffer, "</tr>"); g_free (evolution_imagesdir); g_free (name); g_free (email_addr); }
static void render_contact_list_row (EABContactFormatter *formatter, EDestination *destination, GString *buffer) { gboolean list_collapsed = FALSE; const gchar *textrep; gchar *name = NULL, *email_addr = NULL; textrep = e_destination_get_textrep (destination, TRUE); if (!eab_parse_qp_email (textrep, &name, &email_addr)) email_addr = g_strdup (textrep); g_string_append (buffer, "<tr>"); if (e_destination_is_evolution_list (destination)) { g_string_append_printf ( buffer, "<td width=" IMAGE_COL_WIDTH " valign=\"top\" align=\"left\">" "<button type=\"button\" id=\"%s\" class=\"header-collapse _evo_collapse_button\" style=\"display: inline-block;\">" "<img src=\"gtk-stock://pan-down-symbolic\" />" "</button>" "</td><td width=\"100%%\" align=\"left\">%s", e_destination_get_contact_uid (destination), name ? name : email_addr); if (!list_collapsed) { const GList *dest, *dests; g_string_append_printf ( buffer, "<br><table cellspacing=\"1\" id=\"list-%s\">", e_destination_get_contact_uid (destination)); dests = e_destination_list_get_root_dests (destination); for (dest = dests; dest; dest = dest->next) { render_contact_list_row ( formatter, dest->data, buffer); } g_string_append (buffer, "</table>"); } g_string_append (buffer, "</td>"); } else { if (name && *name) { g_string_append_printf ( buffer, "<td colspan=\"2\">%s <" "<a href=\"mailto:%s\">%s</a>>" "</td>", name, email_addr, email_addr); } else { g_string_append_printf ( buffer, "<td colspan=\"2\">" "<a href=\"mailto:%s\">%s</a>" "</td>", email_addr, email_addr); } } g_string_append (buffer, "</tr>"); g_free (name); g_free (email_addr); }