Add proxy auto-config support to service and IP config framework
authorMarcel Holtmann <marcel@holtmann.org>
Fri, 30 Jul 2010 03:46:12 +0000 (20:46 -0700)
committerMarcel Holtmann <marcel@holtmann.org>
Fri, 30 Jul 2010 03:46:12 +0000 (20:46 -0700)
src/connman.h
src/ipconfig.c
src/service.c

index 4ef60f1..d0b1d2d 100644 (file)
@@ -258,6 +258,9 @@ int __connman_ipconfig_set_gateway(struct connman_ipconfig *ipconfig,
 int __connman_ipconfig_set_address(struct connman_ipconfig *ipconfig);
 int __connman_ipconfig_clear_address(struct connman_ipconfig *ipconfig);
 
+int __connman_ipconfig_set_proxy_autoconfig(struct connman_ipconfig *ipconfig,
+                                                       const char *url);
+
 int __connman_ipconfig_load(struct connman_ipconfig *ipconfig,
                GKeyFile *keyfile, const char *identifier, const char *prefix);
 int __connman_ipconfig_save(struct connman_ipconfig *ipconfig,
@@ -481,6 +484,8 @@ void __connman_service_set_domainname(struct connman_service *service,
                                                const char *domainname);
 const char *__connman_service_get_domainname(struct connman_service *service);
 const char *__connman_service_get_nameserver(struct connman_service *service);
+void __connman_service_set_proxy_autoconfig(struct connman_service *service,
+                                                       const char *url);
 
 unsigned long __connman_service_stats_get_rx_packets(struct connman_service *service);
 unsigned long __connman_service_stats_get_tx_packets(struct connman_service *service);
index bdc1cda..66442a2 100644 (file)
@@ -1189,6 +1189,27 @@ int __connman_ipconfig_clear_address(struct connman_ipconfig *ipconfig)
        return 0;
 }
 
+int __connman_ipconfig_set_proxy_autoconfig(struct connman_ipconfig *ipconfig,
+                                                        const char *url)
+{
+       struct connman_ipdevice *ipdevice;
+
+       DBG("ipconfig %p", ipconfig);
+
+       if (ipconfig == NULL || ipconfig->index < 0)
+               return -ENODEV;
+
+       ipdevice = g_hash_table_lookup(ipdevice_hash,
+                                       GINT_TO_POINTER(ipconfig->index));
+       if (ipdevice == NULL)
+               return -ENXIO;
+
+       g_free(ipdevice->pac);
+       ipdevice->pac = g_strdup(url);
+
+       return 0;
+}
+
 int __connman_ipconfig_enable(struct connman_ipconfig *ipconfig)
 {
        struct connman_ipdevice *ipdevice;
index 347623c..2093b0f 100644 (file)
@@ -996,6 +996,16 @@ static void domain_configuration_changed(struct connman_service *service)
                                DBUS_TYPE_STRING, append_domainconfig, service);
 }
 
+static void proxy_changed(struct connman_service *service)
+{
+       if (is_connected(service) == FALSE)
+               return;
+
+       connman_dbus_property_changed_dict(service->path,
+                                       CONNMAN_SERVICE_INTERFACE, "Proxy",
+                                                       append_proxy, service);
+}
+
 static void append_properties(DBusMessageIter *dict, dbus_bool_t limited,
                                        struct connman_service *service)
 {
@@ -1175,6 +1185,19 @@ void __connman_service_list_struct(DBusMessageIter *iter)
        g_sequence_foreach(service_list, append_struct, iter);
 }
 
+void __connman_service_set_proxy_autoconfig(struct connman_service *service,
+                                                        const char *url)
+{
+       if (service == NULL)
+               return;
+
+       if (__connman_ipconfig_set_proxy_autoconfig(service->ipconfig,
+                                                               url) < 0)
+               return;
+
+       proxy_changed(service);
+}
+
 static DBusMessage *get_properties(DBusConnection *conn,
                                        DBusMessage *msg, void *user_data)
 {