From: Jose Dapena Paz Date: Wed, 28 Jan 2009 15:39:03 +0000 (+0000) Subject: Reactivate checking available security protocols (fixes NB#95740). X-Git-Tag: git_migration_finished~694 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=f26bfbe154a21ab3482010919af7d394c0d2dd9c Reactivate checking available security protocols (fixes NB#95740). pmo-trunk-r7337 --- diff --git a/src/hildon2/modest-easysetup-wizard-dialog.c b/src/hildon2/modest-easysetup-wizard-dialog.c index 3464b19..246c0cd 100644 --- a/src/hildon2/modest-easysetup-wizard-dialog.c +++ b/src/hildon2/modest-easysetup-wizard-dialog.c @@ -139,6 +139,8 @@ struct _ModestEasysetupWizardDialogPrivate static void save_to_settings (ModestEasysetupWizardDialog *self); static void real_enable_buttons (ModestWizardDialog *dialog, gboolean enable_next); +static GList* check_for_supported_auth_methods (ModestEasysetupWizardDialog* self); +static gboolean check_has_supported_auth_methods(ModestEasysetupWizardDialog* self); static gboolean on_delete_event (GtkWidget *widget, @@ -1697,9 +1699,9 @@ on_before_next (ModestWizardDialog *dialog, GtkWidget *current_page, GtkWidget * set_default_custom_servernames (self); /* Check if the server supports secure authentication */ -/* if (modest_security_options_view_auth_check (security_options)) */ -/* if (!check_has_supported_auth_methods (self)) */ -/* return FALSE; */ + if (modest_security_options_view_auth_check (MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security))) + if (!check_has_supported_auth_methods (self)) + return FALSE; gtk_widget_show (priv->outgoing_security); } @@ -2081,3 +2083,72 @@ save_to_settings (ModestEasysetupWizardDialog *self) g_free (provider_id); } +static GList* +check_for_supported_auth_methods (ModestEasysetupWizardDialog* self) +{ + GError *error = NULL; + ModestProtocolType protocol_type; + const gchar* hostname; + const gchar* username; + ModestProtocolType security_protocol_incoming_type; + ModestProtocolRegistry *registry; + int port_num; + GList *list_auth_methods; + ModestEasysetupWizardDialogPrivate *priv; + + priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self); + registry = modest_runtime_get_protocol_registry (); + protocol_type = modest_servertype_picker_get_active_servertype ( + MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker)); + hostname = gtk_entry_get_text(GTK_ENTRY(priv->entry_incomingserver)); + username = gtk_entry_get_text(GTK_ENTRY(priv->entry_user_username)); + security_protocol_incoming_type = modest_security_options_view_get_connection_protocol + (MODEST_SECURITY_OPTIONS_VIEW (priv->incoming_security)); + port_num = get_port_from_protocol(protocol_type, FALSE); + list_auth_methods = modest_utils_get_supported_secure_authentication_methods (protocol_type, hostname, port_num, + username, GTK_WINDOW (self), &error); + + if (list_auth_methods) { + /* TODO: Select the correct method */ + GList* list = NULL; + GList* method; + 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_has_tag (registry, auth_protocol_type, + MODEST_PROTOCOL_REGISTRY_SECURE_PROTOCOLS)) { + list = g_list_append(list, GINT_TO_POINTER(auth_protocol_type)); + } + } + + g_list_free(list_auth_methods); + + if (list) + return list; + } + + 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); + + return NULL; +} + +static gboolean +check_has_supported_auth_methods(ModestEasysetupWizardDialog* self) +{ + GList* methods = check_for_supported_auth_methods(self); + if (!methods) + { + return FALSE; + } + + g_list_free(methods); + return TRUE; +} + diff --git a/src/widgets/modest-security-options-view.c b/src/widgets/modest-security-options-view.c index 571a293..c56a2fb 100644 --- a/src/widgets/modest-security-options-view.c +++ b/src/widgets/modest-security-options-view.c @@ -348,75 +348,16 @@ 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) */ -/* { */ -/* 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, ¤t_settings); */ - -/* if (self->type == MODEST_SECURITY_OPTIONS_INCOMING) */ -/* server_settings = modest_account_settings_get_store_settings (¤t_settings); */ -/* else */ -/* server_settings = modest_account_settings_get_transport_settings (¤t_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); */ - -/* return retval; */ -/* } */ +ModestProtocolType +modest_security_options_view_get_connection_protocol (ModestSecurityOptionsView *self) +{ + ModestSecurityOptionsViewPrivate *priv; + + 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 modest_serversecurity_picker_get_active_serversecurity (MODEST_SERVERSECURITY_PICKER (priv->security_view)); +} static void modest_security_options_view_init (ModestSecurityOptionsView *self) diff --git a/src/widgets/modest-security-options-view.h b/src/widgets/modest-security-options-view.h index 1fc7121..377ac20 100644 --- a/src/widgets/modest-security-options-view.h +++ b/src/widgets/modest-security-options-view.h @@ -84,6 +84,8 @@ void modest_security_options_view_save_settings (ModestSecurityOptionsView* self void modest_security_options_view_set_server_type (ModestSecurityOptionsView* self, ModestProtocolType server_type); +ModestProtocolType modest_security_options_view_get_connection_protocol (ModestSecurityOptionsView *self); + gboolean modest_security_options_view_changed (ModestSecurityOptionsView* self, ModestAccountSettings *settings);