2007-06-22 Armin Burgmeier <armin@openismus.com>
authorArmin Burgmeier <armin@openismus.com>
Fri, 22 Jun 2007 20:03:30 +0000 (20:03 +0000)
committerArmin Burgmeier <armin@openismus.com>
Fri, 22 Jun 2007 20:03:30 +0000 (20:03 +0000)
* src/maemo/modest-maemo-utils.h:
* src/maemo/modest-maemo-utils.c: Added a GError parameter to
modest_maemo_utils_get_supported_secure_authentication_methods.

* src/maemo/easysetup/modest-easysetup-wizard.c:
* src/maemo/modest-account-settings-dialog.c: Show correct error if
one occured, not just "Server does not support secure authentication".

pmo-trunk-r2381

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

index 9910c7c..4d2468b 100644 (file)
@@ -1,3 +1,13 @@
+2007-06-22  Armin Burgmeier  <armin@openismus.com>
+
+       * src/maemo/modest-maemo-utils.h:
+       * src/maemo/modest-maemo-utils.c: Added a GError parameter to
+       modest_maemo_utils_get_supported_secure_authentication_methods.
+
+       * src/maemo/easysetup/modest-easysetup-wizard.c:
+       * src/maemo/modest-account-settings-dialog.c: Show correct error if
+       one occured, not just "Server does not support secure authentication".
+
 2007-06-22  Murray Cumming  <murrayc@murrayc.com>
 
        * src/modest-tny-account-store.c: (get_password):
        Added modest_ui_actions_on_new_account() as a signal handler for the 
        New Account menu item. It shows the easysetup wizard.
        * po/en_GB.po: Added additional needed logical IDs and translations.
-       
index 39b8046..40754a6 100644 (file)
@@ -162,7 +162,8 @@ static gint get_serverport_incoming(ModestPresetsServerType servertype_incoming,
 
 static GList* check_for_supported_auth_methods(ModestEasysetupWizardDialog* account_wizard)
 {
-               const ModestTransportStoreProtocol protocol = 
+       GError *error = NULL;
+       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));
@@ -172,11 +173,11 @@ static GList* check_for_supported_auth_methods(ModestEasysetupWizardDialog* acco
                                                                                                                                                                                                                                                                                 MODEST_SERVERSECURITY_COMBO_BOX (
                                                                                                                                                                                                                                                                                                                                                                                                                        account_wizard->combo_incoming_security));
      int port_num = get_serverport_incoming(protocol, protocol_security_incoming); 
-     GList *list_auth_methods = 
+     GList *list_auth_methods =
           modest_maemo_utils_get_supported_secure_authentication_methods (
                                                                       protocol, 
-                                                                      hostname, port_num, username, GTK_WINDOW (account_wizard));      
-     if (list_auth_methods) {
+                                                                      hostname, port_num, username, GTK_WINDOW (account_wizard), &error);
+       if (list_auth_methods) {
           /* TODO: Select the correct method */
                          GList* list = NULL;
                          GList* method;
@@ -193,7 +194,9 @@ static GList* check_for_supported_auth_methods(ModestEasysetupWizardDialog* acco
                 /* no secure methods supported */
      GtkWidget* error_dialog = gtk_message_dialog_new(GTK_WINDOW(account_wizard),
                                                      GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
-                                                     GTK_BUTTONS_OK, _("Server does not support secure authentication!"));
+                                                     GTK_BUTTONS_OK, error != NULL ? error->message : _("Server does not support secure authentication!"));
+     if(error != NULL) g_error_free(error);
+
      gtk_dialog_run(GTK_DIALOG(error_dialog));
      gtk_widget_destroy(error_dialog);
      return NULL;
index c5ae11d..c24a2d3 100644 (file)
@@ -1270,9 +1270,10 @@ save_configuration (ModestAccountSettingsDialog *dialog)
        {
                if (gtk_toggle_button_get_active (
                                GTK_TOGGLE_BUTTON (dialog->checkbox_incoming_auth))) {
+                       GError *error = NULL;
                        GList *list_auth_methods = 
                                modest_maemo_utils_get_supported_secure_authentication_methods (dialog->incoming_protocol, 
-                                       hostname, port_num, username, GTK_WINDOW (dialog));     
+                                       hostname, port_num, username, GTK_WINDOW (dialog), &error);
                        if (list_auth_methods) {
                                /* Use the first supported method.
                                 * TODO: Should we prioritize them, to prefer a particular one? */
@@ -1294,7 +1295,8 @@ save_configuration (ModestAccountSettingsDialog *dialog)
                  {
              GtkWidget* error_dialog = gtk_message_dialog_new(GTK_WINDOW(dialog),
                                                               GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
-                                                              GTK_BUTTONS_OK, _("Server does not support secure authentication!"));
+                                                              GTK_BUTTONS_OK, (error != NULL) ? error->message : _("Server does not support secure authentication!"));
+             if(error != NULL) g_error_free(error);
              gtk_dialog_run(GTK_DIALOG(error_dialog));
              gtk_widget_destroy(error_dialog);
                                /* This is a nasty hack. jschmid. */
index 9a27aaa..1162573 100644 (file)
@@ -258,7 +258,8 @@ typedef struct
        gboolean cancel;
        GList *result;
        GtkWidget* dialog;
-  GtkWidget* progress;
+       GtkWidget* progress;
+       GError* error;
 } ModestGetSupportedAuthInfo;
 
 static void on_camel_account_get_supported_secure_authentication_status (
@@ -276,7 +277,7 @@ on_camel_account_get_supported_secure_authentication (
                
        ModestGetSupportedAuthInfo *info = (ModestGetSupportedAuthInfo*)user_data;
        g_return_if_fail (info);
-       
+
        /* Free everything if the actual action was canceled */
        if (info->cancel)
        {
@@ -285,6 +286,14 @@ on_camel_account_get_supported_secure_authentication (
                return;
        }
 
+       /* Why is this a pointer to a pointer? We are not supposed to set it,
+        * are we? */
+       if(err != NULL && *err != NULL)
+       {
+               printf("Err: %s\n", (*err)->message);
+               info->error = g_error_copy(*err);
+       }
+       
        if (!auth_types) {
                printf ("DEBUG: %s: auth_types is NULL.\n", __FUNCTION__);
                info->finished = TRUE; /* We are blocking, waiting for this. */
@@ -327,7 +336,7 @@ static void on_secure_auth_cancel(GtkWidget* dialog, int response, gpointer user
 }
 
 GList* modest_maemo_utils_get_supported_secure_authentication_methods (ModestTransportStoreProtocol proto, 
-       const gchar* hostname, gint port, const gchar* username, GtkWindow *parent_window)
+       const gchar* hostname, gint port, const gchar* username, GtkWindow *parent_window, GError** error)
 {
        g_return_val_if_fail (proto != MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN, NULL);
        
@@ -364,6 +373,7 @@ GList* modest_maemo_utils_get_supported_secure_authentication_methods (ModestTra
        tny_account_set_proto (tny_account,
                               modest_protocol_info_get_transport_store_protocol_name(proto));
 
+       tny_account_set_hostname (tny_account, hostname);
        /* Required for POP, at least */
        tny_account_set_user (tny_account, username);
                               
@@ -374,8 +384,6 @@ GList* modest_maemo_utils_get_supported_secure_authentication_methods (ModestTra
        g_return_val_if_fail (session, NULL);
        tny_camel_account_set_session (TNY_CAMEL_ACCOUNT(tny_account), session);
        
-       tny_account_set_hostname (tny_account, hostname);
-       
        if(port > 0)
                tny_account_set_port (tny_account, port);
                
@@ -385,6 +393,7 @@ GList* modest_maemo_utils_get_supported_secure_authentication_methods (ModestTra
        info->finished = FALSE;
        info->result = NULL;
        info->cancel = FALSE;
+       info->error = NULL;
        info->progress = gtk_progress_bar_new();
   info->dialog = gtk_dialog_new_with_buttons(_("Authentication"),
                                                                                                                                parent_window, GTK_DIALOG_MODAL,
@@ -420,6 +429,9 @@ GList* modest_maemo_utils_get_supported_secure_authentication_methods (ModestTra
        GList *result = info->result;
        if (!info->cancel)
        {
+               if(info->error != NULL)
+                       g_propagate_error(error, info->error);
+
                g_slice_free (ModestGetSupportedAuthInfo, info);
                info = NULL;
        }
index 022ab3a..31c3a5d 100644 (file)
@@ -105,7 +105,7 @@ TnyFsStream *modest_maemo_utils_create_temp_stream (const gchar *extension, gcha
  */
 
 GList* modest_maemo_utils_get_supported_secure_authentication_methods (ModestTransportStoreProtocol proto, 
-       const gchar* hostname, gint port, const gchar* username, GtkWindow *parent_window);
+       const gchar* hostname, gint port, const gchar* username, GtkWindow *parent_window, GError** error);
 
 /**
  * modest_maemo_utils_setup_images_filechooser: