5 * Copyright (C) 2007-2010 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 static unsigned int next_lookup_token = 1;
32 static GSList *driver_list = NULL;
36 connman_proxy_lookup_cb cb;
41 static gboolean lookup_callback(gpointer user_data)
43 struct proxy_lookup *lookup = user_data;
48 lookup->cb(NULL, lookup->user_data);
55 unsigned int connman_proxy_lookup(const char *interface, const char *url,
56 connman_proxy_lookup_cb cb, void *user_data)
58 struct proxy_lookup *lookup;
60 DBG("interface %s url %s", interface, url);
62 if (interface == NULL)
65 lookup = g_try_new0(struct proxy_lookup, 1);
69 lookup->token = next_lookup_token++;
72 lookup->user_data = user_data;
74 lookup->watch = g_timeout_add_seconds(0, lookup_callback, lookup);
75 if (lookup->watch == 0) {
80 DBG("token %u", lookup->token);
85 void connman_proxy_lookup_cancel(unsigned int token)
87 DBG("token %u", token);
90 void connman_proxy_driver_lookup_notify(struct connman_service *service,
91 const char *url, const char *result)
93 DBG("service %p url %s result %s", service, url, result);
99 static gint compare_priority(gconstpointer a, gconstpointer b)
101 const struct connman_proxy_driver *driver1 = a;
102 const struct connman_proxy_driver *driver2 = b;
104 return driver2->priority - driver1->priority;
108 * connman_proxy_driver_register:
109 * @driver: Proxy driver definition
111 * Register a new proxy driver
113 * Returns: %0 on success
115 int connman_proxy_driver_register(struct connman_proxy_driver *driver)
117 DBG("driver %p name %s", driver, driver->name);
119 driver_list = g_slist_insert_sorted(driver_list, driver,
126 * connman_proxy_driver_unregister:
127 * @driver: Proxy driver definition
129 * Remove a previously registered proxy driver
131 void connman_proxy_driver_unregister(struct connman_proxy_driver *driver)
133 DBG("driver %p name %s", driver, driver->name);
135 driver_list = g_slist_remove(driver_list, driver);
138 int __connman_proxy_init(void)
145 void __connman_proxy_cleanup(void)