Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: chromeos/dbus/fake_bluetooth_input_client.cc

Issue 14048007: Bluetooth: D-Bus client interface for org.bluez.Input1 (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: merged Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 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/fake_bluetooth_input_client.h"
6
7 #include <map>
8
9 #include "base/logging.h"
10 #include "base/stl_util.h"
11 #include "chromeos/dbus/bluetooth_property.h"
12 #include "dbus/bus.h"
13 #include "dbus/message.h"
14 #include "dbus/object_manager.h"
15 #include "dbus/object_path.h"
16 #include "dbus/object_proxy.h"
17 #include "third_party/cros_system_api/dbus/service_constants.h"
18
19 namespace chromeos {
20
21 FakeBluetoothInputClient::Properties::Properties(
22 const PropertyChangedCallback& callback)
23 : ExperimentalBluetoothInputClient::Properties(
24 NULL,
25 bluetooth_input::kExperimentalBluetoothInputInterface,
26 callback) {
27 }
28
29 FakeBluetoothInputClient::Properties::~Properties() {
30 }
31
32 void FakeBluetoothInputClient::Properties::Get(
33 dbus::PropertyBase* property,
34 dbus::PropertySet::GetCallback callback) {
35 VLOG(1) << "Get " << property->name();
36 callback.Run(false);
37 }
38
39 void FakeBluetoothInputClient::Properties::GetAll() {
40 VLOG(1) << "GetAll";
41 }
42
43 void FakeBluetoothInputClient::Properties::Set(
44 dbus::PropertyBase *property,
45 dbus::PropertySet::SetCallback callback) {
46 VLOG(1) << "Set " << property->name();
47 callback.Run(false);
48 }
49
50
51 FakeBluetoothInputClient::FakeBluetoothInputClient() {
52 }
53
54 FakeBluetoothInputClient::~FakeBluetoothInputClient() {
55 // Clean up Properties structures
56 STLDeleteValues(&properties_map_);
57 }
58
59 void FakeBluetoothInputClient::AddObserver(Observer* observer) {
60 observers_.AddObserver(observer);
61 }
62
63 void FakeBluetoothInputClient::RemoveObserver(Observer* observer) {
64 observers_.RemoveObserver(observer);
65 }
66
67 FakeBluetoothInputClient::Properties*
68 FakeBluetoothInputClient::GetProperties(const dbus::ObjectPath& object_path) {
69 PropertiesMap::iterator iter = properties_map_.find(object_path);
70 if (iter != properties_map_.end())
71 return iter->second;
72 return NULL;
73 }
74
75 void FakeBluetoothInputClient::AddInputDevice(
76 const dbus::ObjectPath& object_path) {
77 if (properties_map_.find(object_path) != properties_map_.end())
78 return;
79
80 Properties* properties = new Properties(base::Bind(
81 &FakeBluetoothInputClient::OnPropertyChanged,
82 base::Unretained(this),
83 object_path));
84 // TODO(deymo): Return a different ReconnectMode value for different devices.
keybuk 2013/04/18 15:51:30 since the requisite CL has landed, it makes sense
deymo 2013/04/18 20:20:16 Done.
85 properties->reconnect_mode.ReplaceValue(
86 bluetooth_input::kAnyReconnectModeProperty);
87
88 properties_map_[object_path] = properties;
89
90 FOR_EACH_OBSERVER(ExperimentalBluetoothInputClient::Observer, observers_,
91 InputAdded(object_path));
92 }
93
94 void FakeBluetoothInputClient::RemoveInputDevice(
95 const dbus::ObjectPath& object_path) {
96 PropertiesMap::iterator it = properties_map_.find(object_path);
97
98 if (it == properties_map_.end())
99 return;
100 delete it->second;
101 properties_map_.erase(it);
102
103 FOR_EACH_OBSERVER(ExperimentalBluetoothInputClient::Observer, observers_,
104 InputRemoved(object_path));
105 }
106
107 void FakeBluetoothInputClient::OnPropertyChanged(
108 const dbus::ObjectPath& object_path,
109 const std::string& property_name) {
110 FOR_EACH_OBSERVER(ExperimentalBluetoothInputClient::Observer, observers_,
111 InputPropertyChanged(object_path, property_name));
112 }
113
114 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698