2007-04-20 Murray Cumming <murrayc@murrayc.com>
[modest] / src / modest-account-mgr.c
index dfaec74..89a3d5b 100644 (file)
@@ -407,19 +407,24 @@ modest_account_mgr_add_server_account (ModestAccountMgr * self,
                   supported */
                key = _modest_account_mgr_get_account_keyname (name, MODEST_ACCOUNT_OPTIONS, TRUE);
                /* Enable subscriptions and check the mails in all folders */
-               option_list = g_slist_append (option_list, "use_lsub");
-               option_list = g_slist_append (option_list, "check_all");
+               option_list = g_slist_append (option_list, MODEST_ACCOUNT_OPTION_USE_LSUB);
+               option_list = g_slist_append (option_list, MODEST_ACCOUNT_OPTION_CHECK_ALL);
+
+               /* TODO: Remove this hack. These are hard-coded camel options to make the connection work.
+                * The regular connection options (set later here) should be interpreted instead 
+                * because in future these camel options will not be in gconf. murrayc.
+                */
                /* Security options */
                switch (security) {
                case MODEST_PROTOCOL_SECURITY_NONE:
-                       option_list = g_slist_append (option_list, "use_ssl=never");
+                       option_list = g_slist_append (option_list, MODEST_ACCOUNT_OPTION_SSL "= " MODEST_ACCOUNT_OPTION_SSL_NEVER);
                        break;
                case MODEST_PROTOCOL_SECURITY_SSL:
                case MODEST_PROTOCOL_SECURITY_TLS:
-                       option_list = g_slist_append (option_list, "use_ssl=always");
+                       option_list = g_slist_append (option_list, MODEST_ACCOUNT_OPTION_SSL "= " MODEST_ACCOUNT_OPTION_SSL_ALWAYS);
                        break;
                case MODEST_PROTOCOL_SECURITY_TLS_OP:
-                       option_list = g_slist_append (option_list, "use_ssl=when-possible");
+                       option_list = g_slist_append (option_list, MODEST_ACCOUNT_OPTION_SSL "= " MODEST_ACCOUNT_OPTION_SSL_WHEN_POSSIBLE);
                        break;
                default:
                        g_warning ("Invalid security option");
@@ -433,6 +438,10 @@ modest_account_mgr_add_server_account (ModestAccountMgr * self,
                }
                g_slist_free (option_list);
                g_free (key);
+               
+               
+               /* Add the security settings: */
+               modest_server_account_set_security (self, name, security);
        }
 
 cleanup:
@@ -935,6 +944,40 @@ modest_account_mgr_account_exists (ModestAccountMgr * self, const gchar * name,
        return retval;
 }
 
+gboolean       modest_account_mgr_account_with_display_name_exists       (ModestAccountMgr *self,
+                                                          const gchar *display_name)
+{
+       GSList *account_names = NULL;
+       GSList *cursor = NULL;
+       
+       cursor = account_names = modest_account_mgr_account_names (self);
+
+       gboolean found = FALSE;
+       
+       /* Look at each non-server account to check their display names; */
+       while (cursor) {
+               const gchar * account_name = (gchar*)cursor->data;
+               
+               ModestAccountData *account_data = modest_account_mgr_get_account_data (self, account_name);
+               if (!account_data) {
+                       g_printerr ("modest: failed to get account data for %s\n", account_name);
+                       continue;
+               }
+
+               if(account_data->display_name && (strcmp (account_data->display_name, display_name) == 0)) {
+                       found = TRUE;
+                       break;
+               }
+
+               modest_account_mgr_free_account_data (self, account_data);
+               cursor = cursor->next;
+       }
+       g_slist_free (account_names);
+       
+       return found;
+}
+
+
 
 
 gboolean