- add sources.
[platform/framework/web/crosswalk.git] / src / chromeos / dbus / nfc_property_set.cc
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 #include "chromeos/dbus/nfc_property_set.h"
6
7 #include "base/bind.h"
8 #include "third_party/cros_system_api/dbus/service_constants.h"
9
10 namespace chromeos {
11
12 NfcPropertySet::NfcPropertySet(dbus::ObjectProxy* object_proxy,
13                                const std::string& interface,
14                                const PropertyChangedCallback& callback)
15     : dbus::PropertySet(object_proxy, interface, callback) {
16 }
17
18 void NfcPropertySet::ConnectSignals() {
19   object_proxy()->ConnectToSignal(
20       interface(),
21       nfc_common::kPropertyChangedSignal,
22       base::Bind(&dbus::PropertySet::ChangedReceived, GetWeakPtr()),
23       base::Bind(&dbus::PropertySet::ChangedConnected, GetWeakPtr()));
24 }
25
26 void NfcPropertySet::Get(dbus::PropertyBase* property,
27                          GetCallback callback) {
28   NOTREACHED() << "neard does not implement Get for properties.";
29 }
30
31 void NfcPropertySet::GetAll() {
32   dbus::MethodCall method_call(
33       interface(), nfc_common::kGetProperties);
34   object_proxy()->CallMethod(&method_call,
35                            dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
36                            base::Bind(&dbus::PropertySet::OnGetAll,
37                                       GetWeakPtr()));
38 }
39
40 void NfcPropertySet::Set(dbus::PropertyBase* property,
41                          SetCallback callback) {
42   dbus::MethodCall method_call(
43       interface(), nfc_common::kSetProperty);
44   object_proxy()->CallMethod(&method_call,
45                            dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
46                            base::Bind(&dbus::PropertySet::OnSet,
47                                       GetWeakPtr(),
48                                       property,
49                                       callback));
50 }
51
52 void NfcPropertySet::ChangedReceived(dbus::Signal* signal) {
53   DCHECK(signal);
54   dbus::MessageReader reader(signal);
55   UpdatePropertyFromReader(&reader);
56 }
57
58 }  // namespace chromeos