aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--attrib/client.c16
-rw-r--r--attrib/client.h2
-rw-r--r--src/device.c11
-rw-r--r--src/device.h1
4 files changed, 11 insertions, 19 deletions
diff --git a/attrib/client.c b/attrib/client.c
index 28e57042..2dd70c94 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -1020,11 +1020,11 @@ static GDBusMethodTable prim_methods[] = {
{ }
};
-static void register_primaries(struct gatt_service *gatt, GSList *primaries)
+static GSList *register_primaries(struct gatt_service *gatt, GSList *primaries)
{
- GSList *l;
+ GSList *l, *paths;
- for (l = primaries; l; l = l->next) {
+ for (paths = NULL, l = primaries; l; l = l->next) {
struct att_primary *att = l->data;
struct primary *prim;
@@ -1040,12 +1040,14 @@ static void register_primaries(struct gatt_service *gatt, GSList *primaries)
DBG("Registered: %s", prim->path);
gatt->primary = g_slist_append(gatt->primary, prim);
- btd_device_add_service(gatt->dev, prim->path);
+ paths = g_slist_append(paths, g_strdup(prim->path));
load_characteristics(prim, gatt);
}
+
+ return paths;
}
-int attrib_client_register(DBusConnection *connection,
+GSList *attrib_client_register(DBusConnection *connection,
struct btd_device *device, int psm,
GAttrib *attrib, GSList *primaries)
{
@@ -1069,11 +1071,9 @@ int attrib_client_register(DBusConnection *connection,
if (attrib)
gatt->attrib = g_attrib_ref(attrib);
- register_primaries(gatt, primaries);
-
gatt_services = g_slist_append(gatt_services, gatt);
- return 0;
+ return register_primaries(gatt, primaries);
}
void attrib_client_unregister(struct btd_device *device)
diff --git a/attrib/client.h b/attrib/client.h
index b4a4eccb..b29797ce 100644
--- a/attrib/client.h
+++ b/attrib/client.h
@@ -22,7 +22,7 @@
*
*/
-int attrib_client_register(DBusConnection *connection,
+GSList *attrib_client_register(DBusConnection *connection,
struct btd_device *device, int psm,
GAttrib *attrib, GSList *primaries);
void attrib_client_unregister(struct btd_device *device);
diff --git a/src/device.c b/src/device.c
index f9b7a735..efe9938c 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2336,18 +2336,11 @@ void device_set_authorizing(struct btd_device *device, gboolean auth)
device->authorizing = auth;
}
-void btd_device_add_service(struct btd_device *device, const char *path)
-{
- if (g_slist_find_custom(device->services, path, (GCompareFunc) strcmp))
- return;
-
- device->services = g_slist_append(device->services, g_strdup(path));
-}
-
void device_register_services(DBusConnection *conn, struct btd_device *device,
GSList *prim_list, int psm)
{
- attrib_client_register(conn, device, psm, NULL, prim_list);
+ device->services = attrib_client_register(conn, device, psm, NULL,
+ prim_list);
device->primaries = g_slist_concat(device->primaries, prim_list);
}
diff --git a/src/device.h b/src/device.h
index 285364f9..2432884b 100644
--- a/src/device.h
+++ b/src/device.h
@@ -56,7 +56,6 @@ void device_probe_drivers(struct btd_device *device, GSList *profiles);
const sdp_record_t *btd_device_get_record(struct btd_device *device,
const char *uuid);
GSList *btd_device_get_primaries(struct btd_device *device);
-void btd_device_add_service(struct btd_device *device, const char *path);
void device_register_services(DBusConnection *conn, struct btd_device *device,
GSList *prim_list, int psm);
void btd_device_add_uuid(struct btd_device *device, const char *uuid);