mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-15 08:14:28 +08:00
client: Use g_dbus_proxy_lookup()
This commit is contained in:
parent
a5d01a31ab
commit
6bf4c63d66
@ -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,
|
||||
|
@ -392,9 +392,8 @@ static gboolean device_is_child(GDBusProxy *device, GDBusProxy *master)
|
||||
|
||||
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;
|
||||
@ -404,16 +403,8 @@ static gboolean service_is_child(GDBusProxy *service)
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user