aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2010-10-16 15:43:53 +0300
committerMarcel Holtmann <marcel@holtmann.org>2010-10-16 15:43:53 +0300
commit67aa9c358090818a872cef2711bea4405943161f (patch)
treee2ee58ebf15d418a5b7b36dcf410b586ddc4138c
parentf2ca83d33949c14b60aaa6993248dc6dd8b5fd29 (diff)
downloadpacrunner-67aa9c358090818a872cef2711bea4405943161f.tar.gz
Add support for tracking list of active proxy configurations
-rw-r--r--src/manager.c4
-rw-r--r--src/pacrunner.h3
-rw-r--r--src/proxy.c52
3 files changed, 59 insertions, 0 deletions
diff --git a/src/manager.c b/src/manager.c
index 64e41d2..c4fe90e 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -51,6 +51,8 @@ static void destroy_config(gpointer data)
DBG("path %s", config->path);
+ pacrunner_proxy_disable(config->proxy);
+
pacrunner_proxy_unref(config->proxy);
if (config->watch > 0)
@@ -228,6 +230,8 @@ static DBusMessage *create_proxy_config(DBusConnection *conn,
g_hash_table_insert(config_list, config->path, config);
+ pacrunner_proxy_enable(config->proxy);
+
return g_dbus_create_reply(msg, DBUS_TYPE_OBJECT_PATH, &config->path,
DBUS_TYPE_INVALID);
}
diff --git a/src/pacrunner.h b/src/pacrunner.h
index 99a1a48..5ab65b8 100644
--- a/src/pacrunner.h
+++ b/src/pacrunner.h
@@ -90,6 +90,9 @@ int pacrunner_proxy_set_script(struct pacrunner_proxy *proxy,
int pacrunner_proxy_set_server(struct pacrunner_proxy *proxy,
const char *server);
+int pacrunner_proxy_enable(struct pacrunner_proxy *proxy);
+int pacrunner_proxy_disable(struct pacrunner_proxy *proxy);
+
const char *pacrunner_proxy_lookup(const char *url, const char *host);
int __pacrunner_proxy_init(void);
diff --git a/src/proxy.c b/src/proxy.c
index 1190483..f2c9a5c 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -253,6 +253,44 @@ int pacrunner_proxy_set_server(struct pacrunner_proxy *proxy,
return 0;
}
+static GList *proxy_list = NULL;
+
+int pacrunner_proxy_enable(struct pacrunner_proxy *proxy)
+{
+ DBG("proxy %p", proxy);
+
+ if (proxy == NULL)
+ return -EINVAL;
+
+ proxy = pacrunner_proxy_ref(proxy);
+ if (proxy == NULL)
+ return -EIO;
+
+ proxy_list = g_list_append(proxy_list, proxy);
+
+ return 0;
+}
+
+int pacrunner_proxy_disable(struct pacrunner_proxy *proxy)
+{
+ GList *list;
+
+ DBG("proxy %p", proxy);
+
+ if (proxy == NULL)
+ return -EINVAL;
+
+ list = g_list_find(proxy_list, proxy);
+ if (list == NULL)
+ return -ENXIO;
+
+ proxy_list = g_list_remove_link(proxy_list, list);
+
+ pacrunner_proxy_unref(proxy);
+
+ return 0;
+}
+
const char *pacrunner_proxy_lookup(const char *url, const char *host)
{
DBG("url %s host %s", url, host);
@@ -269,5 +307,19 @@ int __pacrunner_proxy_init(void)
void __pacrunner_proxy_cleanup(void)
{
+ GList *list;
+
DBG("");
+
+ for (list = g_list_first(proxy_list); list; list = g_list_next(list)) {
+ struct pacrunner_proxy *proxy = list->data;
+
+ DBG("proxy %p", proxy);
+
+ if (proxy != NULL)
+ pacrunner_proxy_unref(proxy);
+ }
+
+ g_list_free(proxy_list);
+ proxy_list = NULL;
}