Remove providers based on their VPN service path
authorSamuel Ortiz <sameo@linux.intel.com>
Mon, 27 Sep 2010 23:36:32 +0000 (01:36 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 27 Sep 2010 23:39:17 +0000 (01:39 +0200)
src/provider.c
test/disconnect-vpn

index b7dc9e9..adad8df 100644 (file)
@@ -216,18 +216,30 @@ int __connman_provider_connect(struct connman_provider *provider)
 int __connman_provider_remove(const char *path)
 {
        struct connman_provider *provider;
+       GHashTableIter iter;
+       gpointer value, key;
 
        DBG("path %s", path);
 
-       provider = g_hash_table_lookup(provider_hash, path);
-       if (provider == NULL) {
-               DBG("patch %s not found", path);
-               return -ENXIO;
-       }
+       g_hash_table_iter_init(&iter, provider_hash);
+       while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
+               const char *srv_path;
+               provider = value;
 
-       g_hash_table_remove(provider_hash, path);
+               if (provider->vpn_service == NULL)
+                       continue;
 
-       return 0;
+               srv_path = __connman_service_get_path(provider->vpn_service);
+
+               if (g_strcmp0(srv_path, path) == 0) {
+                       DBG("Removing VPN %s", provider->identifier);
+                       g_hash_table_remove(provider_hash,
+                                               provider->identifier);
+                       return 0;
+               }
+       }
+
+       return -ENXIO;
 }
 
 static int set_connected(struct connman_provider *provider,
index 2367f13..21b50d8 100755 (executable)
@@ -4,7 +4,7 @@ import sys
 import dbus
 
 if (len(sys.argv) < 2):
-       print "Usage: %s <provider name> " % (sys.argv[0])
+       print "Usage: %s <VPN service path> " % (sys.argv[0])
        sys.exit(1)
 
 bus = dbus.SystemBus()
@@ -18,5 +18,4 @@ print "remove path is %s" %(path)
 
 manager.RemoveProvider(sys.argv[1])
 
-print "remove path is %s" %(path)