OLD | NEW |
(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 "base/stl_util.h" |
| 6 #include "chromeos/dbus/fake_old_bluetooth_device_client.h" |
| 7 |
| 8 namespace chromeos { |
| 9 |
| 10 FakeOldBluetoothDeviceClient::Properties::Properties( |
| 11 const PropertyChangedCallback& callback) : |
| 12 BluetoothDeviceClient::Properties(NULL, callback) { |
| 13 } |
| 14 |
| 15 FakeOldBluetoothDeviceClient::Properties::~Properties() { |
| 16 } |
| 17 |
| 18 void FakeOldBluetoothDeviceClient::Properties::Get( |
| 19 dbus::PropertyBase* property, |
| 20 dbus::PropertySet::GetCallback callback) { |
| 21 VLOG(1)<< "Get " << property->name(); |
| 22 callback.Run(false); |
| 23 } |
| 24 |
| 25 void FakeOldBluetoothDeviceClient::Properties::GetAll() { |
| 26 VLOG(1) << "GetAll"; |
| 27 } |
| 28 |
| 29 void FakeOldBluetoothDeviceClient::Properties::Set( |
| 30 dbus::PropertyBase *property, |
| 31 dbus::PropertySet::SetCallback callback) { |
| 32 VLOG(1) << "Set " << property->name(); |
| 33 callback.Run(false); |
| 34 } |
| 35 |
| 36 FakeOldBluetoothDeviceClient::FakeOldBluetoothDeviceClient() { |
| 37 dbus::ObjectPath dev0("/fake/hci0/dev0"); |
| 38 |
| 39 Properties* properties = new Properties(base::Bind( |
| 40 &FakeOldBluetoothDeviceClient::OnPropertyChanged, |
| 41 base::Unretained(this), |
| 42 dev0)); |
| 43 properties->address.ReplaceValue("00:11:22:33:44:55"); |
| 44 properties->name.ReplaceValue("Fake Device"); |
| 45 properties->paired.ReplaceValue(true); |
| 46 properties->trusted.ReplaceValue(true); |
| 47 |
| 48 properties_map_[dev0] = properties; |
| 49 } |
| 50 |
| 51 FakeOldBluetoothDeviceClient::~FakeOldBluetoothDeviceClient() { |
| 52 // Clean up Properties structures |
| 53 STLDeleteValues(&properties_map_); |
| 54 } |
| 55 |
| 56 void FakeOldBluetoothDeviceClient::AddObserver(Observer* observer) { |
| 57 observers_.AddObserver(observer); |
| 58 } |
| 59 |
| 60 void FakeOldBluetoothDeviceClient::RemoveObserver(Observer* observer) { |
| 61 observers_.RemoveObserver(observer); |
| 62 } |
| 63 |
| 64 FakeOldBluetoothDeviceClient::Properties* |
| 65 FakeOldBluetoothDeviceClient::GetProperties( |
| 66 const dbus::ObjectPath& object_path) { |
| 67 VLOG(1)<< "GetProperties: " << object_path.value(); |
| 68 PropertiesMap::iterator iter = properties_map_.find(object_path); |
| 69 if (iter != properties_map_.end()) |
| 70 return iter->second; |
| 71 return NULL; |
| 72 } |
| 73 |
| 74 void FakeOldBluetoothDeviceClient::DiscoverServices( |
| 75 const dbus::ObjectPath& object_path, |
| 76 const std::string& pattern, |
| 77 const ServicesCallback& callback) { |
| 78 VLOG(1) << "DiscoverServices: " << object_path.value() << " " << pattern; |
| 79 |
| 80 ServiceMap services; |
| 81 callback.Run(object_path, services, false); |
| 82 } |
| 83 |
| 84 void FakeOldBluetoothDeviceClient::CancelDiscovery( |
| 85 const dbus::ObjectPath& object_path, |
| 86 const DeviceCallback& callback) { |
| 87 VLOG(1) << "CancelDiscovery: " << object_path.value(); |
| 88 callback.Run(object_path, false); |
| 89 } |
| 90 |
| 91 void FakeOldBluetoothDeviceClient::Disconnect( |
| 92 const dbus::ObjectPath& object_path, |
| 93 const DeviceCallback& callback) { |
| 94 VLOG(1) << "Disconnect: " << object_path.value(); |
| 95 callback.Run(object_path, false); |
| 96 } |
| 97 |
| 98 void FakeOldBluetoothDeviceClient::CreateNode( |
| 99 const dbus::ObjectPath& object_path, |
| 100 const std::string& uuid, |
| 101 const NodeCallback& callback) { |
| 102 VLOG(1) << "CreateNode: " << object_path.value() << " " << uuid; |
| 103 callback.Run(dbus::ObjectPath(), false); |
| 104 } |
| 105 |
| 106 void FakeOldBluetoothDeviceClient::RemoveNode( |
| 107 const dbus::ObjectPath& object_path, |
| 108 const dbus::ObjectPath& node_path, |
| 109 const DeviceCallback& callback) { |
| 110 VLOG(1) << "RemoveNode: " << object_path.value() |
| 111 << " " << node_path.value(); |
| 112 callback.Run(object_path, false); |
| 113 } |
| 114 |
| 115 void FakeOldBluetoothDeviceClient::OnPropertyChanged( |
| 116 dbus::ObjectPath object_path, |
| 117 const std::string& property_name) { |
| 118 FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, |
| 119 DevicePropertyChanged(object_path, property_name)); |
| 120 } |
| 121 |
| 122 } // namespace chromeos |
OLD | NEW |