+static gchar *
+attachments_as_html(TnyMsgIface *msg)
+{
+ gboolean attachments_found = FALSE;
+ GString *appendix;
+ const GList *attl;
+ const gchar *content_type, *filename;
+ if (!msg)
+ return g_malloc0(1);
+ appendix = g_string_new("<HTML><BODY>\n<h5>Attachments:</h5>\n");
+ attl = tny_msg_iface_get_parts(msg);
+ while (attl) {
+ filename = "";
+ content_type = tny_msg_mime_part_iface_get_content_type(
+ TNY_MSG_MIME_PART_IFACE(attl->data));
+ g_return_if_fail(content_type);
+ if (strcmp (content_type, "image/jpeg") == 0 || strcmp (content_type, "image/gif") == 0) {
+ filename = tny_msg_mime_part_iface_get_filename(
+ TNY_MSG_MIME_PART_IFACE(attl->data));
+ if (!filename)
+ filename = "unknown";
+ else
+ attachments_found = TRUE;
+ g_string_append_printf(appendix, "<A href=\"attachment:%s\">%s</A>: %s<BR>\n", filename, filename, content_type);
+ }
+ attl = attl->next;
+ }
+ g_string_append(appendix, "</BODY></HTML>");
+ if (!attachments_found)
+ g_string_assign(appendix, "");
+ return g_string_free(appendix, FALSE);
+}
+