{
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,
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;
}
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);
/* 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;
/* 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);
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);
}
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);
}
}
-
-
gboolean
modest_account_mgr_add_server_account (ModestAccountMgr * self,
const gchar * name, const gchar *hostname,
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;
}
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) {
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;
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;
+}