+ /* It could happen that the window was closed. So we
+ assume it is a cancelation */
+ if (!GTK_WIDGET_VISIBLE (helper->self))
+ goto free;
+
+ /* Remove the progress hint */
+ set_progress_hint (helper->self, FALSE);
+
+ content_type = tny_mime_part_get_content_type (mime_part);
+ if (content_type && g_str_has_prefix (content_type, "message/rfc822")) {
+ ModestWindowMgr *mgr;
+ ModestWindow *msg_win = NULL;
+ TnyMsg * msg;
+ gchar *account;
+ const gchar *mailbox;
+ TnyStream *file_stream;
+ gint fd;
+
+ fd = g_open (helper->file_path, O_RDONLY, 0644);
+ if (fd != -1) {
+ TnyMsg *top_msg;
+ file_stream = tny_fs_stream_new (fd);
+
+ mgr = modest_runtime_get_window_mgr ();
+
+ account = g_strdup (modest_window_get_active_account (MODEST_WINDOW (helper->self)));
+ mailbox = modest_window_get_active_mailbox (MODEST_WINDOW (helper->self));
+
+ if (!account)
+ account = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr ());
+
+ msg = tny_camel_msg_new ();
+ tny_camel_msg_parse (msg, file_stream);
+
+ if (priv->top_msg)
+ top_msg = g_object_ref (priv->top_msg);
+ else
+ top_msg = tny_msg_view_get_msg (TNY_MSG_VIEW (priv->msg_view));
+
+ msg_win = modest_msg_view_window_new_for_attachment (TNY_MSG (msg), top_msg,
+ account, mailbox, helper->attachment_uid);
+ if (top_msg) g_object_unref (top_msg);
+ modest_window_set_zoom (MODEST_WINDOW (msg_win),
+ modest_window_get_zoom (MODEST_WINDOW (helper->self)));
+ if (modest_window_mgr_register_window (mgr, msg_win, MODEST_WINDOW (helper->self)))
+ gtk_widget_show_all (GTK_WIDGET (msg_win));
+ else
+ gtk_widget_destroy (GTK_WIDGET (msg_win));
+ g_object_unref (msg);
+ g_object_unref (file_stream);
+ } else {
+ modest_platform_information_banner (NULL, NULL, _("mail_ib_file_operation_failed"));
+ }
+
+ } else {
+
+ /* make the file read-only */
+ g_chmod(helper->file_path, 0444);