[libproxy] Add pacrunner support
David Woodhouse
dwmw2 at fedoraproject.org
Thu Jul 18 13:32:30 UTC 2013
commit e0c342dc14394014859562f80cdb01bff922609d
Author: David Woodhouse <David.Woodhouse at intel.com>
Date: Thu Jul 18 14:30:13 2013 +0100
Add pacrunner support
...onfig-module-for-querying-PacRunner-d-mon.patch | 177 ++++++++++++++++++++
libproxy.spec | 29 +++-
2 files changed, 205 insertions(+), 1 deletions(-)
---
diff --git a/0001-Add-config-module-for-querying-PacRunner-d-mon.patch b/0001-Add-config-module-for-querying-PacRunner-d-mon.patch
new file mode 100644
index 0000000..6b9a1d4
--- /dev/null
+++ b/0001-Add-config-module-for-querying-PacRunner-d-mon.patch
@@ -0,0 +1,177 @@
+From 6f6d2dd74e6a1bd0e356e9290d733672afcf8f70 Mon Sep 17 00:00:00 2001
+From: David Woodhouse <David.Woodhouse at intel.com>
+Date: Wed, 8 Dec 2010 12:13:43 +0000
+Subject: [PATCH] =?UTF-8?q?Add=20config=20module=20for=20querying=20PacRun?=
+ =?UTF-8?q?ner=20d=C3=A6mon?=
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+---
+ libproxy/cmake/modules.cmk | 2 +
+ libproxy/cmake/modules/config_pacrunner.cmk | 3 +
+ libproxy/modules/config_pacrunner.cpp | 122 ++++++++++++++++++++++++++++
+ 3 files changed, 127 insertions(+)
+ create mode 100644 libproxy/cmake/modules/config_pacrunner.cmk
+ create mode 100644 libproxy/modules/config_pacrunner.cpp
+
+diff --git a/libproxy/cmake/modules.cmk b/libproxy/cmake/modules.cmk
+index 68ff898..2593d29 100644
+--- a/libproxy/cmake/modules.cmk
++++ b/libproxy/cmake/modules.cmk
+@@ -8,6 +8,7 @@ endif()
+ # Do module determination
+ include(cmake/pxmodule.cmk)
+ include(cmake/pkgconfig.cmk)
++include(cmake/modules/config_pacrunner.cmk)
+ include(cmake/modules/config_envvar.cmk)
+ include(cmake/modules/config_sysconfig.cmk)
+ include(cmake/modules/config_gnome.cmk)
+@@ -28,6 +29,7 @@ endif()
+ ## Module definition
+ #
+ message("MODULES TO BUILD:")
++px_module(config_pacrunner "${DBUS_FOUND}" 0 ${DBUS_LIBRARIES})
+ px_module(config_envvar "${ENVVAR_FOUND}" 1)
+ px_module(config_sysconfig "${SYSCONFIG_FOUND}" 1)
+ px_module(config_gnome "${GNOME2_FOUND}" 0)
+diff --git a/libproxy/cmake/modules/config_pacrunner.cmk b/libproxy/cmake/modules/config_pacrunner.cmk
+new file mode 100644
+index 0000000..11dde89
+--- /dev/null
++++ b/libproxy/cmake/modules/config_pacrunner.cmk
+@@ -0,0 +1,3 @@
++if (NOT WIN32 AND NOT APPLE)
++ px_check_modules(DBUS dbus-1)
++endif()
+diff --git a/libproxy/modules/config_pacrunner.cpp b/libproxy/modules/config_pacrunner.cpp
+new file mode 100644
+index 0000000..b4cf723
+--- /dev/null
++++ b/libproxy/modules/config_pacrunner.cpp
+@@ -0,0 +1,122 @@
++/*******************************************************************************
++ * libproxy - A library for proxy configuration
++ * Copyright (C) 2010 Intel Corporation
++ *
++ * This library is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2.1 of the License, or (at your option) any later version.
++ *
++ * This library is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with this library; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ ******************************************************************************/
++
++#include "../extension_config.hpp"
++using namespace libproxy;
++
++#include <string.h>
++#include <dbus/dbus.h>
++
++class pacrunner_config_extension : public config_extension {
++public:
++ pacrunner_config_extension() {
++ this->conn = NULL;
++ }
++
++ ~pacrunner_config_extension() {
++ if (this->conn) dbus_connection_close(this->conn);
++ }
++
++ class scoped_dbus_message {
++ public:
++ scoped_dbus_message(DBusMessage *msg) {
++ this->msg = msg;
++ }
++
++ ~scoped_dbus_message() {
++ if (this->msg)
++ dbus_message_unref(msg);
++ }
++
++ private:
++ DBusMessage *msg;
++ };
++
++ vector<url> get_config(const url &dest) throw (runtime_error) {
++ // Make sure we have a valid connection with a proper match
++ DBusConnection *conn = this->conn;
++ vector<url> response;
++
++ if (!conn || !dbus_connection_get_is_connected(conn))
++ {
++ // If the connection was disconnected,
++ // close it an clear the queue
++ if (conn)
++ {
++ dbus_connection_close(conn);
++ dbus_connection_read_write(conn, 0);
++ for (DBusMessage *msg=NULL ; (msg = dbus_connection_pop_message(conn)) ; dbus_message_unref(msg)) {};
++ }
++
++ // Create a new connections
++ conn = dbus_bus_get_private(DBUS_BUS_SYSTEM, NULL);
++ this->conn = conn;
++ if (!conn)
++ throw runtime_error("Unable to set up DBus connection");
++
++ // If connection was successful, set it up
++ dbus_connection_set_exit_on_disconnect(conn, false);
++ }
++
++ DBusMessage *msg, *reply;
++
++ msg = dbus_message_new_method_call("org.pacrunner",
++ "/org/pacrunner/client",
++ "org.pacrunner.Client",
++ "FindProxyForURL");
++ if (!msg)
++ throw runtime_error("Unable to create PacRunner DBus call");
++
++ string dest_str = dest.to_string();
++ string dest_host = dest.get_host();
++ const char *dest_cstr = dest_str.c_str();
++ const char *dest_host_cstr = dest_host.c_str();
++
++ dbus_message_append_args(msg, DBUS_TYPE_STRING, &dest_cstr,
++ DBUS_TYPE_STRING, &dest_host_cstr,
++ DBUS_TYPE_INVALID);
++
++ reply = dbus_connection_send_with_reply_and_block(conn, msg, -1, NULL);
++
++ dbus_message_unref(msg);
++
++ if (!reply)
++ throw runtime_error("Failed to get DBus response from PacRunner");
++
++ scoped_dbus_message smsg(reply);
++ char *str = NULL;
++ dbus_message_get_args(reply, NULL, DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID);
++
++ if (!str || !strlen(str) || !::strcmp(str, "DIRECT"))
++ response.push_back(url("direct://"));
++ else if (!strncmp(str, "PROXY ", 6))
++ response.push_back(url("http://" + string(str + 6)));
++ else if (!strncmp(str, "SOCKS ", 6))
++ response.push_back(url("socks://" + string(str + 6)));
++ else {
++ throw runtime_error("Unrecognised proxy response from PacRunner: " + string(str));
++ }
++ return response;
++ }
++
++private:
++ DBusConnection *conn;
++};
++
++MM_MODULE_INIT_EZ(pacrunner_config_extension, true, NULL, NULL);
+--
+1.8.2.1
+
diff --git a/libproxy.spec b/libproxy.spec
index a4dd789..3db700e 100644
--- a/libproxy.spec
+++ b/libproxy.spec
@@ -8,11 +8,12 @@
%global _with_kde 1
%global _with_networkmanager 1
%global _with_python 1
+%global _with_pacrunner 1
%endif
Name: libproxy
Version: 0.4.11
-Release: 4%{?svn}%{?dist}
+Release: 5%{?svn}%{?dist}
Summary: A library handling all the details of proxy configuration
Group: System Environment/Libraries
@@ -22,6 +23,8 @@ URL: http://code.google.com/p/libproxy/
Source0: http://libproxy.googlecode.com/files/libproxy-%{version}%{?svn}.tar.gz
Patch0: libproxy-0.4.10-mozjs.patch
Patch1: 0001-pacrunner_mozjs-Also-support-mozjs-17.0.patch
+# http://code.google.com/p/libproxy/issues/detail?id=152
+Patch2: 0001-Add-config-module-for-querying-PacRunner-d-mon.patch
BuildRequires: python-devel
BuildRequires: libmodman-devel >= 2.0.1
@@ -45,6 +48,8 @@ BuildRequires: dbus-devel
%{?_with_webkitgtk3:BuildRequires: webkitgtk3-devel}
# kde
%{?_with_kde:BuildRequires: kdelibs-devel}
+# pacrunner
+%{?_with_pacrunner:BuildRequires: dbus-devel}
#Obsoletes of disabled subpackages
%{!?_with_mozjs:
@@ -158,6 +163,18 @@ The %{name}-webkit package contains the %{name} plugin for
webkitgtk3.
}
+%{?_with_pacrunner:
+%package pacrunner
+Summary: Plugin for %{name} and PacRunner
+Group: System Environment/Libraries
+Requires: %{name} = %{version}-%{release}
+Provides: %{name}-pac = %{version}-%{release}
+
+%description pacrunner
+The %{name}-pacrunner package contains the %{name} plugin for
+PacRunner.
+}
+
%package devel
Summary: Development files for %{name}
@@ -173,6 +190,7 @@ developing applications that use %{name}.
%setup -q
%patch0 -p1 -b .orig
%patch1 -p1 -b .orig
+%patch2 -p1 -b .orig
%build
%{cmake} \
@@ -260,6 +278,12 @@ make test
%{_libdir}/%{name}/%{version}/modules/pacrunner_webkit.so
}
+%{?_with_pacrunner:
+%files pacrunner
+%defattr(-,root,root,-)
+%{_libdir}/%{name}/%{version}/modules/config_pacrunner.so
+}
+
%files devel
%defattr(-,root,root,-)
%{_includedir}/proxy.h
@@ -269,6 +293,9 @@ make test
%changelog
+* Thu Jul 18 2013 David Woodhouse <David.Woodhouse at intel.com> - 0.4.11-5
+- Add PacRunner module now that Fedora has PacRunner
+
* Mon Jun 03 2013 Colin Walters <walters at redhat.com> - 0.4.11-4
- Add patch to build with mozjs17, use it by default
More information about the scm-commits
mailing list