X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-account-mgr.c;h=44d7421eeda87274df9959979f0294fc17495541;hp=fee90c30141423bc4db84c630280d35c24b76392;hb=d2766e0125d45ae66dbe70b51eb90e3b0e493982;hpb=e565f583b5b88c4e1cc330f5ed22c39f86525a32 diff --git a/src/modest-account-mgr.c b/src/modest-account-mgr.c index fee90c3..44d7421 100644 --- a/src/modest-account-mgr.c +++ b/src/modest-account-mgr.c @@ -56,12 +56,12 @@ on_timeout_notify_changes (gpointer data) { ModestAccountMgr *self = MODEST_ACCOUNT_MGR (data); ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self); - + /* TODO: Also store the account names, and notify one list for each account, * if anything uses the account names. */ if (priv->changed_conf_keys) { - gchar *default_account = + gchar *default_account = modest_account_mgr_get_default_account (self); g_signal_emit (G_OBJECT(self), signals[ACCOUNT_CHANGED_SIGNAL], 0, @@ -69,6 +69,7 @@ on_timeout_notify_changes (gpointer data) g_free (default_account); + g_slist_foreach (priv->changed_conf_keys, (GFunc) g_free, NULL); g_slist_free (priv->changed_conf_keys); priv->changed_conf_keys = NULL; } @@ -79,8 +80,6 @@ on_timeout_notify_changes (gpointer data) static void on_key_change (ModestConf *conf, const gchar *key, ModestConfEvent event, gpointer user_data) { - /* printf("DEBUG: %s: key=%s\n", __FUNCTION__, key); */ - ModestAccountMgr *self = MODEST_ACCOUNT_MGR (user_data); ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self); @@ -91,8 +90,8 @@ on_key_change (ModestConf *conf, const gchar *key, ModestConfEvent event, gpoint /* Store the key for later notification in our timeout callback. * Notifying for every key change would cause unnecessary work: */ - priv->changed_conf_keys = g_slist_append (NULL, - (gpointer)key); + priv->changed_conf_keys = g_slist_append (priv->changed_conf_keys, + (gpointer) g_strdup (key)); } gboolean is_account_key = FALSE; @@ -129,7 +128,7 @@ on_key_change (ModestConf *conf, const gchar *key, ModestConfEvent event, gpoint /* Store the key for later notification in our timeout callback. * Notifying for every key change would cause unnecessary work: */ priv->changed_conf_keys = g_slist_append (NULL, - (gpointer)key); + (gpointer) g_strdup (key)); } g_free (account); @@ -189,7 +188,7 @@ modest_account_mgr_class_init (ModestAccountMgrClass * klass) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET(ModestAccountMgrClass,account_changed), NULL, NULL, - modest_marshal_VOID__STRING_STRING_BOOLEAN, + modest_marshal_VOID__STRING_POINTER_BOOLEAN, G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN); } @@ -219,8 +218,10 @@ modest_account_mgr_finalize (GObject * obj) if (priv->timeout) g_source_remove (priv->timeout); - if (priv->changed_conf_keys) + if (priv->changed_conf_keys) { + g_slist_foreach (priv->changed_conf_keys, (GFunc) g_free, NULL); g_slist_free (priv->changed_conf_keys); + } G_OBJECT_CLASS(parent_class)->finalize (obj); } @@ -347,8 +348,6 @@ modest_account_mgr_add_account (ModestAccountMgr *self, } - - gboolean modest_account_mgr_add_server_account (ModestAccountMgr * self, const gchar * name, const gchar *hostname, @@ -581,8 +580,10 @@ modest_account_mgr_remove_account (ModestAccountMgr * self, if (default_account_name && (strcmp (default_account_name, name) == 0)) modest_account_mgr_unset_default_account (self); g_free (default_account_name); + + /* pick another one as the new default account */ + modest_account_mgr_set_first_account_as_default (self); } - return retval; } @@ -994,7 +995,6 @@ modest_account_mgr_account_exists (ModestAccountMgr * self, const gchar * name, g_return_val_if_fail (name, FALSE); keyname = _modest_account_mgr_get_account_keyname (name, NULL, server_account); - priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self); retval = modest_conf_key_exists (priv->modest_conf, keyname, &err); if (err) { @@ -1007,8 +1007,8 @@ modest_account_mgr_account_exists (ModestAccountMgr * self, const gchar * name, return retval; } -gboolean modest_account_mgr_account_with_display_name_exists (ModestAccountMgr *self, - const gchar *display_name) +gboolean +modest_account_mgr_account_with_display_name_exists (ModestAccountMgr *self, const gchar *display_name) { GSList *account_names = NULL; GSList *cursor = NULL; @@ -1160,3 +1160,15 @@ _modest_account_mgr_get_account_keyname (const gchar *account_name, const gchar return retval; } + +gboolean +modest_account_mgr_has_accounts (ModestAccountMgr* self, gboolean enabled) +{ + /* Check that at least one account exists: */ + GSList *account_names = modest_account_mgr_account_names (self, + enabled); + gboolean accounts_exist = account_names != NULL; + g_slist_free (account_names); + + return accounts_exist; +}