summaryrefslogtreecommitdiffstats
path: root/hcid
diff options
context:
space:
mode:
Diffstat (limited to 'hcid')
-rw-r--r--hcid/adapter.c5
-rw-r--r--hcid/dbus-hci.c23
-rw-r--r--hcid/device.c5
-rw-r--r--hcid/device.h1
4 files changed, 27 insertions, 7 deletions
diff --git a/hcid/adapter.c b/hcid/adapter.c
index b6cfd269..608355f3 100644
--- a/hcid/adapter.c
+++ b/hcid/adapter.c
@@ -3412,11 +3412,6 @@ failed:
adapter->create = NULL;
}
-static gint device_address_cmp(struct device *device, const gchar *address)
-{
- return strcasecmp(device->address, address);
-}
-
static DBusHandlerResult create_device(DBusConnection *conn,
DBusMessage *msg, void *data)
{
diff --git a/hcid/dbus-hci.c b/hcid/dbus-hci.c
index c1faa4a8..52d7342e 100644
--- a/hcid/dbus-hci.c
+++ b/hcid/dbus-hci.c
@@ -572,7 +572,8 @@ int hcid_dbus_unregister_device(uint16_t id)
return ret;
}
-static void create_stored_device(char *key, char *value, void *user_data)
+static void create_stored_device_from_profiles(char *key, char *value,
+ void *user_data)
{
struct adapter *adapter = user_data;
GSList *uuids = bt_string2list(value);
@@ -583,15 +584,33 @@ static void create_stored_device(char *key, char *value, void *user_data)
adapter->devices = g_slist_append(adapter->devices, device);
}
+static void create_stored_device_from_linkkeys(char *key, char *value,
+ void *user_data)
+{
+ struct adapter *adapter = user_data;
+ struct device *device;
+
+ if (g_slist_find_custom(adapter->devices,
+ key, (GCompareFunc) device_address_cmp))
+ return;
+
+ device = device_create(connection, adapter, key, NULL);
+ if (device)
+ adapter->devices = g_slist_append(adapter->devices, device);
+}
+
static void register_devices(bdaddr_t *src, struct adapter *adapter)
{
char filename[PATH_MAX + 1];
char addr[18];
ba2str(src, addr);
+
create_name(filename, PATH_MAX, STORAGEDIR, addr, "profiles");
+ textfile_foreach(filename, create_stored_device_from_profiles, adapter);
- textfile_foreach(filename, create_stored_device, adapter);
+ create_name(filename, PATH_MAX, STORAGEDIR, addr, "linkkeys");
+ textfile_foreach(filename, create_stored_device_from_linkkeys, adapter);
}
int hcid_dbus_start_device(uint16_t id)
diff --git a/hcid/device.c b/hcid/device.c
index c0f0ddbc..2b331361 100644
--- a/hcid/device.c
+++ b/hcid/device.c
@@ -1004,3 +1004,8 @@ void device_destroy(struct device *device, DBusConnection *conn)
dbus_connection_destroy_object_path(conn, device->path);
}
+
+gint device_address_cmp(struct device *device, const gchar *address)
+{
+ return strcasecmp(device->address, address);
+}
diff --git a/hcid/device.h b/hcid/device.h
index 08d4c1b0..db6eed8b 100644
--- a/hcid/device.h
+++ b/hcid/device.h
@@ -34,3 +34,4 @@ struct device {
struct device *device_create(DBusConnection *conn, struct adapter *adapter,
const gchar *address, GSList *uuids);
void device_destroy(struct device *device, DBusConnection *conn);
+gint device_address_cmp(struct device *device, const gchar *address);