return msg;
}
+
+TnyTransportAccount *
+modest_tny_account_store_get_transport_account_from_outbox_header(ModestTnyAccountStore *self, TnyHeader *header)
+{
+ TnyIterator *acc_iter;
+ ModestTnyAccountStorePrivate *priv;
+ TnyTransportAccount *header_acc = NULL;
+ const gchar *msg_id;
+
+ g_return_val_if_fail (MODEST_IS_TNY_ACCOUNT_STORE (self), NULL);
+ g_return_val_if_fail (TNY_IS_HEADER (header), NULL);
+ priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE (self);
+
+ msg_id = modest_tny_send_queue_get_msg_id (header);
+ acc_iter = tny_list_create_iterator (priv->transport_accounts);
+ while (!header_acc && !tny_iterator_is_done (acc_iter)) {
+ TnyTransportAccount *account = TNY_TRANSPORT_ACCOUNT (tny_iterator_get_current (acc_iter));
+ ModestTnySendQueue *send_queue;
+ ModestTnySendQueueStatus status;
+ send_queue = modest_runtime_get_send_queue(TNY_TRANSPORT_ACCOUNT(account));
+ status = modest_tny_send_queue_get_msg_status(send_queue, msg_id);
+ if (status != MODEST_TNY_SEND_QUEUE_UNKNONW) {
+ header_acc = g_object_ref(account);
+ }
+ g_object_unref (account);
+ tny_iterator_next (acc_iter);
+ }
+
+ g_object_unref(acc_iter);
+ return header_acc;
+}
TnyAccount **ac_out);
+/**
+ * modest_tny_account_store_get_transport_account_from_outbox_header:
+ * @self: a #ModestTnyAccountStore
+ * @header: a #TnyHeader
+ *
+ * Gets the transport account from a header that is in the outbox
+ *
+ * Returns: %NULL or a %TnyTransportAccount
+ */
+TnyTransportAccount *
+modest_tny_account_store_get_transport_account_from_outbox_header(ModestTnyAccountStore *self,
+ TnyHeader *header);
+
G_END_DECLS
#endif /* __MODEST_TNY_ACCOUNT_STORE_H__ */
TnyFolderType folder_type = TNY_FOLDER_TYPE_UNKNOWN;
gchar *account = NULL;
TnyFolder *folder;
+ gboolean open_in_editor = FALSE;
/* Do nothing if there was any problem with the mail
operation. The error will be shown by the error_handler of
folder_type = modest_tny_folder_get_local_or_mmc_folder_type (folder);
}
+ if (folder_type == TNY_FOLDER_TYPE_OUTBOX) {
+ TnyTransportAccount *traccount = NULL;
+ ModestTnyAccountStore *accstore = modest_runtime_get_account_store();
+ traccount = modest_tny_account_store_get_transport_account_from_outbox_header(accstore, header);
+ if (traccount) {
+ ModestTnySendQueue *send_queue = NULL;
+ ModestTnySendQueueStatus status;
+ char *msg_id;
+ account = g_strdup(modest_tny_account_get_parent_modest_account_name_for_server_account(
+ TNY_ACCOUNT(traccount)));
+ send_queue = modest_runtime_get_send_queue(traccount);
+ msg_id = modest_tny_send_queue_get_msg_id (header);
+ status = modest_tny_send_queue_get_msg_status(send_queue, msg_id);
+ /* Only open messages in outbox with the editor if they are in Failed state */
+ if (status == MODEST_TNY_SEND_QUEUE_FAILED) {
+ open_in_editor = TRUE;
+ }
+ g_free(msg_id);
+ g_object_unref(traccount);
+ } else {
+ g_warning("Cannot get transport account for message in outbox!!");
+ }
+ } else if (folder_type == TNY_FOLDER_TYPE_DRAFTS) {
+ open_in_editor = TRUE; /* Open in editor if the message is in the Drafts folder */
+ }
+
/* Get account */
if (!account)
account = g_strdup (modest_window_get_active_account (MODEST_WINDOW (parent_win)));
if (!account)
account = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr());
- /* If the header is in the drafts folder then open the editor,
- else the message view window */
- if (folder_type == TNY_FOLDER_TYPE_DRAFTS) {
+ if (open_in_editor) {
ModestAccountMgr *mgr = modest_runtime_get_account_mgr ();
const gchar *from_header = NULL;