X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fhildon2%2Fmodest-msg-view-window.c;h=01d71570fee022d6beb9f4461bad0ccf2edd392f;hp=a920277b0779e5de3c1c0758eab053fbcb2fafa0;hb=3a69262f88128f4dd3c78bbe62abc90f13491ded;hpb=5a7851e566dfb725811b7eb542bb203b6138faa7 diff --git a/src/hildon2/modest-msg-view-window.c b/src/hildon2/modest-msg-view-window.c index a920277..01d7157 100644 --- a/src/hildon2/modest-msg-view-window.c +++ b/src/hildon2/modest-msg-view-window.c @@ -117,6 +117,7 @@ struct _ModestMsgViewWindowPrivate { GtkWidget *remove_attachment_banner; gchar *msg_uid; + TnyMimePart *other_body; GSList *sighandlers; }; @@ -448,6 +449,7 @@ modest_msg_view_window_init (ModestMsgViewWindow *obj) priv->purge_timeout = 0; priv->remove_attachment_banner = NULL; priv->msg_uid = NULL; + priv->other_body = NULL; priv->sighandlers = NULL; @@ -610,6 +612,11 @@ modest_msg_view_window_finalize (GObject *obj) call this function before */ modest_msg_view_window_disconnect_signals (MODEST_WINDOW (obj)); + if (priv->other_body != NULL) { + g_object_unref (priv->other_body); + priv->other_body = NULL; + } + if (priv->header_model != NULL) { g_object_unref (priv->header_model); priv->header_model = NULL; @@ -1040,11 +1047,23 @@ modest_msg_view_window_new_for_search_result (TnyMsg *msg, return MODEST_WINDOW(window); } +gboolean +modest_msg_view_window_is_other_body (ModestMsgViewWindow *self) +{ + ModestMsgViewWindowPrivate *priv = NULL; + + g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW (self), FALSE); + priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self); + + return (priv->other_body != NULL); +} + ModestWindow * -modest_msg_view_window_new_for_attachment (TnyMsg *msg, - const gchar *modest_account_name, - const gchar *mailbox, - const gchar *msg_uid) +modest_msg_view_window_new_with_other_body (TnyMsg *msg, + TnyMimePart *other_body, + const gchar *modest_account_name, + const gchar *mailbox, + const gchar *msg_uid) { GObject *obj = NULL; ModestMsgViewWindowPrivate *priv; @@ -1057,7 +1076,12 @@ modest_msg_view_window_new_for_attachment (TnyMsg *msg, modest_msg_view_window_construct (MODEST_MSG_VIEW_WINDOW (obj), modest_account_name, mailbox, msg_uid); - tny_msg_view_set_msg (TNY_MSG_VIEW (priv->msg_view), msg); + if (other_body) { + priv->other_body = g_object_ref (other_body); + modest_msg_view_set_msg_with_other_body (MODEST_MSG_VIEW (priv->msg_view), msg, other_body); + } else { + tny_msg_view_set_msg (TNY_MSG_VIEW (priv->msg_view), msg); + } update_window_title (MODEST_MSG_VIEW_WINDOW (obj)); /* gtk_widget_show_all (GTK_WIDGET (obj)); */ @@ -1070,6 +1094,15 @@ modest_msg_view_window_new_for_attachment (TnyMsg *msg, return MODEST_WINDOW(obj); } +ModestWindow * +modest_msg_view_window_new_for_attachment (TnyMsg *msg, + const gchar *modest_account_name, + const gchar *mailbox, + const gchar *msg_uid) +{ + return modest_msg_view_window_new_with_other_body (msg, NULL, modest_account_name, mailbox, msg_uid); +} + static void modest_msg_view_window_on_row_changed (GtkTreeModel *header_model, GtkTreePath *arg1, @@ -2496,7 +2529,7 @@ modest_msg_view_window_view_attachment (ModestMsgViewWindow *window, if (tny_mime_part_is_purged (mime_part)) goto frees; - if (!modest_tny_mime_part_is_msg (mime_part)) { + if (!modest_tny_mime_part_is_msg (mime_part) && tny_mime_part_get_filename (mime_part)) { gchar *filepath = NULL; const gchar *att_filename = tny_mime_part_get_filename (mime_part); gboolean show_error_banner = FALSE; @@ -2537,6 +2570,42 @@ modest_msg_view_window_view_attachment (ModestMsgViewWindow *window, g_free (filepath); if (show_error_banner) modest_platform_information_banner (NULL, NULL, _("mail_ib_file_operation_failed")); + } else if (!modest_tny_mime_part_is_msg (mime_part)) { + ModestWindowMgr *mgr; + ModestWindow *msg_win = NULL; + TnyMsg *current_msg; + gboolean found; + TnyHeader *header; + + current_msg = modest_msg_view_window_get_message (MODEST_MSG_VIEW_WINDOW (window)); + mgr = modest_runtime_get_window_mgr (); + header = tny_msg_get_header (TNY_MSG (current_msg)); + found = modest_window_mgr_find_registered_message_uid (mgr, + attachment_uid, + &msg_win); + + if (found) { + g_warning ("window for this body is already being created"); + } else { + + /* it's not found, so create a new window for it */ + modest_window_mgr_register_header (mgr, header, attachment_uid); /* register the uid before building the window */ + gchar *account = g_strdup (modest_window_get_active_account (MODEST_WINDOW (window))); + const gchar *mailbox = modest_window_get_active_mailbox (MODEST_WINDOW (window)); + if (!account) + account = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr ()); + + msg_win = modest_msg_view_window_new_with_other_body (TNY_MSG (current_msg), TNY_MIME_PART (mime_part), + account, mailbox, attachment_uid); + + modest_window_set_zoom (MODEST_WINDOW (msg_win), + modest_window_get_zoom (MODEST_WINDOW (window))); + if (modest_window_mgr_register_window (mgr, msg_win, MODEST_WINDOW (window))) + gtk_widget_show_all (GTK_WIDGET (msg_win)); + else + gtk_widget_destroy (GTK_WIDGET (msg_win)); + } + g_object_unref (current_msg); } else { /* message attachment */ TnyHeader *header = NULL; @@ -2692,10 +2761,11 @@ save_mime_parts_to_file_with_checks (SaveMimePartInfo *info) if (replaced_files == 1) { SaveMimePartPair *pair = files->data; - const gchar *filename = tny_mime_part_get_filename (pair->part); + const gchar *basename = strrchr (pair->filename, G_DIR_SEPARATOR) + 1; + gchar *message = g_strdup_printf ("%s\n%s", _FM("docm_nc_replace_file"), - (filename) ? filename : ""); + (basename) ? basename : ""); confirm_overwrite_dialog = hildon_note_new_confirmation (NULL, message); g_free (message); } else { @@ -3032,7 +3102,15 @@ update_window_title (ModestMsgViewWindow *window) msg = tny_msg_view_get_msg (TNY_MSG_VIEW (priv->msg_view)); - if (msg != NULL) { + if (priv->other_body) { + gchar *description; + + description = modest_tny_mime_part_get_header_value (priv->other_body, "Content-Description"); + if (description) { + g_strstrip (description); + subject = description; + } + } else if (msg != NULL) { header = tny_msg_get_header (msg); subject = tny_header_dup_subject (header); g_object_unref (header);