* only support 'enabled/disabled' for accounts, not server accounts
authorDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Mon, 31 Jul 2006 13:06:00 +0000 (13:06 +0000)
committerDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Mon, 31 Jul 2006 13:06:00 +0000 (13:06 +0000)
pmo-trunk-r443

src/modest-account-mgr.c
src/modest-account-mgr.h

index d080cdc..4fee9f3 100644 (file)
@@ -133,8 +133,10 @@ on_key_change (ModestConf *conf, const gchar *key, ModestConfEvent event, gpoint
        }
 
        /* is this account enabled? */
        }
 
        /* is this account enabled? */
-       enabled = modest_account_mgr_account_get_enabled (self, account,
-                                                         is_server_account);
+       if (is_server_account)
+               enabled = TRUE;
+       else 
+               enabled = modest_account_mgr_account_get_enabled (self, account);
 
        /* account was changed.
         * and always notify when enabled/disabled changes
 
        /* account was changed.
         * and always notify when enabled/disabled changes
@@ -257,20 +259,19 @@ null_means_empty (const gchar * str)
 
 gboolean
 modest_account_mgr_account_set_enabled (ModestAccountMgr *self, const gchar* name,
 
 gboolean
 modest_account_mgr_account_set_enabled (ModestAccountMgr *self, const gchar* name,
-                                       gboolean is_server_account, gboolean enabled)
+                                       gboolean enabled)
 {
        return modest_account_mgr_set_bool (self, name,
                                            MODEST_ACCOUNT_ENABLED, enabled,
 {
        return modest_account_mgr_set_bool (self, name,
                                            MODEST_ACCOUNT_ENABLED, enabled,
-                                           is_server_account, NULL);
+                                           FALSE, NULL);
 }
 
 
 gboolean
 }
 
 
 gboolean
-modest_account_mgr_account_get_enabled (ModestAccountMgr *self, const gchar* name,
-                                       gboolean is_server_account)
+modest_account_mgr_account_get_enabled (ModestAccountMgr *self, const gchar* name)
 {
        return modest_account_mgr_get_bool (self, name,
 {
        return modest_account_mgr_get_bool (self, name,
-                                           MODEST_ACCOUNT_ENABLED, is_server_account,
+                                           MODEST_ACCOUNT_ENABLED, FALSE,
                                            NULL);
 }
 
                                            NULL);
 }
 
@@ -331,7 +332,7 @@ modest_account_mgr_add_account (ModestAccountMgr *self,
                }
        }
 
                }
        }
 
-       modest_account_mgr_account_set_enabled (self, name, FALSE, TRUE);
+       modest_account_mgr_account_set_enabled (self, name, TRUE);
        
        return TRUE;
 }
        
        return TRUE;
 }
@@ -382,9 +383,6 @@ modest_account_mgr_add_server_account (ModestAccountMgr * self,
        key = get_account_keyname (name, MODEST_ACCOUNT_PROTO, TRUE);
        modest_conf_set_string (priv->modest_conf, key, null_means_empty (proto), NULL);
        g_free (key);
        key = get_account_keyname (name, MODEST_ACCOUNT_PROTO, TRUE);
        modest_conf_set_string (priv->modest_conf, key, null_means_empty (proto), NULL);
        g_free (key);
-
-       /* enable it */
-       modest_account_mgr_account_set_enabled (self, name, TRUE, TRUE);
        
        return TRUE;
 }
        
        return TRUE;
 }
@@ -443,8 +441,7 @@ GSList *
 modest_account_mgr_search_server_accounts (ModestAccountMgr * self,
                                           const gchar * account_name,
                                           ModestProtoType type,
 modest_account_mgr_search_server_accounts (ModestAccountMgr * self,
                                           const gchar * account_name,
                                           ModestProtoType type,
-                                          const gchar *proto,
-                                          gboolean only_enabled)
+                                          const gchar *proto)
 {
        GSList *accounts;
        GSList *cursor;
 {
        GSList *accounts;
        GSList *cursor;
@@ -475,18 +472,14 @@ modest_account_mgr_search_server_accounts (ModestAccountMgr * self,
        while (cursor) {
                gchar *account;
                gchar *acc_proto;
        while (cursor) {
                gchar *account;
                gchar *acc_proto;
-               gboolean enabled;
                
                account = account_from_key ((gchar*)cursor->data, NULL, NULL);
                
                account = account_from_key ((gchar*)cursor->data, NULL, NULL);
-               
-               enabled   = modest_account_mgr_account_get_enabled (self, account, TRUE);
                acc_proto = modest_account_mgr_get_string (self, account, MODEST_ACCOUNT_PROTO,
                                                           TRUE, NULL);
                if ((!acc_proto) ||                                /* proto not defined? */
                    (type != MODEST_PROTO_TYPE_ANY &&              /* proto type ...     */
                     modest_proto_type (acc_proto) != type) ||     /* ... matches?       */
                acc_proto = modest_account_mgr_get_string (self, account, MODEST_ACCOUNT_PROTO,
                                                           TRUE, NULL);
                if ((!acc_proto) ||                                /* proto not defined? */
                    (type != MODEST_PROTO_TYPE_ANY &&              /* proto type ...     */
                     modest_proto_type (acc_proto) != type) ||     /* ... matches?       */
-                   (proto && strcmp (proto, acc_proto) != 0) ||   /* proto matches?     */
-                   (!enabled && only_enabled)) {                  /* account enabled?   */
+                   (proto && strcmp (proto, acc_proto) != 0)) {  /* proto matches?     */
                        /* match! remove from the list */
                        GSList *nxt = cursor->next;
                        accounts = g_slist_delete_link (accounts, cursor);
                        /* match! remove from the list */
                        GSList *nxt = cursor->next;
                        accounts = g_slist_delete_link (accounts, cursor);
@@ -510,13 +503,13 @@ modest_account_mgr_account_names (ModestAccountMgr * self, GError ** err)
        ModestAccountMgrPrivate *priv;
        const size_t prefix_len = strlen (MODEST_ACCOUNT_NAMESPACE "/");
 
        ModestAccountMgrPrivate *priv;
        const size_t prefix_len = strlen (MODEST_ACCOUNT_NAMESPACE "/");
 
-
        g_return_val_if_fail (self, NULL);
 
        priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
 
        accounts = modest_conf_list_subkeys (priv->modest_conf,
                                              MODEST_ACCOUNT_NAMESPACE, err);
        g_return_val_if_fail (self, NULL);
 
        priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
 
        accounts = modest_conf_list_subkeys (priv->modest_conf,
                                              MODEST_ACCOUNT_NAMESPACE, err);
+       
        return strip_prefix_from_elements (accounts, prefix_len);
 }
 
        return strip_prefix_from_elements (accounts, prefix_len);
 }
 
index c524f6f..eb9b0c7 100644 (file)
@@ -171,8 +171,7 @@ GSList*             modest_account_mgr_account_names    (ModestAccountMgr *self, GEr
 GSList*  modest_account_mgr_search_server_accounts  (ModestAccountMgr *self,
                                                     const gchar*    account_name,
                                                     ModestProtoType type,
 GSList*  modest_account_mgr_search_server_accounts  (ModestAccountMgr *self,
                                                     const gchar*    account_name,
                                                     ModestProtoType type,
-                                                    const gchar*    proto,
-                                                    gboolean only_enabled);
+                                                    const gchar*    proto);
 
 /**
  * modest_account_mgr_account_exists:
 
 /**
  * modest_account_mgr_account_exists:
@@ -196,7 +195,6 @@ gboolean    modest_account_mgr_account_exists         (ModestAccountMgr *self,
  * modest_account_mgr_account_set_enabled
  * @self: a ModestAccountMgr instance
  * @name: the account name 
  * modest_account_mgr_account_set_enabled
  * @self: a ModestAccountMgr instance
  * @name: the account name 
- * @server_account: if TRUE, this is a server account
  * @enabled: if TRUE, the account will be enabled, if FALSE, it will be disabled
  * 
  * enable/disabled an account
  * @enabled: if TRUE, the account will be enabled, if FALSE, it will be disabled
  * 
  * enable/disabled an account
@@ -204,21 +202,19 @@ gboolean  modest_account_mgr_account_exists         (ModestAccountMgr *self,
  * Returns: TRUE if it worked, FALSE otherwise
  */
 gboolean modest_account_mgr_account_set_enabled (ModestAccountMgr *self, const gchar* name,
  * Returns: TRUE if it worked, FALSE otherwise
  */
 gboolean modest_account_mgr_account_set_enabled (ModestAccountMgr *self, const gchar* name,
-                                                gboolean is_server_account, gboolean enabled);
+                                                gboolean enabled);
 
 
 /**
  * modest_account_mgr_account_get_enabled:
  * @self: a ModestAccountMgr instance
  * @name: the account name to check
 
 
 /**
  * modest_account_mgr_account_get_enabled:
  * @self: a ModestAccountMgr instance
  * @name: the account name to check
- * @server_account: if TRUE, this is a server account
  *
  * check whether a certain account is enabled
  *
  * Returns: TRUE if it is enabled, FALSE otherwise
  */
  *
  * check whether a certain account is enabled
  *
  * Returns: TRUE if it is enabled, FALSE otherwise
  */
-gboolean modest_account_mgr_account_get_enabled (ModestAccountMgr *self, const gchar* name,
-                                                gboolean is_server_account);
+gboolean modest_account_mgr_account_get_enabled (ModestAccountMgr *self, const gchar* name);
 
 
 /**
 
 
 /**