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 ResultCallback is used for methods that return a boolean value | |
96 // indicating success (true) or failure (false). | |
97 typedef base::Callback<void(bool result)> ResultCallback; | |
keybuk
2012/06/08 20:06:39
This isn't the style of these classes - they use s
bryeung
2012/06/14 15:31:07
Done.
| |
98 | |
94 // The address of this adapter. The address format is "XX:XX:XX:XX:XX:XX", | 99 // The address of this adapter. The address format is "XX:XX:XX:XX:XX:XX", |
95 // where each XX is a hexadecimal number. | 100 // where each XX is a hexadecimal number. |
96 const std::string& address() const { return address_; } | 101 const std::string& address() const { return address_; } |
97 | 102 |
98 // Indicates whether the adapter is actually present on the system, for | 103 // Indicates whether the adapter is actually present on the system, for |
99 // the default adapter this indicates whether any adapter is present. | 104 // the default adapter this indicates whether any adapter is present. |
100 virtual bool IsPresent() const; | 105 virtual bool IsPresent() const; |
101 | 106 |
102 // Indicates whether the adapter radio is powered. | 107 // Indicates whether the adapter radio is powered. |
103 virtual bool IsPowered() const; | 108 virtual bool IsPowered() const; |
(...skipping 20 matching lines...) Expand all Loading... | |
124 typedef std::vector<BluetoothDevice*> DeviceList; | 129 typedef std::vector<BluetoothDevice*> DeviceList; |
125 virtual DeviceList GetDevices(); | 130 virtual DeviceList GetDevices(); |
126 typedef std::vector<const BluetoothDevice*> ConstDeviceList; | 131 typedef std::vector<const BluetoothDevice*> ConstDeviceList; |
127 virtual ConstDeviceList GetDevices() const; | 132 virtual ConstDeviceList GetDevices() const; |
128 | 133 |
129 // Returns a pointer to the device with the given address |address| or | 134 // Returns a pointer to the device with the given address |address| or |
130 // NULL if no such device is known. | 135 // NULL if no such device is known. |
131 BluetoothDevice* GetDevice(const std::string& address); | 136 BluetoothDevice* GetDevice(const std::string& address); |
132 const BluetoothDevice* GetDevice(const std::string& address) const; | 137 const BluetoothDevice* GetDevice(const std::string& address) const; |
133 | 138 |
139 // Requests the local Out Of Band pairing data. | |
140 virtual void ReadLocalOutOfBandPairingData( | |
141 const BluetoothOutOfBandClient::DataCallback& callback) const; | |
142 | |
143 // Sets the Out Of Band pairing data for the device at |address| to |data|. | |
144 void SetOutOfBandPairingData(const std::string& address, | |
145 const chromeos::BluetoothOutOfBandPairingData& data, | |
146 const chromeos::BluetoothOutOfBandClient::SuccessCallback& callback); | |
keybuk
2012/06/08 20:06:39
Should this not be on BluetoothDevice if it takes
bryeung
2012/06/14 15:31:08
Done.
| |
147 | |
148 // Clears the Out Of Band pairing data for the device at |address|. | |
149 virtual void ClearOutOfBandPairingData(const std::string& address, | |
150 const chromeos::BluetoothOutOfBandClient::SuccessCallback& callback); | |
keybuk
2012/06/08 20:06:39
Likewise maybe this should be on BluetoothDevice?
bryeung
2012/06/14 15:31:08
Done.
| |
151 | |
134 // Creates the instance for the default adapter, whichever that may | 152 // Creates the instance for the default adapter, whichever that may |
135 // be at the time. Use IsPresent() and the AdapterPresentChanged() observer | 153 // be at the time. Use IsPresent() and the AdapterPresentChanged() observer |
136 // method to determine whether an adapter is actually available or not. | 154 // method to determine whether an adapter is actually available or not. |
137 static BluetoothAdapter* CreateDefaultAdapter(); | 155 static BluetoothAdapter* CreateDefaultAdapter(); |
138 | 156 |
139 // Creates an instance for a specific adapter named by |address|, which | 157 // Creates an instance for a specific adapter named by |address|, which |
140 // may be the bluetooth address of the adapter or a device name such as | 158 // may be the bluetooth address of the adapter or a device name such as |
141 // "hci0". | 159 // "hci0". |
142 static BluetoothAdapter* Create(const std::string& address); | 160 static BluetoothAdapter* Create(const std::string& address); |
143 | 161 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 // instance. | 314 // instance. |
297 typedef std::map<const std::string, BluetoothDevice*> DevicesMap; | 315 typedef std::map<const std::string, BluetoothDevice*> DevicesMap; |
298 DevicesMap devices_; | 316 DevicesMap devices_; |
299 | 317 |
300 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapter); | 318 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapter); |
301 }; | 319 }; |
302 | 320 |
303 } // namespace chromeos | 321 } // namespace chromeos |
304 | 322 |
305 #endif // CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_ADAPTER_H_ | 323 #endif // CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_ADAPTER_H_ |
OLD | NEW |