| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_ADAPTER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_ADAPTER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_ADAPTER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_ADAPTER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 16 #include "chromeos/dbus/bluetooth_adapter_client.h" | 16 #include "chromeos/dbus/bluetooth_adapter_client.h" |
| 17 #include "chromeos/dbus/bluetooth_device_client.h" | 17 #include "chromeos/dbus/bluetooth_device_client.h" |
| 18 #include "chromeos/dbus/bluetooth_manager_client.h" | 18 #include "chromeos/dbus/bluetooth_manager_client.h" |
| 19 #include "chromeos/dbus/bluetooth_out_of_band_client.h" |
| 19 #include "dbus/object_path.h" | 20 #include "dbus/object_path.h" |
| 20 | 21 |
| 21 namespace chromeos { | 22 namespace chromeos { |
| 22 | 23 |
| 23 class BluetoothDevice; | 24 class BluetoothDevice; |
| 24 | 25 |
| 25 // The BluetoothAdapter class represents a local Bluetooth adapter which | 26 // The BluetoothAdapter class represents a local Bluetooth adapter which |
| 26 // may be used to interact with remote Bluetooth devices. As well as | 27 // may be used to interact with remote Bluetooth devices. As well as |
| 27 // providing support for determining whether an adapter is present, and | 28 // providing support for determining whether an adapter is present, and |
| 28 // whether the radio is powered, this class also provides support for | 29 // whether the radio is powered, this class also provides support for |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // Adds and removes observers for events on this bluetooth adapter, | 85 // Adds and removes observers for events on this bluetooth adapter, |
| 85 // if monitoring multiple adapters check the |adapter| parameter of | 86 // if monitoring multiple adapters check the |adapter| parameter of |
| 86 // observer methods to determine which adapter is issuing the event. | 87 // observer methods to determine which adapter is issuing the event. |
| 87 void AddObserver(Observer* observer); | 88 void AddObserver(Observer* observer); |
| 88 void RemoveObserver(Observer* observer); | 89 void RemoveObserver(Observer* observer); |
| 89 | 90 |
| 90 // The ErrorCallback is used for methods that can fail in which case it | 91 // The ErrorCallback is used for methods that can fail in which case it |
| 91 // is called, in the success case the callback is simply not called. | 92 // is called, in the success case the callback is simply not called. |
| 92 typedef base::Callback<void()> ErrorCallback; | 93 typedef base::Callback<void()> ErrorCallback; |
| 93 | 94 |
| 95 // The BluetoothOutOfBandPairingDataCallback is used to return |
| 96 // BluetoothOutOfBandPairingData to the caller. |
| 97 typedef base::Callback<void(const BluetoothOutOfBandPairingData& data)> |
| 98 BluetoothOutOfBandPairingDataCallback; |
| 99 |
| 94 // The address of this adapter. The address format is "XX:XX:XX:XX:XX:XX", | 100 // The address of this adapter. The address format is "XX:XX:XX:XX:XX:XX", |
| 95 // where each XX is a hexadecimal number. | 101 // where each XX is a hexadecimal number. |
| 96 const std::string& address() const { return address_; } | 102 const std::string& address() const { return address_; } |
| 97 | 103 |
| 98 // Indicates whether the adapter is actually present on the system, for | 104 // Indicates whether the adapter is actually present on the system, for |
| 99 // the default adapter this indicates whether any adapter is present. | 105 // the default adapter this indicates whether any adapter is present. |
| 100 virtual bool IsPresent() const; | 106 virtual bool IsPresent() const; |
| 101 | 107 |
| 102 // Indicates whether the adapter radio is powered. | 108 // Indicates whether the adapter radio is powered. |
| 103 virtual bool IsPowered() const; | 109 virtual bool IsPowered() const; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 128 typedef std::vector<BluetoothDevice*> DeviceList; | 134 typedef std::vector<BluetoothDevice*> DeviceList; |
| 129 virtual DeviceList GetDevices(); | 135 virtual DeviceList GetDevices(); |
| 130 typedef std::vector<const BluetoothDevice*> ConstDeviceList; | 136 typedef std::vector<const BluetoothDevice*> ConstDeviceList; |
| 131 virtual ConstDeviceList GetDevices() const; | 137 virtual ConstDeviceList GetDevices() const; |
| 132 | 138 |
| 133 // Returns a pointer to the device with the given address |address| or | 139 // Returns a pointer to the device with the given address |address| or |
| 134 // NULL if no such device is known. | 140 // NULL if no such device is known. |
| 135 BluetoothDevice* GetDevice(const std::string& address); | 141 BluetoothDevice* GetDevice(const std::string& address); |
| 136 const BluetoothDevice* GetDevice(const std::string& address) const; | 142 const BluetoothDevice* GetDevice(const std::string& address) const; |
| 137 | 143 |
| 144 // Requests the local Out Of Band pairing data. |
| 145 virtual void ReadLocalOutOfBandPairingData( |
| 146 const BluetoothOutOfBandPairingDataCallback& callback, |
| 147 const ErrorCallback& error_callback); |
| 148 |
| 138 // Creates the instance for the default adapter, whichever that may | 149 // Creates the instance for the default adapter, whichever that may |
| 139 // be at the time. Use IsPresent() and the AdapterPresentChanged() observer | 150 // be at the time. Use IsPresent() and the AdapterPresentChanged() observer |
| 140 // method to determine whether an adapter is actually available or not. | 151 // method to determine whether an adapter is actually available or not. |
| 141 static BluetoothAdapter* CreateDefaultAdapter(); | 152 static BluetoothAdapter* CreateDefaultAdapter(); |
| 142 | 153 |
| 143 // Creates an instance for a specific adapter named by |address|, which | 154 // Creates an instance for a specific adapter named by |address|, which |
| 144 // may be the bluetooth address of the adapter or a device name such as | 155 // may be the bluetooth address of the adapter or a device name such as |
| 145 // "hci0". | 156 // "hci0". |
| 146 static BluetoothAdapter* Create(const std::string& address); | 157 static BluetoothAdapter* Create(const std::string& address); |
| 147 | 158 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 void OnStopDiscovery(const base::Closure& callback, | 218 void OnStopDiscovery(const base::Closure& callback, |
| 208 const ErrorCallback& error_callback, | 219 const ErrorCallback& error_callback, |
| 209 const dbus::ObjectPath& adapter_path, | 220 const dbus::ObjectPath& adapter_path, |
| 210 bool success); | 221 bool success); |
| 211 | 222 |
| 212 // Updates the tracked state of the adapter's discovering state to | 223 // Updates the tracked state of the adapter's discovering state to |
| 213 // |discovering| and notifies observers. Called on receipt of a property | 224 // |discovering| and notifies observers. Called on receipt of a property |
| 214 // changed signal, and directly using values obtained from properties. | 225 // changed signal, and directly using values obtained from properties. |
| 215 void DiscoveringChanged(bool discovering); | 226 void DiscoveringChanged(bool discovering); |
| 216 | 227 |
| 228 // Called by dbus:: in response to the ReadLocalData method call. |
| 229 void OnReadLocalData(const BluetoothOutOfBandPairingDataCallback& callback, |
| 230 const ErrorCallback& error_callback, |
| 231 const BluetoothOutOfBandPairingData& data, |
| 232 bool success); |
| 233 |
| 217 // BluetoothAdapterClient::Observer override. | 234 // BluetoothAdapterClient::Observer override. |
| 218 // | 235 // |
| 219 // Called when the adapter with object path |adapter_path| has a | 236 // Called when the adapter with object path |adapter_path| has a |
| 220 // change in value of the property named |property_name|. | 237 // change in value of the property named |property_name|. |
| 221 virtual void AdapterPropertyChanged(const dbus::ObjectPath& adapter_path, | 238 virtual void AdapterPropertyChanged(const dbus::ObjectPath& adapter_path, |
| 222 const std::string& property_name) | 239 const std::string& property_name) |
| 223 OVERRIDE; | 240 OVERRIDE; |
| 224 | 241 |
| 225 // BluetoothDeviceClient::Observer override. | 242 // BluetoothDeviceClient::Observer override. |
| 226 // | 243 // |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 // instance. | 326 // instance. |
| 310 typedef std::map<const std::string, BluetoothDevice*> DevicesMap; | 327 typedef std::map<const std::string, BluetoothDevice*> DevicesMap; |
| 311 DevicesMap devices_; | 328 DevicesMap devices_; |
| 312 | 329 |
| 313 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapter); | 330 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapter); |
| 314 }; | 331 }; |
| 315 | 332 |
| 316 } // namespace chromeos | 333 } // namespace chromeos |
| 317 | 334 |
| 318 #endif // CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_ADAPTER_H_ | 335 #endif // CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_ADAPTER_H_ |
| OLD | NEW |