diff --git a/client/gatt.c b/client/gatt.c
index 224a78a..3d0222e 100644
--- a/client/gatt.c
+++ b/client/gatt.c
static gboolean chrc_is_child(GDBusProxy *characteristic)
{
- GList *l;
DBusMessageIter iter;
- const char *service, *path;
+ const char *service;
if (!g_dbus_proxy_get_property(characteristic, "Service", &iter))
return FALSE;
dbus_message_iter_get_basic(&iter, &service);
- for (l = services; l; l = g_list_next(l)) {
- GDBusProxy *proxy = l->data;
-
- path = g_dbus_proxy_get_path(proxy);
-
- if (!strcmp(path, service))
- return TRUE;
- }
-
- return FALSE;
+ return g_dbus_proxy_lookup(services, NULL, service,
+ "org.bluez.GattService1") != NULL;
}
void gatt_add_characteristic(GDBusProxy *proxy)
list_attributes(path, services);
}
-static GDBusProxy *select_proxy(const char *path, GList *source)
-{
- GList *l;
-
- for (l = source; l; l = g_list_next(l)) {
- GDBusProxy *proxy = l->data;
-
- if (strcmp(path, g_dbus_proxy_get_path(proxy)) == 0)
- return proxy;
- }
-
- return NULL;
-}
-
static GDBusProxy *select_attribute(const char *path)
{
GDBusProxy *proxy;
- proxy = select_proxy(path, services);
+ proxy = g_dbus_proxy_lookup(services, NULL, path,
+ "org.bluez.GattService1");
if (proxy)
return proxy;
- proxy = select_proxy(path, characteristics);
+ proxy = g_dbus_proxy_lookup(characteristics, NULL, path,
+ "org.bluez.GattCharacteristic1");
if (proxy)
return proxy;
- return select_proxy(path, descriptors);
+ return g_dbus_proxy_lookup(descriptors, NULL, path,
+ "org.bluez.GattDescriptor1");
}
static GDBusProxy *select_proxy_by_uuid(GDBusProxy *parent, const char *uuid,
diff --git a/client/main.c b/client/main.c
index 26d99d6..d3aee45 100644
--- a/client/main.c
+++ b/client/main.c
static gboolean service_is_child(GDBusProxy *service)
{
- GList *l;
DBusMessageIter iter;
- const char *device, *path;
+ const char *device;
if (g_dbus_proxy_get_property(service, "Device", &iter) == FALSE)
return FALSE;
if (!default_ctrl)
return FALSE;
- for (l = default_ctrl->devices; l; l = g_list_next(l)) {
- struct GDBusProxy *proxy = l->data;
-
- path = g_dbus_proxy_get_path(proxy);
-
- if (!strcmp(path, device))
- return TRUE;
- }
-
- return FALSE;
+ return g_dbus_proxy_lookup(default_ctrl->devices, NULL, device,
+ "org.bluez.Device1") != NULL;
}
static struct adapter *find_parent(GDBusProxy *device)