instead of querying modest_conf (gconf) all the time
pmo-trunk-r3751
GHashTable *notification_id_accounts;
GHashTable *server_account_key_hash;
GHashTable *account_key_hash;
GHashTable *notification_id_accounts;
GHashTable *server_account_key_hash;
GHashTable *account_key_hash;
+
+ /* cache whether we have accounts; if this is TRUE, we have accounts, if
+ * it's FALSE we _don't know_ if we have account and need to check
+ */
+ gboolean has_accounts;
+ gboolean has_enabled_accounts;
#define MODEST_ACCOUNT_MGR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
#define MODEST_ACCOUNT_MGR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
- MODEST_TYPE_ACCOUNT_MGR, \
+ MODEST_TYPE_ACCOUNT_MGR, \
ModestAccountMgrPrivate))
ModestAccountMgrPrivate))
/**
* modest_account_mgr_set_bool:
* @self: a ModestAccountMgr instance
/**
* modest_account_mgr_set_bool:
* @self: a ModestAccountMgr instance
g_str_equal,
g_free,
(GDestroyNotify)g_hash_table_destroy);
g_str_equal,
g_free,
(GDestroyNotify)g_hash_table_destroy);
+
+ /* FALSE means: status is unknown */
+ priv->has_accounts = FALSE;
+ priv->has_enabled_accounts = FALSE;
/* 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 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);
modest_platform_set_update_interval (0);
modest_platform_set_update_interval (0);
+ /* it was the last account, the has_account / has_enabled_account
+ * changes
+ */
+ priv->has_accounts = priv->has_enabled_accounts = FALSE;
+ } else
modest_account_mgr_free_account_names (acc_names);
return TRUE;
modest_account_mgr_free_account_names (acc_names);
return TRUE;
gboolean
modest_account_mgr_has_accounts (ModestAccountMgr* self, gboolean enabled)
{
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;
+ ModestAccountMgrPrivate* priv;
+ GSList *account_names;
+ gboolean accounts_exist;
+
+ g_return_val_if_fail (MODEST_IS_ACCOUNT_MGR(self), FALSE);
+
+ priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
+ if (enabled && priv->has_enabled_accounts)
+ return TRUE;
+ else if (priv->has_accounts)
+ return TRUE;
+
+ /* Check that at least one account exists: */
+ account_names = modest_account_mgr_account_names (self,enabled);
+ accounts_exist = account_names != NULL;
modest_account_mgr_free_account_names (account_names);
account_names = NULL;
modest_account_mgr_free_account_names (account_names);
account_names = NULL;
+
+ /* cache it. */
+ if (enabled)
+ priv->has_enabled_accounts = accounts_exist;
+ else
+ priv->has_accounts = accounts_exist;
const gchar *server_account_name)
{
ModestTransportStoreProtocol proto;
const gchar *server_account_name)
{
ModestTransportStoreProtocol proto;
+ ModestAccountMgrPrivate* priv;
gchar *proto_name = NULL;
gchar *proto_name = NULL;
+ g_return_if_fail (self);
+ g_return_if_fail (server_account_name);
+
+ priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
+
/* Get protocol */
proto_name = modest_account_mgr_get_string (self, server_account_name,
MODEST_ACCOUNT_PROTO, TRUE);
/* Get protocol */
proto_name = modest_account_mgr_get_string (self, server_account_name,
MODEST_ACCOUNT_PROTO, TRUE);
proto = modest_protocol_info_get_transport_store_protocol (proto_name);
g_free (proto_name);
proto = modest_protocol_info_get_transport_store_protocol (proto_name);
g_free (proto_name);
+ /* there is some update in the account, so we can't
+ * be sure about whether there are still enabled accounts...
+ */
+ priv->has_enabled_accounts = FALSE;
+ priv->has_accounts = FALSE;
+
/* Emit "update-account" */
g_signal_emit (G_OBJECT(self),
signals[ACCOUNT_CHANGED_SIGNAL], 0,
/* Emit "update-account" */
g_signal_emit (G_OBJECT(self),
signals[ACCOUNT_CHANGED_SIGNAL], 0,