* Added new server security picker for hildon2, and replaced
authorJose Dapena Paz <jdapena@igalia.com>
Wed, 1 Oct 2008 15:14:33 +0000 (15:14 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Wed, 1 Oct 2008 15:14:33 +0000 (15:14 +0000)
  usage of the old combobox in security options view and
  smtp connection specific edit window.

pmo-trunk-r5848

src/hildon2/Makefile.am
src/hildon2/modest-connection-specific-smtp-edit-window.c
src/hildon2/modest-default-account-settings-dialog.c
src/hildon2/modest-maemo-security-options-view.c
src/hildon2/modest-serversecurity-picker.c [new file with mode: 0644]
src/hildon2/modest-serversecurity-picker.h [new file with mode: 0644]
src/hildon2/modest-signature-editor-dialog.c
src/widgets/modest-security-options-view.c

index ed55eb6..ab6a698 100644 (file)
@@ -55,6 +55,7 @@ libmodest_ui_la_SOURCES=              \
        modest-easysetup-wizard-dialog.h modest-easysetup-wizard-dialog.c \
        modest-country-picker.h modest-country-picker.c \
        modest-provider-picker.h modest-provider-picker.c \
        modest-easysetup-wizard-dialog.h modest-easysetup-wizard-dialog.c \
        modest-country-picker.h modest-country-picker.c \
        modest-provider-picker.h modest-provider-picker.c \
+       modest-serversecurity-picker.h modest-serversecurity-picker.c \
        modest-servertype-picker.h modest-servertype-picker.c \
        modest-icon-names.h           \
        modest-maemo-global-settings-dialog.c \
        modest-servertype-picker.h modest-servertype-picker.c \
        modest-icon-names.h           \
        modest-maemo-global-settings-dialog.c \
index 37886bc..9fc42ce 100644 (file)
@@ -32,7 +32,7 @@
 #include "modest-hildon-includes.h"
 #include "modest-runtime.h"
 
 #include "modest-hildon-includes.h"
 #include "modest-runtime.h"
 
-#include "widgets/modest-serversecurity-combo-box.h"
+#include "modest-serversecurity-picker.h"
 #include "widgets/modest-secureauth-combo-box.h"
 #include "widgets/modest-validating-entry.h"
 #include <gtk/gtkbutton.h>
 #include "widgets/modest-secureauth-combo-box.h"
 #include "widgets/modest-validating-entry.h"
 #include <gtk/gtkbutton.h>
@@ -64,7 +64,7 @@ struct _ModestConnectionSpecificSmtpEditWindowPrivate
        GtkWidget *combo_outgoing_auth;
        GtkWidget *entry_user_username;
        GtkWidget *entry_user_password;
        GtkWidget *combo_outgoing_auth;
        GtkWidget *entry_user_username;
        GtkWidget *entry_user_password;
-       GtkWidget *combo_outgoing_security;
+       GtkWidget *outgoing_security_picker;
        GtkWidget *entry_port;
        
        GtkWidget *button_ok;
        GtkWidget *entry_port;
        
        GtkWidget *button_ok;
@@ -256,7 +256,7 @@ static void on_set_focus_child (GtkContainer *container, GtkWidget *widget, gpoi
 }
 
 static void
 }
 
 static void
-on_combo_security_changed (GtkComboBox *widget, gpointer user_data)
+on_security_picker_changed (HildonPickerButton *widget, gpointer user_data)
 {
        ModestConnectionSpecificSmtpEditWindow *self = 
                MODEST_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW (user_data);
 {
        ModestConnectionSpecificSmtpEditWindow *self = 
                MODEST_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW (user_data);
@@ -266,8 +266,8 @@ on_combo_security_changed (GtkComboBox *widget, gpointer user_data)
        on_change(GTK_WIDGET(widget), self);
        
        const gint port_number = 
        on_change(GTK_WIDGET(widget), self);
        
        const gint port_number = 
-               modest_serversecurity_combo_box_get_active_serversecurity_port (
-                       MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security));
+               modest_serversecurity_picker_get_active_serversecurity_port (
+                       MODEST_SERVERSECURITY_PICKER (priv->outgoing_security_picker));
 
        if(port_number != 0) {
                hildon_number_editor_set_value (
 
        if(port_number != 0) {
                hildon_number_editor_set_value (
@@ -355,17 +355,15 @@ modest_connection_specific_smtp_edit_window_init (ModestConnectionSpecificSmtpEd
        gtk_widget_show (caption);
        
        /* The secure connection widgets: */    
        gtk_widget_show (caption);
        
        /* The secure connection widgets: */    
-       if (!priv->combo_outgoing_security)
-               priv->combo_outgoing_security = GTK_WIDGET (modest_serversecurity_combo_box_new ());
-       modest_serversecurity_combo_box_fill (
-               MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security), MODEST_PROTOCOLS_TRANSPORT_SMTP);
-       modest_serversecurity_combo_box_set_active_serversecurity (
-               MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security), MODEST_PROTOCOLS_CONNECTION_NONE);
-       caption = hildon_caption_new (sizegroup, _("mcen_li_emailsetup_secure_connection"), 
-               priv->combo_outgoing_security, NULL, HILDON_CAPTION_OPTIONAL);
-       gtk_widget_show (priv->combo_outgoing_security);
-       gtk_box_pack_start (GTK_BOX (vbox), caption, FALSE, FALSE, MODEST_MARGIN_HALF);
-       gtk_widget_show (caption);
+       if (!priv->outgoing_security_picker)
+               priv->outgoing_security_picker = GTK_WIDGET (modest_serversecurity_picker_new ());
+       modest_serversecurity_picker_fill (
+               MODEST_SERVERSECURITY_PICKER (priv->outgoing_security_picker), MODEST_PROTOCOLS_TRANSPORT_SMTP);
+       modest_serversecurity_picker_set_active_serversecurity (
+               MODEST_SERVERSECURITY_PICKER (priv->outgoing_security_picker), MODEST_PROTOCOLS_CONNECTION_NONE);
+       hildon_button_set_title (HILDON_BUTTON (priv->outgoing_security_picker), _("mcen_li_emailsetup_secure_connection"));
+       gtk_widget_show (priv->outgoing_security_picker);
+       gtk_box_pack_start (GTK_BOX (vbox), priv->outgoing_security_picker, FALSE, FALSE, MODEST_MARGIN_HALF);
        
        /* The port number widgets: */
        if (!priv->entry_port)
        
        /* The port number widgets: */
        if (!priv->entry_port)
@@ -380,8 +378,8 @@ modest_connection_specific_smtp_edit_window_init (ModestConnectionSpecificSmtpEd
        gtk_widget_show (caption);
        
        /* Show a default port number when the security method changes, as per the UI spec: */
        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);
-       on_combo_security_changed (GTK_COMBO_BOX (priv->combo_outgoing_security), self);
+       g_signal_connect (G_OBJECT (priv->outgoing_security_picker), "value-changed", (GCallback)on_security_picker_changed, self);
+       on_security_picker_changed (HILDON_PICKER_BUTTON (priv->outgoing_security_picker), self);
        
        /* Add the buttons: */
        gtk_dialog_add_button (GTK_DIALOG (self), _("mcen_bd_dialog_ok"), GTK_RESPONSE_OK);
        
        /* Add the buttons: */
        gtk_dialog_add_button (GTK_DIALOG (self), _("mcen_bd_dialog_ok"), GTK_RESPONSE_OK);
@@ -448,8 +446,8 @@ modest_connection_specific_smtp_edit_window_set_connection (
                gtk_entry_set_text (GTK_ENTRY (priv->entry_user_password), 
                                    modest_server_account_settings_get_password (server_settings));
        
                gtk_entry_set_text (GTK_ENTRY (priv->entry_user_password), 
                                    modest_server_account_settings_get_password (server_settings));
        
-               modest_serversecurity_combo_box_set_active_serversecurity (
-               MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security), 
+               modest_serversecurity_picker_set_active_serversecurity (
+               MODEST_SERVERSECURITY_PICKER (priv->outgoing_security_picker), 
                modest_server_account_settings_get_security_protocol (server_settings));
        
                modest_secureauth_combo_box_set_active_secureauth (
                modest_server_account_settings_get_security_protocol (server_settings));
        
                modest_secureauth_combo_box_set_active_secureauth (
@@ -500,8 +498,8 @@ modest_connection_specific_smtp_edit_window_get_settings (ModestConnectionSpecif
                                                     gtk_entry_get_text (GTK_ENTRY (priv->entry_user_password)));
        
        modest_server_account_settings_set_security_protocol (server_settings, 
                                                     gtk_entry_get_text (GTK_ENTRY (priv->entry_user_password)));
        
        modest_server_account_settings_set_security_protocol (server_settings, 
-                                                    modest_serversecurity_combo_box_get_active_serversecurity (
-                                                    MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security)));
+                                                    modest_serversecurity_picker_get_active_serversecurity (
+                                                    MODEST_SERVERSECURITY_PICKER (priv->outgoing_security_picker)));
        modest_server_account_settings_set_auth_protocol (server_settings,
                                                          modest_secureauth_combo_box_get_active_secureauth (
                                                          MODEST_SECUREAUTH_COMBO_BOX (priv->combo_outgoing_auth)));
        modest_server_account_settings_set_auth_protocol (server_settings,
                                                          modest_secureauth_combo_box_get_active_secureauth (
                                                          MODEST_SECUREAUTH_COMBO_BOX (priv->combo_outgoing_auth)));
index 54a6a3c..9d8e433 100644 (file)
@@ -41,7 +41,6 @@
 #include "modest-hildon-includes.h"
 #include "modest-default-account-settings-dialog.h"
 #include "modest-account-mgr.h"
 #include "modest-hildon-includes.h"
 #include "modest-default-account-settings-dialog.h"
 #include "modest-account-mgr.h"
-#include "widgets/modest-serversecurity-combo-box.h"
 #include "widgets/modest-secureauth-combo-box.h"
 #include "widgets/modest-validating-entry.h"
 #include "widgets/modest-retrieve-combo-box.h"
 #include "widgets/modest-secureauth-combo-box.h"
 #include "widgets/modest-validating-entry.h"
 #include "widgets/modest-retrieve-combo-box.h"
@@ -678,19 +677,6 @@ update_incoming_server_title (ModestDefaultAccountSettingsDialog *self,
        g_free (with_asterisk);
 }
 
        g_free (with_asterisk);
 }
 
-/** Change the caption title for the incoming server, 
- * as specified in the UI spec:
- */
-/* static void  */
-/* update_incoming_server_security_choices (ModestDefaultAccountSettingsDialog *self,  */
-/*                                      ModestProtocolType protocol) */
-/* { */
-/*     /\* Fill the combo with appropriately titled choices for POP or IMAP. *\/ */
-/*     /\* The choices are the same, but the titles are different, as in the UI spec. *\/ */
-/*     modest_serversecurity_combo_box_fill ( */
-/*             MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_incoming_security), protocol); */
-/* } */
-           
 static GtkWidget* 
 create_page_incoming (ModestDefaultAccountSettingsDialog *self)
 {
 static GtkWidget* 
 create_page_incoming (ModestDefaultAccountSettingsDialog *self)
 {
@@ -781,41 +767,6 @@ on_button_outgoing_smtp_servers (GtkButton *button, gpointer user_data)
        priv->modified = TRUE;
 }
 
        priv->modified = TRUE;
 }
 
-/* static void */
-/* on_combo_outgoing_auth_changed (GtkComboBox *widget, gpointer user_data) */
-/* { */
-/*     ModestDefaultAccountSettingsDialog *self; */
-/*     ModestProtocolRegistry *protocol_registry; */
-/*     ModestProtocolType protocol_security;    */
-/*     gboolean secureauth_used; */
-
-/*     self = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data); */
-/*     protocol_registry = modest_runtime_get_protocol_registry (); */
-       
-/*     protocol_security =  */
-/*             modest_secureauth_combo_box_get_active_secureauth ( */
-/*                     MODEST_SECUREAUTH_COMBO_BOX (priv->combo_outgoing_auth)); */
-/*     secureauth_used = modest_protocol_registry_protocol_type_is_secure (protocol_registry, protocol_security); */
-       
-/*     gtk_widget_set_sensitive (priv->caption_outgoing_username, secureauth_used); */
-/*     gtk_widget_set_sensitive (priv->caption_outgoing_password, secureauth_used); */
-/* } */
-
-/* static void */
-/* on_combo_outgoing_security_changed (GtkComboBox *widget, gpointer user_data) */
-/* { */
-/*     ModestDefaultAccountSettingsDialog *self = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data); */
-       
-/*     const gint port_number =  */
-/*             modest_serversecurity_combo_box_get_active_serversecurity_port ( */
-/*                     MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security)); */
-
-/*     if(port_number != 0) { */
-/*             hildon_number_editor_set_value ( */
-/*                     HILDON_NUMBER_EDITOR (priv->entry_outgoing_port), port_number); */
-/*     }                */
-/* } */
-
 static void
 on_missing_mandatory_data (ModestSecurityOptionsView *security_view,
                           gboolean missing,
 static void
 on_missing_mandatory_data (ModestSecurityOptionsView *security_view,
                           gboolean missing,
@@ -998,62 +949,6 @@ check_data (ModestDefaultAccountSettingsDialog *self)
                return FALSE;
        }
        
                return FALSE;
        }
        
-/*     /\* Find a suitable authentication method when secure authentication is desired *\/ */
-/*     port_num = hildon_number_editor_get_value ( */
-/*             HILDON_NUMBER_EDITOR (priv->entry_incoming_port)); */
-/*     username = gtk_entry_get_text (GTK_ENTRY (priv->entry_user_username)); */
-
-/*     protocol_registry = modest_runtime_get_protocol_registry (); */
-
-/*     protocol_security_incoming = modest_serversecurity_combo_box_get_active_serversecurity ( */
-/*             MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_incoming_security)); */
-/*     if (!modest_protocol_registry_protocol_type_is_secure(protocol_registry, protocol_security_incoming)) */
-/*     { */
-/*             if (gtk_toggle_button_get_active ( */
-/*                             GTK_TOGGLE_BUTTON (priv->checkbox_incoming_auth))) { */
-/*                     GError *error = NULL; */
-/*                     GList *list_auth_methods; */
-
-/*                     list_auth_methods =  */
-/*                             modest_utils_get_supported_secure_authentication_methods (priv->incoming_protocol,  */
-/*                                                                                       hostname, port_num, username, GTK_WINDOW (self), &error); */
-/*                     if (list_auth_methods) { */
-/*                             GList* method; */
-
-/*                             /\* Use the first supported method. */
-/*                              * TODO: Should we prioritize them, to prefer a particular one? *\/ */
-/*                             for (method = list_auth_methods; method != NULL; method = g_list_next(method)) */
-/*                             { */
-/*                                     ModestProtocolType proto = (ModestProtocolType)(GPOINTER_TO_INT(method->data)); */
-/*                                     // Allow secure methods, e.g MD5 only */
-/*                                     if (modest_protocol_registry_protocol_type_is_secure(protocol_registry, proto)) */
-/*                                     { */
-/*                                             priv->protocol_authentication_incoming = proto; */
-/*                                             break; */
-/*                                     } */
-/*                             } */
-/*                             g_list_free (list_auth_methods); */
-/*                     } */
-
-/*                     if (list_auth_methods == NULL ||  */
-/*                         !modest_protocol_registry_protocol_type_is_secure(protocol_registry, priv->protocol_authentication_incoming)) */
-/*                     { */
-/*                             if(error == NULL || error->domain != modest_utils_get_supported_secure_authentication_error_quark() || */
-/*                                             error->code != MODEST_UTILS_GET_SUPPORTED_SECURE_AUTHENTICATION_ERROR_CANCELED) */
-/*                                     modest_platform_information_banner(GTK_WIDGET (self), NULL,  */
-/*                                                                    _("mcen_ib_unableto_discover_auth_methods")); */
-
-/*                             if(error != NULL) */
-/*                                     g_error_free(error); */
-                                       
-/*                             /\* This is a nasty hack. jschmid. *\/ */
-/*                             /\* Don't let the dialog close *\/ */
-/*                             /\*g_signal_stop_emission_by_name (dialog, "response");*\/ */
-/*                             return FALSE; */
-/*                     } */
-/*             } */
-/*     } */
-       
        return TRUE;
 }
 
        return TRUE;
 }
 
index 0090aa4..36c0177 100644 (file)
@@ -35,7 +35,7 @@
 #include "modest-account-protocol.h"
 #include "widgets/modest-ui-constants.h"
 #include "widgets/modest-validating-entry.h"
 #include "modest-account-protocol.h"
 #include "widgets/modest-ui-constants.h"
 #include "widgets/modest-validating-entry.h"
-#include "widgets/modest-serversecurity-combo-box.h"
+#include "modest-serversecurity-picker.h"
 #include "widgets/modest-secureauth-combo-box.h"
 #ifdef MODEST_HAVE_HILDON0_WIDGETS
 #include <hildon-widgets/hildon-caption.h>
 #include "widgets/modest-secureauth-combo-box.h"
 #ifdef MODEST_HAVE_HILDON0_WIDGETS
 #include <hildon-widgets/hildon-caption.h>
@@ -64,7 +64,7 @@ on_security_changed (GtkWidget *widget,
                     ModestMaemoSecurityOptionsView *self)
 {
        ModestSecurityOptionsViewPrivate* ppriv;
                     ModestMaemoSecurityOptionsView *self)
 {
        ModestSecurityOptionsViewPrivate* ppriv;
-       ModestServersecurityComboBox *combo;
+       ModestServersecurityPicker *picker;
        ModestProtocolType proto_type;
        ModestProtocolRegistry *proto_registry;
        gboolean is_secure;
        ModestProtocolType proto_type;
        ModestProtocolRegistry *proto_registry;
        gboolean is_secure;
@@ -72,8 +72,8 @@ on_security_changed (GtkWidget *widget,
        ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
 
        proto_registry = modest_runtime_get_protocol_registry ();
        ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
 
        proto_registry = modest_runtime_get_protocol_registry ();
-       combo = MODEST_SERVERSECURITY_COMBO_BOX (ppriv->security_view);
-       proto_type = modest_serversecurity_combo_box_get_active_serversecurity (combo);
+       picker = MODEST_SERVERSECURITY_PICKER (ppriv->security_view);
+       proto_type = modest_serversecurity_picker_get_active_serversecurity (picker);
 
        is_secure = modest_protocol_registry_protocol_type_has_tag (proto_registry, proto_type, 
                                                                    MODEST_PROTOCOL_REGISTRY_SECURE_PROTOCOLS);
 
        is_secure = modest_protocol_registry_protocol_type_has_tag (proto_registry, proto_type, 
                                                                    MODEST_PROTOCOL_REGISTRY_SECURE_PROTOCOLS);
@@ -89,7 +89,7 @@ on_security_changed (GtkWidget *widget,
 
        if (ppriv->full) {
                gint port_number = 
 
        if (ppriv->full) {
                gint port_number = 
-                       modest_serversecurity_combo_box_get_active_serversecurity_port (MODEST_SERVERSECURITY_COMBO_BOX (ppriv->security_view));
+                       modest_serversecurity_picker_get_active_serversecurity_port (MODEST_SERVERSECURITY_PICKER (ppriv->security_view));
                
                if(port_number) {
                        hildon_number_editor_set_value (HILDON_NUMBER_EDITOR (ppriv->port_view), 
                
                if(port_number) {
                        hildon_number_editor_set_value (HILDON_NUMBER_EDITOR (ppriv->port_view), 
@@ -134,15 +134,13 @@ create_incoming_security (ModestSecurityOptionsView* self,
                          GtkSizeGroup *size_group)
 {
        ModestSecurityOptionsViewPrivate *ppriv;
                          GtkSizeGroup *size_group)
 {
        ModestSecurityOptionsViewPrivate *ppriv;
-       GtkWidget *combo_caption, *check_caption, *entry_caption = NULL;
+       GtkWidget *check_caption, *entry_caption = NULL;
 
        ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
 
        /* Create widgets for incoming security */
 
        ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
 
        /* Create widgets for incoming security */
-       ppriv->security_view = GTK_WIDGET (modest_serversecurity_combo_box_new ());
-       combo_caption = hildon_caption_new (size_group, _("mcen_li_emailsetup_secure_connection"),
-                                           ppriv->security_view, NULL, 
-                                           HILDON_CAPTION_OPTIONAL);
+       ppriv->security_view = GTK_WIDGET (modest_serversecurity_picker_new ());
+       hildon_button_set_title (HILDON_BUTTON (ppriv->security_view), _("mcen_li_emailsetup_secure_connection"));
 
        if (ppriv->full) {              
                ppriv->port_view = GTK_WIDGET (hildon_number_editor_new (PORT_MIN, PORT_MAX));
 
        if (ppriv->full) {              
                ppriv->port_view = GTK_WIDGET (hildon_number_editor_new (PORT_MIN, PORT_MAX));
@@ -157,11 +155,11 @@ create_incoming_security (ModestSecurityOptionsView* self,
                                    ppriv->auth_view, NULL, HILDON_CAPTION_OPTIONAL);
 
        /* Track changes in UI */       
                                    ppriv->auth_view, NULL, HILDON_CAPTION_OPTIONAL);
 
        /* Track changes in UI */       
-       g_signal_connect (G_OBJECT (ppriv->security_view), "changed",
+       g_signal_connect (G_OBJECT (ppriv->security_view), "value-changed",
                          G_CALLBACK (on_security_changed), self);
 
        /* Pack into container */
                          G_CALLBACK (on_security_changed), self);
 
        /* Pack into container */
-       gtk_box_pack_start (GTK_BOX (self), combo_caption,
+       gtk_box_pack_start (GTK_BOX (self), ppriv->security_view,
                            FALSE, FALSE, MODEST_MARGIN_HALF);
        if (ppriv->full)
                gtk_box_pack_start (GTK_BOX (self), entry_caption, 
                            FALSE, FALSE, MODEST_MARGIN_HALF);
        if (ppriv->full)
                gtk_box_pack_start (GTK_BOX (self), entry_caption, 
@@ -176,7 +174,6 @@ create_incoming_security (ModestSecurityOptionsView* self,
        }
        gtk_widget_show (ppriv->security_view);
        gtk_widget_show (ppriv->auth_view);
        }
        gtk_widget_show (ppriv->security_view);
        gtk_widget_show (ppriv->auth_view);
-       gtk_widget_show (combo_caption);
        gtk_widget_show (check_caption);
 }
 
        gtk_widget_show (check_caption);
 }
 
@@ -231,17 +228,16 @@ create_outgoing_security (ModestSecurityOptionsView* self,
                          GtkSizeGroup *size_group)
 {
        ModestSecurityOptionsViewPrivate *ppriv;
                          GtkSizeGroup *size_group)
 {
        ModestSecurityOptionsViewPrivate *ppriv;
-       GtkWidget *sec_caption, *auth_caption, *user_caption = NULL;
+       GtkWidget *auth_caption, *user_caption = NULL;
        GtkWidget *pwd_caption = NULL, *port_caption = NULL;
 
        ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
        
        /* The secure connection widgets */
        GtkWidget *pwd_caption = NULL, *port_caption = NULL;
 
        ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
        
        /* The secure connection widgets */
-       ppriv->security_view = GTK_WIDGET (modest_serversecurity_combo_box_new ());
-       modest_serversecurity_combo_box_fill (MODEST_SERVERSECURITY_COMBO_BOX (ppriv->security_view), 
+       ppriv->security_view = GTK_WIDGET (modest_serversecurity_picker_new ());
+       modest_serversecurity_picker_fill (MODEST_SERVERSECURITY_PICKER (ppriv->security_view), 
                                              MODEST_PROTOCOLS_TRANSPORT_SMTP);
                                              MODEST_PROTOCOLS_TRANSPORT_SMTP);
-       sec_caption = hildon_caption_new (size_group, _("mcen_li_emailsetup_secure_connection"),
-                                     ppriv->security_view, NULL, HILDON_CAPTION_OPTIONAL);
+       hildon_button_set_title (HILDON_BUTTON (ppriv->security_view), _("mcen_li_emailsetup_secure_connection"));
        
        /* The secure authentication widgets */
        ppriv->auth_view = GTK_WIDGET (modest_secureauth_combo_box_new ());
        
        /* The secure authentication widgets */
        ppriv->auth_view = GTK_WIDGET (modest_secureauth_combo_box_new ());
@@ -292,7 +288,7 @@ create_outgoing_security (ModestSecurityOptionsView* self,
        }
 
        /* Track changes in UI */       
        }
 
        /* Track changes in UI */       
-       g_signal_connect (G_OBJECT (ppriv->security_view), "changed",
+       g_signal_connect (G_OBJECT (ppriv->security_view), "value-changed",
                          G_CALLBACK (on_security_changed), self);
        if (ppriv->full) {
                g_signal_connect (G_OBJECT (ppriv->auth_view), "changed",
                          G_CALLBACK (on_security_changed), self);
        if (ppriv->full) {
                g_signal_connect (G_OBJECT (ppriv->auth_view), "changed",
@@ -302,8 +298,8 @@ create_outgoing_security (ModestSecurityOptionsView* self,
        }
 
        /* Initialize widgets */
        }
 
        /* Initialize widgets */
-       modest_serversecurity_combo_box_set_active_serversecurity (
-               MODEST_SERVERSECURITY_COMBO_BOX (ppriv->security_view), 
+       modest_serversecurity_picker_set_active_serversecurity (
+               MODEST_SERVERSECURITY_PICKER (ppriv->security_view), 
                MODEST_PROTOCOLS_CONNECTION_NONE);
        modest_secureauth_combo_box_set_active_secureauth (
           MODEST_SECUREAUTH_COMBO_BOX (ppriv->auth_view),
                MODEST_PROTOCOLS_CONNECTION_NONE);
        modest_secureauth_combo_box_set_active_secureauth (
           MODEST_SECUREAUTH_COMBO_BOX (ppriv->auth_view),
@@ -314,11 +310,11 @@ create_outgoing_security (ModestSecurityOptionsView* self,
                gtk_box_pack_start (GTK_BOX (self), auth_caption, FALSE, FALSE, MODEST_MARGIN_HALF);
                gtk_box_pack_start (GTK_BOX (self), user_caption, FALSE, FALSE, MODEST_MARGIN_HALF);
                gtk_box_pack_start (GTK_BOX (self), pwd_caption, FALSE, FALSE, MODEST_MARGIN_HALF);
                gtk_box_pack_start (GTK_BOX (self), auth_caption, FALSE, FALSE, MODEST_MARGIN_HALF);
                gtk_box_pack_start (GTK_BOX (self), user_caption, FALSE, FALSE, MODEST_MARGIN_HALF);
                gtk_box_pack_start (GTK_BOX (self), pwd_caption, FALSE, FALSE, MODEST_MARGIN_HALF);
-               gtk_box_pack_start (GTK_BOX (self), sec_caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+               gtk_box_pack_start (GTK_BOX (self), ppriv->security_view, FALSE, FALSE, MODEST_MARGIN_HALF);
                gtk_box_pack_start (GTK_BOX (self), port_caption, FALSE, FALSE, MODEST_MARGIN_HALF);
        } else {
                /* The order is different */
                gtk_box_pack_start (GTK_BOX (self), port_caption, FALSE, FALSE, MODEST_MARGIN_HALF);
        } else {
                /* The order is different */
-               gtk_box_pack_start (GTK_BOX (self), sec_caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+               gtk_box_pack_start (GTK_BOX (self), ppriv->security_view, FALSE, FALSE, MODEST_MARGIN_HALF);
                gtk_box_pack_start (GTK_BOX (self), auth_caption, FALSE, FALSE, MODEST_MARGIN_HALF);
        }
 
                gtk_box_pack_start (GTK_BOX (self), auth_caption, FALSE, FALSE, MODEST_MARGIN_HALF);
        }
 
@@ -333,7 +329,6 @@ create_outgoing_security (ModestSecurityOptionsView* self,
        }
        gtk_widget_show (ppriv->security_view);
        gtk_widget_show (ppriv->auth_view);
        }
        gtk_widget_show (ppriv->security_view);
        gtk_widget_show (ppriv->auth_view);
-       gtk_widget_show (sec_caption);
        gtk_widget_show (auth_caption);
 }
 
        gtk_widget_show (auth_caption);
 }
 
@@ -407,7 +402,7 @@ modest_maemo_security_options_view_save_settings (ModestSecurityOptionsView* sel
        if (ppriv->full) {
                server_port = hildon_number_editor_get_value (HILDON_NUMBER_EDITOR (ppriv->port_view));
        } else {
        if (ppriv->full) {
                server_port = hildon_number_editor_get_value (HILDON_NUMBER_EDITOR (ppriv->port_view));
        } else {
-               server_port = modest_serversecurity_combo_box_get_active_serversecurity_port (MODEST_SERVERSECURITY_COMBO_BOX (ppriv->security_view));
+               server_port = modest_serversecurity_picker_get_active_serversecurity_port (MODEST_SERVERSECURITY_PICKER (ppriv->security_view));
        }
 
        modest_server_account_settings_set_port (server_settings, server_port);
        }
 
        modest_server_account_settings_set_port (server_settings, server_port);
diff --git a/src/hildon2/modest-serversecurity-picker.c b/src/hildon2/modest-serversecurity-picker.c
new file mode 100644 (file)
index 0000000..267f6e1
--- /dev/null
@@ -0,0 +1,307 @@
+/* Copyright (c) 2006, 2008 Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived from
+ *   this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "modest-serversecurity-picker.h"
+#include <modest-runtime.h>
+#include <modest-account-protocol.h>
+#include <gtk/gtkliststore.h>
+#include <gtk/gtkcelllayout.h>
+#include <gtk/gtkcellrenderertext.h>
+#include <glib/gi18n.h>
+
+#include <stdlib.h>
+#include <string.h> /* For memcpy() */
+
+/* Include config.h so that _() works: */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+G_DEFINE_TYPE (ModestServersecurityPicker, modest_serversecurity_picker, HILDON_TYPE_PICKER_BUTTON);
+
+#define MODEST_SERVERSECURITY_PICKER_GET_PRIVATE(o) \
+       (G_TYPE_INSTANCE_GET_PRIVATE ((o), MODEST_TYPE_SERVERSECURITY_PICKER, ModestServersecurityPickerPrivate))
+
+typedef struct _ModestServersecurityPickerPrivate ModestServersecurityPickerPrivate;
+
+struct _ModestServersecurityPickerPrivate
+{
+       GtkTreeModel *model;
+       ModestProtocolType protocol;
+};
+
+static void
+modest_serversecurity_picker_finalize (GObject *object)
+{
+       ModestServersecurityPickerPrivate *priv = MODEST_SERVERSECURITY_PICKER_GET_PRIVATE (object);
+
+       g_object_unref (G_OBJECT (priv->model));
+
+       G_OBJECT_CLASS (modest_serversecurity_picker_parent_class)->finalize (object);
+}
+
+static void
+modest_serversecurity_picker_class_init (ModestServersecurityPickerClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+       g_type_class_add_private (klass, sizeof (ModestServersecurityPickerPrivate));
+
+       object_class->finalize = modest_serversecurity_picker_finalize;
+}
+
+enum MODEL_COLS {
+       MODEL_COL_NAME = 0, /* a string */
+       MODEL_COL_ID = 1 /* an int. */
+};
+
+static void
+modest_serversecurity_picker_init (ModestServersecurityPicker *self)
+{
+       ModestServersecurityPickerPrivate *priv = MODEST_SERVERSECURITY_PICKER_GET_PRIVATE (self);
+
+       priv->model = NULL;
+
+}
+
+static gchar *
+touch_selector_print_func (HildonTouchSelector *selector)
+{
+       GtkTreeIter iter;
+       if (hildon_touch_selector_get_selected (HILDON_TOUCH_SELECTOR (selector), 0, &iter)) {
+               GtkTreeModel *model;
+               GValue value = {0,};
+               
+               model = hildon_touch_selector_get_model (HILDON_TOUCH_SELECTOR (selector), 0);
+               gtk_tree_model_get_value (model, &iter, MODEL_COL_NAME, &value);
+               return g_value_dup_string (&value);
+       }
+       return NULL;
+}
+
+ModestServersecurityPicker*
+modest_serversecurity_picker_new (void)
+{
+       ModestServersecurityPicker *self;
+       ModestServersecurityPickerPrivate *priv;
+       GtkCellRenderer *renderer;
+       GtkWidget *selector;
+
+       self = g_object_new (MODEST_TYPE_SERVERSECURITY_PICKER, 
+                            "arrangement", HILDON_BUTTON_ARRANGEMENT_VERTICAL,
+                            "size", HILDON_SIZE_AUTO,
+                            NULL);
+       priv = MODEST_SERVERSECURITY_PICKER_GET_PRIVATE (self);
+
+       /* Create a tree model,
+        * with a string for the name, and an ID for the servertype.
+        * This must match our MODEL_COLS enum constants.
+        */
+       priv->model = GTK_TREE_MODEL (gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT));
+       renderer = gtk_cell_renderer_text_new ();
+       g_object_set (G_OBJECT (renderer), "ellipsize", PANGO_ELLIPSIZE_END, NULL);
+
+       selector = hildon_touch_selector_new ();
+       hildon_touch_selector_append_column (HILDON_TOUCH_SELECTOR (selector), GTK_TREE_MODEL (priv->model),
+                                            renderer, "text", MODEL_COL_NAME, NULL);
+
+       hildon_touch_selector_set_model (HILDON_TOUCH_SELECTOR (selector), 0, GTK_TREE_MODEL (priv->model));
+       hildon_touch_selector_set_print_func (HILDON_TOUCH_SELECTOR (selector), touch_selector_print_func);
+
+       hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (self), HILDON_TOUCH_SELECTOR (selector));
+
+       return self;
+}
+
+/* Fill the picker box with appropriate choices.
+ * #picker: The picker box.
+ * @protocol: IMAP or POP.
+ */
+void modest_serversecurity_picker_fill (ModestServersecurityPicker *picker, ModestProtocolType protocol_type)
+{
+       ModestServersecurityPickerPrivate *priv;
+       ModestProtocol *protocol;
+
+       priv = MODEST_SERVERSECURITY_PICKER_GET_PRIVATE (picker);
+       priv->protocol = protocol_type; /* Remembered for later. */
+       protocol = modest_protocol_registry_get_protocol_by_type (modest_runtime_get_protocol_registry (),
+                                                                 protocol_type);
+       
+       /* Remove any existing rows: */
+       GtkListStore *liststore = GTK_LIST_STORE (priv->model);
+       gtk_list_store_clear (liststore);
+       
+       GtkTreeIter iter;
+       gtk_list_store_append (liststore, &iter);
+       /* TODO: This logical ID is not in the .po file: */
+       gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint) MODEST_PROTOCOLS_CONNECTION_NONE, MODEL_COL_NAME, _("mcen_fi_advsetup_other_security_none"), -1);
+       
+       gtk_list_store_append (liststore, &iter);
+       gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOLS_CONNECTION_TLS, MODEL_COL_NAME, _("mcen_fi_advsetup_other_security_normal"), -1);
+       
+       /* Add security choices with protocol-specific names, as in the UI spec:
+        * (Note: Changing the title seems pointless. murrayc) */
+       gchar *protocol_name = modest_protocol_get_translation (protocol, MODEST_PROTOCOL_TRANSLATION_SSL_PROTO_NAME);
+       if (protocol_name) {
+               gtk_list_store_append (liststore, &iter);
+               gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOLS_CONNECTION_SSL, MODEL_COL_NAME, protocol_name, -1);
+               g_free (protocol_name);
+       } else {
+               /* generic fallback */
+               gtk_list_store_append (liststore, &iter);
+               gtk_list_store_set (liststore, &iter, MODEL_COL_ID, (gint)MODEST_PROTOCOLS_CONNECTION_SSL, MODEL_COL_NAME, _("mcen_fi_advsetup_other_security_ssl"), -1);
+       }
+}
+
+static gint get_port_for_security (ModestProtocolType protocol_type, ModestProtocolType security_type)
+{
+       /* See the UI spec, section Email Wizards, Incoming Details [MSG-WIZ001]: */
+       gint result = 0;
+       ModestProtocol *protocol, *security;
+       ModestProtocolRegistry *protocol_registry;
+       gboolean use_alternate_port;
+
+       protocol_registry = modest_runtime_get_protocol_registry ();
+       protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry, protocol_type);
+       security = modest_protocol_registry_get_protocol_by_type (protocol_registry, security_type);
+
+       g_return_val_if_fail ((security != NULL && protocol != NULL), 0);
+
+       use_alternate_port = modest_protocol_registry_protocol_type_has_tag (protocol_registry, security_type,
+                                                                            MODEST_PROTOCOL_REGISTRY_USE_ALTERNATE_PORT);
+
+       /* Get the default port number for this protocol with this security: */
+       if (use_alternate_port) {
+               result = modest_account_protocol_get_alternate_port (MODEST_ACCOUNT_PROTOCOL (protocol));
+       } else {
+               result = modest_account_protocol_get_port (MODEST_ACCOUNT_PROTOCOL (protocol));
+       }
+
+       return result;
+}
+
+/**
+ * Returns the selected serversecurity, 
+ * or MODEST_PROTOCOLS_CONNECTION_NONE if no serversecurity was selected.
+ */
+ModestProtocolType
+modest_serversecurity_picker_get_active_serversecurity (ModestServersecurityPicker *picker)
+{
+       GtkTreeIter active;
+       gboolean found;
+       GtkWidget *selector;
+
+       selector = GTK_WIDGET (hildon_picker_button_get_selector (HILDON_PICKER_BUTTON (picker)));
+
+       found = hildon_touch_selector_get_selected (HILDON_TOUCH_SELECTOR (selector), 0, &active);
+       if (found) {
+               ModestServersecurityPickerPrivate *priv = MODEST_SERVERSECURITY_PICKER_GET_PRIVATE (picker);
+
+               ModestProtocolType serversecurity = MODEST_PROTOCOLS_CONNECTION_NONE;
+               gtk_tree_model_get (priv->model, &active, MODEL_COL_ID, &serversecurity, -1);
+               return serversecurity;  
+       }
+
+       return MODEST_PROTOCOLS_CONNECTION_NONE; /* Failed. */
+}
+
+/**
+ * Returns the default port to be used for the selected serversecurity, 
+ * or 0 if no serversecurity was selected.
+ */
+gint
+modest_serversecurity_picker_get_active_serversecurity_port (ModestServersecurityPicker *picker)
+{
+       ModestServersecurityPickerPrivate *priv = MODEST_SERVERSECURITY_PICKER_GET_PRIVATE (picker);
+       
+       ModestProtocolType security = modest_serversecurity_picker_get_active_serversecurity 
+               (picker);
+       return get_port_for_security (priv->protocol, security);
+}
+       
+/* This allows us to pass more than one piece of data to the signal handler,
+ * and get a result: */
+typedef struct 
+{
+               ModestServersecurityPicker* self;
+               ModestProtocolType id;
+               gboolean found;
+} ForEachData;
+
+static gboolean
+on_model_foreach_select_id(GtkTreeModel *model, 
+       GtkTreePath *path, GtkTreeIter *iter, gpointer user_data)
+{
+       ForEachData *state = (ForEachData*)(user_data);
+       
+       /* Select the item if it has the matching ID: */
+       ModestProtocolType id = MODEST_PROTOCOL_REGISTRY_TYPE_INVALID;
+       gtk_tree_model_get (model, iter, MODEL_COL_ID, &id, -1); 
+       if(id == state->id) {
+               GtkWidget *selector;
+               selector = GTK_WIDGET (hildon_picker_button_get_selector (HILDON_PICKER_BUTTON (state->self)));
+               hildon_touch_selector_select_iter (HILDON_TOUCH_SELECTOR (selector), 0, iter, TRUE);
+               hildon_button_set_value (HILDON_BUTTON (state->self),
+                                        hildon_touch_selector_get_current_text (HILDON_TOUCH_SELECTOR (selector)));
+               
+               state->found = TRUE;
+               return TRUE; /* Stop walking the tree. */
+       }
+       
+       return FALSE; /* Keep walking the tree. */
+}
+
+/**
+ * Selects the specified serversecurity, 
+ * or MODEST_PROTOCOLS_CONNECTION_NONE if no serversecurity was selected.
+ */
+gboolean
+modest_serversecurity_picker_set_active_serversecurity (ModestServersecurityPicker *picker,
+                                                       ModestProtocolType serversecurity)
+{
+       ModestServersecurityPickerPrivate *priv = MODEST_SERVERSECURITY_PICKER_GET_PRIVATE (picker);
+       
+       /* Create a state instance so we can send two items of data to the signal handler: */
+       ForEachData *state = g_new0 (ForEachData, 1);
+       state->self = picker;
+       state->id = serversecurity;
+       state->found = FALSE;
+       
+       /* Look at each item, and select the one with the correct ID: */
+       gtk_tree_model_foreach (priv->model, &on_model_foreach_select_id, state);
+
+       const gboolean result = state->found;
+       
+       /* Free the state instance: */
+       g_free(state);
+       
+       return result;
+}
+
diff --git a/src/hildon2/modest-serversecurity-picker.h b/src/hildon2/modest-serversecurity-picker.h
new file mode 100644 (file)
index 0000000..9f9499e
--- /dev/null
@@ -0,0 +1,84 @@
+/* Copyright (c) 2007, 2008 Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived from
+ *   this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _MODEST_SERVERSECURITY_PICKER
+#define _MODEST_SERVERSECURITY_PICKER
+
+#include <hildon/hildon-picker-button.h>
+#include "modest-protocol-registry.h"
+
+G_BEGIN_DECLS
+
+#define MODEST_TYPE_SERVERSECURITY_PICKER modest_serversecurity_picker_get_type()
+
+#define MODEST_SERVERSECURITY_PICKER(obj) \
+       (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+       MODEST_TYPE_SERVERSECURITY_PICKER, ModestServersecurityPicker))
+
+#define MODEST_SERVERSECURITY_PICKER_CLASS(klass) \
+       (G_TYPE_CHECK_CLASS_CAST ((klass), \
+       MODEST_TYPE_SERVERSECURITY_PICKER, ModestServersecurityPickerClass))
+
+#define MODEST_IS_SERVERSECURITY_PICKER(obj) \
+       (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+       MODEST_TYPE_SERVERSECURITY_PICKER))
+
+#define MODEST_IS_SERVERSECURITY_PICKER_CLASS(klass) \
+       (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+       MODEST_TYPE_SERVERSECURITY_PICKER))
+
+#define MODEST_SERVERSECURITY_PICKER_GET_CLASS(obj) \
+       (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+       MODEST_TYPE_SERVERSECURITY_PICKER, ModestServersecurityPickerClass))
+
+typedef struct {
+       HildonPickerButton parent;
+} ModestServersecurityPicker;
+
+typedef struct {
+       HildonPickerButtonClass parent_class;
+} ModestServersecurityPickerClass;
+
+GType modest_serversecurity_picker_get_type (void);
+
+ModestServersecurityPicker* modest_serversecurity_picker_new (void);
+
+void modest_serversecurity_picker_fill (ModestServersecurityPicker *picker, ModestProtocolType protocol);
+
+ModestProtocolType modest_serversecurity_picker_get_active_serversecurity (ModestServersecurityPicker *picker);
+
+gboolean modest_serversecurity_picker_set_active_serversecurity (ModestServersecurityPicker *picker,
+                                                                ModestProtocolType serversecurity);
+
+gint modest_serversecurity_picker_get_active_serversecurity_port (ModestServersecurityPicker *picker);
+
+
+G_END_DECLS
+
+#endif /* _MODEST_SERVERSECURITY_PICKER */
index a0a190d..2eb6069 100644 (file)
@@ -30,8 +30,6 @@
 #include "modest-signature-editor-dialog.h"
 #include "widgets/modest-ui-constants.h"
 #include "modest-hildon-includes.h"
 #include "modest-signature-editor-dialog.h"
 #include "widgets/modest-ui-constants.h"
 #include "modest-hildon-includes.h"
-#include "widgets/modest-serversecurity-combo-box.h"
-#include "widgets/modest-secureauth-combo-box.h"
 #include "widgets/modest-validating-entry.h"
 #include "modest-runtime.h"
 #include <modest-account-mgr-helpers.h>
 #include "widgets/modest-validating-entry.h"
 #include "modest-runtime.h"
 #include <modest-account-mgr-helpers.h>
index 61566e1..60263fe 100644 (file)
 #include "modest-platform.h"
 #include "modest-security-options-view.h"
 #include "modest-security-options-view-priv.h"
 #include "modest-platform.h"
 #include "modest-security-options-view.h"
 #include "modest-security-options-view-priv.h"
+#ifdef MODEST_TOOLKIT_HILDON2
+#include "modest-serversecurity-picker.h"
+#else
 #include "widgets/modest-serversecurity-combo-box.h"
 #include "widgets/modest-serversecurity-combo-box.h"
+#endif
 #include "widgets/modest-secureauth-combo-box.h"
 
 /* list my signals */
 #include "widgets/modest-secureauth-combo-box.h"
 
 /* list my signals */
@@ -52,7 +56,6 @@ modest_security_options_view_load_settings (ModestSecurityOptionsView* self,
        ModestSecurityOptionsViewPrivate *priv;
        ModestServerAccountSettings *server_settings;
        ModestProtocolType server_proto, secure_protocol, secure_auth;
        ModestSecurityOptionsViewPrivate *priv;
        ModestServerAccountSettings *server_settings;
        ModestProtocolType server_proto, secure_protocol, secure_auth;
-       ModestServersecurityComboBox *combo;
 
        priv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
 
 
        priv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
 
@@ -71,9 +74,12 @@ modest_security_options_view_load_settings (ModestSecurityOptionsView* self,
        priv->initial_state.port = modest_server_account_settings_get_port (server_settings);
 
        /* Update UI */
        priv->initial_state.port = modest_server_account_settings_get_port (server_settings);
 
        /* Update UI */
-       combo = MODEST_SERVERSECURITY_COMBO_BOX (priv->security_view);
        modest_security_options_view_set_server_type (self, server_proto);
        modest_security_options_view_set_server_type (self, server_proto);
-       modest_serversecurity_combo_box_set_active_serversecurity (combo, secure_protocol);
+#ifdef MODEST_TOOLKIT_HILDON2
+       modest_serversecurity_picker_set_active_serversecurity (MODEST_SERVERSECURITY_PICKER (priv->security_view), secure_protocol);
+#else
+       modest_serversecurity_combo_box_set_active_serversecurity (MODEST_SERVERSECURITY_COMBO_BOX (priv->security_view), secure_protocol);
+#endif
 
 /*             update_incoming_server_title (dialog, dialog->incoming_protocol); */
 
 
 /*             update_incoming_server_title (dialog, dialog->incoming_protocol); */
 
@@ -132,7 +138,11 @@ modest_security_options_view_save_settings (ModestSecurityOptionsView* self,
        auth_protocol = MODEST_PROTOCOLS_AUTH_NONE;
 
        /* Get data */
        auth_protocol = MODEST_PROTOCOLS_AUTH_NONE;
 
        /* Get data */
+#ifdef MODEST_TOOLKIT_HILDON2
+       security_proto = modest_serversecurity_picker_get_active_serversecurity (MODEST_SERVERSECURITY_PICKER (priv->security_view));
+#else
        security_proto = modest_serversecurity_combo_box_get_active_serversecurity (MODEST_SERVERSECURITY_COMBO_BOX (priv->security_view));
        security_proto = modest_serversecurity_combo_box_get_active_serversecurity (MODEST_SERVERSECURITY_COMBO_BOX (priv->security_view));
+#endif
 
        if (self->type == MODEST_SECURITY_OPTIONS_INCOMING) {
                if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->auth_view))) {
 
        if (self->type == MODEST_SECURITY_OPTIONS_INCOMING) {
                if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->auth_view))) {
@@ -178,14 +188,17 @@ modest_security_options_view_set_server_type (ModestSecurityOptionsView* self,
                                              ModestProtocolType server_type)
 {
        ModestSecurityOptionsViewPrivate *priv;
                                              ModestProtocolType server_type)
 {
        ModestSecurityOptionsViewPrivate *priv;
-       ModestServersecurityComboBox *combo;
-
        priv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
        priv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
-       combo = MODEST_SERVERSECURITY_COMBO_BOX (priv->security_view);
-               
-       modest_serversecurity_combo_box_fill (combo, server_type);
-       modest_serversecurity_combo_box_set_active_serversecurity (combo,
+
+#ifdef MODEST_TOOLKIT_HILDON2          
+       modest_serversecurity_picker_fill (MODEST_SERVERSECURITY_PICKER (priv->security_view), server_type);
+       modest_serversecurity_picker_set_active_serversecurity (MODEST_SERVERSECURITY_PICKER (priv->security_view),
+                                                               MODEST_PROTOCOLS_CONNECTION_NONE);
+#else
+       modest_serversecurity_combo_box_fill (MODEST_SERVERSECURITY_COMBO_BOX (priv->security_view), server_type);
+       modest_serversecurity_combo_box_set_active_serversecurity (MODEST_SERVERSECURITY_COMBO_BOX (priv->security_view),
                                                                   MODEST_PROTOCOLS_CONNECTION_NONE);
                                                                   MODEST_PROTOCOLS_CONNECTION_NONE);
+#endif
 }
 
 static void
 }
 
 static void
@@ -199,8 +212,13 @@ get_current_state (ModestSecurityOptionsView* self,
        proto_registry = modest_runtime_get_protocol_registry ();
 
        /* Get security */
        proto_registry = modest_runtime_get_protocol_registry ();
 
        /* Get security */
+#ifdef MODEST_TOOLKIT_HILDON2
+       state->security = 
+               modest_serversecurity_picker_get_active_serversecurity (MODEST_SERVERSECURITY_PICKER (priv->security_view));
+#else
        state->security = 
                modest_serversecurity_combo_box_get_active_serversecurity (MODEST_SERVERSECURITY_COMBO_BOX (priv->security_view));
        state->security = 
                modest_serversecurity_combo_box_get_active_serversecurity (MODEST_SERVERSECURITY_COMBO_BOX (priv->security_view));
+#endif
 
        /* Get auth */
        if (self->type == MODEST_SECURITY_OPTIONS_OUTGOING) {
 
        /* Get auth */
        if (self->type == MODEST_SECURITY_OPTIONS_OUTGOING) {
@@ -275,8 +293,13 @@ modest_security_options_view_auth_check (ModestSecurityOptionsView* self)
        protocol_registry = modest_runtime_get_protocol_registry ();
 
        /* Check if the server supports secure authentication */
        protocol_registry = modest_runtime_get_protocol_registry ();
 
        /* Check if the server supports secure authentication */
+#ifdef MODEST_TOOLKIT_HILDON2
+       security_incoming_type = 
+               modest_serversecurity_picker_get_active_serversecurity (MODEST_SERVERSECURITY_PICKER (priv->security_view));
+#else
        security_incoming_type = 
                modest_serversecurity_combo_box_get_active_serversecurity (MODEST_SERVERSECURITY_COMBO_BOX (priv->security_view));
        security_incoming_type = 
                modest_serversecurity_combo_box_get_active_serversecurity (MODEST_SERVERSECURITY_COMBO_BOX (priv->security_view));
+#endif
 
        auth_active = 
                gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->auth_view));
 
        auth_active = 
                gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->auth_view));