diff options
author | ERAMOTO Masaya <eramoto.masaya@jp.fujitsu.com> | 2017-12-28 14:44:03 +0900 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2018-01-02 14:15:46 -0200 |
commit | 6bf4c63d66d04b2434656de9f98836ac11cf27b7 (patch) | |
tree | 1e2fc443873889ce9e9c721bed4d86e1b0989c9a /client/gatt.c | |
parent | a5d01a31abfdd7baba3709805066ffd271d74f79 (diff) | |
download | bluez-6bf4c63d66d04b2434656de9f98836ac11cf27b7.tar.gz |
client: Use g_dbus_proxy_lookup()
Diffstat (limited to 'client/gatt.c')
-rw-r--r-- | client/gatt.c | 38 |
1 files changed, 9 insertions, 29 deletions
diff --git a/client/gatt.c b/client/gatt.c index 224a78a13..3d0222e63 100644 --- a/client/gatt.c +++ b/client/gatt.c @@ -206,25 +206,16 @@ static void print_characteristic(GDBusProxy *proxy, const char *description) 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) @@ -378,33 +369,22 @@ void gatt_list_attributes(const char *path) 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, |