#include "modest-debug.h"
#include "modest-search.h"
#include "widgets/modest-msg-edit-window.h"
+#include "widgets/modest-window-mgr.h"
#include "modest-tny-msg.h"
#include "modest-platform.h"
#include "modest-defs.h"
{
OpenMsgPerformerInfo *info;
TnyFolder *folder = NULL;
+ 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));
info = (OpenMsgPerformerInfo *) user_data;
if (canceled || err) {
- modest_platform_run_information_dialog (NULL, _("mail_ni_ui_folder_get_msg_folder_error"), TRUE);
+ if (!canceled)
+ 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 {
+ } else if (account == TNY_ACCOUNT (local_folders_account)) {
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;
- }
-
- if (!(modest_tny_folder_is_local_folder (folder) &&
+ } else {
+ folder = NULL;
+ }
+ if (!(folder && modest_tny_folder_is_local_folder (folder) &&
(modest_tny_folder_get_local_or_mmc_folder_type (folder) == TNY_FOLDER_TYPE_DRAFTS))) {
ModestWindowMgr *win_mgr;
ModestWindow *msg_view;
gtk_window_present (GTK_WINDOW(msg_view));
} else {
const gchar *modest_account_name;
- TnyAccount *account;
-
- account = tny_folder_get_account (folder);
if (account) {
modest_account_name =
modest_tny_account_get_parent_modest_account_name_for_server_account (account);
gtk_widget_show_all (GTK_WIDGET (msg_view));
}
}
- g_object_unref (account);
+ if (account)
+ g_object_unref (account);
}
on_find_msg_async_destroy (info);
if (is_merge || account) {
OpenMsgPerformerInfo *info;
TnyFolder *folder = NULL;
+ ModestTnyAccountStore *account_store;
+ ModestTnyLocalFoldersAccount *local_folders_account;
info = g_slice_new0 (OpenMsgPerformerInfo);
if (account)
info->animation = NULL;
info->animation_timeout = 0;
+ 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));
+
/* Try to get the message, if it's already downloaded
we don't need to connect */
if (account) {
- folder = tny_store_account_find_folder (TNY_STORE_ACCOUNT (account), uri, NULL);
- } else {
- ModestTnyAccountStore *account_store;
- ModestTnyLocalFoldersAccount *local_folders_account;
+ TnyDevice *device;
+ gboolean device_online;
- 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));
+ device = modest_runtime_get_device ();
+ device_online = tny_device_is_online (device);
+ if (!device_online || TNY_ACCOUNT (local_folders_account) == account) {
+ folder = tny_store_account_find_folder (TNY_STORE_ACCOUNT (account), uri, NULL);
+ } else {
+ folder = NULL;
+ }
+ } else {
folder = modest_tny_local_folders_account_get_merged_outbox (local_folders_account);
g_object_unref (local_folders_account);
+ info->connect = FALSE;
}
if (folder) {
- TnyDevice *device;
- gboolean device_online;
-
- device = modest_runtime_get_device();
- device_online = tny_device_is_online (device);
- if (device_online) {
- info->connect = TRUE;
+ TnyMsg *msg = tny_folder_find_msg (folder, uri, NULL);
+ if (msg) {
+ info->connect = FALSE;
+ g_object_unref (msg);
} else {
- TnyMsg *msg = tny_folder_find_msg (folder, uri, NULL);
- if (msg) {
- info->connect = FALSE;
- g_object_unref (msg);
- } else {
- info->connect = TRUE;
- }
+ info->connect = TRUE;
}
g_object_unref (folder);
}
on_idle_send_receive(gpointer user_data)
{
gboolean auto_update;
- ModestWindow *top_win = NULL;
-
- top_win = modest_window_mgr_get_current_top (modest_runtime_get_window_mgr ());
gdk_threads_enter (); /* CHECKED */
MODEST_CONF_AUTO_UPDATE, NULL);
if (auto_update)
- /* Do send receive */
- modest_ui_actions_do_send_receive_all (top_win, FALSE, FALSE, FALSE);
+ /* Do send receive. Never set the current top window
+ as we always assume that DBus send/receive requests
+ are not user driven */
+ modest_ui_actions_do_send_receive_all (NULL, FALSE, FALSE, FALSE);
else
/* Disable auto update */
modest_platform_set_update_interval (0);
top = modest_window_mgr_show_initial_window (mgr);
#ifdef MODEST_TOOLKIT_HILDON2
- if (MODEST_IS_ACCOUNTS_WINDOW (top)) {
- GtkWidget *new_window;
- ModestProtocolType store_protocol;
- gboolean mailboxes_protocol;
-
- store_protocol = modest_account_mgr_get_store_protocol (modest_runtime_get_account_mgr (),
- acc_name);
- mailboxes_protocol =
- modest_protocol_registry_protocol_type_has_tag (modest_runtime_get_protocol_registry (),
- store_protocol,
- MODEST_PROTOCOL_REGISTRY_MULTI_MAILBOX_PROVIDER_PROTOCOLS);
-
- if (mailboxes_protocol) {
- new_window = GTK_WIDGET (modest_mailboxes_window_new (acc_name));
- } else {
- new_window = GTK_WIDGET (modest_folder_window_new (NULL));
- modest_folder_window_set_account (MODEST_FOLDER_WINDOW (new_window),
- acc_name);
- }
+ GtkWidget *new_window;
+ ModestProtocolType store_protocol;
+ gboolean mailboxes_protocol;
+
+ store_protocol = modest_account_mgr_get_store_protocol (modest_runtime_get_account_mgr (),
+ acc_name);
+ mailboxes_protocol =
+ modest_protocol_registry_protocol_type_has_tag (modest_runtime_get_protocol_registry (),
+ store_protocol,
+ MODEST_PROTOCOL_REGISTRY_MULTI_MAILBOX_PROVIDER_PROTOCOLS);
+
+ if (mailboxes_protocol) {
+ new_window = GTK_WIDGET (modest_mailboxes_window_new (acc_name));
+ } else {
+ new_window = GTK_WIDGET (modest_folder_window_new (NULL));
+ modest_folder_window_set_account (MODEST_FOLDER_WINDOW (new_window),
+ acc_name);
+ }
- if (modest_window_mgr_register_window (mgr, MODEST_WINDOW (new_window), NULL)) {
- gtk_widget_show (new_window);
- } else {
- gtk_widget_destroy (new_window);
- new_window = NULL;
- }
+ if (modest_window_mgr_register_window (mgr, MODEST_WINDOW (new_window), NULL)) {
+ gtk_widget_show (new_window);
+ } else {
+ gtk_widget_destroy (new_window);
+ new_window = NULL;
}
#else
if (MODEST_IS_MAIN_WINDOW (top)) {
return FALSE;
}
+static gboolean
+on_idle_present_modal (gpointer user_data)
+{
+ gdk_threads_enter ();
+ gtk_window_present (user_data);
+ gdk_threads_leave ();
+
+ return FALSE;
+}
+
+
/* Callback for normal D-BUS messages */
gint
modest_dbus_req_handler(const gchar * interface, const gchar * method,
GArray * arguments, gpointer data,
osso_rpc_t * retval)
{
+ GtkWindow *dialog;
+
/* Check memory low conditions */
if (modest_platform_check_memory_low (NULL, FALSE)) {
g_idle_add (on_idle_show_memory_low, NULL);
goto param_error;
}
+ /* Check if there is already a dialog or note open */
+ dialog = modest_window_mgr_get_modal (modest_runtime_get_window_mgr());
+ if (dialog) {
+ g_idle_add (on_idle_present_modal, dialog);
+ return OSSO_OK;
+ }
+
if (g_ascii_strcasecmp (method, MODEST_DBUS_METHOD_MAIL_TO) == 0) {
if (arguments->len != MODEST_DBUS_MAIL_TO_ARGS_COUNT)
goto param_error;
g_idle_add (notify_error_in_dbus_callback, NULL);
return OSSO_ERROR;
}
-
+
/* A complex D-Bus type (like a struct),
* used to return various information about a search hit.
*/