+get_related_images (ModestMsgEditWindow *self, TnyMsg *msg)
+{
+ TnyMimePart *parent = NULL;
+ const gchar *content_type = NULL;
+ ModestMsgEditWindowPrivate *priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (self);
+
+ content_type = tny_mime_part_get_content_type (TNY_MIME_PART (msg));
+
+ if (content_type && !g_strcasecmp (content_type, "multipart/related")) {
+ parent = g_object_ref (msg);
+ } else if (content_type && !g_strcasecmp (content_type, "multipart/mixed")) {
+ TnyList *parts = TNY_LIST (tny_simple_list_new ());
+ TnyIterator *iter;
+
+ tny_mime_part_get_parts (TNY_MIME_PART (msg), parts);
+ iter = tny_list_create_iterator (parts);
+ while (!tny_iterator_is_done (iter)) {
+ TnyMimePart *part;
+ part = TNY_MIME_PART (tny_iterator_get_current (iter));
+ content_type = tny_mime_part_get_content_type (part);
+ if (content_type && !g_strcasecmp (content_type, "multipart/related")) {
+ parent = part;
+ break;
+ } else {
+ g_object_unref (part);
+ }
+ tny_iterator_next (iter);
+ }
+ g_object_unref (iter);
+ g_object_unref (parts);
+ }
+
+ if (parent != NULL) {
+ TnyList *parts = TNY_LIST (tny_simple_list_new ());
+ TnyIterator *iter;
+
+ tny_mime_part_get_parts (TNY_MIME_PART (parent), parts);
+ iter = tny_list_create_iterator (parts);
+ while (!tny_iterator_is_done (iter)) {
+ TnyMimePart *part;
+ part = TNY_MIME_PART (tny_iterator_get_current (iter));
+ content_type = tny_mime_part_get_content_type (part);
+ if (content_type && g_str_has_prefix (content_type, "image/")) {
+ priv->images = g_list_prepend (priv->images, part);
+ } else {
+ g_object_unref (part);
+ }
+ tny_iterator_next (iter);
+ }
+ g_object_unref (iter);
+ g_object_unref (parts);
+ g_object_unref (parent);
+ }
+}
+
+static void