summaryrefslogtreecommitdiffstats
path: root/dundee
diff options
context:
space:
mode:
authorPaulo Borges <paulo.borges@openbossa.org>2013-03-20 19:26:38 -0300
committerDaniel Wagner <daniel.wagner@bmw-carit.de>2013-03-24 13:22:14 +0100
commita3ce2daccd117c020029f842c79947b96ef1abf9 (patch)
tree67c3c23fcc8cc9ca66cef45bff14df72936bfac7 /dundee
parent9e90988fb4f573f292e4f0497d60833fcb35e047 (diff)
downloadofono-a3ce2daccd117c020029f842c79947b96ef1abf9.tar.bz2
dundee: Register/unregister dundee device
This patch adds the dundee device struct to the our Bluetooth device representation.
Diffstat (limited to 'dundee')
-rw-r--r--dundee/bluez5.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/dundee/bluez5.c b/dundee/bluez5.c
index 06a386cd..37ac4d08 100644
--- a/dundee/bluez5.c
+++ b/dundee/bluez5.c
@@ -35,6 +35,8 @@ static GDBusClient *bluez;
static GHashTable *registered_devices;
struct bluetooth_device {
+ struct dundee_device *device;
+
char *path;
char *address;
char *name;
@@ -46,6 +48,9 @@ static void bluetooth_device_destroy(gpointer user_data)
DBG("%s", bt_device->path);
+ if (bt_device->device != NULL)
+ dundee_device_unregister(bt_device->device);
+
g_free(bt_device->path);
g_free(bt_device->address);
g_free(bt_device->name);
@@ -93,6 +98,7 @@ static struct bluetooth_device *bluetooth_device_register(GDBusProxy *proxy)
const char *path = g_dbus_proxy_get_path(proxy);
const char *alias, *address;
struct bluetooth_device *bt_device;
+ struct dundee_device *device;
DBusMessageIter iter;
DBG("%s", path);
@@ -116,9 +122,26 @@ static struct bluetooth_device *bluetooth_device_register(GDBusProxy *proxy)
return NULL;
}
+ device = dundee_device_create(&bluetooth_driver);
+ if (device == NULL)
+ goto free;
+
+ dundee_device_set_data(device, bt_device);
+ dundee_device_set_name(device, bt_device->name);
+
+ if (dundee_device_register(device) < 0) {
+ g_free(device);
+ goto free;
+ }
+
+ bt_device->device = device;
g_hash_table_insert(registered_devices, g_strdup(path), bt_device);
return bt_device;
+
+free:
+ bluetooth_device_destroy(bt_device);
+ return NULL;
}
static void bluetooth_device_unregister(const char *path)