| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chromeos/dbus/fake_bluetooth_input_client.h" | 5 #include "device/bluetooth/dbus/fake_bluetooth_input_client.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| 11 #include "chromeos/dbus/fake_bluetooth_device_client.h" | |
| 12 #include "dbus/bus.h" | 11 #include "dbus/bus.h" |
| 13 #include "dbus/message.h" | 12 #include "dbus/message.h" |
| 14 #include "dbus/object_manager.h" | 13 #include "dbus/object_manager.h" |
| 15 #include "dbus/object_proxy.h" | 14 #include "dbus/object_proxy.h" |
| 15 #include "device/bluetooth/dbus/fake_bluetooth_device_client.h" |
| 16 #include "third_party/cros_system_api/dbus/service_constants.h" | 16 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 17 | 17 |
| 18 namespace chromeos { | 18 namespace bluez { |
| 19 | 19 |
| 20 FakeBluetoothInputClient::Properties::Properties( | 20 FakeBluetoothInputClient::Properties::Properties( |
| 21 const PropertyChangedCallback& callback) | 21 const PropertyChangedCallback& callback) |
| 22 : BluetoothInputClient::Properties( | 22 : BluetoothInputClient::Properties( |
| 23 NULL, | 23 NULL, |
| 24 bluetooth_input::kBluetoothInputInterface, | 24 bluetooth_input::kBluetoothInputInterface, |
| 25 callback) { | 25 callback) {} |
| 26 } | |
| 27 | 26 |
| 28 FakeBluetoothInputClient::Properties::~Properties() { | 27 FakeBluetoothInputClient::Properties::~Properties() {} |
| 29 } | |
| 30 | 28 |
| 31 void FakeBluetoothInputClient::Properties::Get( | 29 void FakeBluetoothInputClient::Properties::Get( |
| 32 dbus::PropertyBase* property, | 30 dbus::PropertyBase* property, |
| 33 dbus::PropertySet::GetCallback callback) { | 31 dbus::PropertySet::GetCallback callback) { |
| 34 VLOG(1) << "Get " << property->name(); | 32 VLOG(1) << "Get " << property->name(); |
| 35 callback.Run(false); | 33 callback.Run(false); |
| 36 } | 34 } |
| 37 | 35 |
| 38 void FakeBluetoothInputClient::Properties::GetAll() { | 36 void FakeBluetoothInputClient::Properties::GetAll() { |
| 39 VLOG(1) << "GetAll"; | 37 VLOG(1) << "GetAll"; |
| 40 } | 38 } |
| 41 | 39 |
| 42 void FakeBluetoothInputClient::Properties::Set( | 40 void FakeBluetoothInputClient::Properties::Set( |
| 43 dbus::PropertyBase *property, | 41 dbus::PropertyBase* property, |
| 44 dbus::PropertySet::SetCallback callback) { | 42 dbus::PropertySet::SetCallback callback) { |
| 45 VLOG(1) << "Set " << property->name(); | 43 VLOG(1) << "Set " << property->name(); |
| 46 callback.Run(false); | 44 callback.Run(false); |
| 47 } | 45 } |
| 48 | 46 |
| 49 | 47 FakeBluetoothInputClient::FakeBluetoothInputClient() {} |
| 50 FakeBluetoothInputClient::FakeBluetoothInputClient() { | |
| 51 } | |
| 52 | 48 |
| 53 FakeBluetoothInputClient::~FakeBluetoothInputClient() { | 49 FakeBluetoothInputClient::~FakeBluetoothInputClient() { |
| 54 // Clean up Properties structures | 50 // Clean up Properties structures |
| 55 STLDeleteValues(&properties_map_); | 51 STLDeleteValues(&properties_map_); |
| 56 } | 52 } |
| 57 | 53 |
| 58 void FakeBluetoothInputClient::Init(dbus::Bus* bus) { | 54 void FakeBluetoothInputClient::Init(dbus::Bus* bus) {} |
| 59 } | |
| 60 | 55 |
| 61 void FakeBluetoothInputClient::AddObserver(Observer* observer) { | 56 void FakeBluetoothInputClient::AddObserver(Observer* observer) { |
| 62 observers_.AddObserver(observer); | 57 observers_.AddObserver(observer); |
| 63 } | 58 } |
| 64 | 59 |
| 65 void FakeBluetoothInputClient::RemoveObserver(Observer* observer) { | 60 void FakeBluetoothInputClient::RemoveObserver(Observer* observer) { |
| 66 observers_.RemoveObserver(observer); | 61 observers_.RemoveObserver(observer); |
| 67 } | 62 } |
| 68 | 63 |
| 69 FakeBluetoothInputClient::Properties* | 64 FakeBluetoothInputClient::Properties* FakeBluetoothInputClient::GetProperties( |
| 70 FakeBluetoothInputClient::GetProperties(const dbus::ObjectPath& object_path) { | 65 const dbus::ObjectPath& object_path) { |
| 71 PropertiesMap::iterator iter = properties_map_.find(object_path); | 66 PropertiesMap::iterator iter = properties_map_.find(object_path); |
| 72 if (iter != properties_map_.end()) | 67 if (iter != properties_map_.end()) |
| 73 return iter->second; | 68 return iter->second; |
| 74 return NULL; | 69 return NULL; |
| 75 } | 70 } |
| 76 | 71 |
| 77 void FakeBluetoothInputClient::AddInputDevice( | 72 void FakeBluetoothInputClient::AddInputDevice( |
| 78 const dbus::ObjectPath& object_path) { | 73 const dbus::ObjectPath& object_path) { |
| 79 if (properties_map_.find(object_path) != properties_map_.end()) | 74 if (properties_map_.find(object_path) != properties_map_.end()) |
| 80 return; | 75 return; |
| 81 | 76 |
| 82 Properties* properties = new Properties(base::Bind( | 77 Properties* properties = |
| 83 &FakeBluetoothInputClient::OnPropertyChanged, | 78 new Properties(base::Bind(&FakeBluetoothInputClient::OnPropertyChanged, |
| 84 base::Unretained(this), | 79 base::Unretained(this), object_path)); |
| 85 object_path)); | |
| 86 | 80 |
| 87 // The LegacyAutopair and DisplayPinCode devices represent a typical mouse | 81 // The LegacyAutopair and DisplayPinCode devices represent a typical mouse |
| 88 // and keyboard respectively, so mark them as ReconnectMode "any". The | 82 // and keyboard respectively, so mark them as ReconnectMode "any". The |
| 89 // DisplayPasskey device represents a Bluetooth 2.1+ keyboard and the | 83 // DisplayPasskey device represents a Bluetooth 2.1+ keyboard and the |
| 90 // ConnectUnpairable device represents a pre-standardization mouse, so mark | 84 // ConnectUnpairable device represents a pre-standardization mouse, so mark |
| 91 // them as ReconnectMode "device". | 85 // them as ReconnectMode "device". |
| 92 if (object_path.value() == FakeBluetoothDeviceClient::kDisplayPasskeyPath || | 86 if (object_path.value() == FakeBluetoothDeviceClient::kDisplayPasskeyPath || |
| 93 object_path.value() == | 87 object_path.value() == |
| 94 FakeBluetoothDeviceClient::kConnectUnpairablePath) { | 88 FakeBluetoothDeviceClient::kConnectUnpairablePath) { |
| 95 properties->reconnect_mode.ReplaceValue( | 89 properties->reconnect_mode.ReplaceValue( |
| (...skipping 23 matching lines...) Expand all Loading... |
| 119 properties_map_.erase(it); | 113 properties_map_.erase(it); |
| 120 } | 114 } |
| 121 | 115 |
| 122 void FakeBluetoothInputClient::OnPropertyChanged( | 116 void FakeBluetoothInputClient::OnPropertyChanged( |
| 123 const dbus::ObjectPath& object_path, | 117 const dbus::ObjectPath& object_path, |
| 124 const std::string& property_name) { | 118 const std::string& property_name) { |
| 125 FOR_EACH_OBSERVER(BluetoothInputClient::Observer, observers_, | 119 FOR_EACH_OBSERVER(BluetoothInputClient::Observer, observers_, |
| 126 InputPropertyChanged(object_path, property_name)); | 120 InputPropertyChanged(object_path, property_name)); |
| 127 } | 121 } |
| 128 | 122 |
| 129 } // namespace chromeos | 123 } // namespace bluez |
| OLD | NEW |