iterator = tny_list_create_iterator (parts);
while (!tny_iterator_is_done (iterator)) {
TnyMimePart *subpart = TNY_MIME_PART (tny_iterator_get_current (iterator));
iterator = tny_list_create_iterator (parts);
while (!tny_iterator_is_done (iterator)) {
TnyMimePart *subpart = TNY_MIME_PART (tny_iterator_get_current (iterator));
- TnyMimePart *subpart_copy = copy_mime_part (subpart);
- tny_mime_part_add_part (result, subpart_copy);
- g_object_unref (subpart);
+ if (subpart) {
+ TnyMimePart *subpart_copy = copy_mime_part (subpart);
+ tny_mime_part_add_part (result, subpart_copy);
+ g_object_unref (subpart);
+ }
+
gchar *to_quote_converted = modest_text_utils_convert_to_html (to_quote);
g_free (to_quote);
to_quote = to_quote_converted;
gchar *to_quote_converted = modest_text_utils_convert_to_html (to_quote);
g_free (to_quote);
to_quote = to_quote_converted;
/* we need to strdown the content type, because
* tny_mime_part_has_content_type does not do it...
*/
/* we need to strdown the content type, because
* tny_mime_part_has_content_type does not do it...
*/
- content_type = g_ascii_strdown
- (tny_mime_part_get_content_type (part), -1);
+ if (part) {
+ content_type = g_ascii_strdown
+ (tny_mime_part_get_content_type (part), -1);
+ }
if (g_str_has_prefix (content_type, mime_type) &&
!tny_mime_part_is_attachment (part))
if (g_str_has_prefix (content_type, mime_type) &&
!tny_mime_part_is_attachment (part))
-create_reply_forward_mail (TnyMsg *msg, const gchar *from, const gchar *signature,
+create_reply_forward_mail (TnyMsg *msg, TnyHeader *header, const gchar *from, const gchar *signature,
ModestFormatter *formatter;
gchar *subject_prefix;
/* Get body from original msg. Always look for the text/plain
part of the message to create the reply/forwarded mail */
ModestFormatter *formatter;
gchar *subject_prefix;
/* Get body from original msg. Always look for the text/plain
part of the message to create the reply/forwarded mail */
- header = tny_msg_get_header (msg);
- body = modest_tny_msg_find_body_part (msg, FALSE);
+ if (header)
+ g_object_ref (header);
+ else
+ header = tny_msg_get_header (msg);
+
+ if (msg != NULL)
+ body = modest_tny_msg_find_body_part (msg, FALSE);
/* TODO: select the formatter from account prefs */
if (modest_conf_get_bool (modest_runtime_get_conf (), MODEST_CONF_PREFER_FORMATTED_TEXT, NULL))
/* TODO: select the formatter from account prefs */
if (modest_conf_get_bool (modest_runtime_get_conf (), MODEST_CONF_PREFER_FORMATTED_TEXT, NULL))
tny_mime_part_get_parts (TNY_MIME_PART (msg), parts);
tny_list_foreach (parts, add_if_attachment, &attachments_list);
tny_mime_part_get_parts (TNY_MIME_PART (msg), parts);
tny_list_foreach (parts, add_if_attachment, &attachments_list);
- new_msg = create_reply_forward_mail (msg, from, signature, FALSE, forward_type, attachments_list);
+ new_msg = create_reply_forward_mail (msg, NULL, from, signature, FALSE, forward_type, attachments_list);
const gchar *from,
const gchar *signature,
ModestTnyMsgReplyType reply_type,
ModestTnyMsgReplyMode reply_mode)
{
TnyMsg *new_msg = NULL;
const gchar *from,
const gchar *signature,
ModestTnyMsgReplyType reply_type,
ModestTnyMsgReplyMode reply_mode)
{
TnyMsg *new_msg = NULL;
- parts = TNY_LIST (tny_simple_list_new());
- tny_mime_part_get_parts (TNY_MIME_PART (msg), parts);
- tny_list_foreach (parts, add_if_attachment, &attachments_list);
+ if (msg != NULL) {
+ parts = TNY_LIST (tny_simple_list_new());
+ tny_mime_part_get_parts (TNY_MIME_PART (msg), parts);
+ tny_list_foreach (parts, add_if_attachment, &attachments_list);
+ }
- new_msg = create_reply_forward_mail (msg, from, signature, TRUE, reply_type, attachments_list);
+ new_msg = create_reply_forward_mail (msg, header, from, signature, TRUE, reply_type, attachments_list);
if (attachments_list) {
g_list_foreach (attachments_list, (GFunc) g_object_unref, NULL);
g_list_free (attachments_list);
}
if (attachments_list) {
g_list_foreach (attachments_list, (GFunc) g_object_unref, NULL);
g_list_free (attachments_list);
}