diff options
author | keybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-15 01:03:30 +0000 |
---|---|---|
committer | keybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-15 01:03:30 +0000 |
commit | 7375e8b24e5c3bc64ff6c679a2cbe17397c9c431 (patch) | |
tree | 63fd9cbed94f7ba7a6fa87ab46e76a0056519c85 /chromeos/dbus/bluetooth_device_client.cc | |
parent | 1014b1a6ccd05cb913372e7712cd47801530a6a9 (diff) | |
download | chromium_src-7375e8b24e5c3bc64ff6c679a2cbe17397c9c431.zip chromium_src-7375e8b24e5c3bc64ff6c679a2cbe17397c9c431.tar.gz chromium_src-7375e8b24e5c3bc64ff6c679a2cbe17397c9c431.tar.bz2 |
bluetooth: Create stub manager, adapter and device.
These stub classes are used when building Chrome on Linux with
chromeos=1. They allow sufficient UI to work to show a Bluetooth
adapter, enable and disable it, and show an unconnected fake device
associated with it.
This can be trivially extended to provide all manner of fake
Bluetooth information for UI development.
BUG=chromium-os:28555
TEST=out/Debug/chrome
Change-Id: I7af28be76355fad735389aaf2fa499d0a8dfd76b
Review URL: https://chromiumcodereview.appspot.com/10823301
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151621 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/dbus/bluetooth_device_client.cc')
-rw-r--r-- | chromeos/dbus/bluetooth_device_client.cc | 69 |
1 files changed, 67 insertions, 2 deletions
diff --git a/chromeos/dbus/bluetooth_device_client.cc b/chromeos/dbus/bluetooth_device_client.cc index 264de0d..10bda3f 100644 --- a/chromeos/dbus/bluetooth_device_client.cc +++ b/chromeos/dbus/bluetooth_device_client.cc @@ -20,8 +20,9 @@ namespace chromeos { -BluetoothDeviceClient::Properties::Properties(dbus::ObjectProxy* object_proxy, - PropertyChangedCallback callback) +BluetoothDeviceClient::Properties::Properties( + dbus::ObjectProxy* object_proxy, + const PropertyChangedCallback& callback) : BluetoothPropertySet(object_proxy, bluetooth_device::kBluetoothDeviceInterface, callback) { @@ -464,18 +465,68 @@ class BluetoothDeviceClientImpl: public BluetoothDeviceClient, // nothing. class BluetoothDeviceClientStubImpl : public BluetoothDeviceClient { public: + struct Properties : public BluetoothDeviceClient::Properties { + explicit Properties(const PropertyChangedCallback& callback) + : BluetoothDeviceClient::Properties(NULL, callback) { + } + + virtual ~Properties() { + } + + virtual void Get(dbus::PropertyBase* property, + dbus::PropertySet::GetCallback callback) OVERRIDE { + VLOG(1) << "Get " << property->name(); + callback.Run(false); + } + + virtual void GetAll() OVERRIDE { + VLOG(1) << "GetAll"; + } + + virtual void Set(dbus::PropertyBase *property, + dbus::PropertySet::SetCallback callback) OVERRIDE { + VLOG(1) << "Set " << property->name(); + callback.Run(false); + } + }; + + BluetoothDeviceClientStubImpl() { + dbus::ObjectPath dev0("/fake/hci0/dev0"); + + Properties* properties = new Properties(base::Bind( + &BluetoothDeviceClientStubImpl::OnPropertyChanged, + base::Unretained(this), + dev0)); + properties->address.ReplaceValue("00:11:22:33:44:55"); + properties->name.ReplaceValue("Fake Device"); + properties->paired.ReplaceValue(true); + properties->trusted.ReplaceValue(true); + + properties_map_[dev0] = properties; + } + + virtual ~BluetoothDeviceClientStubImpl() { + // Clean up Properties structures + STLDeleteValues(&properties_map_); + } + // BluetoothDeviceClient override. virtual void AddObserver(Observer* observer) OVERRIDE { + observers_.AddObserver(observer); } // BluetoothDeviceClient override. virtual void RemoveObserver(Observer* observer) OVERRIDE { + observers_.RemoveObserver(observer); } // BluetoothDeviceClient override. virtual Properties* GetProperties(const dbus::ObjectPath& object_path) OVERRIDE { VLOG(1) << "GetProperties: " << object_path.value(); + PropertiesMap::iterator iter = properties_map_.find(object_path); + if (iter != properties_map_.end()) + return iter->second; return NULL; } @@ -519,6 +570,20 @@ class BluetoothDeviceClientStubImpl : public BluetoothDeviceClient { << " " << node_path.value(); callback.Run(object_path, false); } + + private: + void OnPropertyChanged(dbus::ObjectPath object_path, + const std::string& property_name) { + FOR_EACH_OBSERVER(BluetoothDeviceClient::Observer, observers_, + DevicePropertyChanged(object_path, property_name)); + } + + // List of observers interested in event notifications from us. + ObserverList<Observer> observers_; + + // Static properties we typedef. + typedef std::map<const dbus::ObjectPath, Properties *> PropertiesMap; + PropertiesMap properties_map_; }; BluetoothDeviceClient::BluetoothDeviceClient() { |