2007-06-05 Johannes Schmid <johannes.schmid@openismus.com>
authorJohannes Schmid <johannes.schmid@openismus.com>
Tue, 5 Jun 2007 18:41:59 +0000 (18:41 +0000)
committerJohannes Schmid <johannes.schmid@openismus.com>
Tue, 5 Jun 2007 18:41:59 +0000 (18:41 +0000)
* src/maemo/easysetup/modest-easysetup-wizard.c:
(get_serverport_incoming), (on_before_next), (create_account):
* src/maemo/modest-account-settings-dialog.c:
(modest_account_settings_dialog_set_account_name):
* src/maemo/modest-maemo-utils.c:
(on_camel_account_get_supported_secure_authentication_status),
(on_camel_account_get_supported_secure_authentication),
(on_secure_auth_cancel),
(modest_maemo_utils_get_supported_secure_authentication_methods):

Implemented security authentication for settings and easysetup.

pmo-trunk-r2072

ChangeLog
ChangeLog2
src/maemo/easysetup/modest-easysetup-wizard.c
src/maemo/modest-account-settings-dialog.c
src/maemo/modest-maemo-utils.c

index acb6b92..69aec3c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1 +1,15 @@
+2007-06-05  Johannes Schmid,,,  <jhs@idefix>
+
+       reviewed by: <delete if not using a buddy>
+
+       * src/maemo/easysetup/modest-easysetup-wizard.c:
+       (get_serverport_incoming), (on_before_next), (create_account):
+       * src/maemo/modest-account-settings-dialog.c:
+       (modest_account_settings_dialog_set_account_name):
+       * src/maemo/modest-maemo-utils.c:
+       (on_camel_account_get_supported_secure_authentication_status),
+       (on_camel_account_get_supported_secure_authentication),
+       (on_secure_auth_cancel),
+       (modest_maemo_utils_get_supported_secure_authentication_methods):
+
 * please check the svn log instead
index 5bc678b..6b98590 100644 (file)
@@ -1,3 +1,17 @@
+2007-06-05  Johannes Schmid <johannes.schmid@openismus.com>
+
+       * src/maemo/easysetup/modest-easysetup-wizard.c:
+       (get_serverport_incoming), (on_before_next), (create_account):
+       * src/maemo/modest-account-settings-dialog.c:
+       (modest_account_settings_dialog_set_account_name):
+       * src/maemo/modest-maemo-utils.c:
+       (on_camel_account_get_supported_secure_authentication_status),
+       (on_camel_account_get_supported_secure_authentication),
+       (on_secure_auth_cancel),
+       (modest_maemo_utils_get_supported_secure_authentication_methods):
+
+       Implemented security authentication for settings and easysetup.
+
 2007-06-05  Murray Cumming  <murrayc@murrayc.com>
 
        * src/maemo/modest-main-window.c: (create_details_widget):
index f4ae2ca..2974dba 100644 (file)
@@ -145,6 +145,21 @@ set_default_custom_servernames(ModestEasysetupWizardDialog *dialog);
 
 static void on_combo_servertype_changed(GtkComboBox *combobox, gpointer user_data);
 
+static gint get_serverport_incoming(ModestPresetsServerType servertype_incoming,
+                                                                                                                                               ModestPresetsSecurity security_incoming)
+{
+       int serverport_incoming = 0;
+               /* We don't check for SMTP here as that is impossible for an incoming server. */
+               if (servertype_incoming == MODEST_PRESETS_SERVER_TYPE_IMAP) {
+                       serverport_incoming =
+                               (security_incoming & MODEST_PRESETS_SECURITY_SECURE_INCOMING_ALTERNATE_PORT) ? 993 : 143; 
+               } else if (servertype_incoming == MODEST_PRESETS_SERVER_TYPE_POP) {
+                       serverport_incoming =
+                               (security_incoming & MODEST_PRESETS_SECURITY_SECURE_INCOMING_ALTERNATE_PORT) ? 995 : 110; 
+               }
+       return serverport_incoming;
+}
+
 static void
 invoke_enable_buttons_vfunc (ModestEasysetupWizardDialog *wizard_dialog)
 {
@@ -1225,18 +1240,19 @@ on_before_next (ModestWizardDialog *dialog, GtkWidget *current_page, GtkWidget *
     /* Check if the server support secure authentication */
     if (gtk_toggle_button_get_active (
                        GTK_TOGGLE_BUTTON (account_wizard->checkbox_incoming_auth))) {
-#if 0
                                const ModestTransportStoreProtocol protocol = 
           easysetup_servertype_combo_box_get_active_servertype (
                                                                 EASYSETUP_SERVERTYPE_COMBO_BOX (account_wizard->combo_incoming_servertype));
         const gchar* hostname = gtk_entry_get_text(GTK_ENTRY(account_wizard->entry_incomingserver));
-        /* FIXME: Get correct port */
-
-        int port_num = 22; 
+                               const ModestConnectionProtocol protocol_security_incoming = 
+                                       modest_serversecurity_combo_box_get_active_serversecurity (
+                                                                                                                                                                                                                                                                                MODEST_SERVERSECURITY_COMBO_BOX (
+                                                                                                                                                                                                                                                                                                                                                                                                                       account_wizard->combo_incoming_security));
+        int port_num = get_serverport_incoming(protocol, protocol_security_incoming); 
         GList *list_auth_methods = 
           modest_maemo_utils_get_supported_secure_authentication_methods (
                                                                       protocol, 
-                                                                      hostname, port_num, GTK_WINDOW (dialog));        
+                                                                      hostname, port_num, GTK_WINDOW (account_wizard));        
         if (list_auth_methods) {
           /* TODO: Select the correct method */
           g_list_free (list_auth_methods);
@@ -1250,7 +1266,6 @@ on_before_next (ModestWizardDialog *dialog, GtkWidget *current_page, GtkWidget *
           gtk_widget_destroy(error_dialog);
           return FALSE;
         }
-#endif
                 }
        }
        
@@ -1435,18 +1450,15 @@ create_account (ModestEasysetupWizardDialog *self, gboolean enabled)
                                                                                                   TRUE /* incoming */);
 
                g_warning ("security incoming: %x", security_incoming);
-               
+                       
                /* We don't check for SMTP here as that is impossible for an incoming server. */
                if (servertype_incoming == MODEST_PRESETS_SERVER_TYPE_IMAP) {
                        protocol_incoming = MODEST_PROTOCOL_STORE_IMAP;
-                       serverport_incoming =
-                               (security_incoming & MODEST_PRESETS_SECURITY_SECURE_INCOMING_ALTERNATE_PORT) ? 993 : 143; 
                } else if (servertype_incoming == MODEST_PRESETS_SERVER_TYPE_POP) {
-                       protocol_incoming = MODEST_PROTOCOL_STORE_POP;
-                       serverport_incoming =
-                               (security_incoming & MODEST_PRESETS_SECURITY_SECURE_INCOMING_ALTERNATE_PORT) ? 995 : 110; 
+                       protocol_incoming = MODEST_PROTOCOL_STORE_POP; 
                }
-                               
+               serverport_incoming = get_serverport_incoming(servertype_incoming, security_incoming);
+               
                if (security_incoming & MODEST_PRESETS_SECURITY_SECURE_INCOMING)
                        protocol_security_incoming = MODEST_PROTOCOL_CONNECTION_SSL; /* TODO: Is this what we want? */
                
index fd4ed07..d71e2d6 100644 (file)
@@ -1061,6 +1061,8 @@ void modest_account_settings_dialog_set_account_name (ModestAccountSettingsDialo
         * If secure authentication is checked, require one of the secure methods during connection: SSL, TLS, CRAM-MD5 etc. 
                 * TODO: Do we need to discover which of these (SSL, TLS, CRAM-MD5) is supported?
          */
+               /* Is AUTH_PASSWORD a secure method? We accept AUTH_PASSWORD while
+               saving so we should accept it here, too */
                const ModestAuthProtocol secure_auth = modest_server_account_get_secure_auth(
                        dialog->account_manager, incoming_account->account_name);
                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (dialog->checkbox_incoming_auth), 
index 7754685..6c8b0ae 100644 (file)
@@ -255,20 +255,16 @@ modest_maemo_utils_create_temp_stream (const gchar *extension, gchar **path)
 typedef struct 
 {
        gboolean finished;
+       gboolean cancel;
        GList *result;
-  GtkWidget* banner;
+       GtkWidget* dialog;
+  GtkWidget* progress;
 } ModestGetSupportedAuthInfo;
 
-#if 0
 static void on_camel_account_get_supported_secure_authentication_status (
        GObject *self, TnyStatus *status, gpointer user_data)
 {
-
-       printf ("DEBUG: %s.\n", __FUNCTION__);
-  ModestGetSupportedAuthInfo* info = (ModestGetSupportedAuthInfo*) user_data;
-  GDK_THREADS_ENTER();
-  hildon_banner_set_fraction(HILDON_BANNER(info->banner), tny_status_get_fraction(status));
-  GDK_THREADS_LEAVE();
+       /*ModestGetSupportedAuthInfo* info = (ModestGetSupportedAuthInfo*) user_data;*/
 }
 
 static void
@@ -277,7 +273,6 @@ on_camel_account_get_supported_secure_authentication (
   TnyList *auth_types, GError **err, 
   gpointer user_data)
 {
-       printf ("DEBUG: %s.\n", __FUNCTION__);
                
        ModestGetSupportedAuthInfo *info = (ModestGetSupportedAuthInfo*)user_data;
        g_return_if_fail (info);
@@ -313,14 +308,19 @@ on_camel_account_get_supported_secure_authentication (
   printf("DEBUG: finished\n");
        info->finished = TRUE; /* We are blocking, waiting for this. */
 }
-#endif
+
+static void on_secure_auth_cancel(GtkWidget* dialog, int response, gpointer user_data)
+{
+       ModestGetSupportedAuthInfo *info = (ModestGetSupportedAuthInfo*)user_data;
+       g_return_if_fail(info);
+       /* We are blocking */
+       info->result = NULL;
+       info->cancel = TRUE;
+}
 
 GList* modest_maemo_utils_get_supported_secure_authentication_methods (ModestTransportStoreProtocol proto, 
        const gchar* hostname, gint port, GtkWindow *parent_window)
 {
-       return NULL;
-/* FIXME: Activate when changes are merged into tinymail */
-#if 0
        g_return_val_if_fail (proto != MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN, NULL);
        
        /*
@@ -373,12 +373,19 @@ GList* modest_maemo_utils_get_supported_secure_authentication_methods (ModestTra
        ModestGetSupportedAuthInfo *info = g_slice_new (ModestGetSupportedAuthInfo);
        info->finished = FALSE;
        info->result = NULL;
-       GtkWidget* progressbar = gtk_progress_bar_new();
-  info->banner = hildon_banner_show_progress (GTK_WIDGET(parent_window), 
-                                              GTK_PROGRESS_BAR(progressbar),
-                                              _("Checking for supported authentification types"));
-  gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progressbar));
+       info->progress = gtk_progress_bar_new();
+  info->dialog = gtk_dialog_new_with_buttons(_("Checking for supported authentication types"),
+                                                                                                                               parent_window, GTK_DIALOG_MODAL,
+                                                                                                                               GTK_STOCK_CANCEL,
+                                                                                                                               GTK_RESPONSE_REJECT,
+                                                                                                                               NULL);
+       
+       g_signal_connect(G_OBJECT(info->dialog), "response", G_CALLBACK(on_secure_auth_cancel), info);
        
+       gtk_container_add(GTK_CONTAINER(GTK_DIALOG(info->dialog)->vbox), info->progress);
+       gtk_widget_show(info->progress);
+       gtk_widget_show(info->dialog);
+  gtk_progress_bar_pulse(GTK_PROGRESS_BAR(info->progress));
        
        printf ("DEBUG: %s: STARTING.\n", __FUNCTION__);
        tny_camel_account_get_supported_secure_authentication (
@@ -390,16 +397,15 @@ GList* modest_maemo_utils_get_supported_secure_authentication_methods (ModestTra
        /* Block until the callback has been called,
         * driving the main context, so that the (idle handler) callback can be 
         * called, and so that our dialog is clickable: */
-       while (!(info->finished)) {
+       while (!(info->finished) && (!info->cancel)) {
     gtk_main_iteration_do(FALSE); 
        }
        
-  gtk_widget_destroy(info->banner);
+  gtk_widget_destroy(info->dialog);
                
        GList *result = info->result;
        g_slice_free (ModestGetSupportedAuthInfo, info);
        info = NULL;
        
        return result;
-#endif
 }