| 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 <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 ERROR_UNKNOWN, | 74 ERROR_UNKNOWN, |
| 75 ERROR_INPROGRESS, | 75 ERROR_INPROGRESS, |
| 76 ERROR_FAILED, | 76 ERROR_FAILED, |
| 77 ERROR_AUTH_FAILED, | 77 ERROR_AUTH_FAILED, |
| 78 ERROR_AUTH_CANCELED, | 78 ERROR_AUTH_CANCELED, |
| 79 ERROR_AUTH_REJECTED, | 79 ERROR_AUTH_REJECTED, |
| 80 ERROR_AUTH_TIMEOUT, | 80 ERROR_AUTH_TIMEOUT, |
| 81 ERROR_UNSUPPORTED_DEVICE | 81 ERROR_UNSUPPORTED_DEVICE |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 // Interface for observing changes from bluetooth devices. | |
| 85 class Observer { | |
| 86 public: | |
| 87 virtual ~Observer() {} | |
| 88 | |
| 89 // Called when a new GATT service |service| is added to the device |device|, | |
| 90 // as the service is received from the device. Don't cache |service|. Store | |
| 91 // its identifier instead (i.e. BluetoothGattService::GetIdentifier). | |
| 92 virtual void GattServiceAdded(BluetoothDevice* device, | |
| 93 BluetoothGattService* service) {} | |
| 94 | |
| 95 // Called when the GATT service |service| is removed from the device | |
| 96 // |device|. This can happen if the attribute database of the remote device | |
| 97 // changes or when |device| gets removed. | |
| 98 virtual void GattServiceRemoved(BluetoothDevice* device, | |
| 99 BluetoothGattService* service) {} | |
| 100 | |
| 101 // TODO(keybuk): add observers for pairing and connection. | |
| 102 }; | |
| 103 | |
| 104 // Interface for negotiating pairing of bluetooth devices. | 84 // Interface for negotiating pairing of bluetooth devices. |
| 105 class PairingDelegate { | 85 class PairingDelegate { |
| 106 public: | 86 public: |
| 107 virtual ~PairingDelegate() {} | 87 virtual ~PairingDelegate() {} |
| 108 | 88 |
| 109 // This method will be called when the Bluetooth daemon requires a | 89 // This method will be called when the Bluetooth daemon requires a |
| 110 // PIN Code for authentication of the device |device|, the delegate should | 90 // PIN Code for authentication of the device |device|, the delegate should |
| 111 // obtain the code from the user and call SetPinCode() on the device to | 91 // obtain the code from the user and call SetPinCode() on the device to |
| 112 // provide it, or RejectPairing() or CancelPairing() to reject or cancel | 92 // provide it, or RejectPairing() or CancelPairing() to reject or cancel |
| 113 // the request. | 93 // the request. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 // authorized. The delegate should decide whether the user should confirm | 163 // authorized. The delegate should decide whether the user should confirm |
| 184 // or not, then call ConfirmPairing() on the device to confirm the pairing | 164 // or not, then call ConfirmPairing() on the device to confirm the pairing |
| 185 // (whether by user action or by default), RejectPairing() on the device to | 165 // (whether by user action or by default), RejectPairing() on the device to |
| 186 // reject or CancelPairing() on the device to cancel authorization for | 166 // reject or CancelPairing() on the device to cancel authorization for |
| 187 // any other reason. | 167 // any other reason. |
| 188 virtual void AuthorizePairing(BluetoothDevice* device) = 0; | 168 virtual void AuthorizePairing(BluetoothDevice* device) = 0; |
| 189 }; | 169 }; |
| 190 | 170 |
| 191 virtual ~BluetoothDevice(); | 171 virtual ~BluetoothDevice(); |
| 192 | 172 |
| 193 // Adds and removes observers for events on this Bluetooth device. If | |
| 194 // monitoring multiple devices, check the |device| parameter of the observer | |
| 195 // methods to determine which device is issuing the event. | |
| 196 virtual void AddObserver(Observer* observer) = 0; | |
| 197 virtual void RemoveObserver(Observer* observer) = 0; | |
| 198 | |
| 199 // Returns the Bluetooth class of the device, used by GetDeviceType() | 173 // Returns the Bluetooth class of the device, used by GetDeviceType() |
| 200 // and metrics logging, | 174 // and metrics logging, |
| 201 virtual uint32 GetBluetoothClass() const = 0; | 175 virtual uint32 GetBluetoothClass() const = 0; |
| 202 | 176 |
| 203 // Returns the Bluetooth of address the device. This should be used as | 177 // Returns the Bluetooth of address the device. This should be used as |
| 204 // a unique key to identify the device and copied where needed. | 178 // a unique key to identify the device and copied where needed. |
| 205 virtual std::string GetAddress() const = 0; | 179 virtual std::string GetAddress() const = 0; |
| 206 | 180 |
| 207 // Returns the allocation source of the identifier returned by GetVendorID(), | 181 // Returns the allocation source of the identifier returned by GetVendorID(), |
| 208 // where available, or VENDOR_ID_UNKNOWN where not. | 182 // where available, or VENDOR_ID_UNKNOWN where not. |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 | 403 |
| 430 private: | 404 private: |
| 431 // Returns a localized string containing the device's bluetooth address and | 405 // Returns a localized string containing the device's bluetooth address and |
| 432 // a device type for display when |name_| is empty. | 406 // a device type for display when |name_| is empty. |
| 433 base::string16 GetAddressWithLocalizedDeviceTypeName() const; | 407 base::string16 GetAddressWithLocalizedDeviceTypeName() const; |
| 434 }; | 408 }; |
| 435 | 409 |
| 436 } // namespace device | 410 } // namespace device |
| 437 | 411 |
| 438 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 412 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
| OLD | NEW |