From 03960198dd4a1f06e961575767a99518831333a1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Dapena=20Paz?= Date: Wed, 27 Jan 2010 16:05:01 +0100 Subject: [PATCH 1/1] Preserver headers of messages in drafts and sending messages. --- src/hildon2/modest-msg-edit-window.c | 6 ++++++ src/hildon2/modest-msg-view-window.c | 2 ++ src/modest-mail-operation.c | 13 ++++++++++++- src/modest-mail-operation.h | 4 +++- src/modest-tny-msg.c | 21 +++++++++++++++++++-- src/modest-tny-msg.h | 4 ++-- src/modest-ui-actions.c | 14 ++++++++------ 7 files changed, 52 insertions(+), 12 deletions(-) diff --git a/src/hildon2/modest-msg-edit-window.c b/src/hildon2/modest-msg-edit-window.c index e384845..b0ba454 100644 --- a/src/hildon2/modest-msg-edit-window.c +++ b/src/hildon2/modest-msg-edit-window.c @@ -1349,6 +1349,7 @@ set_msg (ModestMsgEditWindow *self, TnyMsg *msg, gboolean preserve_is_rich) TnyFolder *msg_folder; gboolean is_html = FALSE; gboolean field_view_set; + TnyList *orig_header_pairs; g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (self)); g_return_if_fail (TNY_IS_MSG (msg)); @@ -1484,6 +1485,11 @@ set_msg (ModestMsgEditWindow *self, TnyMsg *msg, gboolean preserve_is_rich) g_object_unref (msg_folder); } + orig_header_pairs = TNY_LIST (tny_simple_list_new ()); + tny_mime_part_get_header_pairs (TNY_MIME_PART (msg), orig_header_pairs); + modest_msg_edit_window_set_custom_header_pairs (self, orig_header_pairs); + g_object_unref (orig_header_pairs); + g_free (to); g_free (subject); g_free (cc); diff --git a/src/hildon2/modest-msg-view-window.c b/src/hildon2/modest-msg-view-window.c index f3ff4f0..3b96231 100644 --- a/src/hildon2/modest-msg-view-window.c +++ b/src/hildon2/modest-msg-view-window.c @@ -557,6 +557,7 @@ init_window (ModestMsgViewWindow *obj) "hovershoot-max", 0, NULL); gtk_container_add (GTK_CONTAINER (priv->main_scroll), priv->msg_view); + g_object_ref (priv->msg_view); gtk_box_pack_start (GTK_BOX(main_vbox), priv->main_scroll, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER(obj), main_vbox); @@ -636,6 +637,7 @@ modest_msg_view_window_finalize (GObject *obj) /* Sanity check: shouldn't be needed, the window mgr should call this function before */ modest_msg_view_window_disconnect_signals (MODEST_WINDOW (obj)); + g_object_unref (priv->msg_view); if (priv->fetch_image_redraw_handler > 0) { g_source_remove (priv->fetch_image_redraw_handler); diff --git a/src/modest-mail-operation.c b/src/modest-mail-operation.c index 2a0176e..020ad46 100644 --- a/src/modest-mail-operation.c +++ b/src/modest-mail-operation.c @@ -246,6 +246,7 @@ static void modest_mail_operation_create_msg (ModestMailOperation *self const GList *images_list, TnyHeaderFlags priority_flags, const gchar *references, const gchar *in_reply_to, + TnyList *header_pairs, ModestMailOperationCreateMsgCallback callback, gpointer userdata); @@ -265,6 +266,7 @@ typedef struct GList *attachments_list; GList *images_list; TnyHeaderFlags priority_flags; + TnyList *header_pairs; ModestMailOperationCreateMsgCallback callback; gpointer userdata; } CreateMsgInfo; @@ -853,6 +855,7 @@ create_msg_thread (gpointer thread_data) info->references, info->in_reply_to, info->plain_body, info->attachments_list, &attached, + info->header_pairs, &(priv->error)); } else { new_msg = modest_tny_msg_new_html_plain (info->to, info->from, info->cc, @@ -861,6 +864,7 @@ create_msg_thread (gpointer thread_data) info->html_body, info->plain_body, info->attachments_list, info->images_list, &attached, + info->header_pairs, &(priv->error)); } @@ -898,6 +902,7 @@ create_msg_thread (gpointer thread_data) g_list_free (info->attachments_list); g_list_foreach (info->images_list, (GFunc) g_object_unref, NULL); g_list_free (info->images_list); + g_object_unref (info->header_pairs); if (info->callback) { CreateMsgIdleInfo *idle_info; @@ -929,6 +934,7 @@ modest_mail_operation_create_msg (ModestMailOperation *self, TnyHeaderFlags priority_flags, const gchar *references, const gchar *in_reply_to, + TnyList *header_pairs, ModestMailOperationCreateMsgCallback callback, gpointer userdata) { @@ -951,6 +957,7 @@ modest_mail_operation_create_msg (ModestMailOperation *self, info->images_list = g_list_copy ((GList *) images_list); g_list_foreach (info->images_list, (GFunc) g_object_ref, NULL); info->priority_flags = 0 | priority_flags; + info->header_pairs = tny_list_copy (header_pairs); info->callback = callback; info->userdata = userdata; @@ -1107,7 +1114,8 @@ modest_mail_operation_send_new_mail (ModestMailOperation *self, const GList *images_list, const gchar *references, const gchar *in_reply_to, - TnyHeaderFlags priority_flags) + TnyHeaderFlags priority_flags, + TnyList *header_pairs) { ModestMailOperationPrivate *priv = NULL; SendNewMailInfo *info; @@ -1144,6 +1152,7 @@ modest_mail_operation_send_new_mail (ModestMailOperation *self, modest_mail_operation_create_msg (self, from, to, cc, bcc, subject, plain_body, html_body, attachments_list, images_list, priority_flags, references, in_reply_to, + header_pairs, modest_mail_operation_send_new_mail_cb, info); } @@ -1375,6 +1384,7 @@ modest_mail_operation_save_to_drafts (ModestMailOperation *self, TnyHeaderFlags priority_flags, const gchar *references, const gchar *in_reply_to, + TnyList *header_pairs, SaveToDraftstCallback callback, gpointer user_data) { @@ -1401,6 +1411,7 @@ modest_mail_operation_save_to_drafts (ModestMailOperation *self, modest_mail_operation_create_msg (self, from, to, cc, bcc, subject, plain_body, html_body, attachments_list, images_list, priority_flags, references, in_reply_to, + header_pairs, modest_mail_operation_save_to_drafts_cb, info); } diff --git a/src/modest-mail-operation.h b/src/modest-mail-operation.h index 2388479..fc0a240 100644 --- a/src/modest-mail-operation.h +++ b/src/modest-mail-operation.h @@ -397,7 +397,8 @@ void modest_mail_operation_send_new_mail (ModestMailOperation *self, const GList *images_list, const gchar *references, const gchar *in_reply_to, - TnyHeaderFlags priority_flags); + TnyHeaderFlags priority_flags, + TnyList *header_pairs); /** @@ -438,6 +439,7 @@ void modest_mail_operation_save_to_drafts (ModestMailOperation *self, TnyHeaderFlags priority_flags, const gchar *references, const gchar *in_reply_to, + TnyList *header_pairs, SaveToDraftstCallback callback, gpointer user_data); /** diff --git a/src/modest-tny-msg.c b/src/modest-tny-msg.c index 3d66340..b41d390 100644 --- a/src/modest-tny-msg.c +++ b/src/modest-tny-msg.c @@ -61,12 +61,27 @@ static gboolean is_ascii(const gchar *s); static TnyMimePart* modest_tny_msg_find_body_part_from_mime_part (TnyMimePart *msg, gboolean want_html); static TnyMimePart* modest_tny_msg_find_calendar_from_mime_part (TnyMimePart *msg); +static void +add_header_pairs (TnyMimePart *part, TnyList *header_pairs) +{ + TnyIterator *iterator; + + iterator = tny_list_create_iterator (header_pairs); + while (!tny_iterator_is_done (iterator)) { + TnyPair *current = (TnyPair *) tny_iterator_get_current (iterator); + tny_mime_part_set_header_pair (part, tny_pair_get_name (current), tny_pair_get_value (current)); + g_object_unref (current); + tny_iterator_next (iterator); + } + g_object_unref (iterator); +} + TnyMsg* modest_tny_msg_new (const gchar* mailto, const gchar* from, const gchar *cc, const gchar *bcc, const gchar* subject, const gchar *references, const gchar *in_reply_to, const gchar *body, - GList *attachments, gint *attached, GError **err) + GList *attachments, gint *attached, TnyList *header_pairs, GError **err) { TnyMsg *new_msg; TnyHeader *header; @@ -75,6 +90,7 @@ modest_tny_msg_new (const gchar* mailto, const gchar* from, const gchar *cc, /* Create new msg */ new_msg = modest_formatter_create_message (NULL, TRUE, (attachments != NULL), FALSE); + add_header_pairs (TNY_MIME_PART (new_msg), header_pairs); header = tny_msg_get_header (new_msg); if ((from != NULL) && (strlen(from) > 0)) { @@ -130,7 +146,7 @@ modest_tny_msg_new_html_plain (const gchar* mailto, const gchar* from, const gch const gchar *bcc, const gchar* subject, const gchar *references, const gchar *in_reply_to, const gchar *html_body, const gchar *plain_body, - GList *attachments, GList *images, gint *attached, GError **err) + GList *attachments, GList *images, gint *attached, TnyList *header_pairs, GError **err) { TnyMsg *new_msg; TnyHeader *header; @@ -139,6 +155,7 @@ modest_tny_msg_new_html_plain (const gchar* mailto, const gchar* from, const gch /* Create new msg */ new_msg = modest_formatter_create_message (NULL, FALSE, (attachments != NULL), (images != NULL)); + add_header_pairs (TNY_MIME_PART (new_msg), header_pairs); header = tny_msg_get_header (new_msg); if ((from != NULL) && (strlen(from) > 0)) { diff --git a/src/modest-tny-msg.h b/src/modest-tny-msg.h index bc9d81c..c6f2d92 100644 --- a/src/modest-tny-msg.h +++ b/src/modest-tny-msg.h @@ -81,7 +81,7 @@ TnyMsg* modest_tny_msg_new (const gchar* mailto, const gchar* mailfrom, const gc const gchar *bcc, const gchar* subject, const gchar *references, const gchar *in_reply_to, const gchar *body, - GList *attachments, gint *attached, GError **err); + GList *attachments, gint *attached, TnyList *header_pairs, GError **err); /** * modest_tny_msg_new_html_plain: @@ -105,7 +105,7 @@ TnyMsg* modest_tny_msg_new_html_plain (const gchar* mailto, const gchar* mailfro const gchar *bcc, const gchar* subject, const gchar *references, const gchar *in_reply_to, const gchar *html_body, const gchar *plain_body, - GList *attachments, GList *images, gint *attached, GError **err); + GList *attachments, GList *images, gint *attached, TnyList *header_pairs, GError **err); /** * modest_tny_msg_find_body_part: diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index 08af12c..258d0c9 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -842,6 +842,7 @@ modest_ui_actions_compose_msg(ModestWindow *win, GnomeVFSFileSize total_size, allowed_size; guint64 available_disk, expected_size, parts_size; guint parts_count; + TnyList *header_pairs; /* we check for low-mem */ if (modest_platform_check_memory_low (win, TRUE)) @@ -915,8 +916,11 @@ modest_ui_actions_compose_msg(ModestWindow *win, body = use_signature ? g_strconcat ((body_str) ? body_str : "", signature, NULL) : g_strdup(body_str); + header_pairs = TNY_LIST (tny_simple_list_new ()); msg = modest_tny_msg_new_html_plain (to_str, from_str, cc_str, bcc_str, subject_str, - NULL, NULL, body, NULL, NULL, NULL, NULL, NULL); + NULL, NULL, body, NULL, NULL, NULL, NULL, header_pairs, NULL); + g_object_unref (header_pairs); + if (!msg) { g_printerr ("modest: failed to create new msg\n"); goto cleanup; @@ -2230,7 +2234,6 @@ modest_ui_actions_reply_calendar (ModestWindow *win, TnyList *header_pairs) gboolean use_signature; TnyMsg *new_msg; GtkWidget *msg_win; - gdouble parent_zoom; const gchar *account_name; const gchar *mailbox; TnyHeader *msg_header; @@ -2276,9 +2279,6 @@ modest_ui_actions_reply_calendar (ModestWindow *win, TnyList *header_pairs) mgr = modest_runtime_get_window_mgr (); modest_window_mgr_register_window (mgr, MODEST_WINDOW (msg_win), (ModestWindow *) win); - parent_zoom = modest_window_get_zoom (MODEST_WINDOW (win)); - modest_window_set_zoom (MODEST_WINDOW (msg_win), parent_zoom); - /* Show edit window */ gtk_widget_show_all (GTK_WIDGET (msg_win)); @@ -3306,6 +3306,7 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi data->priority_flags, data->references, data->in_reply_to, + data->custom_header_pairs, on_save_to_drafts_cb, g_object_ref(edit_window)); @@ -3467,7 +3468,8 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window) data->images, data->references, data->in_reply_to, - data->priority_flags); + data->priority_flags, + data->custom_header_pairs); if (modest_mail_operation_get_status (mail_operation) == MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS) modest_platform_information_banner (NULL, NULL, _("mcen_ib_outbox_waiting_to_be_sent")); -- 1.7.9.5