Fix bug #3209 ‘autoconfig does not use full email address as username’
authorRicardo Mones <ricardo@mones.org>
Wed, 26 Aug 2015 08:59:29 +0000 (10:59 +0200)
committerRicardo Mones <ricardo@mones.org>
Wed, 26 Aug 2015 09:05:15 +0000 (11:05 +0200)
If a provider supports Auto-Configuring it's likely to be using the
full email address as user ID, not the local machine $USER.

src/gtk/gtkutils.c
src/gtk/gtkutils.h
src/prefs_account.c
src/wizard.c

index 8f806f6..f4c1ca8 100644 (file)
@@ -1904,13 +1904,19 @@ static void auto_configure_done(const gchar *hostname, gint port, gboolean ssl,
                if (data->auth_checkbtn)
                        gtk_toggle_button_set_active(data->auth_checkbtn, TRUE);
 
+               /* Set user ID to full email address, which is used by the
+                * majority of providers where auto-configuration works.
+                */
+               if (data->uid_entry)
+                       gtk_entry_set_text(data->uid_entry, data->address);
+
                gtk_label_set_text(data->info_label, _("Done."));
        } else {
        gtk_label_set_text(data->info_label, _("Failed."));
        }
        gtk_widget_show(GTK_WIDGET(data->configure_button));
        gtk_widget_hide(GTK_WIDGET(data->cancel_button));
-       g_free(data->domain);
+       g_free(data->address);
        g_free(data);
 }
 
@@ -1965,14 +1971,16 @@ void auto_configure_service(AutoConfigureData *data)
        const gchar *cur_service = data->ssl_service != NULL ? data->ssl_service : data->tls_service;
 
        cm_return_if_fail(cur_service != NULL);
-       cm_return_if_fail(data->domain != NULL);
+       cm_return_if_fail(data->address != NULL);
 
        resolver = g_resolver_get_default();
        if (resolver != NULL) {
+               const gchar *domain = strchr(data->address, '@') + 1;
+
                gtk_label_set_text(data->info_label, _("Configuring..."));
                gtk_widget_hide(GTK_WIDGET(data->configure_button));
                gtk_widget_show(GTK_WIDGET(data->cancel_button));
-               g_resolver_lookup_service_async(resolver, cur_service, "tcp", data->domain,
+               g_resolver_lookup_service_async(resolver, cur_service, "tcp", domain,
                                        data->cancel, resolve_done, data);
        }
 }
index 39a8a32..39fdbdb 100644 (file)
@@ -213,7 +213,7 @@ claws_input_add    (gint          source,
 typedef struct _AutoConfigureData {
        const gchar *ssl_service;
        const gchar *tls_service;
-       gchar *domain;
+       gchar *address;
 
        GtkEntry *hostname_entry;
        GtkToggleButton *set_port;
@@ -223,6 +223,7 @@ typedef struct _AutoConfigureData {
        GtkToggleButton *tls_checkbtn;
        GtkToggleButton *ssl_checkbtn;
        GtkToggleButton *auth_checkbtn;
+       GtkEntry *uid_entry;
        GtkLabel *info_label;
        GtkButton *configure_button;
        GtkButton *cancel_button;
index b388c85..f0adb80 100644 (file)
@@ -3850,7 +3850,6 @@ static void auto_configure_cb (GtkWidget *widget, gpointer data)
                           _("Failed (wrong address)"));
                return;
        }
-       domain = strchr(address, '@') + 1;
 
        if (protocol == A_POP3 || protocol == A_IMAP4) {
                recv_data = g_new0(AutoConfigureData, 1);
@@ -3862,7 +3861,7 @@ static void auto_configure_cb (GtkWidget *widget, gpointer data)
                case A_POP3:
                        recv_data->ssl_service = "pop3s";
                        recv_data->tls_service = "pop3";
-                       recv_data->domain = g_strdup(domain);
+                       recv_data->address = g_strdup(address);
                        recv_data->hostname_entry = GTK_ENTRY(basic_page.recvserv_entry);
                        recv_data->set_port = GTK_TOGGLE_BUTTON(advanced_page.popport_checkbtn);
                        recv_data->port = GTK_SPIN_BUTTON(advanced_page.popport_spinbtn);
@@ -3870,11 +3869,12 @@ static void auto_configure_cb (GtkWidget *widget, gpointer data)
                        recv_data->ssl_checkbtn = GTK_TOGGLE_BUTTON(ssl_page.pop_ssltunnel_radiobtn);
                        recv_data->default_port = 110;
                        recv_data->default_ssl_port = 995;
+                       recv_data->uid_entry = GTK_ENTRY(basic_page.uid_entry);
                        break;
                case A_IMAP4:
                        recv_data->ssl_service = "imaps";
                        recv_data->tls_service = "imap";
-                       recv_data->domain = g_strdup(domain);
+                       recv_data->address = g_strdup(address);
                        recv_data->hostname_entry = GTK_ENTRY(basic_page.recvserv_entry);
                        recv_data->set_port = GTK_TOGGLE_BUTTON(advanced_page.imapport_checkbtn);
                        recv_data->port = GTK_SPIN_BUTTON(advanced_page.imapport_spinbtn);
@@ -3882,6 +3882,7 @@ static void auto_configure_cb (GtkWidget *widget, gpointer data)
                        recv_data->ssl_checkbtn = GTK_TOGGLE_BUTTON(ssl_page.imap_ssltunnel_radiobtn);
                        recv_data->default_port = 143;
                        recv_data->default_ssl_port = 993;
+                       recv_data->uid_entry = GTK_ENTRY(basic_page.uid_entry);
                        break;
                default:
                        cm_return_if_fail(FALSE);
@@ -3897,7 +3898,7 @@ static void auto_configure_cb (GtkWidget *widget, gpointer data)
 
        send_data->ssl_service = NULL;
        send_data->tls_service = "submission";
-       send_data->domain = g_strdup(domain);
+       recv_data->address = g_strdup(address);
        send_data->hostname_entry = GTK_ENTRY(basic_page.smtpserv_entry);
        send_data->set_port = GTK_TOGGLE_BUTTON(advanced_page.smtpport_checkbtn);
        send_data->port = GTK_SPIN_BUTTON(advanced_page.smtpport_spinbtn);
@@ -3905,6 +3906,7 @@ static void auto_configure_cb (GtkWidget *widget, gpointer data)
        send_data->ssl_checkbtn = NULL;
        send_data->default_port = 25;
        send_data->default_ssl_port = -1;
+       send_data->uid_entry = NULL;
        send_data->auth_checkbtn = GTK_TOGGLE_BUTTON(send_page.smtp_auth_checkbtn);
 
        auto_configure_service(send_data);
index 18505f4..c37c815 100644 (file)
@@ -1374,7 +1374,6 @@ static void auto_configure_cb (GtkWidget *widget, gpointer data)
                           _("Failed (wrong address)"));
                return;
        }
-       domain = strchr(address, '@') + 1;
 
        if (protocol == A_POP3 || protocol == A_IMAP4) {
                recv_data = g_new0(AutoConfigureData, 1);
@@ -1386,7 +1385,7 @@ static void auto_configure_cb (GtkWidget *widget, gpointer data)
                case A_POP3:
                        recv_data->ssl_service = "pop3s";
                        recv_data->tls_service = "pop3";
-                       recv_data->domain = g_strdup(domain);
+                       recv_data->address = g_strdup(address);
                        recv_data->hostname_entry = GTK_ENTRY(wizard->recv_server);
                        recv_data->set_port = NULL;
                        recv_data->port = NULL;
@@ -1398,7 +1397,7 @@ static void auto_configure_cb (GtkWidget *widget, gpointer data)
                case A_IMAP4:
                        recv_data->ssl_service = "imaps";
                        recv_data->tls_service = "imap";
-                       recv_data->domain = g_strdup(domain);
+                       recv_data->address = g_strdup(address);
                        recv_data->hostname_entry = GTK_ENTRY(wizard->recv_server);
                        recv_data->set_port = NULL;
                        recv_data->port = NULL;
@@ -1421,7 +1420,7 @@ static void auto_configure_cb (GtkWidget *widget, gpointer data)
 
        send_data->ssl_service = NULL;
        send_data->tls_service = "submission";
-       send_data->domain = g_strdup(domain);
+       send_data->address = g_strdup(address);
        send_data->hostname_entry = GTK_ENTRY(wizard->smtp_server);
        send_data->set_port = NULL;
        send_data->port = NULL;