[vlc-devel] commit: HTTP access: support for libproxy, with configure autodetection ( Dominique Leuenberger )

git version control git at videolan.org
Sun Jun 15 14:26:33 CEST 2008


vlc | branch: master | Dominique Leuenberger <dominique at leuenberger.net> | Sun Jun  8 16:56:35 2008 +0300| [d408d54f23107e7e2eb1274c910c0e56977ef6fd]

HTTP access: support for libproxy, with configure autodetection

Libproxy can read proxy settings from KDE, GNOME, NetworkManager, or
the environment.

Signed-off-by: Rémi Denis-Courmont <rdenis at simphalempin.com>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d408d54f23107e7e2eb1274c910c0e56977ef6fd
---

 configure.ac          |   15 +++++++++++++++
 modules/access/http.c |   38 +++++++++++++++++++++++++++++++++++++-
 2 files changed, 52 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index fd7bba2..7aecb5a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1666,6 +1666,21 @@ fi
 AM_CONDITIONAL(BUILD_HTTPD, [test "${enable_httpd}" != "no"])
 
 dnl
+dnl libproxy support
+dnl
+AC_ARG_ENABLE(libproxy,
+  [  --enable-libproxy       libproxy support (default auto)])
+AS_IF([test "${enable_libproxy}" != "no"], [
+  AC_CHECK_HEADERS(proxy.h, [
+    VLC_ADD_LIBS([access_http],[-lproxy])
+  ], [
+    AS_IF([test "x${enable_libproxy}" != "x"], [
+      AC_MSG_ERROR([libproxy could not be found on your system])
+    ])
+  ])
+])
+
+dnl
 dnl VideoLAN manager
 dnl
 AC_ARG_ENABLE(vlm,
diff --git a/modules/access/http.c b/modules/access/http.c
index cfb207d..e397a1f 100644
--- a/modules/access/http.c
+++ b/modules/access/http.c
@@ -52,6 +52,9 @@
 
 #include <assert.h>
 
+#ifdef HAVE_PROXY_H
+#    include "proxy.h"
+#endif
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
@@ -315,7 +318,40 @@ static int OpenWithCookies( vlc_object_t *p_this, vlc_array_t *cookies )
         vlc_UrlParse( &p_sys->proxy, psz, 0 );
         free( psz );
     }
-#ifdef HAVE_GETENV
+#ifdef HAVE_PROXY_H
+    else
+    {
+        pxProxyFactory *pf = px_proxy_factory_new();
+        if (pf)
+        {
+            char *buf;
+            int i;
+            i=asprintf(&buf, "%s://%s", p_access->psz_access, p_access->psz_path);
+            if (i >= 0)
+            {
+                msg_Dbg(p_access, "asking libproxy about url '%s'", buf);
+                char **proxies = px_proxy_factory_get_proxies(pf, buf);
+                if (proxies[0])
+                {
+                    msg_Dbg(p_access, "libproxy suggest to use '%s'", proxies[0]);
+                    if(strcmp(proxies[0],"direct://") != 0) 
+                    {
+                        p_sys->b_proxy = true;
+                        vlc_UrlParse( &p_sys->proxy, proxies[0], 0);
+                    }
+                }
+                for(i=0;proxies[i];i++) free(proxies[i]);
+                free(proxies);
+                free(buf);
+                px_proxy_factory_free(pf);
+            }
+        }
+        else
+        {
+            msg_Err(p_access, "Allocating memory for libproxy failed");
+        }
+    }
+#elif HAVE_GETENV
     else
     {
         psz = getenv( "http_proxy" );




More information about the vlc-devel mailing list