tag: Implement Adapter property
authorSamuel Ortiz <sameo@linux.intel.com>
Sun, 24 Nov 2013 22:51:07 +0000 (23:51 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Sun, 24 Nov 2013 23:02:32 +0000 (00:02 +0100)
In order to not only rely on a specific naming scheme, the tag Adapter
path is now exported as a property.

doc/tag-api.txt
src/tag.c

index 8aaf33a..303438b 100644 (file)
@@ -23,7 +23,7 @@ Properties    string Type [readonly]
 
                        The NFC tag type.
                        Possible values are "Type 1", "Type 2", "Type 3",
 
                        The NFC tag type.
                        Possible values are "Type 1", "Type 2", "Type 3",
-                       "Type 4" and "NFC-DEP"
+                       "Type 4" and "NFC-DEP".
 
                string Protocol [readonly]
 
 
                string Protocol [readonly]
 
@@ -33,7 +33,11 @@ Properties   string Type [readonly]
 
                boolean ReadOnly [readonly]
 
 
                boolean ReadOnly [readonly]
 
-                       Give the current status of tag's read mode
+                       Give the current status of tag's read mode.
+
+               object Adapter [readonly]
+
+                       The object path of the adapter the tag belongs to.
 
 
 Record hierarchy
 
 
 Record hierarchy
index 3afb0ee..146a87a 100644 (file)
--- a/src/tag.c
+++ b/src/tag.c
@@ -224,6 +224,27 @@ static gboolean property_get_readonly(const GDBusPropertyTable *property,
        return TRUE;
 }
 
        return TRUE;
 }
 
+static gboolean property_get_adapter(const GDBusPropertyTable *property,
+                                       DBusMessageIter *iter, void *user_data)
+{
+       struct near_tag *tag = user_data;
+       struct near_adapter *adapter;
+       const char *path;
+
+       adapter = __near_adapter_get(tag->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 void tag_read_cb(uint32_t adapter_idx, uint32_t target_idx, int status)
 {
        struct near_tag *tag;
 static void tag_read_cb(uint32_t adapter_idx, uint32_t target_idx, int status)
 {
        struct near_tag *tag;
@@ -450,6 +471,7 @@ static const GDBusPropertyTable tag_properties[] = {
        { "Type", "s", property_get_type },
        { "Protocol", "s", property_get_protocol },
        { "ReadOnly", "b", property_get_readonly },
        { "Type", "s", property_get_type },
        { "Protocol", "s", property_get_protocol },
        { "ReadOnly", "b", property_get_readonly },
+       { "Adapter", "o", property_get_adapter },
 
        { }
 };
 
        { }
 };