2007-08-31 Murray Cumming <murrayc@murrayc.com>
authorMurray Cumming <murrayc@murrayc.com>
Fri, 31 Aug 2007 16:02:51 +0000 (16:02 +0000)
committerMurray Cumming <murrayc@murrayc.com>
Fri, 31 Aug 2007 16:02:51 +0000 (16:02 +0000)
* src/modest-defs.h: Rename MODEST_CONF_CONNECTION_SPECIFIC_SMTP_LIST to
MODEST_CONF_CONNECTION_SPECIFIC_SMTP_LIST and make it a global list
for use by all accounts that enable the MODEST_ACCOUNT_USE_CONNECTION_SPECIFIC_SMTP
boolean, because this is the specified behaviour in the UI spec.
* src/modest-account-mgr-helpers.h:
* src/modest-account-mgr-helpers.c:
(modest_account_mgr_set_connection_specific_smtp),
(modest_account_mgr_remove_connection_specific_smtp),
(modest_account_mgr_get_connection_specific_smtp): Remove the account_name
parameter.
* src/maemo/modest-connection-specific-smtp-window.h:
* src/maemo/modest-connection-specific-smtp-window.c:
(modest_connection_specific_smtp_window_finalize),
(modest_connection_specific_smtp_window_fill_with_connections),
(modest_connection_specific_smtp_window_save_server_accounts):
Remove the account_name parameters and member variable.
* src/maemo/easysetup/modest-easysetup-wizard.c:
(on_button_outgoing_smtp_servers), (create_account):
* src/maemo/modest-account-settings-dialog.c:
(on_button_outgoing_smtp_servers), (check_data),
(modest_account_settings_dialog_set_account_name),
(save_configuration):
* src/maemo/modest-maemo-utils.c: (on_account_online),
(modest_maemo_utils_get_supported_secure_authentication_methods):
* src/modest-tny-account-store.c:
(get_smtp_specific_transport_account_for_open_connection),
(insert_account), (add_connection_specific_transport_accounts):
* src/modest-ui-actions.c: (on_smtp_servers_window_hide),
(modest_ui_actions_on_smtp_servers):
 Adapt to the changed API.

pmo-trunk-r3176

ChangeLog2
src/maemo/easysetup/modest-easysetup-wizard.c
src/maemo/modest-account-settings-dialog.c
src/maemo/modest-connection-specific-smtp-window.c
src/maemo/modest-connection-specific-smtp-window.h
src/maemo/modest-maemo-utils.c
src/modest-account-mgr-helpers.c
src/modest-account-mgr-helpers.h
src/modest-defs.h
src/modest-tny-account-store.c
src/modest-ui-actions.c

index b1272c9..304cab9 100644 (file)
@@ -1,3 +1,36 @@
+2007-08-31  Murray Cumming  <murrayc@murrayc.com>
+
+       * src/modest-defs.h: Rename MODEST_CONF_CONNECTION_SPECIFIC_SMTP_LIST to 
+       MODEST_CONF_CONNECTION_SPECIFIC_SMTP_LIST and make it a global list 
+       for use by all accounts that enable the MODEST_ACCOUNT_USE_CONNECTION_SPECIFIC_SMTP
+       boolean, because this is the specified behaviour in the UI spec.
+       * src/modest-account-mgr-helpers.h:
+       * src/modest-account-mgr-helpers.c:
+       (modest_account_mgr_set_connection_specific_smtp),
+       (modest_account_mgr_remove_connection_specific_smtp),
+       (modest_account_mgr_get_connection_specific_smtp): Remove the account_name 
+       parameter.
+       * src/maemo/modest-connection-specific-smtp-window.h:
+       * src/maemo/modest-connection-specific-smtp-window.c:
+       (modest_connection_specific_smtp_window_finalize),
+       (modest_connection_specific_smtp_window_fill_with_connections),
+       (modest_connection_specific_smtp_window_save_server_accounts):
+       Remove the account_name parameters and member variable.
+       * src/maemo/easysetup/modest-easysetup-wizard.c:
+       (on_button_outgoing_smtp_servers), (create_account):
+       * src/maemo/modest-account-settings-dialog.c:
+       (on_button_outgoing_smtp_servers), (check_data),
+       (modest_account_settings_dialog_set_account_name),
+       (save_configuration):
+       * src/maemo/modest-maemo-utils.c: (on_account_online),
+       (modest_maemo_utils_get_supported_secure_authentication_methods):
+       * src/modest-tny-account-store.c:
+       (get_smtp_specific_transport_account_for_open_connection),
+       (insert_account), (add_connection_specific_transport_accounts):
+       * src/modest-ui-actions.c: (on_smtp_servers_window_hide),
+       (modest_ui_actions_on_smtp_servers):
+        Adapt to the changed API.
+
 2007-08-29  Armin Burgmeier  <armin@openismus.com>
 
        * src/modest-protocol-info.h:
index 471ae4c..97015fb 100644 (file)
@@ -859,8 +859,7 @@ on_button_outgoing_smtp_servers (GtkButton *button, gpointer user_data)
        if (!(self->specific_window)) {
                self->specific_window = GTK_WIDGET (modest_connection_specific_smtp_window_new ());
                modest_connection_specific_smtp_window_fill_with_connections (
-                       MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (self->specific_window), self->account_manager, 
-                       NULL /* account_name, not known yet. */);
+                       MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (self->specific_window), self->account_manager);
        }
 
        /* Show the window: */
@@ -1838,12 +1837,12 @@ create_account (ModestEasysetupWizardDialog *self, gboolean enabled)
                MODEST_ACCOUNT_RETRIEVE, retrieve, FALSE /* not server account */);
 
        /* Save the connection-specific SMTP server accounts. */
-        modest_account_mgr_set_use_connection_specific_smtp(self->account_manager, account_name,
+        modest_account_mgr_set_use_connection_specific_smtp(self->account_manager, account_name, 
                 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self->checkbox_outgoing_smtp_specific)));
        gboolean result = TRUE;
        if (self->specific_window)
                result = modest_connection_specific_smtp_window_save_server_accounts (
-                       MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (self->specific_window), account_name);
+                       MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (self->specific_window));
                        
        g_free (self->saved_account_name);
        self->saved_account_name = g_strdup (account_name);
index f2e01a3..3d9ee26 100644 (file)
@@ -697,8 +697,7 @@ on_button_outgoing_smtp_servers (GtkButton *button, gpointer user_data)
        if (!(self->specific_window)) {
                self->specific_window = GTK_WIDGET (modest_connection_specific_smtp_window_new ());
                modest_connection_specific_smtp_window_fill_with_connections (
-                       MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (self->specific_window), self->account_manager, 
-                       self->account_name);
+                       MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (self->specific_window), self->account_manager);
        }
 
        /* Show the window: */  
@@ -1028,12 +1027,14 @@ check_data (ModestAccountSettingsDialog *self)
                        HILDON_NUMBER_EDITOR (self->entry_incoming_port));
        const gchar* username = gtk_entry_get_text (GTK_ENTRY (self->entry_user_username));
 
+       /*
        const ModestConnectionProtocol protocol_security_incoming = modest_serversecurity_combo_box_get_active_serversecurity (
                MODEST_SERVERSECURITY_COMBO_BOX (self->combo_incoming_security));
-
+       */
        /* If we use an encrypted protocol then there is no need to encrypt the password */
-       /* I don't think this is a good assumption. It overrides the user's request. murrayc: */
-       if (!modest_protocol_info_is_secure(protocol_security_incoming))
+       /* I don't think this is a good assumption. It overrides the user's request. murrayc: 
+        *  if (!modest_protocol_info_is_secure(protocol_security_incoming)) */
+       if (TRUE)
        {
                if (gtk_toggle_button_get_active (
                                GTK_TOGGLE_BUTTON (self->checkbox_incoming_auth))) {
@@ -1382,8 +1383,7 @@ void modest_account_settings_dialog_set_account_name (ModestAccountSettingsDialo
                
                const gboolean has_specific = 
                        modest_account_mgr_get_use_connection_specific_smtp (
-                               dialog->account_manager, 
-                               account_name);
+                               dialog->account_manager, account_name);
                gtk_toggle_button_set_active (
                        GTK_TOGGLE_BUTTON (dialog->checkbox_outgoing_smtp_specific), 
                        has_specific);
@@ -1573,11 +1573,11 @@ save_configuration (ModestAccountSettingsDialog *dialog)
        account_title = NULL;
        
        /* Save connection-specific SMTP server accounts: */
-        modest_account_mgr_set_use_connection_specific_smtp(dialog->account_manager, account_name,
-               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbox_outgoing_smtp_specific)));
+       modest_account_mgr_set_use_connection_specific_smtp(dialog->account_manager, account_name,
+               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbox_outgoing_smtp_specific)));
        if (dialog->specific_window) {
                return modest_connection_specific_smtp_window_save_server_accounts (
-                       MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (dialog->specific_window), account_name);
+                       MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (dialog->specific_window));
        }
        else
                return TRUE;
index be4ad5c..b6d276e 100644 (file)
@@ -63,7 +63,6 @@ struct _ModestConnectionSpecificSmtpWindowPrivate
        GtkWidget *button_edit;
        
        ModestAccountMgr *account_manager;
-       gchar* account_name;
 };
 
 static void
@@ -127,7 +126,6 @@ modest_connection_specific_smtp_window_finalize (GObject *object)
        }
        
        g_object_unref (G_OBJECT (priv->model));
-       g_free (priv->account_name);
        
        G_OBJECT_CLASS (modest_connection_specific_smtp_window_parent_class)->finalize (object);
 }
@@ -151,13 +149,11 @@ modest_connection_specific_smtp_window_class_init (ModestConnectionSpecificSmtpW
 /* #define DEBUG_WITHOUT_LIBCONIC 1 */
 
 void
-modest_connection_specific_smtp_window_fill_with_connections (ModestConnectionSpecificSmtpWindow *self, ModestAccountMgr *account_manager,
-       const gchar* account_name)
+modest_connection_specific_smtp_window_fill_with_connections (ModestConnectionSpecificSmtpWindow *self, ModestAccountMgr *account_manager)
 {
        ModestConnectionSpecificSmtpWindowPrivate *priv = 
                CONNECTION_SPECIFIC_SMTP_WINDOW_GET_PRIVATE (self);
        priv->account_manager = account_manager;
-       priv->account_name = account_name ? g_strdup (account_name) : NULL;
        
        GtkListStore *liststore = GTK_LIST_STORE (priv->model);
        
@@ -179,27 +175,26 @@ modest_connection_specific_smtp_window_fill_with_connections (ModestConnectionSp
                ConIcIap *iap = (ConIcIap*)iter->data;
                if (iap) {
                        #ifdef DEBUG_WITHOUT_LIBCONIC
-                       const gchar *name = "debug name";
-                       const gchar *id = "debug id";
+                       const gchar *connection_name = "debug name";
+                       const gchar *connection_id = "debug id";
                        #else
-                       const gchar *name = con_ic_iap_get_name (iap);
-                       const gchar *id = con_ic_iap_get_id (iap);
+                       const gchar *connection_name = con_ic_iap_get_name (iap);
+                       const gchar *connection_id = con_ic_iap_get_id (iap);
                        #endif
                        
-                       printf ("debug: iac name=%s, id=%s\n", name, id);
+                       printf ("debug: iac name=%s, id=%s\n", connection_name, connection_id);
                        
                        /* Get any already-associated connection-specific server account: */
                        gchar *server_account_name = NULL;
-                       if (priv->account_name)
-                               server_account_name = modest_account_mgr_get_connection_specific_smtp (
-                                       priv->account_manager, priv->account_name, name);
+                       server_account_name = modest_account_mgr_get_connection_specific_smtp (
+                               priv->account_manager, connection_name);
                                        
                        /* Add the row to the model: */
                        GtkTreeIter iter;
                        gtk_list_store_append (liststore, &iter);
                        gtk_list_store_set(liststore, &iter, 
-                               MODEL_COL_ID, id, 
-                               MODEL_COL_NAME, name,
+                               MODEL_COL_ID, connection_id, 
+                               MODEL_COL_NAME, connection_name,
                                MODEL_COL_SERVER_ACCOUNT_NAME, server_account_name,
                                -1);
                                
@@ -466,11 +461,9 @@ modest_connection_specific_smtp_window_new (void)
 }
 
 /** The application should call this when the user changes should be saved.
- * @account_name: Specify this again in case it was not previously known.
  */
 gboolean
-modest_connection_specific_smtp_window_save_server_accounts (ModestConnectionSpecificSmtpWindow *self, 
-       const gchar* account_name)
+modest_connection_specific_smtp_window_save_server_accounts (ModestConnectionSpecificSmtpWindow *self)
 {
        ModestConnectionSpecificSmtpWindowPrivate *priv = 
                CONNECTION_SPECIFIC_SMTP_WINDOW_GET_PRIVATE (self);
@@ -498,8 +491,7 @@ modest_connection_specific_smtp_window_save_server_accounts (ModestConnectionSpe
                if (id && data) { /* The presence of data suggests that there is something to save. */
                        if (!server_account_name) {
                                /* Add a new server account, building a (non-human-visible) name: */
-                               gchar *name_start = g_strdup_printf("%s_specific_%s", 
-                                       priv->account_name, connection_name);
+                               gchar *name_start = g_strdup_printf("specific_%s", connection_name);
                                server_account_name = modest_account_mgr_get_unused_account_name (
                                        priv->account_manager, name_start, TRUE /* server account. */);
                                g_assert (server_account_name);
@@ -515,8 +507,7 @@ modest_connection_specific_smtp_window_save_server_accounts (ModestConnectionSpe
                                        
                                /* associate the specific server account with this connection for this account: */
                                success = success && modest_account_mgr_set_connection_specific_smtp (
-                                       priv->account_manager, priv->account_name,
-                                        connection_name, server_account_name);
+                                       priv->account_manager, connection_name, server_account_name);
        
                                /* Save the new name in the treemodel, so it can be edited again later: */
                                gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter, 
index f94a93f..1372cc5 100644 (file)
@@ -73,11 +73,10 @@ ModestConnectionSpecificSmtpWindow* modest_connection_specific_smtp_window_new (
 
 void
 modest_connection_specific_smtp_window_fill_with_connections (ModestConnectionSpecificSmtpWindow *self, 
-       ModestAccountMgr *account_manager, const gchar* account_name);
+       ModestAccountMgr *account_manager);
 
 gboolean
-modest_connection_specific_smtp_window_save_server_accounts (ModestConnectionSpecificSmtpWindow *self, 
-       const gchar* account_name);
+modest_connection_specific_smtp_window_save_server_accounts (ModestConnectionSpecificSmtpWindow *self);
 
 G_END_DECLS
 
index 6b83f2b..3f05e5b 100644 (file)
@@ -375,7 +375,31 @@ static void on_secure_auth_cancel(GtkWidget* dialog, int response, gpointer user
        }
 }
 
-GList* modest_maemo_utils_get_supported_secure_authentication_methods (ModestTransportStoreProtocol proto, 
+
+typedef struct
+{
+       GMainLoop* loop;
+} UserData;
+
+static UserData *user_data = NULL;
+
+static void
+on_account_online (TnyCamelAccount *account, GError *err)
+{
+       printf ("DEBUGa1: %s\n", __FUNCTION__);
+       
+       if (err) {
+               printf("DEBUG: %s: error=\n  %s\n", __FUNCTION__, err->message);        
+       }
+       
+       /* Allow the function that requested this callback to continue: */
+       /* TODO: Tinymail should really give us user_data with this callback. */
+       if (user_data && user_data->loop)
+               g_main_loop_quit (user_data->loop);
+}
+
+GList*
+modest_maemo_utils_get_supported_secure_authentication_methods (ModestTransportStoreProtocol proto, 
        const gchar* hostname, gint port, const gchar* username, GtkWindow *parent_window, GError** error)
 {
        g_return_val_if_fail (proto != MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN, NULL);
@@ -422,6 +446,9 @@ GList* modest_maemo_utils_get_supported_secure_authentication_methods (ModestTra
        /* Required for POP, at least */
        tny_account_set_user (tny_account, username);
                               
+       if(port > 0)
+               tny_account_set_port (tny_account, port);
+               
        /* Set the session for the account, so we can use it: */
        ModestTnyAccountStore *account_store = modest_runtime_get_account_store ();
        TnySessionCamel *session = 
@@ -429,10 +456,36 @@ GList* modest_maemo_utils_get_supported_secure_authentication_methods (ModestTra
        g_return_val_if_fail (session, NULL);
        tny_camel_account_set_session (TNY_CAMEL_ACCOUNT(tny_account), session);
        
-       if(port > 0)
-               tny_account_set_port (tny_account, port);
-               
-
+       
+       /* This blocks on the result: */
+       /* TODO: Fix tinymail to take user_data for the callback instead of using one static instance: */
+       if (user_data)  {
+               g_slice_free (UserData, user_data);
+               user_data = NULL;
+       }
+       
+       user_data = g_slice_new0 (UserData);
+       user_data->loop = g_main_loop_new (NULL, FALSE /* not running */);
+
+       /* We get a warning if we don't do use tny_camel_account_set_online():
+        * GLIB CRITICAL ** camel-lite - camel_service_query_auth_types: assertion `service != NULL' failed.
+        */
+       tny_camel_account_set_online (TNY_CAMEL_ACCOUNT (tny_account), TRUE, &on_account_online);
+       printf ("DEBUGa2: %s\n", __FUNCTION__);
+       
+       /* This main loop will run until the idle handler has stopped it: */
+       printf ("DEBUG: %s: before g_main_loop_run()\n", __FUNCTION__);
+       GDK_THREADS_LEAVE();
+       g_main_loop_run (user_data->loop);
+       GDK_THREADS_ENTER();
+       printf ("DEBUG: %s: after g_main_loop_run()\n", __FUNCTION__);
+       g_main_loop_unref (user_data->loop);
+       /* g_main_context_unref (context); */
+
+       g_slice_free (UserData, user_data);
+       user_data = NULL;
+       
+       
        /* Ask camel to ask the server, asynchronously: */
        ModestGetSupportedAuthInfo *info = g_slice_new (ModestGetSupportedAuthInfo);
        info->result = NULL;
index 73362c4..2c3c868 100644 (file)
@@ -98,28 +98,40 @@ ModestTransportStoreProtocol modest_account_mgr_get_store_protocol (ModestAccoun
 }
 
 gboolean modest_account_mgr_set_connection_specific_smtp (ModestAccountMgr *self, 
-       const gchar* account_name,
        const gchar* connection_name, const gchar* server_account_name)
 {
-       modest_account_mgr_remove_connection_specific_smtp (self, account_name, connection_name);
+       modest_account_mgr_remove_connection_specific_smtp (self, connection_name);
        
-       GSList *list = modest_account_mgr_get_list (self, account_name, 
-                                                       MODEST_ACCOUNT_CONNECTION_SPECIFIC_SMTP_LIST,
-                                                   MODEST_CONF_VALUE_STRING, FALSE);
-               
-       /* The server account is in the item after the connection name: */
-       GSList *list_connection = g_slist_append (list, (gpointer)connection_name);
-       list_connection = g_slist_append (list_connection, (gpointer)server_account_name);
-       
-       /* Reset the changed list: */
-       modest_account_mgr_set_list (self, account_name, 
-                                                       MODEST_ACCOUNT_CONNECTION_SPECIFIC_SMTP_LIST, list_connection,
-                                                   MODEST_CONF_VALUE_STRING, FALSE);
+       ModestConf *conf = MODEST_ACCOUNT_MGR_GET_PRIVATE (self)->modest_conf;
+
+       gboolean result = TRUE;
+       GError *err = NULL;
+       GSList *list = modest_conf_get_list (conf, 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);
+               err = NULL;
+               result = FALSE;
+       } else {        
+               /* The server account is in the item after the connection name: */
+               GSList *list_connection = g_slist_append (list, (gpointer)connection_name);
+               list_connection = g_slist_append (list_connection, (gpointer)server_account_name);
+       
+               /* Reset the changed list: */
+               modest_conf_set_list (conf, MODEST_CONF_CONNECTION_SPECIFIC_SMTP_LIST, list_connection,
+                                                   MODEST_CONF_VALUE_STRING, &err);
+               if (err) {
+                       g_printerr ("modest: %s: error setting list: %s.\n", __FUNCTION__, err->message);
+                       g_error_free (err);
+                       result = FALSE;
+               }
+       }
                                
        /* TODO: Should we free the items too, or just the list? */
        g_slist_free (list);
        
-       return TRUE;
+       return result;
 }
 
 /**
@@ -133,11 +145,22 @@ gboolean modest_account_mgr_set_connection_specific_smtp (ModestAccountMgr *self
  * Returns: TRUE if it worked, FALSE otherwise
  */                             
 gboolean modest_account_mgr_remove_connection_specific_smtp (ModestAccountMgr *self, 
-       const gchar* account_name, const gchar* connection_name)
+       const gchar* connection_name)
 {
-       GSList *list = modest_account_mgr_get_list (self, account_name, 
-                                                       MODEST_ACCOUNT_CONNECTION_SPECIFIC_SMTP_LIST,
-                                                   MODEST_CONF_VALUE_STRING, FALSE);
+       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);
+       if (err) {
+               g_printerr ("modest: %s: error getting list: %s.\n", __FUNCTION__, err->message);
+               g_error_free (err);
+               err = NULL;
+               result = FALSE;
+       }
+
        if (!list)
                return FALSE;
                
@@ -150,47 +173,58 @@ gboolean modest_account_mgr_remove_connection_specific_smtp (ModestAccountMgr *s
        }
        
        /* Reset the changed list: */
-       modest_account_mgr_set_list (self, account_name, 
-                                                       MODEST_ACCOUNT_CONNECTION_SPECIFIC_SMTP_LIST, list,
-                                                   MODEST_CONF_VALUE_STRING, FALSE);
+       modest_conf_set_list (priv->modest_conf, MODEST_CONF_CONNECTION_SPECIFIC_SMTP_LIST, list,
+                                                   MODEST_CONF_VALUE_STRING, &err);
+       if (err) {
+               g_printerr ("modest: %s: error setting list: %s.\n", __FUNCTION__, err->message);
+               g_error_free (err);
+               result = FALSE;
+       }
                                
        /* TODO: Should we free the items too, or just the list? */
        g_slist_free (list);
        
-       return TRUE;
+       return result;
 }
 
+
 gboolean modest_account_mgr_get_use_connection_specific_smtp (ModestAccountMgr *self, const gchar* account_name)
 {
-       return modest_account_mgr_get_bool (self, account_name,
-                                            MODEST_ACCOUNT_USE_CONNECTION_SPECIFIC_SMTP, FALSE);
+       return modest_account_mgr_get_bool (self, account_name, 
+               MODEST_ACCOUNT_USE_CONNECTION_SPECIFIC_SMTP, FALSE);
 }
 
-gboolean modest_account_mgr_set_use_connection_specific_smtp (ModestAccountMgr *self, const gchar* account_name,
-                                                              gboolean new_value)
+gboolean modest_account_mgr_set_use_connection_specific_smtp (ModestAccountMgr *self, const gchar* account_name, 
+       gboolean new_value)
 {
-        return modest_account_mgr_set_bool (self, account_name, MODEST_ACCOUNT_USE_CONNECTION_SPECIFIC_SMTP,
-                                            new_value, FALSE);
+       return modest_account_mgr_set_bool (self, account_name, MODEST_ACCOUNT_USE_CONNECTION_SPECIFIC_SMTP, 
+               new_value, FALSE);
 }
 
 /**
  * modest_account_mgr_get_connection_specific_smtp
  * @self: a ModestAccountMgr instance
- * @name: the account name
  * @connection_name: A libconic IAP connection name
  * 
  * 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* account_name,
-                                        const gchar* connection_name)
+gchar* modest_account_mgr_get_connection_specific_smtp (ModestAccountMgr *self,  const gchar* connection_name)
 {
        gchar *result = NULL;
        
-       GSList *list = modest_account_mgr_get_list (self, account_name, 
-                                                       MODEST_ACCOUNT_CONNECTION_SPECIFIC_SMTP_LIST,
-                                                   MODEST_CONF_VALUE_STRING, FALSE);
+       ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
+       
+       GError *err = NULL;
+       GSList *list = modest_conf_get_list (priv->modest_conf, 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);
+               err = NULL;
+       }
+
        if (!list)
                return NULL;
 
index ef57144..1422dd2 100644 (file)
@@ -218,7 +218,6 @@ ModestTransportStoreProtocol modest_account_mgr_get_store_protocol (ModestAccoun
 /**
  * modest_account_mgr_set_connection_specific_smtp
  * @self: a ModestAccountMgr instance
- * @name: the account name
  * @connection_name: A libconic IAP connection name
  * @server_account_name: a server account name to use for this connection.
  * 
@@ -226,21 +225,20 @@ ModestTransportStoreProtocol modest_account_mgr_get_store_protocol (ModestAccoun
  *
  * Returns: TRUE if it worked, FALSE otherwise
  */
-gboolean modest_account_mgr_set_connection_specific_smtp (ModestAccountMgr *self, const gchar* name,
+gboolean modest_account_mgr_set_connection_specific_smtp (ModestAccountMgr *self, 
                                         const gchar* connection_name, const gchar* server_account_name);
 
 /**
  * modest_account_mgr_remove_connection_specific_smtp
  * @self: a ModestAccountMgr instance
- * @name: the account name
  * @connection_name: A libconic IAP connection name
  * 
- * Disassacoiate a server account to use with the specific connection for this account.
+ * Disassociate 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* name,
-                                        const gchar* connection_name);
+gboolean modest_account_mgr_remove_connection_specific_smtp (ModestAccountMgr *self, 
+       const gchar* connection_name);
 
 /**
  * modest_account_mgr_get_use_connection_specific_smtp
@@ -254,23 +252,22 @@ gboolean modest_account_mgr_get_use_connection_specific_smtp (ModestAccountMgr *
  * modest_account_mgr_set_use_connection_specific_smtp
  * @self: a ModestAccountMgr instance
  * @account_name: the account name
- * @new_value: New value that indicates if if this account should use connection-specific smtp server accounts
+ * @new_value: New value that indicates if if this account should use connection-specific smtp server accounts.
  * @result: TRUE if it succeeded, FALSE otherwise
  */
 gboolean modest_account_mgr_set_use_connection_specific_smtp (ModestAccountMgr *self, const gchar* account_name,
-                                                              gboolean new_value);
+       gboolean new_value);
 
 /**
  * modest_account_mgr_get_connection_specific_smtp
  * @self: a ModestAccountMgr instance
- * @name: the account name
  * @connection_name: A libconic IAP connection name
  * 
  * 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* name,
+gchar* modest_account_mgr_get_connection_specific_smtp (ModestAccountMgr *self, 
                                         const gchar* connection_name);
 
 
index b92e781..adf668d 100644 (file)
  * alernating between a connection name, followed by a corresponding server account name.
  * That's not pretty, but it's nicer than dealing with escaping of a = separator if 
  * putting them both in one string. */
-#define MODEST_ACCOUNT_CONNECTION_SPECIFIC_SMTP_LIST "specific_smtp"
+#define MODEST_CONF_CONNECTION_SPECIFIC_SMTP_LIST "/specific_smtp" /* one list used for all accounts. */
 #define MODEST_ACCOUNT_USE_CONNECTION_SPECIFIC_SMTP  "use_specific_smtp" /* boolean */
 
 /* server account keys */
index da34c49..25bd212 100644 (file)
@@ -114,8 +114,7 @@ static void    on_vfs_volume_unmounted     (GnomeVFSVolumeMonitor *volume_monito
 static void    modest_tny_account_store_forget_password_in_memory (ModestTnyAccountStore *self, 
                                                                   const gchar *server_account_name);
 
-static void    add_connection_specific_transport_accounts         (ModestTnyAccountStore *self,
-                                                                  const gchar *account_name);
+static void    add_connection_specific_transport_accounts         (ModestTnyAccountStore *self);
 
 /* list my signals */
 enum {
@@ -1397,7 +1396,7 @@ modest_tny_account_store_get_server_account (ModestTnyAccountStore *self,
 
 static TnyAccount*
 get_smtp_specific_transport_account_for_open_connection (ModestTnyAccountStore *self,
-                                                        const gchar *account_name)
+       const gchar *account_name)
 {
        /* Get the current connection: */
        TnyDevice *device = modest_runtime_get_device ();
@@ -1406,7 +1405,6 @@ get_smtp_specific_transport_account_for_open_connection (ModestTnyAccountStore *
                return NULL;
 
        g_return_val_if_fail (self, NULL);
-       g_return_val_if_fail (account_name, NULL);
        
        
 #ifdef MODEST_PLATFORM_MAEMO
@@ -1429,13 +1427,13 @@ get_smtp_specific_transport_account_for_open_connection (ModestTnyAccountStore *
        /*  Get the connection-specific transport acccount, if any: */
        ModestAccountMgr *account_manager = modest_runtime_get_account_mgr ();
 
-        /* Check if this account has connection-specific SMTP enabled */
-        if (!modest_account_mgr_get_use_connection_specific_smtp (account_manager, account_name)) {
-                return NULL;
-        }
+       /* Check if this account has connection-specific SMTP enabled */
+       if (!modest_account_mgr_get_use_connection_specific_smtp (account_manager, account_name)) {
+               return NULL;
+       }
 
        gchar* server_account_name = modest_account_mgr_get_connection_specific_smtp (account_manager, 
-               account_name, connection_name);
+               connection_name);
 
        /* printf ("DEBUG: %s: server_account_name=%s\n", __FUNCTION__, server_account_name); */
        if (!server_account_name) {
@@ -1613,7 +1611,7 @@ insert_account (ModestTnyAccountStore *self,
                tny_list_append (priv->transport_accounts, G_OBJECT (transport_account));
 
                /* Add connection-specific transport accounts */
-               add_connection_specific_transport_accounts (self, account);
+               add_connection_specific_transport_accounts (self);
 
                /* Create per account local outbox */
                account_outbox = 
@@ -1700,18 +1698,24 @@ on_account_removed (ModestAccountMgr *acc_mgr,
 }
 
 static void
-add_connection_specific_transport_accounts (ModestTnyAccountStore *self,
-                                           const gchar *account_name)
+add_connection_specific_transport_accounts (ModestTnyAccountStore *self)
 {
        ModestTnyAccountStorePrivate *priv = NULL;
        GSList *list_specifics = NULL, *iter = NULL;
 
        priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
 
-       list_specifics = modest_account_mgr_get_list (priv->account_mgr,
-                                                     account_name, 
-                                                     MODEST_ACCOUNT_CONNECTION_SPECIFIC_SMTP_LIST,
-                                                     MODEST_CONF_VALUE_STRING, FALSE);
+       ModestConf *conf = modest_runtime_get_conf ();
+
+       GError *err = NULL;
+       list_specifics = modest_conf_get_list (conf,
+                                                     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);
+               err = NULL;
+       }
                                
        /* Look at each connection-specific transport account for the 
         * modest account: */
@@ -1729,8 +1733,6 @@ add_connection_specific_transport_accounts (ModestTnyAccountStore *self,
                                                                                         priv->session, 
                                                                                         transport_account_name);
                                if (tny_account) {
-                                       modest_tny_account_set_parent_modest_account_name_for_server_account (tny_account, 
-                                                                                                             account_name);
                                        g_object_set_data (G_OBJECT(tny_account), 
                                                           "account_store", 
                                                           (gpointer)self);
index 400233f..f5455dc 100644 (file)
@@ -661,12 +661,9 @@ modest_ui_actions_on_accounts (GtkAction *action, ModestWindow *win)
 static void
 on_smtp_servers_window_hide (GtkWindow* window, gpointer user_data)
 {
-       ModestWindow *main_window = MODEST_WINDOW (user_data);
-       
        /* Save any changes. */
        modest_connection_specific_smtp_window_save_server_accounts (
-                       MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (window), 
-                       modest_window_get_active_account (main_window));
+                       MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (window));
        gtk_widget_destroy (GTK_WIDGET (window));
 }
 
@@ -682,22 +679,10 @@ modest_ui_actions_on_smtp_servers (GtkAction *action, ModestWindow *win)
 #ifdef MODEST_PLATFORM_MAEMO /* Defined in config.h */
        
        /* Create the window if necessary: */
-       const gchar *active_account_name = modest_window_get_active_account (win);
-       
-       /* TODO: Dim the menu item (not in the UI spec)? or show a warning,
-        * or show the default account?
-        * If we show the default account then the account name should be shown in 
-        * the window when we show it. */
-       if (!active_account_name) {
-               g_warning ("%s: No account is active.", __FUNCTION__);
-               return;
-       }
-               
        GtkWidget *specific_window = GTK_WIDGET (modest_connection_specific_smtp_window_new ());
        modest_connection_specific_smtp_window_fill_with_connections (
                MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (specific_window), 
-               modest_runtime_get_account_mgr(), 
-               active_account_name);
+               modest_runtime_get_account_mgr());
 
        /* Show the window: */  
        gtk_window_set_transient_for (GTK_WINDOW (specific_window), GTK_WINDOW (win));