[email protected] | 0ae9759 | 2012-10-22 22:06:05 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_WIN_H_ |
| 6 | #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_WIN_H_ |
| 7 | |
| 8 | #include <string> |
[email protected] | d7ba4375 | 2013-02-21 22:27:05 | [diff] [blame] | 9 | #include <vector> |
[email protected] | 0ae9759 | 2012-10-22 22:06:05 | [diff] [blame] | 10 | |
| 11 | #include "base/basictypes.h" |
| 12 | #include "device/bluetooth/bluetooth_device.h" |
[email protected] | d7ba4375 | 2013-02-21 22:27:05 | [diff] [blame] | 13 | #include "device/bluetooth/bluetooth_task_manager_win.h" |
[email protected] | 0ae9759 | 2012-10-22 22:06:05 | [diff] [blame] | 14 | |
| 15 | namespace device { |
| 16 | |
[email protected] | d7ba4375 | 2013-02-21 22:27:05 | [diff] [blame] | 17 | class BluetoothAdapterWin; |
[email protected] | e55a50f | 2013-05-05 03:37:09 | [diff] [blame] | 18 | class BluetoothServiceRecord; |
[email protected] | d7ba4375 | 2013-02-21 22:27:05 | [diff] [blame] | 19 | |
[email protected] | 0ae9759 | 2012-10-22 22:06:05 | [diff] [blame] | 20 | class BluetoothDeviceWin : public BluetoothDevice { |
| 21 | public: |
[email protected] | 6cc9b8d | 2013-03-18 21:07:03 | [diff] [blame] | 22 | explicit BluetoothDeviceWin( |
| 23 | const BluetoothTaskManagerWin::DeviceState& state); |
[email protected] | 0ae9759 | 2012-10-22 22:06:05 | [diff] [blame] | 24 | virtual ~BluetoothDeviceWin(); |
| 25 | |
[email protected] | d7ba4375 | 2013-02-21 22:27:05 | [diff] [blame] | 26 | // BluetoothDevice override |
[email protected] | 611ae29a | 2013-04-29 21:32:19 | [diff] [blame] | 27 | virtual uint32 GetBluetoothClass() const OVERRIDE; |
[email protected] | 320447d7 | 2013-04-05 03:32:26 | [diff] [blame] | 28 | virtual std::string GetAddress() const OVERRIDE; |
[email protected] | c8154319 | 2014-03-11 22:44:48 | [diff] [blame] | 29 | virtual VendorIDSource GetVendorIDSource() const OVERRIDE; |
[email protected] | 611ae29a | 2013-04-29 21:32:19 | [diff] [blame] | 30 | virtual uint16 GetVendorID() const OVERRIDE; |
| 31 | virtual uint16 GetProductID() const OVERRIDE; |
| 32 | virtual uint16 GetDeviceID() const OVERRIDE; |
[email protected] | 0ae9759 | 2012-10-22 22:06:05 | [diff] [blame] | 33 | virtual bool IsPaired() const OVERRIDE; |
[email protected] | 320447d7 | 2013-04-05 03:32:26 | [diff] [blame] | 34 | virtual bool IsConnected() const OVERRIDE; |
| 35 | virtual bool IsConnectable() const OVERRIDE; |
| 36 | virtual bool IsConnecting() const OVERRIDE; |
[email protected] | 9bf562c | 2014-03-20 19:11:57 | [diff] [blame] | 37 | virtual UUIDList GetUUIDs() const OVERRIDE; |
[email protected] | 0ae9759 | 2012-10-22 22:06:05 | [diff] [blame] | 38 | virtual bool ExpectingPinCode() const OVERRIDE; |
| 39 | virtual bool ExpectingPasskey() const OVERRIDE; |
| 40 | virtual bool ExpectingConfirmation() const OVERRIDE; |
| 41 | virtual void Connect( |
| 42 | PairingDelegate* pairing_delegate, |
| 43 | const base::Closure& callback, |
[email protected] | eb72b66 | 2012-12-18 06:55:41 | [diff] [blame] | 44 | const ConnectErrorCallback& error_callback) OVERRIDE; |
[email protected] | 0ae9759 | 2012-10-22 22:06:05 | [diff] [blame] | 45 | virtual void SetPinCode(const std::string& pincode) OVERRIDE; |
| 46 | virtual void SetPasskey(uint32 passkey) OVERRIDE; |
| 47 | virtual void ConfirmPairing() OVERRIDE; |
| 48 | virtual void RejectPairing() OVERRIDE; |
| 49 | virtual void CancelPairing() OVERRIDE; |
| 50 | virtual void Disconnect( |
| 51 | const base::Closure& callback, |
| 52 | const ErrorCallback& error_callback) OVERRIDE; |
| 53 | virtual void Forget(const ErrorCallback& error_callback) OVERRIDE; |
| 54 | virtual void ConnectToService( |
| 55 | const std::string& service_uuid, |
| 56 | const SocketCallback& callback) OVERRIDE; |
[email protected] | 2862df46 | 2013-04-19 21:07:21 | [diff] [blame] | 57 | virtual void ConnectToProfile( |
| 58 | device::BluetoothProfile* profile, |
[email protected] | 476f29d | 2013-04-24 09:06:51 | [diff] [blame] | 59 | const base::Closure& callback, |
[email protected] | 2862df46 | 2013-04-19 21:07:21 | [diff] [blame] | 60 | const ErrorCallback& error_callback) OVERRIDE; |
[email protected] | 0ae9759 | 2012-10-22 22:06:05 | [diff] [blame] | 61 | virtual void SetOutOfBandPairingData( |
| 62 | const BluetoothOutOfBandPairingData& data, |
| 63 | const base::Closure& callback, |
| 64 | const ErrorCallback& error_callback) OVERRIDE; |
| 65 | virtual void ClearOutOfBandPairingData( |
| 66 | const base::Closure& callback, |
| 67 | const ErrorCallback& error_callback) OVERRIDE; |
| 68 | |
[email protected] | 9bf562c | 2014-03-20 19:11:57 | [diff] [blame] | 69 | // Used by BluetoothProfileWin to retrieve the service record for the given |
| 70 | // |uuid|. |
| 71 | const BluetoothServiceRecord* GetServiceRecord( |
| 72 | const std::string& uuid) const; |
[email protected] | e55a50f | 2013-05-05 03:37:09 | [diff] [blame] | 73 | |
[email protected] | 320447d7 | 2013-04-05 03:32:26 | [diff] [blame] | 74 | protected: |
| 75 | // BluetoothDevice override |
[email protected] | 320447d7 | 2013-04-05 03:32:26 | [diff] [blame] | 76 | virtual std::string GetDeviceName() const OVERRIDE; |
| 77 | |
[email protected] | 0ae9759 | 2012-10-22 22:06:05 | [diff] [blame] | 78 | private: |
[email protected] | d7ba4375 | 2013-02-21 22:27:05 | [diff] [blame] | 79 | friend class BluetoothAdapterWin; |
| 80 | |
[email protected] | 320447d7 | 2013-04-05 03:32:26 | [diff] [blame] | 81 | // Used by BluetoothAdapterWin to update the visible state during |
| 82 | // discovery. |
| 83 | void SetVisible(bool visible); |
| 84 | |
[email protected] | 320447d7 | 2013-04-05 03:32:26 | [diff] [blame] | 85 | // The Bluetooth class of the device, a bitmask that may be decoded using |
| 86 | // https://www.bluetooth.org/Technical/AssignedNumbers/baseband.htm |
| 87 | uint32 bluetooth_class_; |
| 88 | |
| 89 | // The name of the device, as supplied by the remote device. |
| 90 | std::string name_; |
| 91 | |
| 92 | // The Bluetooth address of the device. |
| 93 | std::string address_; |
| 94 | |
[email protected] | 69b6838 | 2013-07-31 15:49:36 | [diff] [blame] | 95 | // Tracked device state, updated by the adapter managing the lifecycle of |
[email protected] | 320447d7 | 2013-04-05 03:32:26 | [diff] [blame] | 96 | // the device. |
| 97 | bool paired_; |
| 98 | bool connected_; |
| 99 | |
| 100 | // Used to send change notifications when a device disappears during |
| 101 | // discovery. |
| 102 | bool visible_; |
| 103 | |
| 104 | // The services (identified by UUIDs) that this device provides. |
[email protected] | 9bf562c | 2014-03-20 19:11:57 | [diff] [blame] | 105 | UUIDList uuids_; |
| 106 | |
| 107 | // The service records retrieved from SDP. |
| 108 | typedef ScopedVector<BluetoothServiceRecord> ServiceRecordList; |
[email protected] | d7ba4375 | 2013-02-21 22:27:05 | [diff] [blame] | 109 | ServiceRecordList service_record_list_; |
[email protected] | d7ba4375 | 2013-02-21 22:27:05 | [diff] [blame] | 110 | |
| 111 | DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceWin); |
[email protected] | 0ae9759 | 2012-10-22 22:06:05 | [diff] [blame] | 112 | }; |
| 113 | |
| 114 | } // namespace device |
| 115 | |
| 116 | #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_WIN_H_ |