Modified webpage: now tinymail repository is in gitorious.
[modest] / src / widgets / modest-security-options-view.c
index 61566e1..7e59adf 100644 (file)
  */
 
 #include <string.h>
-#include <gtk/gtkvbox.h>
+#include <gtk/gtk.h>
 #include "modest-utils.h"
 #include "modest-runtime.h"
 #include "modest-platform.h"
 #include "modest-security-options-view.h"
 #include "modest-security-options-view-priv.h"
-#include "widgets/modest-serversecurity-combo-box.h"
-#include "widgets/modest-secureauth-combo-box.h"
+#ifdef MODEST_TOOLKIT_HILDON2
+#include <modest-hildon-includes.h>
+#endif
 
 /* list my signals */
 enum {
@@ -52,7 +53,6 @@ modest_security_options_view_load_settings (ModestSecurityOptionsView* self,
        ModestSecurityOptionsViewPrivate *priv;
        ModestServerAccountSettings *server_settings;
        ModestProtocolType server_proto, secure_protocol, secure_auth;
-       ModestServersecurityComboBox *combo;
 
        priv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
 
@@ -71,9 +71,8 @@ modest_security_options_view_load_settings (ModestSecurityOptionsView* self,
        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_serversecurity_combo_box_set_active_serversecurity (combo, secure_protocol);
+       modest_serversecurity_selector_set_active_serversecurity (priv->security_view, secure_protocol);
 
 /*             update_incoming_server_title (dialog, dialog->incoming_protocol); */
 
@@ -97,11 +96,11 @@ modest_security_options_view_load_settings (ModestSecurityOptionsView* self,
                /* Active the authentication checkbox */
                if (modest_protocol_registry_protocol_type_is_secure (modest_runtime_get_protocol_registry (), 
                                                                      secure_auth))
-                       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->auth_view),
-                                                     TRUE);
+                       modest_togglable_set_active (priv->auth_view,
+                                                    TRUE);
        } else {
-               modest_secureauth_combo_box_set_active_secureauth (
-                  MODEST_SECUREAUTH_COMBO_BOX (priv->auth_view), secure_auth);
+               modest_secureauth_selector_set_active_secureauth (
+                       priv->auth_view, secure_auth);
        }
 
        MODEST_SECURITY_OPTIONS_VIEW_GET_CLASS (self)->load_settings (self, settings);
@@ -132,10 +131,10 @@ modest_security_options_view_save_settings (ModestSecurityOptionsView* self,
        auth_protocol = MODEST_PROTOCOLS_AUTH_NONE;
 
        /* Get data */
-       security_proto = modest_serversecurity_combo_box_get_active_serversecurity (MODEST_SERVERSECURITY_COMBO_BOX (priv->security_view));
+       security_proto = modest_serversecurity_selector_get_active_serversecurity (priv->security_view);
 
        if (self->type == MODEST_SECURITY_OPTIONS_INCOMING) {
-               if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->auth_view))) {
+               if (modest_togglable_get_active (priv->auth_view)) {
                        if (!modest_protocol_registry_protocol_type_is_secure (proto_registry,
                                                                               security_proto)) {
                                /* TODO */
@@ -146,8 +145,7 @@ modest_security_options_view_save_settings (ModestSecurityOptionsView* self,
                        }
                }
        } else {
-               auth_protocol = modest_secureauth_combo_box_get_active_secureauth (
-                          MODEST_SECUREAUTH_COMBO_BOX (priv->auth_view));
+               auth_protocol = modest_secureauth_selector_get_active_secureauth (priv->auth_view);
        }
 
        /* Save settings */
@@ -178,14 +176,11 @@ modest_security_options_view_set_server_type (ModestSecurityOptionsView* self,
                                              ModestProtocolType server_type)
 {
        ModestSecurityOptionsViewPrivate *priv;
-       ModestServersecurityComboBox *combo;
-
        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,
-                                                                  MODEST_PROTOCOLS_CONNECTION_NONE);
+
+       modest_serversecurity_selector_fill (priv->security_view, server_type);
+       modest_serversecurity_selector_set_active_serversecurity (priv->security_view,
+                                                                 MODEST_PROTOCOLS_CONNECTION_NONE);
 }
 
 static void
@@ -199,16 +194,18 @@ get_current_state (ModestSecurityOptionsView* self,
        proto_registry = modest_runtime_get_protocol_registry ();
 
        /* Get security */
-       state->security = 
-               modest_serversecurity_combo_box_get_active_serversecurity (MODEST_SERVERSECURITY_COMBO_BOX (priv->security_view));
+       state->security =
+               modest_serversecurity_selector_get_active_serversecurity (priv->security_view);
+       state->port =
+               modest_serversecurity_selector_get_active_serversecurity_port (priv->security_view);
 
        /* Get auth */
        if (self->type == MODEST_SECURITY_OPTIONS_OUTGOING) {
-               state->auth = modest_secureauth_combo_box_get_active_secureauth (MODEST_SECUREAUTH_COMBO_BOX (priv->auth_view));
+               state->auth = modest_secureauth_selector_get_active_secureauth (priv->auth_view);
                if (priv->full) {
                }
        } else {
-               if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->auth_view)))
+               if (modest_togglable_get_active (priv->auth_view))
                        state->auth = priv->initial_state.auth;
                else
                        state->auth = MODEST_PROTOCOLS_AUTH_NONE;
@@ -276,10 +273,10 @@ modest_security_options_view_auth_check (ModestSecurityOptionsView* self)
 
        /* Check if the server supports secure authentication */
        security_incoming_type = 
-               modest_serversecurity_combo_box_get_active_serversecurity (MODEST_SERVERSECURITY_COMBO_BOX (priv->security_view));
+               modest_serversecurity_selector_get_active_serversecurity (priv->security_view);
 
        auth_active = 
-               gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->auth_view));
+               modest_togglable_get_active (priv->auth_view);
        is_secure = 
                modest_protocol_registry_protocol_type_has_tag (protocol_registry, 
                                                                security_incoming_type, 
@@ -291,74 +288,15 @@ modest_security_options_view_auth_check (ModestSecurityOptionsView* self)
                return FALSE;
 }
 
-GList* 
-modest_security_options_view_get_supported_auth_methods (ModestSecurityOptionsView *self,
-                                                        const gchar *hostname,
-                                                        const gchar *username,
-                                                        ModestProtocolType server_type)
+ModestProtocolType 
+modest_security_options_view_get_connection_protocol (ModestSecurityOptionsView *self)
 {
-       GtkWindow *window;
-       GError *error = NULL;
-       GList *list_auth_methods, *retval = NULL;
        ModestSecurityOptionsViewPrivate *priv;
-       ModestAccountSettings current_settings;
-       ModestServerAccountSettings *server_settings;
-       
-       priv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
-
-       window = GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (self), GTK_TYPE_WINDOW));
-
-       /* Get current settings */
-       modest_security_options_view_save_settings (self, &current_settings);
-
-       if (self->type == MODEST_SECURITY_OPTIONS_INCOMING)
-               server_settings = modest_account_settings_get_store_settings (&current_settings);
-       else
-               server_settings = modest_account_settings_get_transport_settings (&current_settings);
-
-       list_auth_methods =
-               modest_utils_get_supported_secure_authentication_methods (server_type,
-                                                                         hostname,
-                                                                         modest_server_account_settings_get_port (server_settings),
-                                                                         username,
-                                                                         window,
-                                                                         &error);
-
-       if (list_auth_methods) {
-               GList *list = NULL, *method = NULL;
-               ModestProtocolRegistry *registry = modest_runtime_get_protocol_registry ();
-
-               for (method = list_auth_methods; method != NULL; method = g_list_next(method)) {
-                       ModestProtocolType auth_protocol_type = 
-                               (ModestProtocolType) (GPOINTER_TO_INT(method->data));
-                       if (modest_protocol_registry_protocol_type_is_secure (registry, 
-                                                                             auth_protocol_type)) {
-                               list = g_list_append(list, GINT_TO_POINTER(auth_protocol_type));
-                       }
-               }
-               g_list_free(list_auth_methods);
-               if (list) {
-                       retval = list;
-                       goto end;
-               }
-       }
 
-       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);
-
- end:
-       /* Frees */
-       g_object_unref (server_settings);
+       g_return_val_if_fail (MODEST_IS_SECURITY_OPTIONS_VIEW (self), MODEST_PROTOCOL_REGISTRY_TYPE_INVALID);
+       priv = MODEST_SECURITY_OPTIONS_VIEW_GET_PRIVATE (self);
 
-       return retval;
+       return modest_serversecurity_selector_get_active_serversecurity (priv->security_view);
 }
 
 static void 
@@ -373,6 +311,8 @@ modest_security_options_view_init (ModestSecurityOptionsView *self)
        priv->auth_view = NULL;
        priv->user_entry = NULL;
        priv->pwd_entry = NULL;
+       priv->full = FALSE;
+       priv->changed = FALSE;
 }
 
 static void