summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2013-11-25 00:00:03 +0100
committerSamuel Ortiz <sameo@linux.intel.com>2013-11-25 00:02:46 +0100
commit1038cc3211d8d60603657dfeef9a4bbbce1fab90 (patch)
tree971277d22e34d0f543a824ba341e8cf678011a6e
parent146b9cd51896f5ded3a9afb67c2afc036f1e3f04 (diff)
downloadneard-1038cc3211d8d60603657dfeef9a4bbbce1fab90.tar.gz
neard-1038cc3211d8d60603657dfeef9a4bbbce1fab90.tar.bz2
neard-1038cc3211d8d60603657dfeef9a4bbbce1fab90.zip
device: Implement Adapter property
In order to not only rely on a specific naming scheme, the device Adapter path is now exported as a property.
-rw-r--r--doc/device-api.txt3
-rw-r--r--src/device.c33
2 files changed, 33 insertions, 3 deletions
diff --git a/doc/device-api.txt b/doc/device-api.txt
index 0852368..94efcfa 100644
--- a/doc/device-api.txt
+++ b/doc/device-api.txt
@@ -33,3 +33,6 @@ Method void Push(dict attributes)
org.neard.Error.InvalidArguments
org.neard.Error.InProgress
+Properties object Adapter [readonly]
+
+ The object path of the adapter the device belongs to.
diff --git a/src/device.c b/src/device.c
index 5e67443..a6598e0 100644
--- a/src/device.c
+++ b/src/device.c
@@ -225,12 +225,39 @@ error:
return __near_error_failed(msg, -err);
}
+static gboolean property_get_adapter(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *user_data)
+{
+ struct near_device *device = user_data;
+ struct near_adapter *adapter;
+ const char *path;
+
+ adapter = __near_adapter_get(device->adapter_idx);
+ if (!adapter)
+ return FALSE;
+
+ path = __near_adapter_get_path(adapter);
+ if (!path)
+ return FALSE;
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path);
+
+ return TRUE;
+
+}
+
static const GDBusMethodTable device_methods[] = {
{ GDBUS_ASYNC_METHOD("Push", GDBUS_ARGS({"attributes", "a{sv}"}),
NULL, push_ndef) },
{ },
};
+static const GDBusPropertyTable device_properties[] = {
+ { "Adapter", "o", property_get_adapter },
+
+ { }
+};
+
void __near_device_remove(struct near_device *device)
{
char *path = device->path;
@@ -346,9 +373,9 @@ bool __near_device_register_interface(struct near_device *device)
DBG("connection %p", connection);
return g_dbus_register_interface(connection, device->path,
- NFC_DEVICE_INTERFACE,
- device_methods, NULL, NULL,
- device, NULL);
+ NFC_DEVICE_INTERFACE,
+ device_methods, NULL,
+ device_properties, device, NULL);
}
int __near_device_listen(struct near_device *device, near_device_io_cb cb)