2007-04-18 Murray Cumming <murrayc@murrayc.com>
authorMurray Cumming <murrayc@murrayc.com>
Wed, 18 Apr 2007 18:51:24 +0000 (18:51 +0000)
committerMurray Cumming <murrayc@murrayc.com>
Wed, 18 Apr 2007 18:51:24 +0000 (18:51 +0000)
* src/maemo/modest-connection-specific-smtp-edit-window.c:
        (on_combo_security_changed):
        (modest_connection_specific_smtp_edit_window_init):
        Auto-fill the port number as in the account settings.

        (modest_connection_specific_smtp_edit_window_set_connection):
        * src/maemo/modest-connection-specific-smtp-edit-window.h:
        * src/maemo/modest-connection-specific-smtp-window.c:
        (fill_with_connections), (on_button_edit),
        (modest_connection_specific_smtp_window_init):
        Turn the edit window into a dialog to simplify the code, and
        set a WM hint as in a GtkDialog, because only a popup can be on top of
        another window in Maemo, and popups usually have no WM decoration.

        * src/modest-defs.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):
        * src/modest-account-mgr-helpers.h: Some functions to write the
        connection-specific SMTP server information. Not yet used.

pmo-trunk-r1592

ChangeLog2
src/maemo/easysetup/modest-easysetup-wizard.c
src/maemo/modest-account-settings-dialog.c
src/maemo/modest-connection-specific-smtp-edit-window.c
src/maemo/modest-connection-specific-smtp-edit-window.h
src/maemo/modest-connection-specific-smtp-window.c
src/modest-account-mgr-helpers.c
src/modest-account-mgr-helpers.h
src/modest-defs.h
src/widgets/modest-folder-view.c

index 89b9469..1c9556a 100644 (file)
@@ -1,5 +1,35 @@
 2007-04-18  Murray Cumming  <murrayc@murrayc.com>
 
+       * src/maemo/modest-connection-specific-smtp-edit-window.c:
+       (on_combo_security_changed): 
+       (modest_connection_specific_smtp_edit_window_init):
+       Auto-fill the port number as in the account settings.
+       
+       (modest_connection_specific_smtp_edit_window_set_connection):
+       * src/maemo/modest-connection-specific-smtp-edit-window.h:
+       * src/maemo/modest-connection-specific-smtp-window.c:
+       (fill_with_connections), (on_button_edit),
+       (modest_connection_specific_smtp_window_init): 
+       Turn the edit window into a dialog to simplify the code, and 
+       set a WM hint as in a GtkDialog, because only a popup can be on top of 
+       another window in Maemo, and popups usually have no WM decoration.
+       
+       * src/modest-defs.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):
+       * src/modest-account-mgr-helpers.h: Some functions to write the 
+       connection-specific SMTP server information. Not yet used.
+
+       
+       * src/widgets/modest-folder-view.c: (text_cell_data):
+       Fix a warning about an uninitialized variable.
+       (on_configuration_key_changed): Put an #ifdef around the use 
+       of gtk_tree_view_column_queue_resize() because it is new in GTK+ 2.10.
+
+2007-04-18  Murray Cumming  <murrayc@murrayc.com>
+
        * src/maemo/modest-account-settings-dialog.h:
        * src/maemo/modest-account-settings-dialog.c:
        Added connect_for_modified() utility function to mark the new modified boolean.
index 0039ffd..ea40c2f 100644 (file)
@@ -589,7 +589,6 @@ on_smtp_servers_window_hide (GtkWindow *window, gpointer user_data)
 static void
 on_button_outgoing_smtp_servers (GtkButton *button, gpointer user_data)
 {
-
        ModestEasysetupWizardDialog * self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
        
        /* Show the window: */
@@ -598,7 +597,7 @@ on_button_outgoing_smtp_servers (GtkButton *button, gpointer user_data)
         */
        GtkWidget *window = GTK_WIDGET (modest_connection_specific_smtp_window_new ());
 
-       gtk_window_set_transient_for (GTK_WINDOW (self), GTK_WINDOW (window));
+       gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (self));
        g_signal_connect (G_OBJECT (window), "hide",
                G_CALLBACK (on_smtp_servers_window_hide), self);
        gtk_widget_show (window);
index 9223814..ce3dd19 100644 (file)
@@ -510,7 +510,6 @@ on_smtp_servers_window_hide (GtkWindow *window, gpointer user_data)
 static void
 on_button_outgoing_smtp_servers (GtkButton *button, gpointer user_data)
 {
-
        ModestAccountSettingsDialog * self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data);
        
        /* Show the window: */
@@ -518,10 +517,12 @@ on_button_outgoing_smtp_servers (GtkButton *button, gpointer user_data)
         * so we can supply them when creating the connection somehow.
         */
        GtkWidget *window = GTK_WIDGET (modest_connection_specific_smtp_window_new ());
-       gtk_window_set_transient_for (GTK_WINDOW (self), GTK_WINDOW (window));
-       g_signal_connect (G_OBJECT (window), "hide",
-               G_CALLBACK (on_smtp_servers_window_hide), self);
+       gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (self));
+       gtk_window_set_modal (GTK_WINDOW (window), TRUE);
     gtk_widget_show (window);
+    
+    g_signal_connect (G_OBJECT (window), "hide",
+        G_CALLBACK (on_smtp_servers_window_hide), self);
 }
 
 static void
index 65266d4..93f430b 100644 (file)
@@ -15,7 +15,7 @@
 
 #include <glib/gi18n.h>
 
-G_DEFINE_TYPE (ModestConnectionSpecificSmtpEditWindow, modest_connection_specific_smtp_edit_window, GTK_TYPE_WINDOW);
+G_DEFINE_TYPE (ModestConnectionSpecificSmtpEditWindow, modest_connection_specific_smtp_edit_window, GTK_TYPE_DIALOG);
 
 #define CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE(o) \
        (G_TYPE_INSTANCE_GET_PRIVATE ((o), MODEST_TYPE_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW, ModestConnectionSpecificSmtpEditWindowPrivate))
@@ -88,19 +88,22 @@ enum MODEL_COLS {
 };
 
 static void
-on_button_edit (GtkButton *button, gpointer user_data)
+on_combo_security_changed (GtkComboBox *widget, gpointer user_data)
 {
+       ModestConnectionSpecificSmtpEditWindow *self = 
+               MODEST_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW (user_data);
+       ModestConnectionSpecificSmtpEditWindowPrivate *priv = CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (self);
        
-}
-
-static void
-on_button_cancel (GtkButton *button, gpointer user_data)
-{
-       ModestConnectionSpecificSmtpEditWindow *self = MODEST_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW (user_data);
-
-       /* Hide the window.
-        * The code that showed it will respond to the hide signal. */  
-       gtk_widget_hide (GTK_WIDGET (self));
+       
+       const gint port_number = 
+               easysetup_serversecurity_combo_box_get_active_serversecurity_port (
+                       EASYSETUP_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security));
+
+       if(port_number != 0) {
+               gchar* str = g_strdup_printf ("%d", port_number);
+               gtk_entry_set_text (GTK_ENTRY (priv->entry_port), str);
+               g_free (str);   
+       }               
 }
 
 static void
@@ -108,7 +111,7 @@ modest_connection_specific_smtp_edit_window_init (ModestConnectionSpecificSmtpEd
 {
        ModestConnectionSpecificSmtpEditWindowPrivate *priv = CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (self);
        
-       GtkWidget *box = gtk_vbox_new (FALSE, 2);
+       GtkWidget *box = GTK_DIALOG(self)->vbox; /* gtk_vbox_new (FALSE, 2); */
        
        /* Create a size group to be used by all captions.
         * Note that HildonCaption does not create a default size group if we do not specify one.
@@ -124,6 +127,10 @@ modest_connection_specific_smtp_edit_window_init (ModestConnectionSpecificSmtpEd
        gtk_box_pack_start (GTK_BOX (box), caption, FALSE, FALSE, 2);
        gtk_widget_show (caption);
        
+       /* Show a default port number when the security method changes, as per the UI spec: */
+       g_signal_connect (G_OBJECT (priv->combo_outgoing_security), "changed", (GCallback)on_combo_security_changed, self);
+       
+       
        /* The secure authentication widgets: */
        if (!priv->combo_outgoing_auth)
                priv->combo_outgoing_auth = GTK_WIDGET (easysetup_secureauth_combo_box_new ());
@@ -183,21 +190,9 @@ modest_connection_specific_smtp_edit_window_init (ModestConnectionSpecificSmtpEd
        gtk_widget_show (caption);
        
        /* Add the buttons: */
-       GtkWidget *hbox = gtk_hbox_new (FALSE, 2);
-       gtk_box_pack_start (GTK_BOX (box), hbox, TRUE, TRUE, 2);
-       gtk_widget_show (hbox);
-       
-       GtkWidget *button_edit = gtk_button_new_from_stock (GTK_STOCK_EDIT);
-       gtk_box_pack_start (GTK_BOX (hbox), button_edit, TRUE, FALSE, 2);
-       gtk_widget_show (button_edit);
-       g_signal_connect (G_OBJECT (button_edit), "clicked",
-               G_CALLBACK (on_button_edit), self);
-       
-       GtkWidget *button_cancel = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
-       gtk_box_pack_start (GTK_BOX (hbox), button_cancel, TRUE, FALSE, 2);
-       gtk_widget_show (button_cancel);
-       g_signal_connect (G_OBJECT (button_edit), "clicked",
-               G_CALLBACK (on_button_cancel), self);
+       gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_OK, GTK_RESPONSE_OK);
+       gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+       
        
        gtk_widget_show (box);
 }
@@ -208,3 +203,14 @@ modest_connection_specific_smtp_edit_window_new (void)
        return g_object_new (MODEST_TYPE_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW, NULL);
 }
 
+void
+modest_connection_specific_smtp_edit_window_set_connection (
+       ModestConnectionSpecificSmtpEditWindow *window, const gchar* iap_id, const gchar* iap_name)
+{
+       /* This causes a warning because of the %s in the translation, but not in the original string: */
+       gchar* title = g_strdup_printf (_("mcen_ti_connection_connection_name"), iap_name);
+       
+       gtk_window_set_title (GTK_WINDOW (window), title);
+       g_free (title);
+}
+
index 1018ed2..4a115e0 100644 (file)
@@ -30,7 +30,7 @@
 #ifndef __MODEST_MAEMO_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW
 #define __MODEST_MAEMO_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW
 
-#include <gtk/gtkwindow.h>
+#include <gtk/gtkdialog.h>
 #include <gtk/gtktreeview.h>
 
 G_BEGIN_DECLS
@@ -58,18 +58,21 @@ G_BEGIN_DECLS
        MODEST_TYPE_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW, ModestConnectionSpecificSmtpEditWindowClass))
 
 typedef struct {
-       GtkWindow parent;
+       GtkDialog parent;
        
 } ModestConnectionSpecificSmtpEditWindow;
 
 typedef struct {
-       GtkWindowClass parent_class;
+       GtkDialogClass parent_class;
 } ModestConnectionSpecificSmtpEditWindowClass;
 
 GType modest_connection_specific_smtp_edit_window_get_type (void);
 
 ModestConnectionSpecificSmtpEditWindow* modest_connection_specific_smtp_edit_window_new (void);
 
+void modest_connection_specific_smtp_edit_window_set_connection (
+       ModestConnectionSpecificSmtpEditWindow *window, const gchar* iap_id, const gchar* iap_name);
+       
 G_END_DECLS
 
 #endif /* __MODEST_MAEMO_CONNECTION_SPECIFIC_SMTP_WINDOW */
index d53402c..e1fd609 100644 (file)
@@ -2,6 +2,10 @@
 
 #include "modest-connection-specific-smtp-window.h"
 #include "modest-connection-specific-smtp-edit-window.h"
+
+#include <modest-runtime.h>
+#include <tny-maemo-conic-device.h>
+
 #include <gtk/gtktreeview.h>
 #include <gtk/gtkcellrenderertext.h>
 #include <gtk/gtkliststore.h>
@@ -77,24 +81,47 @@ modest_connection_specific_smtp_window_class_init (ModestConnectionSpecificSmtpW
 }
 
 enum MODEL_COLS {
-       MODEL_COL_NAME = 0,
-       MODEL_COL_SERVER_NAME = 1,
-       MODEL_COL_ID = 2
+       MODEL_COL_NAME = 0, /* libconic IAP Name: a string */
+       MODEL_COL_SERVER_NAME = 1, /* a string */
+       MODEL_COL_ID = 2 /* libconic IAP ID: a string */
 };
 
 static void
 fill_with_connections (ModestConnectionSpecificSmtpWindow *self)
 {
-       /* TODO: 
-       * When TnyMaemoDevice provides enough of the libconic API to implement this. */
-}
-
+       printf("debug: fill_with_connections()\n");
+       ModestConnectionSpecificSmtpWindowPrivate *priv = 
+               CONNECTION_SPECIFIC_SMTP_WINDOW_GET_PRIVATE (self);
+       GtkListStore *liststore = GTK_LIST_STORE (priv->model);
        
-static void
-on_edit_window_hide (GtkWindow *window, gpointer user_data)
-{
-       /* Destroy the window when it is closed: */
-       gtk_widget_destroy (GTK_WIDGET (window));
+       TnyDevice *device = modest_runtime_get_device ();
+       g_assert (TNY_IS_MAEMO_CONIC_DEVICE (device));
+       
+       TnyMaemoConicDevice *maemo_device = TNY_MAEMO_CONIC_DEVICE (device);
+       
+       /* Get the list of Internet Access Points: */
+       GSList* list_iaps = tny_maemo_conic_device_get_iap_list (maemo_device);
+       printf("debug: list_iaps=%p, list_iaps size = %d\n", list_iaps, g_slist_length(list_iaps));
+       
+       GSList* iter = list_iaps;
+       while (iter) {
+               ConIcIap *iap = (ConIcIap*)iter->data;
+               if (iap) {
+                       const gchar *name = con_ic_iap_get_name (iap);
+                       const gchar *id = con_ic_iap_get_id (iap);
+                       printf ("debug: iac name=%s, id=%s\n", name, id);
+                       
+                       /* 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, -1);
+               }
+               
+               iter = g_slist_next (iter);     
+       }
+               
+       if (list_iaps)
+               tny_maemo_conic_device_free_iap_list (maemo_device, list_iaps);
 }
 
        
@@ -102,13 +129,33 @@ static void
 on_button_edit (GtkButton *button, gpointer user_data)
 {
        ModestConnectionSpecificSmtpWindow *self = MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (user_data);
+       ModestConnectionSpecificSmtpWindowPrivate *priv = CONNECTION_SPECIFIC_SMTP_WINDOW_GET_PRIVATE (self);
        
-       /* TODO: Specify the chosen connection to edit: */
-       GtkWidget * window = GTK_WIDGET (modest_connection_specific_smtp_edit_window_new ());
-       gtk_window_set_transient_for (GTK_WINDOW (self), GTK_WINDOW (window));
-       g_signal_connect (G_OBJECT (window), "hide",
-               G_CALLBACK (on_edit_window_hide), self);
-       gtk_widget_show (window);
+       gchar *id = NULL;
+       gchar *name = NULL;
+       GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (self));
+       GtkTreeIter iter;
+       GtkTreeModel *model = 0;
+       if (gtk_tree_selection_get_selected (sel, &model, &iter)) {
+               gtk_tree_model_get (priv->model, &iter, 
+                                   MODEL_COL_ID, &id, 
+                                   MODEL_COL_NAME, &name, 
+                                   -1);
+       
+               /* TODO: Is 0 an allowed libconic IAP ID? 
+                * If not then we should check for it. */
+               
+               GtkWidget * window = GTK_WIDGET (modest_connection_specific_smtp_edit_window_new ());
+               modest_connection_specific_smtp_edit_window_set_connection (
+                       MODEST_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW (window), id, name);
+                       
+               gtk_window_set_transient_for (GTK_WINDOW (self), GTK_WINDOW (window));
+               gint response = gtk_dialog_run (GTK_DIALOG (window));
+               gtk_widget_hide (window);
+               if (response == GTK_RESPONSE_OK) {
+
+               }               
+       }
 }
 
 static void
@@ -124,13 +171,19 @@ on_button_cancel (GtkButton *button, gpointer user_data)
 static void
 modest_connection_specific_smtp_window_init (ModestConnectionSpecificSmtpWindow *self)
 {
+       /* This seems to be necessary to make the window show at the front with decoration.
+        * If we use property type=GTK_WINDOW_TOPLEVEL instead of the default GTK_WINDOW_POPUP+decoration, 
+        * then the window will be below the others. */
+       gtk_window_set_type_hint (GTK_WINDOW (self),
+                           GDK_WINDOW_TYPE_HINT_DIALOG);
+                           
        ModestConnectionSpecificSmtpWindowPrivate *priv = CONNECTION_SPECIFIC_SMTP_WINDOW_GET_PRIVATE (self);
 
        /* Create a tree model for the tree view:
         * with a string for the name, a string for the server name, and an int for the ID.
         * This must match our MODEL_COLS enum constants.
         */
-       priv->model = GTK_TREE_MODEL (gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT));
+       priv->model = GTK_TREE_MODEL (gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING));
 
        /* Setup the tree view: */
        priv->treeview = GTK_TREE_VIEW (gtk_tree_view_new_with_model (priv->model));
@@ -169,7 +222,7 @@ modest_connection_specific_smtp_window_init (ModestConnectionSpecificSmtpWindow
        
        /* Add the buttons: */
        GtkWidget *hbox = gtk_hbox_new (FALSE, 2);
-       gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 2);
+       gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 2);
        gtk_widget_show (hbox);
        
        GtkWidget *button_edit = gtk_button_new_from_stock (GTK_STOCK_EDIT);
@@ -181,9 +234,10 @@ modest_connection_specific_smtp_window_init (ModestConnectionSpecificSmtpWindow
        GtkWidget *button_cancel = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
        gtk_box_pack_start (GTK_BOX (hbox), button_cancel, TRUE, FALSE, 2);
        gtk_widget_show (button_cancel);
-       g_signal_connect (G_OBJECT (button_edit), "clicked",
+       g_signal_connect (G_OBJECT (button_cancel), "clicked",
                G_CALLBACK (on_button_cancel), self);
        
+       gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (vbox));
        gtk_widget_show (vbox);
 }
 
index 16b9506..2d38cb0 100644 (file)
@@ -121,6 +121,107 @@ modest_server_account_data_get_option_bool (GSList* options_list, const gchar* o
 }
 #endif
 
+
+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);
+       
+       GSList *list = modest_account_mgr_get_list (self, account_name, 
+                                                       MODEST_ACCOUNT_CONNECTION_SPECIFIC_SMTP_LIST,
+                                                   MODEST_CONF_VALUE_STRING, TRUE);
+               
+       /* The server account is in the item after the connection name: */
+       GSList *list_connection = g_slist_append (list, (gpointer)connection_name);
+       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,
+                                                   MODEST_CONF_VALUE_STRING, TRUE);
+                               
+       /* TODO: Should we free the items too, or just the list? */
+       g_slist_free (list);
+       
+       return TRUE;
+}
+
+/**
+ * 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.
+ *
+ * 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)
+{
+       GSList *list = modest_account_mgr_get_list (self, account_name, 
+                                                       MODEST_ACCOUNT_CONNECTION_SPECIFIC_SMTP_LIST,
+                                                   MODEST_CONF_VALUE_STRING, TRUE);
+       if (!list)
+               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);
+       if (list_connection) {
+               /* remove both items: */
+               GSList *temp = g_slist_delete_link(list_connection, list_connection);
+               g_slist_delete_link(temp, g_slist_next(temp));
+       }
+       
+       /* Reset the changed list: */
+       modest_account_mgr_set_list (self, account_name, 
+                                                       MODEST_ACCOUNT_CONNECTION_SPECIFIC_SMTP_LIST, list,
+                                                   MODEST_CONF_VALUE_STRING, TRUE);
+                               
+       /* TODO: Should we free the items too, or just the list? */
+       g_slist_free (list);
+       
+       return TRUE;
+}
+
+/**
+ * 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 *result = NULL;
+       
+       GSList *list = modest_account_mgr_get_list (self, account_name, 
+                                                       MODEST_ACCOUNT_CONNECTION_SPECIFIC_SMTP_LIST,
+                                                   MODEST_CONF_VALUE_STRING, TRUE);
+       if (!list)
+               return NULL;
+               
+       /* The server account is in the item after the connection name: */
+       GSList *list_connection = g_slist_find_custom (list, connection_name, (GCompareFunc)strcmp);
+       if (list_connection) {
+               GSList * list_server_account = g_slist_next(list_connection);
+               if (list_server_account)
+                       result = g_strdup ((gchar*)(list_server_account->data));
+       }
+                               
+       /* TODO: Should we free the items too, or just the list? */
+       g_slist_free (list);
+       
+       return result;
+}
+                                        
+                                        
+
 static ModestProtocol
 get_secure_auth_for_conf_string(const gchar* value)
 {
index 7bc86d4..cbf1062 100644 (file)
@@ -140,6 +140,46 @@ gboolean modest_account_mgr_set_enabled (ModestAccountMgr *self, const gchar* na
 gboolean modest_account_mgr_get_enabled (ModestAccountMgr *self, const gchar* name);
 
 /**
+ * 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.
+ * 
+ * Specify a server account to use with the specific connection for this account.
+ *
+ * Returns: TRUE if it worked, FALSE otherwise
+ */
+gboolean modest_account_mgr_set_connection_specific_smtp (ModestAccountMgr *self, const gchar* name,
+                                        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.
+ *
+ * Returns: TRUE if it worked, FALSE otherwise
+ */                             
+gboolean modest_account_mgr_remove_connection_specific_smtp (ModestAccountMgr *self, const gchar* name,
+                                        const gchar* connection_name);
+
+/**
+ * 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,
+                                        const gchar* connection_name);
+                                        
+/**
  * modest_server_account_get_secure_auth:
  * @self: a ModestAccountMgr instance
  * @account_name: The name of a server account.
@@ -185,7 +225,7 @@ modest_server_account_get_security (ModestAccountMgr *self, const gchar* account
 void
 modest_server_account_set_security (ModestAccountMgr *self, const gchar* account_name, 
        ModestProtocol security);
-
+       
 #if 0
 /**
  * modest_account_mgr_get_account_option:
index 782170c..67df45e 100644 (file)
 #define MODEST_ACCOUNT_FULLNAME                 "fullname"
 #define MODEST_ACCOUNT_EMAIL             "email"
 
+/* This is a list of strings, with each strings, 
+ * 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"
+
 /* server account keys */
 #define MODEST_ACCOUNT_PASSWORD          "password"          /* string */
 #define MODEST_ACCOUNT_REMEMBER_PWD     "remember_pwd"      /* boolean */
index 9816cb0..3b3ec91 100644 (file)
@@ -255,7 +255,8 @@ text_cell_data  (GtkTreeViewColumn *column,  GtkCellRenderer *renderer,
 
        } else {
                ModestFolderViewPrivate *priv;
-               const gchar *account_name, *account_id;
+               const gchar *account_name = NULL;
+               const gchar *account_id = NULL;
        
                priv =  MODEST_FOLDER_VIEW_GET_PRIVATE (data);
 
@@ -1267,7 +1268,6 @@ on_configuration_key_changed (ModestConf* conf,
                              ModestFolderView *self)
 {
        ModestFolderViewPrivate *priv;
-       GtkTreeViewColumn *tree_column;
 
        if (!key || strcmp (key, MODEST_CONF_DEVICE_NAME))
                return;
@@ -1283,7 +1283,9 @@ on_configuration_key_changed (ModestConf* conf,
                                                                   MODEST_CONF_DEVICE_NAME, NULL);
 
        /* Force a redraw */
-       tree_column = gtk_tree_view_get_column (GTK_TREE_VIEW (self), 
+#if GTK_CHECK_VERSION(2, 8, 0) /* gtk_tree_view_column_queue_resize is only available in GTK+ 2.8 */
+       GtkTreeViewColumn * tree_column = gtk_tree_view_get_column (GTK_TREE_VIEW (self), 
                                                TNY_GTK_FOLDER_STORE_TREE_MODEL_NAME_COLUMN);
        gtk_tree_view_column_queue_resize (tree_column);
+#endif
 }