Fix bug #3526 ‘autoconfiguration: get more detailed error message’
authorRicardo Mones <ricardo@mones.org>
Wed, 30 Sep 2015 21:17:41 +0000 (23:17 +0200)
committerRicardo Mones <ricardo@mones.org>
Thu, 1 Oct 2015 20:06:15 +0000 (22:06 +0200)
Based on original patch by Christian Hesse (thanks!).

src/gtk/gtkutils.c
src/gtk/gtkutils.h

index 695ca62..3500a83 100644 (file)
@@ -1915,7 +1915,19 @@ static void auto_configure_done(const gchar *hostname, gint port, gboolean ssl,
 
                gtk_label_set_text(data->info_label, _("Done."));
        } else {
-       gtk_label_set_text(data->info_label, _("Failed."));
+               const gchar *msg;
+               switch (data->resolver_error) {
+               case G_RESOLVER_ERROR_NOT_FOUND:
+                       msg = g_strdup(_("Failed: no service record found."));
+                       break;
+               case G_RESOLVER_ERROR_TEMPORARY_FAILURE:
+                       msg = g_strdup(_("Failed: network error."));
+                       break;
+               default:
+                       msg = g_strdup_printf(_("Failed: unknown error (%d)."), data->resolver_error);
+               }
+               gtk_label_set_text(data->info_label, msg);
+               g_free(msg);
        }
        gtk_widget_show(GTK_WIDGET(data->configure_button));
        gtk_widget_hide(GTK_WIDGET(data->cancel_button));
@@ -1951,6 +1963,8 @@ static void resolve_done(GObject *source, GAsyncResult *result, gpointer user_da
        } else if (error) {
                if (error->code == G_IO_ERROR_CANCELLED)
                        abort = TRUE;
+               else
+                       data->resolver_error = error->code;
                debug_print("error %s\n", error->message);
                g_error_free(error);
        }
index 39fdbdb..7510387 100644 (file)
@@ -214,6 +214,7 @@ typedef struct _AutoConfigureData {
        const gchar *ssl_service;
        const gchar *tls_service;
        gchar *address;
+       gint resolver_error;
 
        GtkEntry *hostname_entry;
        GtkToggleButton *set_port;