[Xfce4-commits] [panel-plugins/xfce4-weather-plugin] 01/02: Add code to handle proxy authentication (bug #10820).

noreply at xfce.org noreply at xfce.org
Sat Apr 26 08:55:43 CEST 2014


This is an automated email from the git hooks/post-receive script.

hjudt pushed a commit to branch master
in repository panel-plugins/xfce4-weather-plugin.

commit 19458ea08d85aa6c48f3866f3ee2069517d4640d
Author: Issa <flop.m at usa.net>
Date:   Sat Apr 26 08:37:19 2014 +0200

    Add code to handle proxy authentication (bug #10820).
    
    Apply patch by Issa, with some additional cleanup.
    
    User and password are read from HTTP proxy URI set via HTTP_PROXY or
    http_proxy environment variable, e.g.:
    
        http://user:password@host:port
---
 panel-plugin/weather.c |   37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
index 59b8dde..efa8559 100644
--- a/panel-plugin/weather.c
+++ b/panel-plugin/weather.c
@@ -1524,6 +1524,32 @@ mi_click(GtkWidget *widget,
     update_weatherdata_with_reset(data);
 }
 
+static void
+proxy_auth(SoupSession *session,
+           SoupMessage *msg,
+           SoupAuth *auth,
+           gboolean retrying,
+           gpointer user_data)
+{
+    SoupURI *soup_proxy_uri;
+    const gchar *proxy_uri;
+
+    if (!retrying) {
+        if (msg->status_code == SOUP_STATUS_PROXY_AUTHENTICATION_REQUIRED) {
+            proxy_uri = g_getenv("HTTP_PROXY");
+            if (!proxy_uri)
+                proxy_uri = g_getenv("http_proxy");
+            if (proxy_uri) {
+                soup_proxy_uri = soup_uri_new(proxy_uri);
+                soup_auth_authenticate(auth,
+                                       soup_uri_get_user(soup_proxy_uri),
+                                       soup_uri_get_password(soup_proxy_uri));
+                soup_uri_free(soup_proxy_uri);
+            }
+        }
+    }
+}
+
 
 #ifdef HAVE_UPOWER_GLIB
 static void
@@ -1781,6 +1807,7 @@ xfceweather_create_control(XfcePanelPlugin *plugin)
     plugin_data *data = g_slice_new0(plugin_data);
     SoupURI *soup_proxy_uri;
     const gchar *proxy_uri;
+    const gchar *proxy_user;
     GtkWidget *refresh, *refresh_icon;
     GdkPixbuf *icon = NULL;
     data_types lbl;
@@ -1819,9 +1846,17 @@ xfceweather_create_control(XfcePanelPlugin *plugin)
     if (!proxy_uri)
         proxy_uri = g_getenv("http_proxy");
     if (proxy_uri) {
-        soup_proxy_uri = soup_uri_new (proxy_uri);
+        soup_proxy_uri = soup_uri_new(proxy_uri);
         g_object_set(data->session, SOUP_SESSION_PROXY_URI,
                      soup_proxy_uri, NULL);
+
+        /* check if uri contains authentication info */
+        proxy_user = soup_uri_get_user(soup_proxy_uri);
+        if (proxy_user && strlen(proxy_user) > 0) {
+            g_signal_connect(G_OBJECT(data->session), "authenticate",
+                             G_CALLBACK(proxy_auth), NULL);
+        }
+
         soup_uri_free(soup_proxy_uri);
     }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list