[totem] backend: Add proxy support



commit 8aa70d5b8e019552271d528e849d68891a029969
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Mar 29 02:38:42 2012 +0200

    backend: Add proxy support
    
    https://bugzilla.gnome.org/show_bug.cgi?id=395429

 configure.in                              |    2 +-
 src/backend/bacon-video-widget-gst-0.10.c |   68 +++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+), 1 deletions(-)
---
diff --git a/configure.in b/configure.in
index f3f2f05..64dea74 100644
--- a/configure.in
+++ b/configure.in
@@ -114,7 +114,7 @@ if test "x$enable_easy_codec_installation" != "xno"; then
 	])
 fi
 
-MM="gstreamer-0.10 >= $GST_REQS gstreamer-base-0.10 >= $GST_REQS gstreamer-plugins-base-0.10 >= $GSTPLUG_REQS gstreamer-tag-0.10 >= $GSTPLUG_REQS clutter-1.0 >= $CLUTTER_REQS clutter-gst-1.0 >= $CLUTTER_GST_REQS clutter-gtk-1.0 mx-1.0"
+MM="gstreamer-0.10 >= $GST_REQS gstreamer-base-0.10 >= $GST_REQS gstreamer-plugins-base-0.10 >= $GSTPLUG_REQS gstreamer-tag-0.10 >= $GSTPLUG_REQS clutter-1.0 >= $CLUTTER_REQS clutter-gst-1.0 >= $CLUTTER_GST_REQS clutter-gtk-1.0 mx-1.0 gsettings-desktop-schemas"
 PKG_CHECK_MODULES(GST, $MM)
 GST_LIBS="$GST_LIBS -lgstbase-$GST_MAJORMINOR -lgstinterfaces-$GST_MAJORMINOR -lgstvideo-$GST_MAJORMINOR -lgstaudio-$GST_MAJORMINOR -lgstpbutils-$GST_MAJORMINOR -lgsttag-$GST_MAJORMINOR"
 AC_SUBST(GST_LIBS)
diff --git a/src/backend/bacon-video-widget-gst-0.10.c b/src/backend/bacon-video-widget-gst-0.10.c
index dafeb65..101d227 100644
--- a/src/backend/bacon-video-widget-gst-0.10.c
+++ b/src/backend/bacon-video-widget-gst-0.10.c
@@ -80,6 +80,7 @@
 #include <gtk/gtkx.h>
 #include <glib/gi18n-lib.h>
 #include <gio/gio.h>
+#include <gdesktop-enums.h>
 
 #include "totem-gst-helpers.h"
 #include "bacon-video-widget.h"
@@ -2164,6 +2165,72 @@ bvw_set_auth_on_element (BaconVideoWidget * bvw, GstElement * element)
 }
 
 static void
+bvw_set_proxy_on_element (BaconVideoWidget * bvw, GstElement * element)
+{
+  GSettings *settings;
+  GDesktopProxyMode mode;
+  char *url;
+  const char *host, *user_id, *user_pw;
+  int port;
+  gboolean is_https;
+
+  if (g_object_class_find_property (G_OBJECT_GET_CLASS (element), "proxy") == NULL ||
+      g_object_class_find_property (G_OBJECT_GET_CLASS (element), "proxy-id") == NULL ||
+      g_object_class_find_property (G_OBJECT_GET_CLASS (element), "proxy-pw") == NULL)
+    return;
+
+  settings = g_settings_new ("org.gnome.system.proxy");
+  mode = g_settings_get_enum (settings, "mode");
+  g_object_unref (settings);
+
+  if (mode == G_DESKTOP_PROXY_MODE_NONE)
+    return;
+  if (mode == G_DESKTOP_PROXY_MODE_AUTO)
+    {
+      /* FIXME: Auto proxy configuration is unhandled */
+      GST_DEBUG ("Auto proxy configuration is unhandled");
+      return;
+    }
+
+  if (g_str_has_prefix (bvw->priv->mrl, "https://";))
+    {
+      settings = g_settings_new ("org.gnome.system.proxy.https");
+      is_https = TRUE;
+    }
+  else
+    {
+      settings = g_settings_new ("org.gnome.system.proxy.http");
+      is_https = FALSE;
+    }
+
+  host = g_settings_get_string (settings, "host");
+  if (*host == '\0')
+    goto finish;
+  port = g_settings_get_int (settings, "port");
+  if (port == 0)
+    goto finish;
+
+  url = g_strdup_printf ("http://%s:%d";, host, port);
+  g_object_set (element, "proxy", url, NULL);
+  g_free (url);
+
+  /* https doesn't handle authentication yet */
+  if (is_https ||
+      g_settings_get_boolean (settings, "use-authentication") == FALSE)
+    goto finish;
+
+  user_id = g_settings_get_string (settings, "authentication-user");
+  user_pw = g_settings_get_string (settings, "authentication-password");
+  g_object_set (element,
+		"proxy-id", user_id,
+		"proxy-pw", user_pw,
+		NULL);
+
+finish:
+  g_object_unref (settings);
+}
+
+static void
 bvw_set_referrer_on_element (BaconVideoWidget * bvw, GstElement * element)
 {
   BaconVideoWidgetPrivate *priv = bvw->priv;
@@ -2216,6 +2283,7 @@ playbin_source_notify_cb (GObject *play, GParamSpec *p, BaconVideoWidget *bvw)
   bvw_set_user_agent_on_element (bvw, source);
   bvw_set_referrer_on_element (bvw, source);
   bvw_set_auth_on_element (bvw, source);
+  bvw_set_proxy_on_element (bvw, source);
 }
 
 static void



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