gboolean contacts_to_add = FALSE;
msg = tny_msg_view_get_msg (TNY_MSG_VIEW (priv->msg_view));
- if (msg == NULL) return;
- recipients = modest_tny_msg_get_all_recipients_list (msg);
+ if (msg == NULL) {
+ TnyHeader *header;
+
+ header = modest_msg_view_window_get_header (self);
+ if (header == NULL)
+ return;
+ recipients = modest_tny_msg_header_get_all_recipients_list (header);
+ g_object_unref (header);
+ } else {
+ recipients = modest_tny_msg_get_all_recipients_list (msg);
+ g_object_unref (msg);
+ }
if (recipients != NULL) {
GtkWidget *picker_dialog;
}
if (recipients) {g_slist_foreach (recipients, (GFunc) g_free, NULL); g_slist_free (recipients);}
- g_object_unref (msg);
}
}
GSList *
-modest_tny_msg_get_all_recipients_list (TnyMsg *msg)
+modest_tny_msg_header_get_all_recipients_list (TnyHeader *header)
{
- TnyHeader *header = NULL;
GSList *recipients = NULL;
gchar *from = NULL, *to = NULL, *cc = NULL, *bcc = NULL;
- if (msg == NULL)
- return NULL;
-
- header = tny_msg_get_header (msg);
if (header == NULL)
return NULL;
return recipients;
}
+GSList *
+modest_tny_msg_get_all_recipients_list (TnyMsg *msg)
+{
+ TnyHeader *header = NULL;
+ GSList *recipients = NULL;
+
+ if (msg == NULL)
+ return NULL;
+
+ header = tny_msg_get_header (msg);
+ if (header == NULL)
+ return NULL;
+
+ recipients = modest_tny_msg_header_get_all_recipients_list (header);
+ g_object_unref (header);
+
+ return recipients;
+}
+
/**
* modest_tny_msg_get_all_recipients_list:
+ * @header: a #TnyHeader
+ *
+ * Obtains a list of all the addresses available in @header.
+ *
+ * Returns: a newly allocated #GSList of strings. Caller should free strings and list.
+ */
+GSList *
+modest_tny_msg_header_get_all_recipients_list (TnyHeader *header);
+
+/**
+ * modest_tny_msg_get_all_recipients_list:
* @msg: a #TnyMsg
*
* Obtains a list of all the addresses available in a message header.
msg = modest_msg_view_window_get_message (MODEST_MSG_VIEW_WINDOW (win));
/* Message is loaded asynchronously, so this could happen */
- if (!msg)
- return TRUE;
+ if (!msg) {
+#ifdef MODEST_TOOLKIT_HILDON2
+ TnyHeader *header;
+
+ header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (win));
+ if (!header)
+ return TRUE;
- recipients = modest_tny_msg_get_all_recipients_list (msg);
+ recipients = modest_tny_msg_header_get_all_recipients_list (header);
+ g_object_unref (header);
+#else
+ return TRUE;
+#endif
+ } else {
+ recipients = modest_tny_msg_get_all_recipients_list (msg);
+ g_object_unref (msg);
+ }
has_recipients_to_add = FALSE;
for (node = recipients; node != NULL; node = g_slist_next (node)) {
g_slist_foreach (recipients, (GFunc) g_free, NULL);
g_slist_free (recipients);
- g_object_unref (msg);
return !has_recipients_to_add;
}