Chromium Code Reviews| 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 DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 // Possible errors passed back to an error callback function in case of a | 55 // Possible errors passed back to an error callback function in case of a |
| 56 // failed call to Connect(). | 56 // failed call to Connect(). |
| 57 enum ConnectErrorCode { | 57 enum ConnectErrorCode { |
| 58 ERROR_UNKNOWN, | 58 ERROR_UNKNOWN, |
| 59 ERROR_INPROGRESS, | 59 ERROR_INPROGRESS, |
| 60 ERROR_FAILED, | 60 ERROR_FAILED, |
| 61 ERROR_AUTH_FAILED, | 61 ERROR_AUTH_FAILED, |
| 62 ERROR_AUTH_CANCELED, | 62 ERROR_AUTH_CANCELED, |
| 63 ERROR_AUTH_REJECTED, | 63 ERROR_AUTH_REJECTED, |
| 64 ERROR_AUTH_TIMEOUT, | 64 ERROR_AUTH_TIMEOUT, |
| 65 ERROR_UNSUPPORTED_DEVICE | 65 ERROR_UNSUPPORTED_DEVICE, |
| 66 ERROR_SDP_FAILED | |
| 66 }; | 67 }; |
| 67 | 68 |
| 68 // Interface for observing changes from bluetooth devices. | 69 // Interface for observing changes from bluetooth devices. |
| 69 class Observer { | 70 class Observer { |
| 70 public: | 71 public: |
| 71 virtual ~Observer() {} | 72 virtual ~Observer() {} |
| 72 | 73 |
| 73 // TODO(keybuk): add observers for pairing and connection. | 74 // TODO(keybuk): add observers for pairing and connection. |
| 74 }; | 75 }; |
| 75 | 76 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 | 172 |
| 172 // Indicates whether the device is bonded to the adapter, bonding is | 173 // Indicates whether the device is bonded to the adapter, bonding is |
| 173 // formed by pairing and exchanging high-security link keys so that | 174 // formed by pairing and exchanging high-security link keys so that |
| 174 // connections may be encrypted. | 175 // connections may be encrypted. |
| 175 virtual bool IsBonded() const; | 176 virtual bool IsBonded() const; |
| 176 | 177 |
| 177 // Indicates whether the device is currently connected to the adapter | 178 // Indicates whether the device is currently connected to the adapter |
| 178 // and at least one service available for use. | 179 // and at least one service available for use. |
| 179 virtual bool IsConnected() const; | 180 virtual bool IsConnected() const; |
| 180 | 181 |
| 182 // Indicates whether the bonded device accepts connections initiated from the | |
| 183 // adapter. This value is undefined for unbonded devices. | |
| 184 virtual bool IsConnectable() const; | |
| 185 | |
| 181 // Returns the services (as UUID strings) that this device provides. | 186 // Returns the services (as UUID strings) that this device provides. |
| 182 typedef std::vector<std::string> ServiceList; | 187 typedef std::vector<std::string> ServiceList; |
| 183 virtual const ServiceList& GetServices() const = 0; | 188 virtual const ServiceList& GetServices() const = 0; |
| 184 | 189 |
| 185 // The ErrorCallback is used for methods that can fail in which case it | 190 // The ErrorCallback is used for methods that can fail in which case it |
| 186 // is called, in the success case the callback is simply not called. | 191 // is called, in the success case the callback is simply not called. |
| 187 typedef base::Callback<void()> ErrorCallback; | 192 typedef base::Callback<void()> ErrorCallback; |
| 188 | 193 |
| 189 // The ConnectErrorCallback is used for methods that can fail with an error, | 194 // The ConnectErrorCallback is used for methods that can fail with an error, |
| 190 // passed back as an error code argument to this callback. | 195 // passed back as an error code argument to this callback. |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 316 // The Bluetooth class of the device, a bitmask that may be decoded using | 321 // The Bluetooth class of the device, a bitmask that may be decoded using |
| 317 // https://www.bluetooth.org/Technical/AssignedNumbers/baseband.htm | 322 // https://www.bluetooth.org/Technical/AssignedNumbers/baseband.htm |
| 318 uint32 bluetooth_class_; | 323 uint32 bluetooth_class_; |
| 319 | 324 |
| 320 // The name of the device, as supplied by the remote device. | 325 // The name of the device, as supplied by the remote device. |
| 321 std::string name_; | 326 std::string name_; |
| 322 | 327 |
| 323 // The Bluetooth address of the device. | 328 // The Bluetooth address of the device. |
| 324 std::string address_; | 329 std::string address_; |
| 325 | 330 |
| 331 // Indicates whether the device normally accepts connections initiated from | |
| 332 // the adapter once paired. | |
| 333 bool connectable_; | |
|
keybuk
2013/02/21 21:08:58
nit: should go below the other bools, to match the
deymo
2013/02/22 23:09:09
Done.
| |
| 334 | |
| 326 // Tracked device state, updated by the adapter managing the lifecyle of | 335 // Tracked device state, updated by the adapter managing the lifecyle of |
| 327 // the device. | 336 // the device. |
| 328 bool visible_; | 337 bool visible_; |
| 329 bool bonded_; | 338 bool bonded_; |
| 330 bool connected_; | 339 bool connected_; |
| 331 | 340 |
| 332 private: | 341 private: |
| 333 // Returns a localized string containing the device's bluetooth address and | 342 // Returns a localized string containing the device's bluetooth address and |
| 334 // a device type for display when |name_| is empty. | 343 // a device type for display when |name_| is empty. |
| 335 string16 GetAddressWithLocalizedDeviceTypeName() const; | 344 string16 GetAddressWithLocalizedDeviceTypeName() const; |
| 336 }; | 345 }; |
| 337 | 346 |
| 338 } // namespace device | 347 } // namespace device |
| 339 | 348 |
| 340 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 349 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
| OLD | NEW |