• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_PROPERTY_SET_H_
6 #define CHROMEOS_DBUS_NFC_PROPERTY_SET_H_
7 
8 #include <string>
9 
10 #include "base/callback.h"
11 #include "dbus/message.h"
12 #include "dbus/object_proxy.h"
13 #include "dbus/property.h"
14 
15 namespace chromeos {
16 
17 // neard doesn't use the standard D-Bus interfaces for property access and
18 // instead defines property accessor methods in each D-Bus interface. This
19 // class customizes dbus::PropertySet to generate the correct method call to
20 // get all properties, connect to the correct signal and parse it correctly.
21 class NfcPropertySet : public dbus::PropertySet {
22  public:
23   NfcPropertySet(dbus::ObjectProxy* object_proxy,
24                  const std::string& interface,
25                  const PropertyChangedCallback& callback);
26 
27   // Destructor; we don't hold on to any references or memory that needs
28   // explicit clean-up, but clang thinks we might.
29   virtual ~NfcPropertySet();
30 
31   // Caches |callback| so that it will be invoked after a call to GetAll()
32   // has successfully received all existing properties from the remote object.
33   void SetAllPropertiesReceivedCallback(const base::Closure& callback);
34 
35   // dbus::PropertySet overrides
36   virtual void ConnectSignals() OVERRIDE;
37   virtual void Get(dbus::PropertyBase* property,
38                    GetCallback callback) OVERRIDE;
39   virtual void GetAll() OVERRIDE;
40   virtual void OnGetAll(dbus::Response* response) OVERRIDE;
41   virtual void Set(dbus::PropertyBase* property,
42                    SetCallback callback) OVERRIDE;
43   virtual void ChangedReceived(dbus::Signal* signal) OVERRIDE;
44 
45  protected:
on_get_all_callback()46   const base::Closure& on_get_all_callback() { return on_get_all_callback_; }
47 
48  private:
49   // Optional callback used to notify clients when all properties were received
50   // after a call to GetAll.
51   base::Closure on_get_all_callback_;
52 
53   DISALLOW_COPY_AND_ASSIGN(NfcPropertySet);
54 };
55 
56 }  // namespace chromeos
57 
58 #endif  // CHROMEOS_DBUS_NFC_PROPERTY_SET_H_
59