From: Dirk-Jan C. Binnema Date: Thu, 25 Oct 2007 15:42:12 +0000 (+0000) Subject: * only set auto-update alarms when there are accounts; X-Git-Tag: git_migration_finished~2214 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=e6c495e0fde387c5abdfafe9d0e58df600932924 * only set auto-update alarms when there are accounts; also check with account addition/deletion. Fixes: NB#64945 pmo-trunk-r3578 --- diff --git a/src/maemo/modest-platform.c b/src/maemo/modest-platform.c index c1143f4..2bdd043 100644 --- a/src/maemo/modest-platform.c +++ b/src/maemo/modest-platform.c @@ -59,12 +59,7 @@ #define HILDON_OSSO_URI_ACTION "uri-action" #define URI_ACTION_COPY "copy:" -/* The maximun number of notifications that could be shown in the - desktop. It's specified by the specs and limited by the screen - size */ -#define MAX_NOTIFICATIONS 6 - -static osso_context_t *osso_context = NULL; +static osso_context_t *osso_context = NULL; /* urgh global */ static void on_modest_conf_update_interval_changed (ModestConf* self, @@ -73,6 +68,8 @@ on_modest_conf_update_interval_changed (ModestConf* self, ModestConfNotificationId id, gpointer user_data) { + g_return_if_fail (key); + if (strcmp (key, MODEST_CONF_UPDATE_INTERVAL) == 0) { const guint update_interval_minutes = modest_conf_get_int (self, MODEST_CONF_UPDATE_INTERVAL, NULL); @@ -107,7 +104,8 @@ modest_platform_init (int argc, char *argv[]) { osso_hw_state_t hw_state = { 0 }; DBusConnection *con; - + GSList *acc_names; + if (!check_required_files ()) { g_printerr ("modest: missing required files\n"); return FALSE; @@ -190,10 +188,16 @@ modest_platform_init (int argc, char *argv[]) "key_changed", G_CALLBACK (on_modest_conf_update_interval_changed), NULL); - - /* Get the initial update interval from gconf: */ - on_modest_conf_update_interval_changed(conf, MODEST_CONF_UPDATE_INTERVAL, - MODEST_CONF_EVENT_KEY_CHANGED, 0, NULL); + + /* only force the setting of the default interval, if there are actually + * any accounts */ + acc_names = modest_account_mgr_account_names (modest_runtime_get_account_mgr(), TRUE); + if (acc_names) { + /* Get the initial update interval from gconf: */ + on_modest_conf_update_interval_changed(conf, MODEST_CONF_UPDATE_INTERVAL, + MODEST_CONF_EVENT_KEY_CHANGED, 0, NULL); + modest_account_mgr_free_account_names (acc_names); + } /* initialize the addressbook */ if (!osso_abook_init (&argc, &argv, osso_context)) { diff --git a/src/modest-account-mgr.c b/src/modest-account-mgr.c index ae3848b..2a309c4 100644 --- a/src/modest-account-mgr.c +++ b/src/modest-account-mgr.c @@ -33,6 +33,7 @@ #include #include #include +#include /* 'private'/'protected' functions */ static void modest_account_mgr_class_init (ModestAccountMgrClass * klass); @@ -358,7 +359,11 @@ modest_account_mgr_add_account (ModestAccountMgr *self, if (!default_account) modest_account_mgr_set_default_account (self, name); g_free (default_account); - + + /* (re)set the automatic account update */ + modest_platform_set_update_interval + (modest_conf_get_int (priv->modest_conf, MODEST_CONF_UPDATE_INTERVAL, NULL)); + return TRUE; } @@ -594,6 +599,14 @@ modest_account_mgr_remove_account (ModestAccountMgr * self, will retrieve also the deleted account */ g_signal_emit (G_OBJECT(self), signals[ACCOUNT_REMOVED_SIGNAL], 0, name); + /* if this was the last account, stop any auto-updating */ + /* (re)set the automatic account update */ + GSList *acc_names = modest_account_mgr_account_names (self, TRUE); + if (!acc_names) + modest_platform_set_update_interval (0); + else + modest_account_mgr_free_account_names (acc_names); + return TRUE; }