+end:
+ on_find_msg_async_destroy (info);
+}
+
+
+static void
+on_open_message_performer (gboolean canceled,
+ GError *err,
+ GtkWindow *parent_window,
+ TnyAccount *account,
+ gpointer user_data)
+{
+ OpenMsgPerformerInfo *info;
+ TnyFolder *folder = NULL;
+
+ info = (OpenMsgPerformerInfo *) user_data;
+ if (canceled || err) {
+ modest_platform_run_information_dialog (NULL, _("mail_ni_ui_folder_get_msg_folder_error"), TRUE);
+ g_idle_add (notify_error_in_dbus_callback, NULL);
+ on_find_msg_async_destroy (info);
+ return;
+ }
+
+ /* Get folder */
+ if (!account) {
+ ModestTnyAccountStore *account_store;
+ ModestTnyLocalFoldersAccount *local_folders_account;
+
+ account_store = modest_runtime_get_account_store ();
+ local_folders_account = MODEST_TNY_LOCAL_FOLDERS_ACCOUNT (
+ modest_tny_account_store_get_local_folders_account (account_store));
+ folder = modest_tny_local_folders_account_get_merged_outbox (local_folders_account);
+ g_object_unref (local_folders_account);
+ } else {
+ folder = tny_store_account_find_folder (TNY_STORE_ACCOUNT (account), info->uri, NULL);
+ }
+ if (!folder) {
+ modest_platform_run_information_dialog (NULL, _("mail_ni_ui_folder_get_msg_folder_error"), TRUE);
+ g_idle_add (notify_error_in_dbus_callback, NULL);
+ on_find_msg_async_destroy (info);
+ return;
+ }
+
+ info->animation_timeout = g_timeout_add (1000, on_show_opening_animation, info);
+ /* Get message */
+ tny_folder_find_msg_async (folder, info->uri, find_msg_async_cb, NULL, info);
+ g_object_unref (folder);
+}
+
+static gboolean
+on_idle_open_message_performer (gpointer user_data)
+{
+ ModestWindow *main_win = NULL;
+ OpenMsgPerformerInfo *info = (OpenMsgPerformerInfo *) user_data;
+
+ main_win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr(),
+ FALSE); /* don't create */
+
+ /* Lock before the call as we're in an idle handler */
+ gdk_threads_enter ();
+ if (info->connect) {
+ modest_platform_connect_and_perform (GTK_WINDOW (main_win), TRUE, info->account,
+ on_open_message_performer, info);
+ } else {
+ on_open_message_performer (FALSE, NULL, GTK_WINDOW (main_win), info->account, info);
+ }
+ gdk_threads_leave ();
+
+ return FALSE;