[gnome-control-center] network: add a warning to the user when the PAC textbox is empty and we're going to use WPAD



commit 88e192c03292d0d601ef1c71ee2d660e8223222d
Author: Richard Hughes <richard hughsie com>
Date:   Fri Mar 18 12:16:26 2011 +0000

    network: add a warning to the user when the PAC textbox is empty and we're going to use WPAD
    
    If you choose Automatic and then don't fill in any configuration URL, it
    defaults to WPAD.
    
    But really, WPAD is a bad default anyway; if you enable it on an untrusted
    network, then anyone else on that network can tell your machine that it should
    proxy all of your web traffic through them.
    
    The best bet might be to just add some explanatory text to the (otherwise
    nearly-empty) Automatic page.
    
    Fixes https://bugzilla.gnome.org/show_bug.cgi?id=641793

 panels/network/cc-network-panel.c |   49 +++++++++++++++++++++++++++++++++++++
 panels/network/network.ui         |   49 +++++++++++++++++++++++++++++++++++++
 2 files changed, 98 insertions(+), 0 deletions(-)
---
diff --git a/panels/network/cc-network-panel.c b/panels/network/cc-network-panel.c
index 5411c7f..77e961a 100644
--- a/panels/network/cc-network-panel.c
+++ b/panels/network/cc-network-panel.c
@@ -161,10 +161,56 @@ cc_network_panel_class_finalize (CcNetworkPanelClass *klass)
 }
 
 static void
+check_wpad_warning (CcNetworkPanel *panel)
+{
+        GtkWidget *widget;
+        gchar *autoconfig_url = NULL;
+        GString *string = NULL;
+        gboolean ret = FALSE;
+        guint mode;
+
+        string = g_string_new ("");
+
+        /* check we're using 'Automatic' */
+        mode = g_settings_get_enum (panel->priv->proxy_settings, "mode");
+        if (mode != 2)
+                goto out;
+
+        /* see if the PAC is blank */
+        autoconfig_url = g_settings_get_string (panel->priv->proxy_settings,
+                                                "autoconfig-url");
+        ret = autoconfig_url == NULL ||
+              autoconfig_url[0] == '\0';
+        if (!ret)
+                goto out;
+
+        g_string_append (string, "<small>");
+
+        /* TRANSLATORS: this is when the use leaves the PAC textbox blank */
+        g_string_append (string, _("Web Proxy Autodiscovery is used when a Configuration URL is not provided."));
+
+        g_string_append (string, " ");
+
+        /* TRANSLATORS: WPAD is bad: if you enable it on an untrusted
+         * network, then anyone else on that network can tell your
+         * machine that it should proxy all of your web traffic
+         * through them. */
+        g_string_append (string, _("This is not recommended for untrusted public networks."));
+        g_string_append (string, "</small>");
+out:
+        widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder,
+                                                     "label_proxy_warning"));
+        gtk_label_set_markup (GTK_LABEL (widget), string->str);
+        g_free (autoconfig_url);
+        g_string_free (string, TRUE);
+}
+
+static void
 panel_settings_changed (GSettings      *settings,
                         const gchar    *key,
                         CcNetworkPanel *panel)
 {
+        check_wpad_warning (panel);
 }
 
 static NetObject *
@@ -213,6 +259,9 @@ panel_proxy_mode_combo_setup_widgets (CcNetworkPanel *panel, guint value)
         widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder,
                                                      "hbox_proxy_socks"));
         gtk_widget_set_visible (widget, value == 1);
+
+        /* perhaps show the wpad warning */
+        check_wpad_warning (panel);
 }
 
 static void
diff --git a/panels/network/network.ui b/panels/network/network.ui
index 33eefd9..6342a7d 100644
--- a/panels/network/network.ui
+++ b/panels/network/network.ui
@@ -2125,6 +2125,54 @@
                                     <property name="position">5</property>
                                   </packing>
                                 </child>
+                                <child>
+                                  <object class="GtkBox" id="box1">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="spacing">9</property>
+                                    <child>
+                                      <object class="GtkBox" id="box2">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <child>
+                                          <object class="GtkLabel" id="label7">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="label"> </property>
+                                          </object>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="fill">True</property>
+                                            <property name="position">0</property>
+                                          </packing>
+                                        </child>
+                                      </object>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">True</property>
+                                        <property name="position">0</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkLabel" id="label_proxy_warning">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="label">WPAD warning...</property>
+                                        <property name="wrap">True</property>
+                                      </object>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">True</property>
+                                        <property name="position">1</property>
+                                      </packing>
+                                    </child>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">False</property>
+                                    <property name="position">6</property>
+                                  </packing>
+                                </child>
                               </object>
                               <packing>
                                 <property name="position">2</property>
@@ -2300,6 +2348,7 @@
       <widget name="hbox21"/>
       <widget name="hbox23"/>
       <widget name="hbox25"/>
+      <widget name="box2"/>
     </widgets>
   </object>
   <object class="GtkSizeGroup" id="sizegroup2">



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]