LAST_SIGNAL
};
-
/* globals */
static GObjectClass *parent_class = NULL;
static guint signals[LAST_SIGNAL] = {0};
-/* We signal key changes in batches, every X seconds: */
-static gboolean
-on_timeout_notify_changes (gpointer data)
-{
- ModestAccountMgr *self = MODEST_ACCOUNT_MGR (data);
- ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
+/* /\* We signal key changes in batches, every X seconds: *\/ */
+/* static gboolean */
+/* 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. */
+/* /\* 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 =
- modest_account_mgr_get_default_account (self);
+/* if (priv->changed_conf_keys) { */
+/* gchar *default_account = */
+/* modest_account_mgr_get_default_account (self); */
- /* printf ("DEBUG: %s: priv->changed_conf_key length=%d\n",
- __FUNCTION__, g_slist_length (priv->changed_conf_keys)); */
- g_signal_emit (G_OBJECT(self), signals[ACCOUNT_CHANGED_SIGNAL], 0,
- default_account, priv->changed_conf_keys, FALSE);
+/* /\* printf ("DEBUG: %s: priv->changed_conf_key length=%d\n", */
+/* __FUNCTION__, g_slist_length (priv->changed_conf_keys)); *\/ */
+/* g_signal_emit (G_OBJECT(self), signals[ACCOUNT_CHANGED_SIGNAL], 0, */
+/* default_account, priv->changed_conf_keys, FALSE); */
- g_free (default_account);
+/* 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;
- }
+/* g_slist_foreach (priv->changed_conf_keys, (GFunc) g_free, NULL); */
+/* g_slist_free (priv->changed_conf_keys); */
+/* priv->changed_conf_keys = NULL; */
+/* } */
- return TRUE; /* Call this again later. */
-}
-
-static void
-on_key_change (ModestConf *conf, const gchar *key, ModestConfEvent event, gpointer user_data)
-{
- ModestAccountMgr *self = MODEST_ACCOUNT_MGR (user_data);
- ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
- gboolean is_account_key;
- gboolean is_server_account;
- gchar* account = NULL;
-
- /* there is only one not-really-account key which will still emit
- * a signal: a change in MODEST_CONF_DEFAULT_ACCOUNT */
- if (key && strcmp (key, MODEST_CONF_DEFAULT_ACCOUNT) == 0) {
- /* Get the default account instead. */
+/* return TRUE; /\* Call this again later. *\/ */
+/* } */
+
+/* static void */
+/* on_key_change (ModestConf *conf, const gchar *key, ModestConfEvent event, gpointer user_data) */
+/* { */
+/* ModestAccountMgr *self = MODEST_ACCOUNT_MGR (user_data); */
+/* ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self); */
+/* gboolean is_account_key; */
+/* gboolean is_server_account; */
+/* gchar* account = NULL; */
+
+/* /\* there is only one not-really-account key which will still emit */
+/* * a signal: a change in MODEST_CONF_DEFAULT_ACCOUNT *\/ */
+/* if (key && strcmp (key, MODEST_CONF_DEFAULT_ACCOUNT) == 0) { */
+/* /\* Get the default account instead. *\/ */
- /* 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 (priv->changed_conf_keys,
- (gpointer) g_strdup (key));
- }
+/* /\* 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 (priv->changed_conf_keys, */
+/* (gpointer) g_strdup (key)); */
+/* } */
- is_account_key = FALSE;
- is_server_account = FALSE;
- account = _modest_account_mgr_account_from_key (key, &is_account_key,
- &is_server_account);
-
- /* if this is not an account-related key change, ignore */
- if (!account)
- return;
-
- /* account was removed. Do not emit an account removed signal
- because it was already being done in the remove_account
- method. Do not notify also the removal of the server
- account keys for the same reason */
- if ((is_account_key || is_server_account) &&
- event == MODEST_CONF_EVENT_KEY_UNSET) {
- g_free (account);
- return;
- }
-
- /* is this account enabled? */
- gboolean enabled = FALSE;
- if (is_server_account)
- enabled = TRUE;
- else
- enabled = modest_account_mgr_get_enabled (self, account);
-
- /* Notify is server account was changed, default account was changed
- * or when enabled/disabled changes:
- */
- if (enabled ||
- g_str_has_suffix (key, MODEST_ACCOUNT_ENABLED) ||
- strcmp (key, MODEST_CONF_DEFAULT_ACCOUNT) == 0) {
- /* 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) g_strdup (key));
- }
- g_free (account);
-}
+/* is_account_key = FALSE; */
+/* is_server_account = FALSE; */
+/* account = _modest_account_mgr_account_from_key (key, &is_account_key, */
+/* &is_server_account); */
+
+/* /\* if this is not an account-related key change, ignore *\/ */
+/* if (!account) */
+/* return; */
+
+/* /\* account was removed. Do not emit an account removed signal */
+/* because it was already being done in the remove_account */
+/* method. Do not notify also the removal of the server */
+/* account keys for the same reason *\/ */
+/* if ((is_account_key || is_server_account) && */
+/* event == MODEST_CONF_EVENT_KEY_UNSET) { */
+/* g_free (account); */
+/* return; */
+/* } */
+
+/* /\* is this account enabled? *\/ */
+/* gboolean enabled = FALSE; */
+/* if (is_server_account) */
+/* enabled = TRUE; */
+/* else */
+/* enabled = modest_account_mgr_get_enabled (self, account); */
+
+/* /\* Notify is server account was changed, default account was changed */
+/* * or when enabled/disabled changes: */
+/* *\/ */
+/* if (enabled || */
+/* g_str_has_suffix (key, MODEST_ACCOUNT_ENABLED) || */
+/* strcmp (key, MODEST_CONF_DEFAULT_ACCOUNT) == 0) { */
+/* /\* 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) g_strdup (key)); */
+/* } */
+/* g_free (account); */
+/* } */
GType
priv->modest_conf = NULL;
priv->busy_accounts = NULL;
- priv->timeout = g_timeout_add (1000 /* milliseconds */, on_timeout_notify_changes, obj);
+/* priv->timeout = g_timeout_add (1000 /\* milliseconds *\/, on_timeout_notify_changes, obj); */
}
static void
priv->modest_conf = NULL;
}
- if (priv->timeout)
- g_source_remove (priv->timeout);
+/* if (priv->timeout) */
+/* g_source_remove (priv->timeout); */
if (priv->changed_conf_keys) {
g_slist_foreach (priv->changed_conf_keys, (GFunc) g_free, NULL);
g_object_ref (G_OBJECT(conf));
priv->modest_conf = conf;
- priv->key_changed_handler_uid =
- g_signal_connect (G_OBJECT (conf), "key_changed",
- G_CALLBACK (on_key_change),
- obj);
+/* priv->key_changed_handler_uid = */
+/* g_signal_connect (G_OBJECT (conf), "key_changed", */
+/* G_CALLBACK (on_key_change), */
+/* obj); */
return MODEST_ACCOUNT_MGR (obj);
}
modest_account_mgr_set_enabled (self, name, enabled);
+ /* Notify the observers */
+ g_signal_emit (self, signals[ACCOUNT_INSERTED_SIGNAL], 0, name);
+
/* if no default account has been defined yet, do so now */
default_account = modest_account_mgr_get_default_account (self);
if (!default_account)