diff options
author | npmccallum <npmccallum@c587cffe-e639-0410-9787-d7902ae8ed56> | 2007-11-21 04:16:38 +0000 |
---|---|---|
committer | npmccallum <npmccallum@c587cffe-e639-0410-9787-d7902ae8ed56> | 2007-11-21 04:16:38 +0000 |
commit | a2984a70eb2b3cae38b02ba0bb2af4a04ade355e (patch) | |
tree | b90d4e319fe6a347276c485ed1acd911dc0d15ac | |
parent | c0a069ead1b9ed908f193666b0266af18dce7107 (diff) | |
download | libproxy-a2984a70eb2b3cae38b02ba0bb2af4a04ade355e.tar.gz |
new kde plugin; reworked plugin building
git-svn-id: http://libproxy.googlecode.com/svn/trunk@61 c587cffe-e639-0410-9787-d7902ae8ed56
-rw-r--r-- | configure.ac | 64 | ||||
-rw-r--r-- | src/plugins/Makefile.am | 33 | ||||
-rw-r--r-- | src/plugins/gnome.c | 2 | ||||
-rw-r--r-- | src/plugins/kde.c | 112 |
4 files changed, 180 insertions, 31 deletions
diff --git a/configure.ac b/configure.ac index e04504d..9ff7e37 100644 --- a/configure.ac +++ b/configure.ac @@ -12,6 +12,40 @@ AC_PROG_LN_S AC_PROG_MAKE_SET ### Checks for libraries for plugins. +# Environmental Variable +AC_ARG_WITH([envvar], + [AS_HELP_STRING([--with-envvar], + [build environmental variable configuration plugin @<:@default=yes@:>@])], + [], [with_envvar=yes]) +AM_CONDITIONAL([WITH_ENVVAR], [test x$with_envvar = xyes]) + +# File +AC_ARG_WITH([file], + [AS_HELP_STRING([--with-file], + [build file-based configuration plugin @<:@default=yes@:>@])], + [], [with_file=yes]) +AM_CONDITIONAL([WITH_FILE], [test x$with_envvar = xyes]) + +# GNOME +AC_ARG_WITH([gnome], + [AS_HELP_STRING([--with-gnome], + [build GNOME configuration plugin @<:@automatic@:>@])], + [], + [PKG_CHECK_EXISTS(gconf-2.0, with_gnome=yes, with_gnome=no)]) +if test x$with_gnome = xyes; then + PKG_CHECK_MODULES(GCONF, gconf-2.0) + AC_SUBST(GCONF_CFLAGS) + AC_SUBST(GCONF_LIBS) +fi +AM_CONDITIONAL([WITH_GNOME], [test x$with_gnome = xyes]) + +# KDE +AC_ARG_WITH([kde], + [AS_HELP_STRING([--with-kde], + [build KDE configuration plugin @<:@default=yes@:>@])], + [], [with_kde=yes]) +AM_CONDITIONAL([WITH_KDE], [test x$with_kde = xyes]) + # Mozilla Javascript AC_ARG_WITH([mozjs], [AS_HELP_STRING([--with-mozjs], @@ -26,19 +60,6 @@ if test x$with_mozjs = xyes; then fi AM_CONDITIONAL([WITH_MOZJS], [test x$with_mozjs = xyes]) -# GConf -AC_ARG_WITH([gnome], - [AS_HELP_STRING([--with-gnome], - [build GConf configuration plugin @<:@automatic@:>@])], - [], - [PKG_CHECK_EXISTS(gconf-2.0, with_gnome=yes, with_gnome=no)]) -if test x$with_gnome = xyes; then - PKG_CHECK_MODULES(GCONF, gconf-2.0) - AC_SUBST(GCONF_CFLAGS) - AC_SUBST(GCONF_LIBS) -fi -AM_CONDITIONAL([WITH_GNOME], [test x$with_gnome = xyes]) - # NetworkManager AC_ARG_WITH([networkmanager], [AS_HELP_STRING([--with-networkmanager], @@ -94,16 +115,17 @@ AC_OUTPUT echo echo "------------------------------------------------------" echo -e "\tPlugins to build..." -echo -e "\t\tenvvar\t\t\tyes" -echo -e "\t\tfile\t\t\tyes" -echo -e "\t\tmozjs\t\t\t$with_mozjs" -echo -e "\t\tgnome\t\t\t$with_gnome" -echo -e "\t\tnetworkmanager\t\t$with_networkmanager" +echo -e "\t\tenvvar : $with_envvar" +echo -e "\t\tfile : $with_file" +echo -e "\t\tgnome : $with_gnome" +echo -e "\t\tkde : $with_kde" +echo -e "\t\tmozjs : $with_mozjs" +echo -e "\t\tnetworkmanager : $with_networkmanager" echo echo -e "\tBindings to build..." -echo -e "\t\tpython\t\t\t$with_python" -echo -e "\t\tjava\t\t\t$with_java" -echo -e "\t\tdotnet\t\t\t$with_dotnet" +echo -e "\t\tpython : $with_python" +echo -e "\t\tjava : $with_java" +echo -e "\t\tdotnet : $with_dotnet" echo "------------------------------------------------------" echo diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am index 20d753d..15113a5 100644 --- a/src/plugins/Makefile.am +++ b/src/plugins/Makefile.am @@ -1,13 +1,22 @@ plugindir = @PLUGINDIR@ # Which modules to build -plugin_LTLIBRARIES = envvar.la file.la -if WITH_MOZJS -plugin_LTLIBRARIES += mozjs.la +plugin_LTLIBRARIES = +if WITH_ENVVAR +plugin_LTLIBRARIES += envvar.la +endif +if WITH_FILE +plugin_LTLIBRARIES += file.la endif if WITH_GNOME plugin_LTLIBRARIES += gnome.la endif +if WITH_KDE +plugin_LTLIBRARIES += kde.la +endif +if WITH_MOZJS +plugin_LTLIBRARIES += mozjs.la +endif if WITH_NETWORKMANAGER plugin_LTLIBRARIES += networkmanager.la endif @@ -24,6 +33,18 @@ file_la_CFLAGS = -I../lib file_la_LIBADD = ../lib/libproxy.la file_la_LDFLAGS = -module -avoid-version +# GConf/GNOME Config Plugin +gnome_la_SOURCES = gnome.c +gnome_la_CFLAGS = -I../lib @GCONF_CFLAGS@ +gnome_la_LIBADD = ../lib/libproxy.la +gnome_la_LDFLAGS = -module -avoid-version @GCONF_LIBS@ + +# KDE Config Plugin +kde_la_SOURCES = kde.c +kde_la_CFLAGS = -I../lib +kde_la_LIBADD = ../lib/libproxy.la +kde_la_LDFLAGS = -module -avoid-version + # Mozilla (Spidermonkey) based PAC runner mozjs_la_SOURCES = mozjs.c mozjs_la_CFLAGS = -I../lib @MOZJS_CFLAGS@ @@ -31,12 +52,6 @@ mozjs_la_LIBADD = ../lib/libproxy.la mozjs_la_LDFLAGS = -module -avoid-version @MOZJS_LIBS@ nodist_mozjs_la_SOURCES = pacutils.h -# GConf/GNOME Config Plugin -gnome_la_SOURCES = gnome.c -gnome_la_CFLAGS = -I../lib @GCONF_CFLAGS@ -gnome_la_LIBADD = ../lib/libproxy.la -gnome_la_LDFLAGS = -module -avoid-version @GCONF_LIBS@ - # NetworkManager Plugin networkmanager_la_SOURCES = networkmanager.c networkmanager_la_CFLAGS = -I../lib @NETWORKMANAGER_CFLAGS@ diff --git a/src/plugins/gnome.c b/src/plugins/gnome.c index 22929e6..5ee25f1 100644 --- a/src/plugins/gnome.c +++ b/src/plugins/gnome.c @@ -108,7 +108,7 @@ gconf_on_get_proxy(pxProxyFactory *self) { // If we are running in GNOME, then make sure this plugin is registered. // Otherwise, make sure this plugin is NOT registered. - if (!system("xlsclients 2>/dev/null | grep -q '[\t ]gnome-session$'")) + if (!system("xlsclients 2>/dev/null | grep -q -E '[\t ]gnome-(session|panel)$'")) px_proxy_factory_config_add(self, "gnome", PX_CONFIG_CATEGORY_SESSION, (pxProxyFactoryPtrCallback) gconf_config_cb); else diff --git a/src/plugins/kde.c b/src/plugins/kde.c new file mode 100644 index 0000000..d177dea --- /dev/null +++ b/src/plugins/kde.c @@ -0,0 +1,112 @@ +/******************************************************************************* + * libproxy - A library for proxy configuration + * Copyright (C) 2006 Nathaniel McCallum <nathaniel@natemccallum.com> + * + * 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 3 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 <stdlib.h> +#include <string.h> + +#include <misc.h> +#include <proxy_factory.h> +#include <config_file.h> + +pxConfig * +kde_config_cb(pxProxyFactory *self) +{ + char *url = NULL, *ignore = NULL, *tmp = getenv("HOME"); + pxConfig *config; + if (!tmp) return NULL; + + // Open the config file + pxConfigFile *cf = px_proxy_factory_misc_get(self, "kde"); + if (!cf || px_config_file_is_stale(cf)) + { + if (cf) px_config_file_free(cf); + tmp = px_strcat(getenv("HOME"), "/.kde/share/config/kioslaverc", NULL); + cf = px_config_file_new(tmp); + px_free(tmp); + px_proxy_factory_misc_set(self, "kde", cf); + } + if (!cf) goto out; + + // Read the config file to find out what type of proxy to use + tmp = px_config_file_get_value(cf, "Proxy Settings", "ProxyType"); + if (!tmp) { px_config_file_free(cf); goto out; } + + // Don't use any proxy + if (!strcmp(tmp, "0")) + url = px_strdup("direct://"); + + // Use a manual proxy + else if (!strcmp(tmp, "1")) + url = px_config_file_get_value(cf, "Proxy Settings", "httpProxy"); + + // Use a manual PAC + else if (!strcmp(tmp, "2")) + { + px_free(tmp); + tmp = px_config_file_get_value(cf, "Proxy Settings", "Proxy Config Script"); + if (tmp) url = px_strcat("pac+", tmp); + } + + // Anything else? Fall back to WPAD... + + // Cleanup + px_free(tmp); + px_config_file_free(cf); + + out: + config = px_malloc0(sizeof(pxConfig)); + config->url = url ? url : px_strdup("wpad://"); + config->ignore = ignore ? ignore : px_strdup(""); + return config; +} + +void +kde_on_get_proxy(pxProxyFactory *self) +{ + // If we are running in KDE, then make sure this plugin is registered. + // Otherwise, make sure this plugin is NOT registered. + if (!system("xlsclients 2>/dev/null | grep -q '[\t ]kicker$'")) + px_proxy_factory_config_add(self, "kde", PX_CONFIG_CATEGORY_SESSION, + (pxProxyFactoryPtrCallback) kde_config_cb); + else + px_proxy_factory_config_del(self, "kde"); + + return; +} + +bool +on_proxy_factory_instantiate(pxProxyFactory *self) +{ + // Note that we instantiate like this because SESSION config plugins + // are only suppossed to remain registered while the application + // is actually IN that session. So for instance, if the app + // was run in GNU screen and is taken out of the GNOME sesion + // it was started in, we should handle that gracefully. + px_proxy_factory_on_get_proxy_add(self, kde_on_get_proxy); + return true; +} + +void +on_proxy_factory_destantiate(pxProxyFactory *self) +{ + px_proxy_factory_on_get_proxy_del(self, kde_on_get_proxy); + px_proxy_factory_config_del(self, "kde"); + px_config_file_free(px_proxy_factory_misc_get(self, "kde")); + px_proxy_factory_misc_set(self, "kde", NULL); +} |