Security options view based in gtk
authorJose Dapena Paz <jdapena@igalia.com>
Tue, 17 Nov 2009 16:58:01 +0000 (17:58 +0100)
committerJose Dapena Paz <jdapena@igalia.com>
Tue, 17 Nov 2009 16:59:12 +0000 (17:59 +0100)
12 files changed:
src/hildon2/modest-default-account-settings-dialog.c
src/hildon2/modest-easysetup-wizard-dialog.c
src/hildon2/modest-maemo-security-options-view.c
src/widgets/Makefile.am
src/widgets/modest-gtk-security-options-view.c [new file with mode: 0644]
src/widgets/modest-gtk-security-options-view.h [new file with mode: 0644]
src/widgets/modest-secureauth-combo-box.h
src/widgets/modest-security-options-view.c
src/widgets/modest-toolkit-factory.c
src/widgets/modest-toolkit-factory.h
src/widgets/modest-validating-entry.c
src/widgets/modest-validating-entry.h

index 540ca69..d1fa2fb 100644 (file)
@@ -655,9 +655,10 @@ create_page_incoming (ModestDefaultAccountSettingsDialog *self,
 
        /* Incoming security widgets */
        priv->incoming_security =
-               modest_maemo_security_options_view_new (MODEST_SECURITY_OPTIONS_INCOMING,
-                                                       TRUE, security_title_sizegroup,
-                                                       security_value_sizegroup);
+               modest_toolkit_factory_create_security_options_view (modest_runtime_get_toolkit_factory (),
+                                                                    MODEST_SECURITY_OPTIONS_INCOMING,
+                                                                    TRUE, security_title_sizegroup,
+                                                                    security_value_sizegroup);
        gtk_box_pack_start (GTK_BOX (box), priv->incoming_security,
                            FALSE, FALSE, 0);
 
@@ -747,9 +748,10 @@ create_page_outgoing (ModestDefaultAccountSettingsDialog *self,
 
        /* Outgoing security widgets */
        priv->outgoing_security = 
-               modest_maemo_security_options_view_new (MODEST_SECURITY_OPTIONS_OUTGOING,
-                                                       TRUE, security_title_sizegroup,
-                                                       security_value_sizegroup);
+               modest_toolkit_factory_create_security_options_view (modest_runtime_get_toolkit_factory (),
+                                                                    MODEST_SECURITY_OPTIONS_OUTGOING,
+                                                                    TRUE, security_title_sizegroup,
+                                                                    security_value_sizegroup);
        gtk_box_pack_start (GTK_BOX (box), priv->outgoing_security, 
                            FALSE, FALSE, 0);
        gtk_widget_show (priv->outgoing_security);
index a6ef66f..377397c 100644 (file)
@@ -1038,9 +1038,9 @@ create_page_custom_incoming (ModestEasysetupWizardDialog *self)
 
        /* The secure connection widgets. These are only valid for
           protocols with security */
-       priv->incoming_security =
-               modest_maemo_security_options_view_new (MODEST_SECURITY_OPTIONS_INCOMING,
-                                                       FALSE, title_sizegroup, value_sizegroup);
+       priv->incoming_security = modest_toolkit_factory_create_security_options_view (modest_runtime_get_toolkit_factory (),
+                                                                                      MODEST_SECURITY_OPTIONS_INCOMING,
+                                                                                      FALSE, title_sizegroup, value_sizegroup);
        gtk_box_pack_start (GTK_BOX (box), priv->incoming_security,
                            FALSE, FALSE, 0);
        gtk_widget_show (priv->incoming_security);
@@ -1171,8 +1171,9 @@ create_page_custom_outgoing (ModestEasysetupWizardDialog *self)
        /* The secure connection widgets. These are only valid for
           protocols with security */
        priv->outgoing_security =
-               modest_maemo_security_options_view_new (MODEST_SECURITY_OPTIONS_OUTGOING,
-                                                       FALSE, title_sizegroup, value_sizegroup);
+               modest_toolkit_factory_create_security_options_view (modest_runtime_get_toolkit_factory (),
+                                                                    MODEST_SECURITY_OPTIONS_OUTGOING,
+                                                                    FALSE, title_sizegroup, value_sizegroup);
        gtk_box_pack_start (GTK_BOX (box), priv->outgoing_security,
                            FALSE, FALSE, 0);
        gtk_widget_show (priv->outgoing_security);
index 069372c..ef66fd8 100644 (file)
@@ -35,7 +35,6 @@
 #include "modest-account-protocol.h"
 #include "widgets/modest-ui-constants.h"
 #include "widgets/modest-validating-entry.h"
-#include "modest-serversecurity-picker.h"
 #include "modest-secureauth-picker.h"
 #include "modest-maemo-utils.h"
 #include "modest-hildon-includes.h"
@@ -73,7 +72,6 @@ on_security_changed (GtkWidget *widget,
                     ModestMaemoSecurityOptionsView *self)
 {
        ModestSecurityOptionsViewPrivate* ppriv;
-       ModestServersecurityPicker *picker;
        ModestProtocolType proto_type;
        ModestProtocolRegistry *proto_registry;
        gboolean is_secure;
@@ -81,8 +79,7 @@ on_security_changed (GtkWidget *widget,
        ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
 
        proto_registry = modest_runtime_get_protocol_registry ();
-       picker = MODEST_SERVERSECURITY_PICKER (ppriv->security_view);
-       proto_type = modest_serversecurity_picker_get_active_serversecurity (picker);
+       proto_type = modest_serversecurity_selector_get_active_serversecurity (ppriv->security_view);
 
        is_secure = modest_protocol_registry_protocol_type_has_tag (proto_registry, proto_type, 
                                                                    MODEST_PROTOCOL_REGISTRY_SECURE_PROTOCOLS);
@@ -98,7 +95,7 @@ on_security_changed (GtkWidget *widget,
 
        if (ppriv->full) {
                gint port_number = 
-                       modest_serversecurity_picker_get_active_serversecurity_port (MODEST_SERVERSECURITY_PICKER (ppriv->security_view));
+                       modest_serversecurity_selector_get_active_serversecurity_port (ppriv->security_view);
                
                if(port_number) {
                        modest_number_entry_set_value (ppriv->port_view,
@@ -148,26 +145,35 @@ create_incoming_security (ModestSecurityOptionsView* self,
 
        ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
 
-       /* Create widgets for incoming security */
-       ppriv->security_view = GTK_WIDGET (modest_serversecurity_picker_new (MODEST_EDITABLE_SIZE,
-                                                                            HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
-       modest_serversecurity_picker_fill (MODEST_SERVERSECURITY_PICKER (ppriv->security_view), 
-                                          modest_protocol_registry_get_pop_type_id ());
-       modest_maemo_utils_set_hbutton_layout (title_size_group,
-                                              value_size_group,
-                                              _("mcen_li_emailsetup_secure_connection"), 
-                                              ppriv->security_view);
-
        ppriv->auth_view = modest_toolkit_factory_create_check_button (modest_runtime_get_toolkit_factory (),
                                                                       _("mcen_li_emailsetup_secure_authentication"));
+       gtk_box_pack_start (GTK_BOX (self), ppriv->auth_view, FALSE, FALSE, 0);
 
-       /* Track changes in UI */
-       g_signal_connect (G_OBJECT (ppriv->security_view), "value-changed",
-                         G_CALLBACK (on_security_changed), self);
+       /* Create widgets for incoming security */
+       ppriv->security_view = modest_toolkit_factory_create_serversecurity_selector (modest_runtime_get_toolkit_factory ());
+       modest_serversecurity_selector_fill (ppriv->security_view,
+                                            modest_protocol_registry_get_pop_type_id ());
+       if (GTK_IS_COMBO_BOX (ppriv->security_view)) {
+               GtkWidget *captioned;
+
+               captioned = modest_maemo_utils_create_captioned (title_size_group, value_size_group,
+                                                                _("mcen_li_emailsetup_secure_connection"), FALSE,
+                                                                ppriv->security_view);
+               g_signal_connect (G_OBJECT (ppriv->security_view), "changed",
+                                 G_CALLBACK (on_security_changed), self);
+               gtk_box_pack_start (GTK_BOX (self), captioned, FALSE, FALSE, 0);
+               gtk_widget_show (captioned);
+       } else {
+               modest_maemo_utils_set_hbutton_layout (title_size_group,
+                                                      value_size_group,
+                                                      _("mcen_li_emailsetup_secure_connection"), 
+                                                      ppriv->security_view);
+               g_signal_connect (G_OBJECT (ppriv->security_view), "value-changed",
+                                 G_CALLBACK (on_security_changed), self);
+               gtk_box_pack_start (GTK_BOX (self), ppriv->security_view, FALSE, FALSE, 0);
+       }
 
        /* Pack into container & show */
-       gtk_box_pack_start (GTK_BOX (self), ppriv->auth_view, FALSE, FALSE, 0);
-       gtk_box_pack_start (GTK_BOX (self), ppriv->security_view, FALSE, FALSE, 0);
        gtk_widget_show (ppriv->security_view);
        gtk_widget_show (ppriv->auth_view);
 
@@ -267,20 +273,26 @@ create_outgoing_security (ModestSecurityOptionsView* self,
                          GtkSizeGroup *value_size_group)
 {
        ModestSecurityOptionsViewPrivate *ppriv;
-       GtkWidget *user_caption = NULL;
+       GtkWidget *user_caption = NULL, *security_caption = NULL;
        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_picker_new (MODEST_EDITABLE_SIZE,
-                                                                            HILDON_BUTTON_ARRANGEMENT_HORIZONTAL));
-       modest_serversecurity_picker_fill (MODEST_SERVERSECURITY_PICKER (ppriv->security_view), 
+       ppriv->security_view = modest_toolkit_factory_create_serversecurity (modest_runtime_get_toolkit_factory ());
+       modest_serversecurity_selector_fill (ppriv->security_view,
                                              MODEST_PROTOCOLS_TRANSPORT_SMTP);
-       modest_maemo_utils_set_hbutton_layout (title_size_group,
-                                              value_size_group,
-                                              _("mcen_li_emailsetup_secure_connection"), 
-                                              ppriv->security_view);
+       if (GTK_IS_COMBO_BOX (ppriv->security_view)) {
+               security_caption = modest_maemo_utils_create_captioned (title_size_group, value_size_group,
+                                                                _("mcen_li_emailsetup_secure_connection"), FALSE,
+                                                                ppriv->security_view);
+       } else {
+               modest_maemo_utils_set_hbutton_layout (title_size_group,
+                                                      value_size_group,
+                                                      _("mcen_li_emailsetup_secure_connection"), 
+                                                      ppriv->security_view);
+               security_caption = ppriv->security_view;
+       }
        
        /* The secure authentication widgets */
        ppriv->auth_view = GTK_WIDGET (modest_secureauth_picker_new (MODEST_EDITABLE_SIZE,
@@ -297,8 +309,10 @@ create_outgoing_security (ModestSecurityOptionsView* self,
                ppriv->user_entry = GTK_WIDGET (modest_validating_entry_new ());
 
                /* Auto-capitalization is the default, so let's turn it off: */
+#ifdef MODEST_TOOLKIT_HILDON2
                hildon_gtk_entry_set_input_mode (GTK_ENTRY (ppriv->user_entry), 
                                                 HILDON_GTK_INPUT_MODE_FULL);
+#endif
 
                user_label = g_strdup_printf("%s*", _("mail_fi_username"));
                user_caption = modest_maemo_utils_create_captioned_with_size_type (title_size_group,
@@ -321,9 +335,11 @@ create_outgoing_security (ModestSecurityOptionsView* self,
                ppriv->pwd_entry = modest_toolkit_factory_create_entry (modest_runtime_get_toolkit_factory ());
 
                /* Auto-capitalization is the default, so let's turn it off */
+#ifdef MODEST_TOOLKIT_HILDON2
                hildon_gtk_entry_set_input_mode (GTK_ENTRY (ppriv->pwd_entry),
                                                 HILDON_GTK_INPUT_MODE_FULL | 
                                                 HILDON_GTK_INPUT_MODE_INVISIBLE);
+#endif
                gtk_entry_set_visibility (GTK_ENTRY (ppriv->pwd_entry), FALSE);
 
                pwd_caption =
@@ -345,9 +361,14 @@ create_outgoing_security (ModestSecurityOptionsView* self,
                                                                            MODEST_EDITABLE_SIZE);
        }
 
-       /* Track changes in UI */       
-       g_signal_connect (G_OBJECT (ppriv->security_view), "value-changed",
-                         G_CALLBACK (on_security_changed), self);
+       /* Track changes in UI */
+       if (GTK_IS_COMBO_BOX (ppriv->security_view)) {
+               g_signal_connect (G_OBJECT (ppriv->security_view), "changed",
+                                 G_CALLBACK (on_security_changed), self);
+       } else {
+               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), "value-changed",
                                  G_CALLBACK (on_auth_changed), self);
@@ -360,8 +381,8 @@ create_outgoing_security (ModestSecurityOptionsView* self,
        }
 
        /* Initialize widgets */
-       modest_serversecurity_picker_set_active_serversecurity (
-               MODEST_SERVERSECURITY_PICKER (ppriv->security_view), 
+       modest_serversecurity_selector_set_active_serversecurity (
+               ppriv->security_view,
                MODEST_PROTOCOLS_CONNECTION_NONE);
        modest_secureauth_picker_set_active_secureauth (
           MODEST_SECUREAUTH_PICKER (ppriv->auth_view),
@@ -473,7 +494,7 @@ modest_maemo_security_options_view_save_settings (ModestSecurityOptionsView* sel
        if (ppriv->full) {
                server_port = modest_number_entry_get_value (ppriv->port_view);
        } else {
-               server_port = modest_serversecurity_picker_get_active_serversecurity_port (MODEST_SERVERSECURITY_PICKER (ppriv->security_view));
+               server_port = modest_serversecurity_selector_get_active_serversecurity_port (ppriv->security_view);
        }
 
        modest_server_account_settings_set_port (server_settings, server_port);
index 8a8986f..4aa30db 100644 (file)
@@ -63,6 +63,8 @@ libmodest_widgets_la_SOURCES=          \
        modest-global-settings-dialog.h \
        modest-gtkhtml-mime-part-view.c \
        modest-gtkhtml-mime-part-view.h \
+       modest-gtk-security-options-view.c \
+       modest-gtk-security-options-view.h \
        modest-hbox-cell-renderer.c    \
        modest-hbox-cell-renderer.h    \
        modest-vbox-cell-renderer.c    \
diff --git a/src/widgets/modest-gtk-security-options-view.c b/src/widgets/modest-gtk-security-options-view.c
new file mode 100644 (file)
index 0000000..aaabee8
--- /dev/null
@@ -0,0 +1,503 @@
+/* Copyright (c) 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-runtime.h"
+#include "modest-security-options-view-priv.h"
+#include "modest-gtk-security-options-view.h"
+#include "modest-text-utils.h"
+#include "modest-platform.h"
+#include "modest-account-protocol.h"
+#include "widgets/modest-ui-constants.h"
+#include "widgets/modest-validating-entry.h"
+#include "widgets/modest-secureauth-combo-box.h"
+
+#define PORT_MIN 1
+#define PORT_MAX 65535
+
+typedef struct _ModestGtkSecurityOptionsViewPrivate ModestGtkSecurityOptionsViewPrivate;
+struct _ModestGtkSecurityOptionsViewPrivate {
+       gboolean missing_data;
+};
+
+#define MODEST_GTK_SECURITY_OPTIONS_VIEW_GET_PRIVATE(o) \
+       (G_TYPE_INSTANCE_GET_PRIVATE((o), \
+                                    MODEST_TYPE_GTK_SECURITY_OPTIONS_VIEW, \
+                                    ModestGtkSecurityOptionsViewPrivate))
+
+static void modest_gtk_security_options_view_init (ModestGtkSecurityOptionsView *obj);
+static void modest_gtk_security_options_view_finalize (GObject *obj);
+static void modest_gtk_security_options_view_class_init (ModestGtkSecurityOptionsViewClass *klass);
+
+G_DEFINE_TYPE (ModestGtkSecurityOptionsView, 
+              modest_gtk_security_options_view, 
+              MODEST_TYPE_SECURITY_OPTIONS_VIEW);
+
+static void on_entry_changed (GtkEditable *editable, gpointer user_data);
+
+/* Tracks changes in the incoming security combo box */
+static void
+on_security_changed (GtkWidget *widget, 
+                    ModestGtkSecurityOptionsView *self)
+{
+       ModestSecurityOptionsViewPrivate* ppriv;
+       ModestProtocolType proto_type;
+       ModestProtocolRegistry *proto_registry;
+       gboolean is_secure;
+
+       ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+
+       proto_registry = modest_runtime_get_protocol_registry ();
+       proto_type = modest_serversecurity_selector_get_active_serversecurity (ppriv->security_view);
+
+       is_secure = modest_protocol_registry_protocol_type_has_tag (proto_registry, proto_type, 
+                                                                   MODEST_PROTOCOL_REGISTRY_SECURE_PROTOCOLS);
+
+       if (MODEST_SECURITY_OPTIONS_VIEW (self)->type == MODEST_SECURITY_OPTIONS_INCOMING) {
+               /* Activate and dim checkbutton if it's secure */
+               modest_togglable_set_active (ppriv->auth_view, 
+                                            is_secure);
+               gtk_widget_set_sensitive (ppriv->auth_view, !is_secure);
+       } else {
+
+       }
+
+       if (ppriv->full) {
+               gint port_number = 
+                       modest_serversecurity_selector_get_active_serversecurity_port (ppriv->security_view);
+               
+               if(port_number) {
+                       modest_number_entry_set_value (ppriv->port_view,
+                                                      port_number);
+               }
+       }
+}
+
+static void
+on_auth_changed (GtkWidget *widget, 
+                ModestGtkSecurityOptionsView *self)
+{
+       ModestSecurityOptionsViewPrivate* ppriv;
+       ModestSecureauthComboBox *combo;
+       ModestProtocolRegistry *protocol_registry;
+       ModestProtocolType auth_proto;
+       gboolean secureauth_used;
+       GtkWidget *user_caption, *pwd_caption;
+
+       ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+       protocol_registry = modest_runtime_get_protocol_registry ();
+       combo = MODEST_SECUREAUTH_COMBO_BOX (ppriv->auth_view);
+
+       auth_proto = modest_secureauth_combo_box_get_active_secureauth (combo);
+       secureauth_used = modest_protocol_registry_protocol_type_is_secure (protocol_registry, 
+                                                                           auth_proto);
+
+       /* Get captions, well dimm the whole widget */
+       user_caption = gtk_widget_get_parent (ppriv->user_entry);
+       pwd_caption = gtk_widget_get_parent (ppriv->pwd_entry);
+       
+       /* Enable / disable */
+       gtk_widget_set_sensitive (user_caption, secureauth_used);
+       gtk_widget_set_sensitive (pwd_caption, secureauth_used);
+
+       /* Check if mandatory data is missing */
+       on_entry_changed (GTK_EDITABLE (ppriv->user_entry), (gpointer) self);
+}
+
+static void
+create_incoming_security (ModestSecurityOptionsView* self,
+                         GtkSizeGroup *title_size_group, GtkSizeGroup *value_size_group)
+{
+       ModestSecurityOptionsViewPrivate *ppriv;
+       GtkWidget *combo_caption, *entry_caption = NULL;
+
+       ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+
+       /* Create widgets for incoming security */
+       ppriv->security_view = modest_toolkit_factory_create_serversecurity_selector (modest_runtime_get_toolkit_factory ());
+       combo_caption = modest_maemo_utils_create_captioned (title_size_group, value_size_group,
+                                                            _("mcen_li_emailsetup_secure_connection"), FALSE,
+                                                            ppriv->security_view);
+
+       if (ppriv->full) {              
+               ppriv->port_view = modest_toolkit_factory_create_number_entry (modest_runtime_get_toolkit_factory (), PORT_MIN, PORT_MAX);
+               entry_caption = modest_maemo_utils_create_captioned (title_size_group, value_size_group,
+                                                                    _("mcen_fi_emailsetup_port"), FALSE,
+                                                                    ppriv->port_view);
+       }
+
+       ppriv->auth_view = modest_toolkit_factory_create_check_button (modest_runtime_get_toolkit_factory (), 
+                                                                      _("mcen_li_emailsetup_secure_authentication"));
+
+       /* Track changes in UI */
+       if (GTK_IS_COMBO_BOX (ppriv->security_view)) {
+               g_signal_connect (G_OBJECT (ppriv->security_view), "changed",
+                                 G_CALLBACK (on_security_changed), self);
+       } else {
+               g_signal_connect (G_OBJECT (ppriv->security_view), "value-changed",
+                                 G_CALLBACK (on_security_changed), self);
+       }
+
+       /* Pack into container */
+       gtk_box_pack_start (GTK_BOX (self), combo_caption,
+                           FALSE, FALSE, MODEST_MARGIN_HALF);
+       if (ppriv->full)
+               gtk_box_pack_start (GTK_BOX (self), entry_caption, 
+                                   FALSE, FALSE, MODEST_MARGIN_HALF);
+       gtk_box_pack_start (GTK_BOX (self), ppriv->auth_view,
+                           FALSE, FALSE, MODEST_MARGIN_HALF);
+
+       /* Show widgets */
+       if (ppriv->full) {
+               gtk_widget_show (ppriv->port_view);
+               gtk_widget_show (entry_caption);
+       }
+       gtk_widget_show (ppriv->security_view);
+       gtk_widget_show (ppriv->auth_view);
+       gtk_widget_show (combo_caption);
+}
+
+static void
+on_entry_max (ModestValidatingEntry *self, 
+             gpointer user_data)
+{
+       modest_platform_information_banner (GTK_WIDGET (self), NULL, 
+                                           _CS("ckdg_ib_maximum_characters_reached"));
+}
+
+/*
+ * TODO: call this whenever the auth combo changes. If we set it
+ * explicitely at the beggining to a value then there is no need to
+ * call this handler directly at the beginning
+ */
+static void
+on_entry_changed (GtkEditable *editable, 
+                 gpointer user_data)
+{
+       ModestSecurityOptionsView* self;
+       ModestGtkSecurityOptionsViewPrivate *priv;
+       ModestSecurityOptionsViewPrivate *ppriv;
+       ModestProtocolType auth_proto;
+       ModestSecureauthComboBox *combo;
+       gboolean is_secure;
+       ModestProtocolRegistry *protocol_registry;
+
+       self = MODEST_SECURITY_OPTIONS_VIEW (user_data);
+       priv = MODEST_GTK_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+       ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+       protocol_registry = modest_runtime_get_protocol_registry ();
+
+       /* Outgoing username is mandatory if outgoing auth is secure */
+       combo = MODEST_SECUREAUTH_COMBO_BOX (ppriv->auth_view);
+       auth_proto = modest_secureauth_combo_box_get_active_secureauth (combo);
+       is_secure = modest_protocol_registry_protocol_type_is_secure (protocol_registry,
+                                                                     auth_proto);
+
+       if (is_secure &&
+           !g_ascii_strcasecmp (gtk_entry_get_text (GTK_ENTRY (ppriv->user_entry)), "")) {
+               priv->missing_data = TRUE;
+       } else {
+               priv->missing_data = FALSE;
+       }
+
+       /* Emit a signal to notify if mandatory data is missing */
+       g_signal_emit_by_name (G_OBJECT (self), "missing_mandatory_data",
+                              priv->missing_data, NULL);
+}
+
+static void
+create_outgoing_security (ModestSecurityOptionsView* self,
+                         GtkSizeGroup *title_size_group, GtkSizeGroup *value_size_group)
+{
+       ModestSecurityOptionsViewPrivate *ppriv;
+       GtkWidget *sec_caption, *auth_caption, *user_caption = NULL;
+       GtkWidget *pwd_caption = NULL, *port_caption = NULL;
+
+       ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+       
+       /* The secure connection widgets */
+       ppriv->security_view = modest_toolkit_factory_create_serversecurity_selector (modest_runtime_get_toolkit_factory ());
+       modest_serversecurity_selector_fill (ppriv->security_view,
+                                            MODEST_PROTOCOLS_TRANSPORT_SMTP);
+       sec_caption = modest_maemo_utils_create_captioned (title_size_group, value_size_group,
+                                                          _("mcen_li_emailsetup_secure_connection"), FALSE,
+                                                          ppriv->security_view);
+       
+       /* The secure authentication widgets */
+       ppriv->auth_view = GTK_WIDGET (modest_secureauth_combo_box_new ());
+       auth_caption = modest_maemo_utils_create_captioned (title_size_group, value_size_group,
+                                                           _("mcen_li_emailsetup_secure_authentication"), FALSE,
+                                                           ppriv->auth_view);
+
+       if (ppriv->full) {
+               gchar *user_label;
+
+               /* Username widgets */
+               ppriv->user_entry = GTK_WIDGET (modest_validating_entry_new ());
+
+               /* Auto-capitalization is the default, so let's turn it off: */
+               hildon_gtk_entry_set_input_mode (GTK_ENTRY (ppriv->user_entry), 
+                                                HILDON_GTK_INPUT_MODE_FULL);
+
+               user_label = g_strdup_printf("%s*", _("mail_fi_username"));
+               user_caption = modest_maemo_utils_create_captioned (title_size_group, value_size_group,
+                                                                   user_label, FALSE,
+                                                                   ppriv->user_entry);
+               g_free (user_label);
+       
+               /* Prevent the use of some characters. Limit the max
+                  length as well */
+               modest_validating_entry_set_unallowed_characters_whitespace (
+                    MODEST_VALIDATING_ENTRY (ppriv->user_entry));      
+               gtk_entry_set_max_length (GTK_ENTRY (ppriv->user_entry), 64);
+               modest_validating_entry_set_max_func (MODEST_VALIDATING_ENTRY (ppriv->user_entry),
+                                                     on_entry_max, self);
+               
+               /* Password widgets */
+               ppriv->pwd_entry = gtk_entry_new ();
+
+               /* Auto-capitalization is the default, so let's turn it off */
+#ifdef MODEST_TOOLKIT_HILDON2
+               hildon_gtk_entry_set_input_mode (GTK_ENTRY (ppriv->pwd_entry),
+                                                HILDON_GTK_INPUT_MODE_FULL | 
+                                                HILDON_GTK_INPUT_MODE_INVISIBLE);
+#endif
+               gtk_entry_set_visibility (GTK_ENTRY (ppriv->pwd_entry), FALSE);
+
+               pwd_caption = modest_maemo_utils_create_captioned (title_size_group, value_size_group,
+                                                                  _("mail_fi_password"), FALSE,
+                                                                  ppriv->pwd_entry);
+
+               ppriv->port_view = modest_toolkit_factory_create_number_entry (modest_runtime_get_toolkit_factory (),
+                                                                              PORT_MIN, PORT_MAX);
+               port_caption = modest_maemo_utils_create_captioned (title_size_group, value_size_group,
+                                                                   _("mcen_fi_emailsetup_port"), FALSE,
+                                                                   ppriv->port_view);
+       }
+
+       /* Track changes in UI */
+       if (GTK_IS_COMBO_BOX (ppriv->security_view)) {
+               g_signal_connect (G_OBJECT (ppriv->security_view), "value-changed",
+                                 G_CALLBACK (on_security_changed), self);
+       } else {
+               g_signal_connect (G_OBJECT (ppriv->security_view), "changed",
+                                 G_CALLBACK (on_security_changed), self);
+       }
+       if (ppriv->full) {
+               g_signal_connect (G_OBJECT (ppriv->auth_view), "changed",
+                                 G_CALLBACK (on_auth_changed), self);
+               g_signal_connect (G_OBJECT (ppriv->user_entry), "changed",
+                                 G_CALLBACK (on_entry_changed), self);
+       }
+
+       /* Initialize widgets */
+       modest_serversecurity_selector_set_active_serversecurity (
+               ppriv->security_view,
+               MODEST_PROTOCOLS_CONNECTION_NONE);
+       modest_secureauth_combo_box_set_active_secureauth (
+          MODEST_SECUREAUTH_COMBO_BOX (ppriv->auth_view),
+          MODEST_PROTOCOLS_AUTH_NONE);
+
+       /* Pack into container */
+       if (ppriv->full) {
+               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), 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), auth_caption, FALSE, FALSE, MODEST_MARGIN_HALF);
+       }
+
+       /* Show widgets */
+       if (ppriv->full) {
+               gtk_widget_show (ppriv->pwd_entry);
+               gtk_widget_show (ppriv->user_entry);
+               gtk_widget_show (ppriv->port_view);
+               gtk_widget_show (pwd_caption);
+               gtk_widget_show (user_caption);
+               gtk_widget_show (port_caption);
+       }
+       gtk_widget_show (ppriv->security_view);
+       gtk_widget_show (ppriv->auth_view);
+       gtk_widget_show (sec_caption);
+       gtk_widget_show (auth_caption);
+}
+
+GtkWidget *    
+modest_gtk_security_options_view_new  (ModestSecurityOptionsType type,
+                                      gboolean full,
+                                      GtkSizeGroup *title_size_group,
+                                      GtkSizeGroup *value_size_group)
+{
+       ModestSecurityOptionsView* self;
+       ModestSecurityOptionsViewPrivate *ppriv;
+
+       self = (ModestSecurityOptionsView *)
+               g_object_new (MODEST_TYPE_GTK_SECURITY_OPTIONS_VIEW, NULL);
+       ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+
+       ppriv->full = full;
+       self->type = type;
+       if (self->type == MODEST_SECURITY_OPTIONS_INCOMING)
+               create_incoming_security (self, title_size_group, value_size_group);
+       else
+               create_outgoing_security (self, title_size_group, value_size_group);
+
+       return (GtkWidget *) self;
+}
+
+static void 
+modest_gtk_security_options_view_load_settings (ModestSecurityOptionsView* self, 
+                                                 ModestAccountSettings *settings)
+{
+       ModestSecurityOptionsViewPrivate *ppriv;
+       ModestServerAccountSettings *server_settings;
+       gint port_number;
+
+       ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+
+       if (self->type == MODEST_SECURITY_OPTIONS_INCOMING)
+               server_settings = modest_account_settings_get_store_settings (settings);
+       else
+               server_settings = modest_account_settings_get_transport_settings (settings);
+       port_number = modest_server_account_settings_get_port (server_settings);
+
+       if (port_number == 0) {
+               /* Show the appropriate port number */
+               on_security_changed (ppriv->security_view, 
+                                    MODEST_GTK_SECURITY_OPTIONS_VIEW (self));
+       } else if (ppriv->full) {
+               /* Keep the user-entered port-number, or the
+                * already-appropriate automatic port number */
+               modest_number_entry_set_value (ppriv->port_view,
+                                              port_number);
+       }
+       /* Frees */
+       g_object_unref (server_settings);
+}
+
+static void
+modest_gtk_security_options_view_save_settings (ModestSecurityOptionsView* self, 
+                                                 ModestAccountSettings *settings)
+{
+       ModestServerAccountSettings *server_settings;
+       ModestSecurityOptionsViewPrivate *ppriv;
+       gint server_port;
+
+       ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+
+       if (self->type == MODEST_SECURITY_OPTIONS_INCOMING)
+               server_settings = modest_account_settings_get_store_settings (settings);
+       else
+               server_settings = modest_account_settings_get_transport_settings (settings);
+
+       if (ppriv->full) {
+               server_port = modest_number_entry_get_value (ppriv->port_view);
+       } else {
+               server_port = modest_serversecurity_selector_get_active_serversecurity_port (ppriv->security_view);
+       }
+
+       modest_server_account_settings_set_port (server_settings, server_port);
+
+       /* Frees */
+       g_object_unref (server_settings);
+}
+
+static gboolean 
+modest_gtk_security_options_view_changed (ModestSecurityOptionsView* self,
+                                         ModestAccountSettings *settings)
+{
+       ModestServerAccountSettings *server_settings;
+       ModestSecurityOptionsViewPrivate *ppriv;
+       gint server_port;
+
+       ppriv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+       
+       /* If we're not showing the port number then it never changes */
+       if (!ppriv->full)
+               return FALSE;
+
+       if (self->type == MODEST_SECURITY_OPTIONS_INCOMING)
+               server_settings = modest_account_settings_get_store_settings (settings);
+       else
+               server_settings = modest_account_settings_get_transport_settings (settings);
+       
+       server_port = 
+               modest_number_entry_get_value (ppriv->port_view);
+
+       /* Frees */
+       g_object_unref (server_settings);
+
+       if (server_port != ppriv->initial_state.port)
+               return TRUE;
+       else
+               return FALSE;
+}
+
+gboolean
+modest_security_options_view_has_missing_mandatory_data (ModestSecurityOptionsView* self)
+{
+       ModestGtkSecurityOptionsViewPrivate *priv;
+
+       priv = MODEST_GTK_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
+
+       return priv->missing_data;
+}
+
+static void
+modest_gtk_security_options_view_init (ModestGtkSecurityOptionsView *obj)
+{
+}
+
+static void
+modest_gtk_security_options_view_finalize (GObject *obj)
+{
+       G_OBJECT_CLASS (modest_gtk_security_options_view_parent_class)->finalize (obj);
+}
+
+
+static void     
+modest_gtk_security_options_view_class_init (ModestGtkSecurityOptionsViewClass *klass)
+{
+       GObjectClass *gobject_class = (GObjectClass*) klass;
+
+       modest_gtk_security_options_view_parent_class = g_type_class_peek_parent (klass);
+
+       g_type_class_add_private (gobject_class, sizeof (ModestGtkSecurityOptionsViewPrivate));
+       gobject_class->finalize = modest_gtk_security_options_view_finalize;
+
+       MODEST_SECURITY_OPTIONS_VIEW_CLASS (klass)->load_settings = 
+               modest_gtk_security_options_view_load_settings;
+       MODEST_SECURITY_OPTIONS_VIEW_CLASS (klass)->save_settings = 
+               modest_gtk_security_options_view_save_settings;
+       MODEST_SECURITY_OPTIONS_VIEW_CLASS (klass)->changed = 
+               modest_gtk_security_options_view_changed;
+}
diff --git a/src/widgets/modest-gtk-security-options-view.h b/src/widgets/modest-gtk-security-options-view.h
new file mode 100644 (file)
index 0000000..1c67bab
--- /dev/null
@@ -0,0 +1,69 @@
+/* Copyright (c) 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_GTK_SECURITY_OPTIONS_VIEW_H__
+#define __MODEST_GTK_SECURITY_OPTIONS_VIEW_H__
+
+#include <glib-object.h>
+#include "modest-security-options-view.h"
+#include <gtk/gtksizegroup.h>
+
+G_BEGIN_DECLS
+
+/* convenience macros */
+#define MODEST_TYPE_GTK_SECURITY_OPTIONS_VIEW             (modest_gtk_security_options_view_get_type())
+#define MODEST_GTK_SECURITY_OPTIONS_VIEW(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_GTK_SECURITY_OPTIONS_VIEW,ModestGtkSecurityOptionsView))
+#define MODEST_GTK_SECURITY_OPTIONS_VIEW_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_GTK_SECURITY_OPTIONS_VIEW,GObject))
+#define MODEST_IS_GTK_SECURITY_OPTIONS_VIEW(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_GTK_SECURITY_OPTIONS_VIEW))
+#define MODEST_IS_GTK_SECURITY_OPTIONS_VIEW_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_GTK_SECURITY_OPTIONS_VIEW))
+#define MODEST_GTK_SECURITY_OPTIONS_VIEW_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_GTK_SECURITY_OPTIONS_VIEW,ModestGtkSecurityOptionsViewClass))
+
+typedef struct _ModestGtkSecurityOptionsView      ModestGtkSecurityOptionsView;
+typedef struct _ModestGtkSecurityOptionsViewClass ModestGtkSecurityOptionsViewClass;
+
+struct _ModestGtkSecurityOptionsView {
+       ModestSecurityOptionsView parent;
+};
+
+struct _ModestGtkSecurityOptionsViewClass {
+       ModestSecurityOptionsViewClass parent_class;
+};
+
+/* member functions */
+GType        modest_gtk_security_options_view_get_type    (void) G_GNUC_CONST;
+
+GtkWidget* modest_gtk_security_options_view_new (ModestSecurityOptionsType type,
+                                                gboolean full,
+                                                GtkSizeGroup *title_size_group,
+                                                GtkSizeGroup *value_size_group);
+
+G_END_DECLS
+
+#endif /* __MODEST_GTK_SECURITY_OPTIONS_VIEW_H__ */
+
index 854ff7a..ed811b4 100644 (file)
@@ -46,11 +46,11 @@ G_BEGIN_DECLS
        (G_TYPE_CHECK_CLASS_CAST ((klass), \
        MODEST_TYPE_SECUREAUTH_COMBO_BOX, ModestSecureauthComboBoxClass))
 
-#define EASYSETUP_IS_SECUREAUTH_COMBO_BOX(obj) \
+#define MODEST_IS_SECUREAUTH_COMBO_BOX(obj) \
        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
        MODEST_TYPE_SECUREAUTH_COMBO_BOX))
 
-#define EASYSETUP_IS_SECUREAUTH_COMBO_BOX_CLASS(klass) \
+#define MODEST_IS_SECUREAUTH_COMBO_BOX_CLASS(klass) \
        (G_TYPE_CHECK_CLASS_TYPE ((klass), \
        MODEST_TYPE_SECUREAUTH_COMBO_BOX))
 
index c3cd853..a03cdfc 100644 (file)
 #include "modest-security-options-view.h"
 #include "modest-security-options-view-priv.h"
 #ifdef MODEST_TOOLKIT_HILDON2
-#include "modest-serversecurity-picker.h"
 #include "modest-secureauth-picker.h"
 #include <modest-hildon-includes.h>
-#else
-#include "widgets/modest-serversecurity-combo-box.h"
-#include "widgets/modest-secureauth-combo-box.h"
 #endif
+#include "widgets/modest-secureauth-combo-box.h"
 
 /* list my signals */
 enum {
@@ -77,11 +74,7 @@ modest_security_options_view_load_settings (ModestSecurityOptionsView* self,
 
        /* Update UI */
        modest_security_options_view_set_server_type (self, server_proto);
-#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
+       modest_serversecurity_selector_set_active_serversecurity (priv->security_view, secure_protocol);
 
 /*             update_incoming_server_title (dialog, dialog->incoming_protocol); */
 
@@ -108,13 +101,15 @@ modest_security_options_view_load_settings (ModestSecurityOptionsView* self,
                        modest_togglable_set_active (priv->auth_view,
                                                     TRUE);
        } else {
+               if (MODEST_IS_SECUREAUTH_COMBO_BOX (priv->auth_view)) {
+                       modest_secureauth_combo_box_set_active_secureauth (
+                               MODEST_SECUREAUTH_COMBO_BOX (priv->auth_view), secure_auth);
+               } else {
 #ifdef MODEST_TOOLKIT_HILDON2
-               modest_secureauth_picker_set_active_secureauth (
-                  MODEST_SECUREAUTH_PICKER (priv->auth_view), secure_auth);
-#else
-               modest_secureauth_combo_box_set_active_secureauth (
-                  MODEST_SECUREAUTH_COMBO_BOX (priv->auth_view), secure_auth);
+                       modest_secureauth_picker_set_active_secureauth (
+                               MODEST_SECUREAUTH_PICKER (priv->auth_view), secure_auth);
 #endif
+               }
        }
 
        MODEST_SECURITY_OPTIONS_VIEW_GET_CLASS (self)->load_settings (self, settings);
@@ -145,11 +140,7 @@ modest_security_options_view_save_settings (ModestSecurityOptionsView* self,
        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));
-#endif
+       security_proto = modest_serversecurity_selector_get_active_serversecurity (priv->security_view);
 
        if (self->type == MODEST_SECURITY_OPTIONS_INCOMING) {
                if (modest_togglable_get_active (priv->auth_view)) {
@@ -163,13 +154,15 @@ modest_security_options_view_save_settings (ModestSecurityOptionsView* self,
                        }
                }
        } else {
+               if  (MODEST_IS_SECUREAUTH_COMBO_BOX (priv->auth_view)) {
+                       auth_protocol = modest_secureauth_combo_box_get_active_secureauth (
+                               MODEST_SECUREAUTH_COMBO_BOX (priv->auth_view));
+               } else {
 #ifdef MODEST_TOOLKIT_HILDON2
-               auth_protocol = modest_secureauth_picker_get_active_secureauth (
-                       MODEST_SECUREAUTH_PICKER (priv->auth_view));
-#else
-               auth_protocol = modest_secureauth_combo_box_get_active_secureauth (
-                       MODEST_SECUREAUTH_COMBO_BOX (priv->auth_view));
+                       auth_protocol = modest_secureauth_picker_get_active_secureauth (
+                               MODEST_SECUREAUTH_PICKER (priv->auth_view));
 #endif
+               }
        }
 
        /* Save settings */
@@ -202,15 +195,9 @@ modest_security_options_view_set_server_type (ModestSecurityOptionsView* self,
        ModestSecurityOptionsViewPrivate *priv;
        priv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
 
-#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);
-#endif
+       modest_serversecurity_selector_fill (priv->security_view, server_type);
+       modest_serversecurity_selector_set_active_serversecurity (priv->security_view,
+                                                                 MODEST_PROTOCOLS_CONNECTION_NONE);
 }
 
 static void
@@ -224,25 +211,20 @@ get_current_state (ModestSecurityOptionsView* self,
        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));
+               modest_serversecurity_selector_get_active_serversecurity (priv->security_view);
        state->port =
-               modest_serversecurity_picker_get_active_serversecurity_port (MODEST_SERVERSECURITY_PICKER (priv->security_view));
-#else
-       state->security =
-               modest_serversecurity_combo_box_get_active_serversecurity (MODEST_SERVERSECURITY_COMBO_BOX (priv->security_view));
-       state->port =
-               modest_serversecurity_combo_box_get_active_serversecurity_port (MODEST_SERVERSECURITY_COMBO_BOX (priv->security_view));
-#endif
+               modest_serversecurity_selector_get_active_serversecurity_port (priv->security_view);
 
        /* Get auth */
        if (self->type == MODEST_SECURITY_OPTIONS_OUTGOING) {
+               if (MODEST_IS_SECUREAUTH_COMBO_BOX (priv->auth_view)) {
+                       state->auth = modest_secureauth_combo_box_get_active_secureauth (MODEST_SECUREAUTH_COMBO_BOX (priv->auth_view));
+               } else {
 #ifdef MODEST_TOOLKIT_HILDON2
-               state->auth = modest_secureauth_picker_get_active_secureauth (MODEST_SECUREAUTH_PICKER (priv->auth_view));
-#else
-               state->auth = modest_secureauth_combo_box_get_active_secureauth (MODEST_SECUREAUTH_COMBO_BOX (priv->auth_view));
+                       state->auth = modest_secureauth_picker_get_active_secureauth (MODEST_SECUREAUTH_PICKER (priv->auth_view));
 #endif
+               }
                if (priv->full) {
                }
        } else {
@@ -313,13 +295,8 @@ modest_security_options_view_auth_check (ModestSecurityOptionsView* self)
        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));
-#endif
+               modest_serversecurity_selector_get_active_serversecurity (priv->security_view);
 
        auth_active = 
                modest_togglable_get_active (priv->auth_view);
@@ -342,11 +319,7 @@ modest_security_options_view_get_connection_protocol (ModestSecurityOptionsView
        g_return_val_if_fail (MODEST_IS_SECURITY_OPTIONS_VIEW (self), MODEST_PROTOCOL_REGISTRY_TYPE_INVALID);
        priv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
 
-#ifdef MODEST_TOOLKIT_HILDON2
-       return modest_serversecurity_picker_get_active_serversecurity (MODEST_SERVERSECURITY_PICKER (priv->security_view));
-#else
-       return modest_serversecurity_combo_box_get_active_serversecurity (MODEST_SERVERSECURITY_COMBO_BOX (priv->security_view));
-#endif
+       return modest_serversecurity_selector_get_active_serversecurity (priv->security_view);
 }
 
 static void 
index 506a738..f83bd32 100644 (file)
@@ -44,7 +44,8 @@
 #define USE_GTK_ENTRY
 #define USE_GTK_FILE_CHOOSER
 #define USE_COUNTRY_COMBOBOX
-#define USE_SERVERSECURITY_PICKER
+#define USE_SERVERSECURITY_COMBOBOX
+#define USE_GTK_SECURITY_OPTIONS_VIEW
 #endif
 
 #ifdef USE_SCROLLED_WINDOW
 #include <modest-serversecurity-picker.h>
 #endif
 
+#ifdef USE_GTK_SECURITY_OPTIONS_VIEW
+#include <modest-gtk-security-options-view.h>
+#else
+#include <modest-maemo-security-options-view.h>
+#endif
+
 static void modest_toolkit_factory_class_init (ModestToolkitFactoryClass *klass);
 static void modest_toolkit_factory_init (ModestToolkitFactory *self);
 
@@ -670,3 +677,19 @@ modest_serversecurity_selector_get_active_serversecurity_port (GtkWidget *combob
        return modest_serversecurity_picker_get_active_serversecurity_port (MODEST_SERVERSECURITY_PICKER (combobox));
 #endif
 }
+
+GtkWidget *
+modest_toolkit_factory_create_security_options_view (ModestToolkitFactory *self, 
+                                                    ModestSecurityOptionsType type,
+                                                    gboolean full, 
+                                                    GtkSizeGroup *title_size_group, 
+                                                    GtkSizeGroup *value_size_group)
+{
+       GtkWidget *result;
+#ifdef USE_GTK_SECURITY_OPTIONS_VIEW
+       result = GTK_WIDGET (modest_gtk_security_options_view_new (type, full, title_size_group, value_size_group));
+#else
+       result = GTK_WIDGET (modest_maemo_security_options_view_new (type, full, title_size_group, value_size_group));
+#endif
+       return result;
+}
index b1cbabb..b263347 100644 (file)
@@ -4,6 +4,7 @@
 #include <glib-object.h>
 #include <gtk/gtk.h>
 #include <modest-presets.h>
+#include <widgets/modest-security-options-view.h>
 
 G_BEGIN_DECLS
 
@@ -48,6 +49,8 @@ struct                                          _ModestToolkitFactoryClass
        GtkWidget * (*create_provider_selector) (ModestToolkitFactory *self);
        GtkWidget * (*create_servertype_selector) (ModestToolkitFactory *self, gboolean filter_providers);
        GtkWidget * (*create_serversecurity_selector) (ModestToolkitFactory *self);
+       GtkWidget * (*create_security_options_view) (ModestToolkitFactory *self, ModestSecurityOptionsType type,
+                                                    gboolean full, GtkSizeGroup *title_size_group, GtkSizeGroup *value_size_group);
 };
 
 struct                                          _ModestToolkitFactory
@@ -96,6 +99,10 @@ modest_toolkit_factory_create_servertype_selector (ModestToolkitFactory *self, g
 GtkWidget *
 modest_toolkit_factory_create_serversecurity_selector (ModestToolkitFactory *self);
 
+GtkWidget *
+modest_toolkit_factory_create_security_options_view (ModestToolkitFactory *self, ModestSecurityOptionsType type,
+                                                    gboolean full, GtkSizeGroup *title_size_group, GtkSizeGroup *value_size_group);
+
 gboolean
 modest_togglable_get_active (GtkWidget *widget);
 
index 22c6c56..6d34d6c 100644 (file)
 #include <config.h>
 #endif
 
-#ifndef MODEST_TOOLKIT_HILDON2
-#define USE_GTK_ENTRY
-#endif
-
 #ifdef USE_GTK_ENTRY
 G_DEFINE_TYPE (ModestValidatingEntry, modest_validating_entry, GTK_TYPE_ENTRY);
 #else
@@ -240,7 +236,7 @@ modest_validating_entry_new (void)
        
        entry = g_object_new (MODEST_TYPE_VALIDATING_ENTRY, NULL);
 
-#ifndef MODEST_TOOLKIT_HILDON2
+#ifdef MODEST_TOOLKIT_HILDON2
        hildon_gtk_widget_set_theme_size (GTK_WIDGET (entry), MODEST_EDITABLE_SIZE);
 #endif
 
index 5ce77f3..7fb0a41 100644 (file)
 #ifndef _MODEST_VALIDATING_ENTRY
 #define _MODEST_VALIDATING_ENTRY
 
-#ifdef MODEST_TOOLKIT_HILDON2
+#ifndef MODEST_TOOLKIT_HILDON2
+#define USE_GTK_ENTRY
+#endif
+
+#ifndef USE_GTK_ENTRY
 #include <hildon/hildon-entry.h>
 #else
 #include <gtk/gtk.h>
@@ -61,7 +65,7 @@ G_BEGIN_DECLS
        MODEST_TYPE_VALIDATING_ENTRY, ModestValidatingEntryClass))
 
 typedef struct {
-#ifdef MODEST_TOOLKIT_HILDON2
+#ifndef USE_GTK_ENTRY
        HildonEntry parent;
 #else
        GtkEntry parent;
@@ -69,7 +73,7 @@ typedef struct {
 } ModestValidatingEntry;
 
 typedef struct {
-#ifdef MODEST_TOOLKIT_HILDON2
+#ifndef USE_GTK_ENTRY
        HildonEntryClass parent_class;
 #else
        GtkEntryClass parent_class;