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 "chromeos/dbus/fake_old_bluetooth_adapter_client.h" |
| 6 |
| 7 namespace chromeos { |
| 8 |
| 9 FakeOldBluetoothAdapterClient::Properties::Properties( |
| 10 const PropertyChangedCallback& callback) : |
| 11 BluetoothAdapterClient::Properties(NULL, callback) { |
| 12 } |
| 13 |
| 14 FakeOldBluetoothAdapterClient::Properties::~Properties() { |
| 15 } |
| 16 |
| 17 void FakeOldBluetoothAdapterClient::Properties::Get( |
| 18 dbus::PropertyBase* property, |
| 19 dbus::PropertySet::GetCallback callback) { |
| 20 VLOG(1)<< "Get " << property->name(); |
| 21 callback.Run(false); |
| 22 } |
| 23 |
| 24 void FakeOldBluetoothAdapterClient::Properties::GetAll() { |
| 25 VLOG(1) << "GetAll"; |
| 26 } |
| 27 |
| 28 void FakeOldBluetoothAdapterClient::Properties::Set( |
| 29 dbus::PropertyBase *property, |
| 30 dbus::PropertySet::SetCallback callback) { |
| 31 VLOG(1) << "Set " << property->name(); |
| 32 if (property->name() == "Powered") { |
| 33 property->ReplaceValueWithSetValue(); |
| 34 callback.Run(true); |
| 35 } else { |
| 36 callback.Run(false); |
| 37 } |
| 38 } |
| 39 |
| 40 FakeOldBluetoothAdapterClient::FakeOldBluetoothAdapterClient() { |
| 41 properties_.reset(new Properties(base::Bind( |
| 42 &FakeOldBluetoothAdapterClient::OnPropertyChanged, |
| 43 base::Unretained(this)))); |
| 44 |
| 45 properties_->address.ReplaceValue("hci0"); |
| 46 properties_->name.ReplaceValue("Fake Adapter"); |
| 47 properties_->pairable.ReplaceValue(true); |
| 48 |
| 49 std::vector<dbus::ObjectPath> devices; |
| 50 devices.push_back(dbus::ObjectPath("/fake/hci0/dev0")); |
| 51 properties_->devices.ReplaceValue(devices); |
| 52 } |
| 53 |
| 54 FakeOldBluetoothAdapterClient::~FakeOldBluetoothAdapterClient() { |
| 55 } |
| 56 |
| 57 void FakeOldBluetoothAdapterClient::AddObserver(Observer* observer) { |
| 58 observers_.AddObserver(observer); |
| 59 } |
| 60 |
| 61 void FakeOldBluetoothAdapterClient::RemoveObserver(Observer* observer) { |
| 62 observers_.RemoveObserver(observer); |
| 63 } |
| 64 |
| 65 FakeOldBluetoothAdapterClient::Properties* |
| 66 FakeOldBluetoothAdapterClient::GetProperties( |
| 67 const dbus::ObjectPath& object_path) { |
| 68 VLOG(1) << "GetProperties: " << object_path.value(); |
| 69 if (object_path.value() == "/fake/hci0") |
| 70 return properties_.get(); |
| 71 else |
| 72 return NULL; |
| 73 } |
| 74 |
| 75 void FakeOldBluetoothAdapterClient::RequestSession( |
| 76 const dbus::ObjectPath& object_path, |
| 77 const AdapterCallback& callback) { |
| 78 VLOG(1) << "RequestSession: " << object_path.value(); |
| 79 callback.Run(object_path, false); |
| 80 } |
| 81 |
| 82 void FakeOldBluetoothAdapterClient::ReleaseSession( |
| 83 const dbus::ObjectPath& object_path, |
| 84 const AdapterCallback& callback) { |
| 85 VLOG(1) << "ReleaseSession: " << object_path.value(); |
| 86 callback.Run(object_path, false); |
| 87 } |
| 88 |
| 89 void FakeOldBluetoothAdapterClient::StartDiscovery( |
| 90 const dbus::ObjectPath& object_path, |
| 91 const AdapterCallback& callback) { |
| 92 VLOG(1) << "StartDiscovery: " << object_path.value(); |
| 93 callback.Run(object_path, false); |
| 94 } |
| 95 |
| 96 void FakeOldBluetoothAdapterClient::StopDiscovery( |
| 97 const dbus::ObjectPath & object_path, |
| 98 const AdapterCallback& callback) { |
| 99 VLOG(1) << "StopDiscovery: " << object_path.value(); |
| 100 callback.Run(object_path, false); |
| 101 } |
| 102 |
| 103 void FakeOldBluetoothAdapterClient::FindDevice( |
| 104 const dbus::ObjectPath& object_path, |
| 105 const std::string& address, |
| 106 const DeviceCallback& callback) { |
| 107 VLOG(1) << "FindDevice: " << object_path.value() << " " << address; |
| 108 callback.Run(dbus::ObjectPath(), false); |
| 109 } |
| 110 |
| 111 void FakeOldBluetoothAdapterClient::CreateDevice( |
| 112 const dbus::ObjectPath& object_path, |
| 113 const std::string& address, |
| 114 const CreateDeviceCallback& callback, |
| 115 const CreateDeviceErrorCallback& error_callback) { |
| 116 VLOG(1) << "CreateDevice: " << object_path.value() << " " << address; |
| 117 error_callback.Run("", ""); |
| 118 } |
| 119 |
| 120 void FakeOldBluetoothAdapterClient::CreatePairedDevice( |
| 121 const dbus::ObjectPath& object_path, |
| 122 const std::string& address, |
| 123 const dbus::ObjectPath& agent_path, |
| 124 const std::string& capability, |
| 125 const CreateDeviceCallback& callback, |
| 126 const CreateDeviceErrorCallback& error_callback) { |
| 127 VLOG(1) << "CreatePairedDevice: " << object_path.value() << " " << address |
| 128 << " " << agent_path.value() << " " << capability; |
| 129 error_callback.Run("", ""); |
| 130 } |
| 131 |
| 132 void FakeOldBluetoothAdapterClient::CancelDeviceCreation( |
| 133 const dbus::ObjectPath& object_path, |
| 134 const std::string& address, |
| 135 const AdapterCallback& callback) { |
| 136 VLOG(1) << "CancelDeviceCreation: " << object_path.value() |
| 137 << " " << address; |
| 138 callback.Run(object_path, false); |
| 139 } |
| 140 |
| 141 void FakeOldBluetoothAdapterClient::RemoveDevice( |
| 142 const dbus::ObjectPath& object_path, |
| 143 const dbus::ObjectPath& device_path, |
| 144 const AdapterCallback& callback) { |
| 145 VLOG(1) << "RemoveDevice: " << object_path.value() |
| 146 << " " << device_path.value(); |
| 147 callback.Run(object_path, false); |
| 148 } |
| 149 |
| 150 void FakeOldBluetoothAdapterClient::RegisterAgent( |
| 151 const dbus::ObjectPath& object_path, |
| 152 const dbus::ObjectPath& agent_path, |
| 153 const std::string& capability, |
| 154 const AdapterCallback& callback) { |
| 155 VLOG(1) << "RegisterAgent: " << object_path.value() |
| 156 << " " << agent_path.value(); |
| 157 callback.Run(object_path, false); |
| 158 } |
| 159 |
| 160 void FakeOldBluetoothAdapterClient::UnregisterAgent( |
| 161 const dbus::ObjectPath& object_path, |
| 162 const dbus::ObjectPath& agent_path, |
| 163 const AdapterCallback& callback) { |
| 164 VLOG(1) << "UnregisterAgent: " << object_path.value() |
| 165 << " " << agent_path.value(); |
| 166 callback.Run(object_path, false); |
| 167 } |
| 168 |
| 169 void FakeOldBluetoothAdapterClient::OnPropertyChanged( |
| 170 const std::string&property_name) { |
| 171 FOR_EACH_OBSERVER(BluetoothAdapterClient::Observer, observers_, |
| 172 AdapterPropertyChanged(dbus::ObjectPath("/fake/hci0"), |
| 173 property_name)); |
| 174 } |
| 175 |
| 176 } // namespace chromeos |
OLD | NEW |