* src/modest-account-mgr-helpers.c:
[modest] / src / modest-account-mgr-helpers.c
index d1c3626..33f88fe 100644 (file)
@@ -65,13 +65,13 @@ gboolean modest_account_mgr_set_signature (ModestAccountMgr *self, const gchar*
        return result;
 }
 
-gchar* modest_account_mgr_get_signature (ModestAccountMgr *self, const gchar* name, 
-       gboolean* use_signature)
+gchar* 
+modest_account_mgr_get_signature (ModestAccountMgr *self, 
+                                 const gchar* name, 
+                                 gboolean* use_signature)
 {
-       if (use_signature) {
-               *use_signature = 
-                       modest_account_mgr_get_bool (self, name, MODEST_ACCOUNT_USE_SIGNATURE, FALSE);
-       }
+       *use_signature = 
+               modest_account_mgr_get_bool (self, name, MODEST_ACCOUNT_USE_SIGNATURE, FALSE);
        
        return modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_SIGNATURE, FALSE);
 }
@@ -98,9 +98,9 @@ ModestTransportStoreProtocol modest_account_mgr_get_store_protocol (ModestAccoun
 
 
 gboolean modest_account_mgr_set_connection_specific_smtp (ModestAccountMgr *self, 
-       const gchar* connection_name, const gchar* server_account_name)
+       const gchar* connection_id, const gchar* server_account_name)
 {
-       modest_account_mgr_remove_connection_specific_smtp (self, connection_name);
+       modest_account_mgr_remove_connection_specific_smtp (self, connection_id);
        
        ModestConf *conf = MODEST_ACCOUNT_MGR_GET_PRIVATE (self)->modest_conf;
 
@@ -115,7 +115,7 @@ gboolean modest_account_mgr_set_connection_specific_smtp (ModestAccountMgr *self
                result = FALSE;
        } else {        
                /* The server account is in the item after the connection name: */
-               list = g_slist_append (list, (gpointer)connection_name);
+               list = g_slist_append (list, (gpointer)connection_id);
                list = g_slist_append (list, (gpointer)server_account_name);
        
                /* Reset the changed list: */
@@ -138,22 +138,22 @@ gboolean modest_account_mgr_set_connection_specific_smtp (ModestAccountMgr *self
  * modest_account_mgr_remove_connection_specific_smtp
  * @self: a ModestAccountMgr instance
  * @name: the account name
- * @connection_name: A libconic IAP connection name
+ * @connection_id: A libconic IAP connection id
  * 
  * Disassacoiate a server account to use with the specific connection for this account.
  *
  * Returns: TRUE if it worked, FALSE otherwise
  */                             
 gboolean modest_account_mgr_remove_connection_specific_smtp (ModestAccountMgr *self, 
-       const gchar* connection_name)
+       const gchar* connection_id)
 {
        ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
        
        gboolean result = TRUE;
        GError *err = NULL;
        GSList *list = modest_conf_get_list (priv->modest_conf, 
-                                                       MODEST_CONF_CONNECTION_SPECIFIC_SMTP_LIST,
-                                                   MODEST_CONF_VALUE_STRING, &err);
+                                            MODEST_CONF_CONNECTION_SPECIFIC_SMTP_LIST,
+                                            MODEST_CONF_VALUE_STRING, &err);
        if (err) {
                g_printerr ("modest: %s: error getting list: %s.\n", __FUNCTION__, err->message);
                g_error_free (err);
@@ -165,7 +165,7 @@ gboolean modest_account_mgr_remove_connection_specific_smtp (ModestAccountMgr *s
                return FALSE;
                
        /* The server account is in the item after the connection name: */
-       GSList *list_connection = g_slist_find_custom (list, connection_name, (GCompareFunc)strcmp);
+       GSList *list_connection = g_slist_find_custom (list, connection_id, (GCompareFunc)strcmp);
        if (list_connection) {
                GSList *account_node = g_slist_next (list_connection);
                /* remove both items: */
@@ -205,13 +205,13 @@ gboolean modest_account_mgr_set_use_connection_specific_smtp (ModestAccountMgr *
 /**
  * modest_account_mgr_get_connection_specific_smtp
  * @self: a ModestAccountMgr instance
- * @connection_name: A libconic IAP connection name
+ * @connection_id: A libconic IAP connection id
  * 
  * Retrieve a server account to use with this specific connection for this account.
  *
  * Returns: a server account name to use for this connection, or NULL if none is specified.
  */                     
-gchar* modest_account_mgr_get_connection_specific_smtp (ModestAccountMgr *self,  const gchar* connection_name)
+gchar* modest_account_mgr_get_connection_specific_smtp (ModestAccountMgr *self,  const gchar* connection_id)
 {
        gchar *result = NULL;
        
@@ -232,8 +232,8 @@ gchar* modest_account_mgr_get_connection_specific_smtp (ModestAccountMgr *self,
        /* The server account is in the item after the connection name: */
        GSList *iter = list;
        while (iter) {
-               const gchar* this_connection_name = (const gchar*)(iter->data);
-               if (strcmp (this_connection_name, connection_name) == 0) {
+               const gchar* this_connection_id = (const gchar*)(iter->data);
+               if (strcmp (this_connection_id, connection_id) == 0) {
                        iter = g_slist_next (iter);
                        
                        if (iter) {
@@ -253,7 +253,7 @@ gchar* modest_account_mgr_get_connection_specific_smtp (ModestAccountMgr *self,
                
        /*
        if (!result) {
-               printf ("  debug: no server found for connection_name=%s.\n", connection_name); 
+               printf ("  debug: no server found for connection_id=%s.\n", connection_id);     
        }
        */
                                
@@ -496,28 +496,39 @@ modest_account_mgr_save_server_settings (ModestAccountMgr *self,
 
                has_errors = !modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_HOSTNAME, 
                                                            hostname, TRUE);
-               has_errors || (has_errors = !modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_USERNAME,
+               if (!has_errors)
+                       (has_errors = !modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_USERNAME,
                                                                           username, TRUE));
-               has_errors || (has_errors = !modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_PASSWORD,
+               if (!has_errors)
+                       (has_errors = !modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_PASSWORD,
                                                                           password, TRUE));
-               has_errors || (has_errors = !modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_PROTO,
+               if (!has_errors)
+                       (has_errors = !modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_PROTO,
                                                                           protocol, TRUE));
-               has_errors || (has_errors = !modest_account_mgr_set_int (self, account_name, MODEST_ACCOUNT_PORT,
+               if (!has_errors)
+                       (has_errors = !modest_account_mgr_set_int (self, account_name, MODEST_ACCOUNT_PORT,
                                                                        port, TRUE));
-               has_errors || (has_errors = !modest_account_mgr_set_string (self, account_name, 
+               if (!has_errors)
+                       (has_errors = !modest_account_mgr_set_string (self, account_name, 
                                                                           MODEST_ACCOUNT_AUTH_MECH,
                                                                           auth_protocol, TRUE));               
-               has_errors || (has_errors = !modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_SECURITY,
+               if (!has_errors)
+                       (has_errors = !modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_SECURITY,
                                                                           security,
                                                                           TRUE));
        } else {
                const gchar *uri = modest_server_account_settings_get_uri (settings);
                has_errors = !modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_URI,
                                                            uri, TRUE);
-               has_errors || (has_errors = !modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_PROTO,
+               if (!has_errors)
+                       (has_errors = !modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_PROTO,
                                                                           protocol, TRUE));
        }
 
+       if (!has_errors) {
+         modest_account_mgr_set_server_account_username_has_succeeded (self, account_name, FALSE);
+       }
+
        return !has_errors;
 
 }
@@ -566,6 +577,7 @@ modest_account_mgr_load_account_settings (ModestAccountMgr *self,
 
        modest_account_settings_set_enabled (settings, modest_account_mgr_get_enabled (self, name));
        modest_account_settings_set_retrieve_type (settings, modest_account_mgr_get_retrieve_type (self, name));
+       modest_account_settings_set_retrieve_limit (settings, modest_account_mgr_get_retrieve_limit (self, name));
 
        default_account    = modest_account_mgr_get_default_account (self);
        modest_account_settings_set_is_default (settings,