adapter: Export CurrentTarget property
authorSamuel Ortiz <sameo@linux.intel.com>
Wed, 27 Apr 2011 16:54:56 +0000 (18:54 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Fri, 21 Oct 2011 06:54:01 +0000 (23:54 -0700)
doc/adapter-api.txt
src/adapter.c

index de8334c..bf1ab45 100644 (file)
@@ -86,7 +86,6 @@ Properties:   string Mode [readwrite]
                        Possible values are "Felica", "MIFARE", "Jewel",
                        "ISO-DEP" and "NFC-DEP".
 
-               array{object} Targets [readonly]
+               object CurrentTarget [readonly]
 
-                       List of target object paths.
-                       This is only valid when the adapter is in initiator mode.
+                       Current target object path.
index 175ff8c..92bc0f2 100644 (file)
@@ -48,6 +48,8 @@ struct near_adapter {
 
        near_bool_t powered;
        near_bool_t polling;
+
+       struct near_target *target;
 };
 
 static void free_adapter(gpointer data)
@@ -122,7 +124,6 @@ static void append_protocols(DBusMessageIter *iter, void *user_data)
        }
 }
 
-
 static DBusMessage *get_properties(DBusConnection *conn,
                                        DBusMessage *msg, void *data)
 {
@@ -149,6 +150,17 @@ static DBusMessage *get_properties(DBusConnection *conn,
        near_dbus_dict_append_array(&dict, "Protocols",
                                DBUS_TYPE_STRING, append_protocols, adapter);
 
+       if (adapter->target != NULL) {
+               const char *target_path;
+
+               target_path = __near_target_get_path(adapter->target);
+
+               if (target_path != NULL) {
+                       near_dbus_dict_append_basic(&dict, "CurrentTarget",
+                               DBUS_TYPE_OBJECT_PATH, &target_path);
+               }
+       }
+
        near_dbus_dict_close(&array, &dict);
 
        return reply;