BlueZ/Device: Add function bluez_device_network_disconnect() 43/19043/1
authorWu Jiangbo <jiangbox.wu@intel.com>
Wed, 2 Apr 2014 02:15:25 +0000 (10:15 +0800)
committerWu Jiangbo <jiangbox.wu@intel.com>
Fri, 4 Apr 2014 11:33:41 +0000 (19:33 +0800)
Change-Id: I0fc2165c0289f9f169f77681d3d2e467f5e5370c
Signed-off-by: Wu Jiangbo <jiangbox.wu@intel.com>
include/bluez.h
lib/bluez.c

index 20503a0..0893ed1 100644 (file)
@@ -245,6 +245,8 @@ GList *bluez_adapter_get_devices(
 int bluez_device_network_connect(
                                struct _bluez_device *device,
                                const gchar *role);
+int bluez_device_network_disconnect(
+                               struct _bluez_device *device);
 
 typedef void (*bluez_device_paired_cb_t)(
                                struct _bluez_device *device,
index 819829b..1aedc1d 100644 (file)
@@ -1756,6 +1756,29 @@ int bluez_device_network_connect(struct _bluez_device *device,
        return 0;
 }
 
+int bluez_device_network_disconnect(struct _bluez_device *device)
+{
+       struct simple_reply_data *reply_data;
+
+       reply_data = g_try_new0(struct simple_reply_data, 1);
+       if (reply_data == NULL) {
+               ERROR("no memory");
+               return -1;
+       }
+
+       reply_data->proxy = device->network_proxy;
+
+       DBG("%p", device->network_proxy);
+       if (!device->network_proxy)
+               return -1;
+
+       g_dbus_proxy_call(device->network_proxy, "Disconnect",
+                               NULL, 0, -1, NULL,
+                               simple_reply_callback, reply_data);
+
+       return 0;
+}
+
 void bluez_device_set_paired_changed_cb(struct _bluez_device *device,
                                        bluez_device_paired_cb_t cb,
                                        gpointer user_data)