11e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
21e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
31e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// found in the LICENSE file.
41e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
51e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#ifndef CHROMEOS_DBUS_NFC_MANAGER_CLIENT_H_
61e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#define CHROMEOS_DBUS_NFC_MANAGER_CLIENT_H_
71e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
81e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include <vector>
91e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
101e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "chromeos/chromeos_export.h"
111e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "chromeos/dbus/dbus_client.h"
121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "chromeos/dbus/nfc_property_set.h"
131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "dbus/object_path.h"
141e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "dbus/object_proxy.h"
151e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "dbus/property.h"
161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
171e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)namespace chromeos {
181e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
191e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// NfcManagerClient is used to communicate with the neard Manager service.
201e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)class CHROMEOS_EXPORT NfcManagerClient : public DBusClient {
211e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) public:
221e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // Structure of properties associated with the NFC manager.
231e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  struct Properties : public NfcPropertySet {
241e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    // List of Adapter object paths.
251e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    dbus::Property<std::vector<dbus::ObjectPath> > adapters;
261e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
271e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    Properties(dbus::ObjectProxy* object_proxy,
281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)               const PropertyChangedCallback& callback);
291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    virtual ~Properties();
301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  };
311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
321e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // Interface for observing changes to the NFC manager. Use this interface
331e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // to be notified when NFC adapters get added or removed.
341e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // NOTE: Users of the NFC D-Bus client code shouldn't need to observe changes
351e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // from NfcManagerClient::Observer; to get notified of changes to the list of
361e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // NFC adapters, use NfcAdapterClient::Observer instead.
371e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  class Observer {
381e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)   public:
391e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    virtual ~Observer() {}
401e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
411e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    // Called when a new adapter with object path |object_path| is added to the
421e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    // system.
431e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    virtual void AdapterAdded(const dbus::ObjectPath& object_path) {}
441e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
451e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    // Called when an adapter with object path |object_path| is removed from the
461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    // system.
471e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    virtual void AdapterRemoved(const dbus::ObjectPath& object_path) {}
481e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
491e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    // Called when the manager property with name |property_name| has acquired
501e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    // a new value.
511e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    virtual void ManagerPropertyChanged(const std::string& property_name) {}
521e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  };
531e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
541e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  virtual ~NfcManagerClient();
551e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
561e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // Adds and removes observers for events on the NFC manager.
571e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  virtual void AddObserver(Observer* observer) = 0;
581e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  virtual void RemoveObserver(Observer* observer) = 0;
591e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
601e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // Obtains the properties of the NFC manager service.
611e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  virtual Properties* GetProperties() = 0;
621e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
631e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // Creates the instance.
64a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  static NfcManagerClient* Create();
651e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
661e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) protected:
671e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  friend class NfcClientTest;
681e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
691e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  NfcManagerClient();
701e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
711e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) private:
721e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(NfcManagerClient);
731e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)};
741e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
751e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)}  // namespace chromeos
761e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
771e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#endif  // CHROMEOS_DBUS_NFC_MANAGER_CLIENT_H_
78