#include "modest-tny-account.h"
#include "modest-tny-folder.h"
#include "modest-ui-actions.h"
+#include "modest-utils.h"
#include "modest-debug.h"
#include "modest-search.h"
#include "widgets/modest-msg-edit-window.h"
}
from_header = tny_header_dup_from (header);
- if (from_header) {
- GSList *accounts = modest_account_mgr_account_names (modest_runtime_get_account_mgr (), TRUE);
- GSList *node = NULL;
- for (node = accounts; node != NULL; node = g_slist_next (node)) {
- gchar *from = modest_account_mgr_get_from_string (modest_runtime_get_account_mgr (), node->data);
-
- if (from && (strcmp (from_header, from) == 0)) {
- g_free (modest_account_name);
- modest_account_name = g_strdup (node->data);
- g_free (from);
- break;
- }
- g_free (from);
- }
- g_slist_foreach (accounts, (GFunc) g_free, NULL);
- g_slist_free (accounts);
- g_free (from_header);
- }
+ modest_account_name = modest_utils_get_account_name_from_recipient (from_header);
+ g_free (from_header);
if (modest_account_name == NULL) {
- modest_account_name = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr ());
+ ModestAccountMgr *mgr = modest_runtime_get_account_mgr ();
+ modest_account_name = modest_account_mgr_get_default_account (mgr);
}
msg_view = modest_msg_edit_window_new (msg, modest_account_name, TRUE);
g_free (modest_account_name);
}
if (msg_view != NULL) {
- modest_window_mgr_register_window (win_mgr, msg_view);
+ modest_window_mgr_register_window (win_mgr, msg_view, NULL);
gtk_widget_show_all (GTK_WIDGET (msg_view));
}
}
modest_header_view_refilter (header_view);
}
-static gboolean
-on_idle_delete_message (gpointer user_data)
+static gpointer
+thread_prepare_delete_message (gpointer userdata)
{
TnyList *headers = NULL, *tmp_headers = NULL;
TnyFolder *folder = NULL;
TnyHeader *header = NULL, *msg_header = NULL;
TnyMsg *msg = NULL;
TnyAccount *account = NULL;
- const char *uri = NULL;
+ char *uri;
gchar *uid = NULL;
ModestMailOperation *mail_op = NULL;
ModestWindow *main_win = NULL;
- uri = (char *) user_data;
-
+ uri = (char *) userdata;
+
msg = find_message_by_url (uri, &account);
if (account)
g_object_unref (account);
if (!msg) {
g_warning ("%s: Could not find message '%s'", __FUNCTION__, uri);
g_idle_add (notify_error_in_dbus_callback, NULL);
+ g_free (uri);
return FALSE;
}
g_warning ("%s: Could not find folder (uri:'%s')", __FUNCTION__, uri);
g_object_unref (msg);
g_idle_add (notify_error_in_dbus_callback, NULL);
+ g_free (uri);
return FALSE;
}
if (folder)
g_object_unref (folder);
g_idle_add (notify_error_in_dbus_callback, NULL);
+ g_free (uri);
return FALSE;
}
/* Clean */
if (header)
g_object_unref (header);
+ g_free (uri);
return FALSE;
}
+static gboolean
+on_idle_delete_message (gpointer user_data)
+{
+ const char *uri = NULL;
+
+ uri = (char *) user_data;
+
+ g_thread_create (thread_prepare_delete_message, g_strdup (uri), FALSE, NULL);
+
+ return FALSE;
+
+}
+
}
if (main_win) {
- /* Ideally, we would just use gtk_widget_show(),
- * but this widget is not coded correctly to support that: */
- gtk_widget_show_all (GTK_WIDGET (main_win));
- gtk_window_present (GTK_WINDOW (main_win));
-
/* If we're showing an already existing window then
reselect the INBOX */
if (!new_window) {
tny_folder_store_get_folders (folder_store,
all_folders,
NULL /* query */,
+ FALSE,
NULL /* error */);
TnyIterator *iter = tny_list_create_iterator (all_folders);