OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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/bluetooth_property.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "dbus/message.h" | |
9 #include "dbus/object_proxy.h" | |
10 #include "third_party/cros_system_api/dbus/service_constants.h" | |
11 | |
12 namespace chromeos { | |
13 | |
14 void BluetoothPropertySet::ConnectSignals() { | |
15 dbus::ObjectProxy* object_proxy = this->object_proxy(); | |
16 DCHECK(object_proxy); | |
17 object_proxy->ConnectToSignal( | |
18 interface(), | |
19 bluetooth_common::kPropertyChangedSignal, | |
20 base::Bind(&dbus::PropertySet::ChangedReceived, GetWeakPtr()), | |
21 base::Bind(&dbus::PropertySet::ChangedConnected, GetWeakPtr())); | |
22 } | |
23 | |
24 void BluetoothPropertySet::ChangedReceived(dbus::Signal* signal) { | |
25 DCHECK(signal); | |
26 | |
27 dbus::MessageReader reader(signal); | |
28 UpdatePropertyFromReader(&reader); | |
29 } | |
30 | |
31 void BluetoothPropertySet::Get(dbus::PropertyBase* property, | |
32 GetCallback callback) { | |
33 NOTREACHED() << "BlueZ does not implement Get for properties"; | |
34 } | |
35 | |
36 void BluetoothPropertySet::GetAll() { | |
37 dbus::MethodCall method_call(interface(), | |
38 bluetooth_common::kGetProperties); | |
39 | |
40 dbus::ObjectProxy* object_proxy = this->object_proxy(); | |
41 DCHECK(object_proxy); | |
42 object_proxy->CallMethod(&method_call, | |
43 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | |
44 base::Bind(&dbus::PropertySet::OnGetAll, | |
45 GetWeakPtr())); | |
46 } | |
47 | |
48 void BluetoothPropertySet::Set(dbus::PropertyBase* property, | |
49 SetCallback callback) { | |
50 dbus::MethodCall method_call(interface(), | |
51 bluetooth_common::kSetProperty); | |
52 dbus::MessageWriter writer(&method_call); | |
53 writer.AppendString(property->name()); | |
54 property->AppendSetValueToWriter(&writer); | |
55 | |
56 dbus::ObjectProxy *object_proxy = this->object_proxy(); | |
57 DCHECK(object_proxy); | |
58 object_proxy->CallMethod(&method_call, | |
59 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | |
60 base::Bind(&dbus::PropertySet::OnSet, | |
61 this->GetWeakPtr(), | |
62 property, | |
63 callback)); | |
64 } | |
65 | |
66 } // namespace chromeos | |
OLD | NEW |