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. 4 5 #ifndef CHROMEOS_DBUS_NFC_MANAGER_CLIENT_H_ 6 #define CHROMEOS_DBUS_NFC_MANAGER_CLIENT_H_ 7 8 #include <vector> 9 10 #include "chromeos/chromeos_export.h" 11 #include "chromeos/dbus/dbus_client.h" 12 #include "chromeos/dbus/nfc_property_set.h" 13 #include "dbus/object_path.h" 14 #include "dbus/object_proxy.h" 15 #include "dbus/property.h" 16 17 namespace chromeos { 18 19 // NfcManagerClient is used to communicate with the neard Manager service. 20 class CHROMEOS_EXPORT NfcManagerClient : public DBusClient { 21 public: 22 // Structure of properties associated with the NFC manager. 23 struct Properties : public NfcPropertySet { 24 // List of Adapter object paths. 25 dbus::Property<std::vector<dbus::ObjectPath> > adapters; 26 27 Properties(dbus::ObjectProxy* object_proxy, 28 const PropertyChangedCallback& callback); 29 virtual ~Properties(); 30 }; 31 32 // Interface for observing changes to the NFC manager. Use this interface 33 // to be notified when NFC adapters get added or removed. 34 // NOTE: Users of the NFC D-Bus client code shouldn't need to observe changes 35 // from NfcManagerClient::Observer; to get notified of changes to the list of 36 // NFC adapters, use NfcAdapterClient::Observer instead. 37 class Observer { 38 public: ~Observer()39 virtual ~Observer() {} 40 41 // Called when a new adapter with object path |object_path| is added to the 42 // system. AdapterAdded(const dbus::ObjectPath & object_path)43 virtual void AdapterAdded(const dbus::ObjectPath& object_path) {} 44 45 // Called when an adapter with object path |object_path| is removed from the 46 // system. AdapterRemoved(const dbus::ObjectPath & object_path)47 virtual void AdapterRemoved(const dbus::ObjectPath& object_path) {} 48 49 // Called when the manager property with name |property_name| has acquired 50 // a new value. ManagerPropertyChanged(const std::string & property_name)51 virtual void ManagerPropertyChanged(const std::string& property_name) {} 52 }; 53 54 virtual ~NfcManagerClient(); 55 56 // Adds and removes observers for events on the NFC manager. 57 virtual void AddObserver(Observer* observer) = 0; 58 virtual void RemoveObserver(Observer* observer) = 0; 59 60 // Obtains the properties of the NFC manager service. 61 virtual Properties* GetProperties() = 0; 62 63 // Creates the instance. 64 static NfcManagerClient* Create(); 65 66 protected: 67 friend class NfcClientTest; 68 69 NfcManagerClient(); 70 71 private: 72 DISALLOW_COPY_AND_ASSIGN(NfcManagerClient); 73 }; 74 75 } // namespace chromeos 76 77 #endif // CHROMEOS_DBUS_NFC_MANAGER_CLIENT_H_ 78