summaryrefslogtreecommitdiff
path: root/vpn
diff options
context:
space:
mode:
authorJukka Rissanen <jukka.rissanen@linux.intel.com>2012-11-12 14:07:46 +0200
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-11-23 12:58:52 +0200
commit23b03900f7554185357bbde46d94c133332f3a7e (patch)
tree97bd2c7497f7f155461c91ffbcd8235639a7c9b4 /vpn
parent946b34645410efefabc7caea512025f5f1da478c (diff)
downloadconnman-23b03900f7554185357bbde46d94c133332f3a7e.tar.gz
connman-23b03900f7554185357bbde46d94c133332f3a7e.tar.bz2
connman-23b03900f7554185357bbde46d94c133332f3a7e.zip
vpn-provider: Send ConnectionRemoved signal when needed
Diffstat (limited to 'vpn')
-rw-r--r--vpn/vpn-provider.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/vpn/vpn-provider.c b/vpn/vpn-provider.c
index c46c9b41..09b782aa 100644
--- a/vpn/vpn-provider.c
+++ b/vpn/vpn-provider.c
@@ -989,16 +989,52 @@ int __vpn_provider_connect(struct vpn_provider *provider)
return err;
}
+static void connection_removed_signal(struct vpn_provider *provider)
+{
+ DBusMessage *signal;
+ DBusMessageIter iter;
+
+ signal = dbus_message_new_signal(VPN_MANAGER_PATH,
+ VPN_MANAGER_INTERFACE, "ConnectionRemoved");
+ if (signal == NULL)
+ return;
+
+ dbus_message_iter_init_append(signal, &iter);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
+ &provider->path);
+ dbus_connection_send(connection, signal, NULL);
+ dbus_message_unref(signal);
+}
+
+static char *get_ident(const char *path)
+{
+ char *pos;
+
+ if (*path != '/')
+ return NULL;
+
+ pos = strrchr(path, '/');
+ if (pos == NULL)
+ return NULL;
+
+ return pos + 1;
+}
+
int __vpn_provider_remove(const char *path)
{
struct vpn_provider *provider;
+ char *ident;
DBG("path %s", path);
- provider = vpn_provider_lookup(path);
+ ident = get_ident(path);
+
+ provider = vpn_provider_lookup(ident);
if (provider != NULL) {
DBG("Removing VPN %s", provider->identifier);
+ connection_removed_signal(provider);
+
provider_unregister(provider);
g_hash_table_remove(provider_hash, provider->identifier);
return 0;