From dbc3d4dbaeee445862c7b0d21715babf7d9e8bbe Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sergio=20Villar=20Sen=C3=ADn?= Date: Fri, 4 Dec 2009 16:20:32 +0100 Subject: [PATCH] Do not restart Modest every X minutes Fixes NB#149093 --- src/dbus_api/modest-dbus-callbacks.c | 7 ------- src/hildon2/com.nokia.modest.service.in | 2 +- src/hildon2/modest.desktop.in | 2 +- src/modest-main.c | 24 ++---------------------- src/modest-runtime.c | 2 +- src/widgets/modest-window-mgr.c | 27 ++++++++++++++++++--------- 6 files changed, 23 insertions(+), 41 deletions(-) diff --git a/src/dbus_api/modest-dbus-callbacks.c b/src/dbus_api/modest-dbus-callbacks.c index 7a5ecd1..3d24c2a 100644 --- a/src/dbus_api/modest-dbus-callbacks.c +++ b/src/dbus_api/modest-dbus-callbacks.c @@ -1532,17 +1532,14 @@ modest_dbus_req_handler(const gchar * interface, const gchar * method, if (g_ascii_strcasecmp (method, MODEST_DBUS_METHOD_MAIL_TO) == 0) { if (arguments->len != MODEST_DBUS_MAIL_TO_ARGS_COUNT) goto param_error; - modest_runtime_set_allow_shutdown (TRUE); return on_mail_to (arguments, data, retval); } else if (g_ascii_strcasecmp (method, MODEST_DBUS_METHOD_OPEN_MESSAGE) == 0) { if (arguments->len != MODEST_DBUS_OPEN_MESSAGE_ARGS_COUNT) goto param_error; - modest_runtime_set_allow_shutdown (TRUE); return on_open_message (arguments, data, retval); } else if (g_ascii_strcasecmp (method, MODEST_DBUS_METHOD_OPEN_ACCOUNT) == 0) { if (arguments->len != MODEST_DBUS_OPEN_ACCOUNT_ARGS_COUNT) goto param_error; - modest_runtime_set_allow_shutdown (TRUE); return on_open_account (arguments, data, retval); } else if (g_ascii_strcasecmp (method, MODEST_DBUS_METHOD_SEND_RECEIVE) == 0) { if (arguments->len != 0) @@ -1555,7 +1552,6 @@ modest_dbus_req_handler(const gchar * interface, const gchar * method, } else if (g_ascii_strcasecmp (method, MODEST_DBUS_METHOD_COMPOSE_MAIL) == 0) { if (arguments->len != MODEST_DBUS_COMPOSE_MAIL_ARGS_COUNT) goto param_error; - modest_runtime_set_allow_shutdown (TRUE); return on_compose_mail (arguments, data, retval); } else if (g_ascii_strcasecmp (method, MODEST_DBUS_METHOD_DELETE_MESSAGE) == 0) { if (arguments->len != MODEST_DBUS_DELETE_MESSAGE_ARGS_COUNT) @@ -1564,17 +1560,14 @@ modest_dbus_req_handler(const gchar * interface, const gchar * method, } else if (g_ascii_strcasecmp (method, MODEST_DBUS_METHOD_OPEN_DEFAULT_INBOX) == 0) { if (arguments->len != 0) goto param_error; - modest_runtime_set_allow_shutdown (TRUE); return on_open_default_inbox (arguments, data, retval); } else if (g_ascii_strcasecmp (method, MODEST_DBUS_METHOD_TOP_APPLICATION) == 0) { if (arguments->len != 0) goto param_error; - modest_runtime_set_allow_shutdown (TRUE); return on_top_application (arguments, data, retval); } else if (g_ascii_strcasecmp (method, MODEST_DBUS_METHOD_OPEN_EDIT_ACCOUNTS_DIALOG) == 0) { if (arguments->len != 0) goto param_error; - modest_runtime_set_allow_shutdown (TRUE); return on_open_edit_accounts_dialog (arguments, data, retval); } else { /* We need to return INVALID here so diff --git a/src/hildon2/com.nokia.modest.service.in b/src/hildon2/com.nokia.modest.service.in index c4698b3..2d125bd 100644 --- a/src/hildon2/com.nokia.modest.service.in +++ b/src/hildon2/com.nokia.modest.service.in @@ -1,4 +1,4 @@ [D-BUS Service] Name=com.nokia.modest -Exec=@prefix@/bin/modest -t 30 +Exec=@prefix@/bin/modest diff --git a/src/hildon2/modest.desktop.in b/src/hildon2/modest.desktop.in index 5405f4e..0ed12b2 100644 --- a/src/hildon2/modest.desktop.in +++ b/src/hildon2/modest.desktop.in @@ -4,7 +4,7 @@ Version=@PACKAGE_VERSION@ Type=Application Name=mcen_ap_name Comment=mcen_ap_name_thumb -Exec=@prefix@/bin/modest -t 30 +Exec=@prefix@/bin/modest X-Text-Domain=modest X-Osso-Service=com.nokia.modest diff --git a/src/modest-main.c b/src/modest-main.c index a74f619..ed753dd 100644 --- a/src/modest-main.c +++ b/src/modest-main.c @@ -37,16 +37,12 @@ #include "modest-ui-actions.h" static gboolean show_ui = FALSE; -static gint shutdown_timeout = 0; static GOptionEntry option_entries [] = { { "show-ui", 's', 0, G_OPTION_ARG_NONE, &show_ui, "Show UI immediately, so no wait for DBUS activation", NULL }, - { "shutdown-timeout", 't', 0, G_OPTION_ARG_INT, &shutdown_timeout, "Timeout in minutes for running Modest in prestart mode", NULL }, { NULL } }; -static guint shutdown_timeout_id = 0; - typedef struct { gulong queue_handler; gulong window_list_handler; @@ -124,13 +120,6 @@ on_window_list_empty (ModestWindowMgr *window_mgr, g_idle_add_full (G_PRIORITY_LOW, on_idle_exit_modest, user_data, NULL); } -static gboolean -shutdown_timeout_handler (gpointer userdata) -{ - modest_runtime_set_allow_shutdown (TRUE); - return FALSE; -} - int main (int argc, char *argv[]) { @@ -138,7 +127,6 @@ main (int argc, char *argv[]) * because we wait for the top_application D-Bus method to * be called. But that's annoying when starting from the * command line.: */ - gboolean show_ui_without_top_application_method = FALSE; int retval = 0; MainSignalHandlers *handlers; ModestTnyAccountStore *acc_store; @@ -158,9 +146,7 @@ main (int argc, char *argv[]) } g_option_context_free (context); - show_ui_without_top_application_method = show_ui; - - if (!show_ui_without_top_application_method) { + if (!show_ui) { g_print ("modest: use 'modest -s' to start from cmdline with UI\n"); } @@ -224,10 +210,9 @@ main (int argc, char *argv[]) * The UI will be shown later (or just after starting if no otehr D-Bus method was used), * when we receive the "top_application" D-Bus method. */ - if (show_ui_without_top_application_method) { + if (show_ui) { ModestWindow *window; - modest_runtime_set_allow_shutdown (TRUE); mgr = modest_runtime_get_window_mgr(); window = modest_window_mgr_show_initial_window (mgr); if (!window) { @@ -237,11 +222,6 @@ main (int argc, char *argv[]) } /* Remove new mail notifications if exist */ modest_platform_remove_new_mail_notifications (FALSE); - } else { - if (shutdown_timeout > 0) { - modest_runtime_set_allow_shutdown (FALSE); - shutdown_timeout_id = g_timeout_add_seconds (shutdown_timeout * 60, shutdown_timeout_handler, NULL); - } } gtk_main (); diff --git a/src/modest-runtime.c b/src/modest-runtime.c index 4e98990..f3ec8b6 100644 --- a/src/modest-runtime.c +++ b/src/modest-runtime.c @@ -58,7 +58,7 @@ static ModestTnyAccountStore *_account_store = NULL; static GSList *_sig_handlers = NULL; /* will modest shut down when window list and mail op queue are empty? */ -static gboolean _allow_shutdown = TRUE; +static gboolean _allow_shutdown = FALSE; /* * private functions declared in modest-runtime-priv.h - diff --git a/src/widgets/modest-window-mgr.c b/src/widgets/modest-window-mgr.c index cb28697..fa198e3 100644 --- a/src/widgets/modest-window-mgr.c +++ b/src/widgets/modest-window-mgr.c @@ -538,16 +538,25 @@ modest_window_mgr_register_window (ModestWindowMgr *self, ModestWindow *window, ModestWindow *parent) { - /* If this is the first registered window then reset the - status of the TnyDevice as it might be forced to be offline - when modest is running in the background (see - modest_tny_account_store_new()) */ - if (modest_window_mgr_get_num_windows (self) == 0) { + gboolean no_windows, retval; + + no_windows = (modest_window_mgr_get_num_windows (self) == 0); + + retval = MODEST_WINDOW_MGR_GET_CLASS (self)->register_window (self, window, parent); + + if (no_windows) { + /* If this is the first registered window then reset the + status of the TnyDevice as it might be forced to be offline + when modest is running in the background (see + modest_tny_account_store_new()) */ if (tny_device_is_forced (modest_runtime_get_device ())) tny_device_reset (modest_runtime_get_device ()); - } - return MODEST_WINDOW_MGR_GET_CLASS (self)->register_window (self, window, parent); + /* Do also allow modest to shutdown when the + application is closed */ + modest_runtime_set_allow_shutdown (TRUE); + } + return retval; } static gboolean @@ -587,7 +596,7 @@ modest_window_mgr_register_window_default (ModestWindowMgr *self, (MODEST_MSG_VIEW_WINDOW (window)); MODEST_DEBUG_BLOCK(g_debug ("registering window for %s", uid ? uid : "");); - + if (has_uid (priv->preregistered_uids, uid)) { priv->preregistered_uids = remove_uid (priv->preregistered_uids, @@ -597,7 +606,7 @@ modest_window_mgr_register_window_default (ModestWindowMgr *self, } else if (MODEST_IS_MSG_EDIT_WINDOW(window)) { const gchar *uid = modest_msg_edit_window_get_message_uid (MODEST_MSG_EDIT_WINDOW (window)); - + MODEST_DEBUG_BLOCK(g_debug ("registering window for %s", uid);); priv->preregistered_uids = -- 1.7.9.5