(fixes NB#151640).
gchar *msg_uid;
TnyMimePart *other_body;
+ TnyMsg * top_msg;
GSList *sighandlers;
};
priv->other_body = NULL;
}
+ if (priv->top_msg != NULL) {
+ g_object_unref (priv->top_msg);
+ priv->top_msg = NULL;
+ }
+
if (priv->header_model != NULL) {
g_object_unref (priv->header_model);
priv->header_model = NULL;
modest_msg_view_window_construct (window, modest_account_name, mailbox, msg_uid);
priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window);
+ priv->top_msg = NULL;
/* Remember the message list's TreeModel so we can detect changes
* and change the list selection when necessary: */
modest_msg_view_window_construct (window, modest_account_name, mailbox, msg_uid);
priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window);
+ priv->top_msg = NULL;
is_merge = g_str_has_prefix (msg_uid, "merge:");
modest_msg_view_window_construct (window, modest_account_name, mailbox, msg_uid);
priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window);
+ priv->top_msg = NULL;
/* Remember the message list's TreeModel so we can detect changes
* and change the list selection when necessary: */
modest_msg_view_window_construct (window, modest_account_name, mailbox, msg_uid);
priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window);
+ priv->top_msg = NULL;
/* Remember that this is a search result,
* so we can disable some UI appropriately: */
ModestWindow *
modest_msg_view_window_new_with_other_body (TnyMsg *msg,
TnyMimePart *other_body,
+ TnyMsg *top_msg,
const gchar *modest_account_name,
const gchar *mailbox,
const gchar *msg_uid)
} else {
tny_msg_view_set_msg (TNY_MSG_VIEW (priv->msg_view), msg);
}
+ if (top_msg) {
+ priv->top_msg = g_object_ref (top_msg);
+ } else {
+ priv->top_msg = NULL;
+ }
update_window_title (MODEST_MSG_VIEW_WINDOW (obj));
update_branding (MODEST_MSG_VIEW_WINDOW (obj));
}
ModestWindow *
-modest_msg_view_window_new_for_attachment (TnyMsg *msg,
+modest_msg_view_window_new_for_attachment (TnyMsg *msg,
+ TnyMsg *top_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);
+ return modest_msg_view_window_new_with_other_body (msg, NULL, top_msg, modest_account_name, mailbox, msg_uid);
}
static void
return tny_msg_view_get_msg (TNY_MSG_VIEW (priv->msg_view));
}
+TnyMsg*
+modest_msg_view_window_get_top_message (ModestMsgViewWindow *self)
+{
+ ModestMsgViewWindowPrivate *priv;
+
+ g_return_val_if_fail (self, NULL);
+
+ priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE(self);
+
+ if (priv->top_msg)
+ return g_object_ref (priv->top_msg);
+ else
+ return NULL;
+}
+
const gchar*
modest_msg_view_window_get_message_uid (ModestMsgViewWindow *self)
{
{
DecodeAsyncHelper *helper = (DecodeAsyncHelper *) user_data;
const gchar *content_type;
+ ModestMsgViewWindowPrivate *priv;
+
+ priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (helper->self);
if (cancelled || err) {
if (err) {
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 ();
msg = tny_camel_msg_new ();
tny_camel_msg_parse (msg, file_stream);
- msg_win = modest_msg_view_window_new_for_attachment (TNY_MSG (msg), account, mailbox, helper->attachment_uid);
+
+ 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)))
if (found) {
g_debug ("window for this body is already being created");
} else {
+ TnyMsg *top_msg;
/* 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 */
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 ());
+
+ 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_with_other_body (TNY_MSG (current_msg), TNY_MIME_PART (mime_part),
+ msg_win = modest_msg_view_window_new_with_other_body (TNY_MSG (current_msg), TNY_MIME_PART (mime_part), top_msg,
account, mailbox, attachment_uid);
+
+ if (top_msg) g_object_unref (top_msg);
modest_window_set_zoom (MODEST_WINDOW (msg_win),
modest_window_get_zoom (MODEST_WINDOW (window)));
* thus, we don't do anything */
g_debug ("window for is already being created");
} else {
+ TnyMsg *top_msg;
/* 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_for_attachment (TNY_MSG (mime_part), account,
- mailbox, attachment_uid);
+ 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 (mime_part), top_msg, 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)))
#endif
#include "modest-account-protocol.h"
#include <camel/camel-stream-null.h>
+#include <widgets/modest-msg-view-window.h>
#define KB 1024
/* Get account and set it into mail_operation */
folder = tny_header_get_folder (header);
- priv->account = modest_tny_folder_get_account (TNY_FOLDER(folder));
+ if (folder == NULL && MODEST_IS_MSG_VIEW_WINDOW (priv->source)) {
+ const gchar *acc_name;
+ acc_name = modest_window_get_active_account (MODEST_WINDOW (priv->source));
+ priv->account = modest_tny_account_store_get_server_account
+ (modest_runtime_get_account_store (),
+ acc_name,
+ TNY_ACCOUNT_TYPE_STORE);
+ folder = modest_tny_folder_store_find_folder_from_uri (TNY_FOLDER_STORE (priv->account),
+ modest_msg_view_window_get_message_uid (MODEST_MSG_VIEW_WINDOW (priv->source)));
+ } else {
+ priv->account = modest_tny_folder_get_account (TNY_FOLDER(folder));
+ }
/* Check for cached messages */
if (progress_feedback) {
gchar *mailbox;
GtkWidget *parent_window;
TnyHeader *header;
+ TnyHeader *top_header;
+ TnyMsg *msg_part;
TnyList *parts;
} ReplyForwardHelper;
win = modest_msg_view_window_new_with_header_model (msg, account, mailbox, (const gchar*) uid,
helper->model, helper->rowref);
} else {
- win = modest_msg_view_window_new_for_attachment (msg, account, mailbox, (const gchar*) uid);
+ win = modest_msg_view_window_new_for_attachment (msg, NULL, account, mailbox, (const gchar*) uid);
}
g_free (uid);
}
ModestWindow *win,
guint reply_forward_type,
TnyHeader *header,
+ TnyMsg *msg_part,
+ TnyHeader *top_header,
TnyList *parts)
{
ReplyForwardHelper *rf_helper = NULL;
rf_helper->action = action;
rf_helper->parent_window = (MODEST_IS_WINDOW (win)) ? GTK_WIDGET (win) : NULL;
rf_helper->header = (header) ? g_object_ref (header) : NULL;
+ rf_helper->top_header = (top_header) ? g_object_ref (top_header) : NULL;
+ rf_helper->msg_part = (msg_part) ? g_object_ref (msg_part) : NULL;
rf_helper->account_name = (active_acc) ?
g_strdup (active_acc) :
modest_account_mgr_get_default_account (modest_runtime_get_account_mgr());
g_free (helper->mailbox);
if (helper->header)
g_object_unref (helper->header);
+ if (helper->top_header)
+ g_object_unref (helper->top_header);
+ if (helper->msg_part)
+ g_object_unref (helper->msg_part);
if (helper->parts)
g_object_unref (helper->parts);
if (helper->parent_window)
information. The summary can lack some data */
TnyHeader *msg_header;
case ACTION_REPLY:
- msg_header = tny_msg_get_header (msg);
+ msg_header = tny_msg_get_header (rf_helper->msg_part?rf_helper->msg_part:msg);
new_msg =
- modest_tny_msg_create_reply_msg (msg, msg_header, from,
+ modest_tny_msg_create_reply_msg (rf_helper->msg_part?rf_helper->msg_part:msg, msg_header, from,
(use_signature) ? signature : NULL,
rf_helper->reply_forward_type,
MODEST_TNY_MSG_REPLY_MODE_SENDER);
g_object_unref (msg_header);
break;
case ACTION_REPLY_TO_ALL:
- msg_header = tny_msg_get_header (msg);
+ msg_header = tny_msg_get_header (rf_helper->msg_part?rf_helper->msg_part:msg);
new_msg =
- modest_tny_msg_create_reply_msg (msg, msg_header, from,
+ modest_tny_msg_create_reply_msg (rf_helper->msg_part?rf_helper->msg_part:msg, msg_header, from,
(use_signature) ? signature : NULL,
rf_helper->reply_forward_type,
MODEST_TNY_MSG_REPLY_MODE_ALL);
break;
case ACTION_FORWARD:
new_msg =
- modest_tny_msg_create_forward_msg (msg, from, (use_signature) ? signature : NULL,
+ modest_tny_msg_create_forward_msg (rf_helper->msg_part?rf_helper->msg_part:msg, from,
+ (use_signature) ? signature : NULL,
rf_helper->reply_forward_type);
edit_type = MODEST_EDIT_TYPE_FORWARD;
break;
modest_ui_actions_disk_operations_error_handler,
NULL, NULL);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
- modest_mail_operation_get_msg_and_parts (mail_op, rf_helper->header, rf_helper->parts, TRUE, reply_forward_cb, rf_helper);
+ modest_mail_operation_get_msg_and_parts (mail_op, rf_helper->top_header, rf_helper->parts, TRUE, reply_forward_cb, rf_helper);
/* Frees */
g_object_unref(mail_op);
if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
TnyMsg *msg = NULL;
+ TnyMsg *top_msg = NULL;
TnyHeader *header = NULL;
/* Get header and message. Do not free them here, the
reply_forward_cb must do it */
msg = modest_msg_view_window_get_message (MODEST_MSG_VIEW_WINDOW(win));
+ top_msg = modest_msg_view_window_get_top_message (MODEST_MSG_VIEW_WINDOW(win));
header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (win));
if (msg && header && (action != ACTION_FORWARD || all_parts_retrieved (TNY_MIME_PART (msg)))) {
/* Create helper */
rf_helper = create_reply_forward_helper (action, win,
- reply_forward_type, header, NULL);
+ reply_forward_type, header, NULL, NULL, NULL);
reply_forward_cb (NULL, header, FALSE, msg, NULL, rf_helper);
} else {
gboolean do_download = TRUE;
if (msg && header && action == ACTION_FORWARD) {
+ if (top_msg == NULL)
+ top_msg = g_object_ref (msg);
/* Not all parts retrieved. Then we have to retrieve them all before
* creating the forward message */
if (!tny_device_is_online (modest_runtime_get_device ())) {
TnyList *pending_parts;
TnyFolder *folder;
TnyAccount *account;
+ TnyHeader *top_header;
/* Create helper */
- pending_parts = forward_pending_parts (msg);
+ top_header = tny_msg_get_header (top_msg);
+ pending_parts = forward_pending_parts (top_msg);
rf_helper = create_reply_forward_helper (action, win,
- reply_forward_type, header, pending_parts);
+ reply_forward_type, header, msg, top_header, pending_parts);
g_object_unref (pending_parts);
- folder = tny_header_get_folder (header);
+ folder = tny_header_get_folder (top_header);
account = tny_folder_get_account (folder);
modest_platform_connect_and_perform (GTK_WINDOW (win),
TRUE, account,
reply_forward_performer,
rf_helper);
- g_object_unref (folder);
+ if (folder) g_object_unref (folder);
g_object_unref (account);
+ if (top_header) g_object_unref (top_header);
}
} else {
if (msg)
g_object_unref (msg);
+ if (top_msg)
+ g_object_unref (top_msg);
if (header)
g_object_unref (header);
} else {
if (download) {
/* Create helper */
rf_helper = create_reply_forward_helper (action, win,
- reply_forward_type, header, NULL);
+ reply_forward_type, header, NULL, NULL, NULL);
if (uncached_msgs > 0) {
modest_platform_connect_and_perform (GTK_WINDOW (win),
TRUE, account,
* Returns: a new #ModestMsgViewWindow, or NULL in case of error
*/
ModestWindow* modest_msg_view_window_new_for_attachment (TnyMsg *msg,
+ TnyMsg *top_msg,
const gchar *modest_account_name,
const gchar *mailbox,
const gchar *msg_uid);
*/
ModestWindow* modest_msg_view_window_new_with_other_body (TnyMsg *msg,
TnyMimePart *other_body,
+ TnyMsg *top_msg,
const gchar *modest_account_name,
const gchar *mailbox,
const gchar *msg_uid);
TnyMsg* modest_msg_view_window_get_message (ModestMsgViewWindow *window);
/**
+ * modest_msg_view_window_get_top_message:
+ * @window: an #ModestMsgViewWindow instance
+ *
+ * get a new reference to the parent message of the tree of views. The caller
+ * must free this new reference
+ *
+ * Returns: a new #TnyMsg instance, or NULL in case of error
+ */
+TnyMsg* modest_msg_view_window_get_top_message (ModestMsgViewWindow *window);
+
+/**
* modest_msg_view_window_get_message_uid:
* @msg: an #ModestMsgViewWindow instance
*