1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROMEOS_DBUS_NFC_TAG_CLIENT_H_
6 #define CHROMEOS_DBUS_NFC_TAG_CLIENT_H_
12 #include "chromeos/chromeos_export.h"
13 #include "chromeos/dbus/dbus_client.h"
14 #include "chromeos/dbus/dbus_client_implementation_type.h"
15 #include "chromeos/dbus/nfc_client_helpers.h"
16 #include "chromeos/dbus/nfc_property_set.h"
17 #include "dbus/object_path.h"
18 #include "dbus/object_proxy.h"
19 #include "dbus/property.h"
23 class NfcAdapterClient;
25 // NfcTagClient is used to communicate with objects representing remote NFC
27 class CHROMEOS_EXPORT NfcTagClient : public DBusClient {
29 // Structure of properties associated with an NFC tag.
30 struct Properties : public NfcPropertySet {
31 // The NFC tag type. Possible values are "Type 1", "Type 2", "Type 3",
33 dbus::Property<std::string> type;
35 // The NFC tag radio protocol. Possible values are "Felica", "MIFARE",
36 // "Jewel", "ISO-DEP", and "NFC-DEP".
37 dbus::Property<std::string> protocol;
39 // List of object paths for NDEF Records associated with the NFC tag.
40 dbus::Property<std::vector<dbus::ObjectPath> > records;
42 // The current status of the tag's read mode.
43 dbus::Property<bool> read_only;
45 Properties(dbus::ObjectProxy* object_proxy,
46 const PropertyChangedCallback& callback);
47 virtual ~Properties();
50 // Interface for observing changes from a remote NFC tag.
53 virtual ~Observer() {}
55 // Called when a remote NFC tag with the object path |object_path| is added
56 // to the set of known tags.
57 virtual void TagFound(const dbus::ObjectPath& object_path) {}
59 // Called when a remote NFC tag with the object path |object_path| is
60 // removed from the set of known tags.
61 virtual void TagLost(const dbus::ObjectPath& object_path) {}
63 // Called when the tag property with the name |property_name| on tag with
64 // object path |object_path| has acquired a new value.
65 virtual void TagPropertyChanged(const dbus::ObjectPath& object_path,
66 const std::string& property_name) {}
69 // TODO(armansito): Move this typedef to the NFC Record client, once
71 typedef std::map<std::string, std::string> RecordAttributes;
73 virtual ~NfcTagClient();
75 // Adds and removes observers for events on all remote NFC tags. Check the
76 // |object_path| parameter of observer methods to determine which tag is
78 virtual void AddObserver(Observer* observer) = 0;
79 virtual void RemoveObserver(Observer* observer) = 0;
81 // Obtain the properties for the NFC tag with object path |object_path|; any
82 // values should be copied if needed.
83 virtual Properties* GetProperties(const dbus::ObjectPath& object_path) = 0;
85 // Creates an NDEF record for the NFC tag with object path |object_path|
86 // using the parameters in |attributes|. |attributes| is a dictionary,
87 // containing the NFC Record properties which will be assigned to the
88 // resulting record object and written to the tag. The properties are defined
89 // by the NFC Record interface (see namespace "nfc_record" in
90 // third_party/cros_system_api/dbus/service_constants.h and
91 // NfcRecordClient::Properties). |attributes| should at least contain a
92 // "Type" plus any other properties associated with that type. For example:
96 // "Encoding": "UTF-8",
98 // "Representation": "Chrome OS rulez!"
102 // "URI": "http://www.chromium.org"
106 const dbus::ObjectPath& object_path,
107 const RecordAttributes& attributes,
108 const base::Closure& callback,
109 const nfc_client_helpers::ErrorCallback& error_callback) = 0;
111 // Creates the instance.
112 static NfcTagClient* Create(DBusClientImplementationType type,
113 NfcAdapterClient* adapter_client);
116 friend class NfcClientTest;
121 DISALLOW_COPY_AND_ASSIGN(NfcTagClient);
124 } // namespace chromeos
126 #endif // CHROMEOS_DBUS_NFC_TAG_CLIENT_H_