[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; |
| 18 | |
[email protected] | 0ae9759 | 2012-10-22 22:06:05 | [diff] [blame] | 19 | class BluetoothDeviceWin : public BluetoothDevice { |
| 20 | public: |
[email protected] | 6cc9b8d | 2013-03-18 21:07:03 | [diff] [blame] | 21 | explicit BluetoothDeviceWin( |
| 22 | const BluetoothTaskManagerWin::DeviceState& state); |
[email protected] | 0ae9759 | 2012-10-22 22:06:05 | [diff] [blame] | 23 | virtual ~BluetoothDeviceWin(); |
| 24 | |
[email protected] | d7ba4375 | 2013-02-21 22:27:05 | [diff] [blame] | 25 | // BluetoothDevice override |
[email protected] | 320447d7 | 2013-04-05 03:32:26 | [diff] [blame] | 26 | virtual std::string GetAddress() const OVERRIDE; |
[email protected] | 0ae9759 | 2012-10-22 22:06:05 | [diff] [blame] | 27 | virtual bool IsPaired() const OVERRIDE; |
[email protected] | 320447d7 | 2013-04-05 03:32:26 | [diff] [blame] | 28 | virtual bool IsConnected() const OVERRIDE; |
| 29 | virtual bool IsConnectable() const OVERRIDE; |
| 30 | virtual bool IsConnecting() const OVERRIDE; |
| 31 | virtual ServiceList GetServices() const OVERRIDE; |
[email protected] | 0ae9759 | 2012-10-22 22:06:05 | [diff] [blame] | 32 | virtual void GetServiceRecords( |
| 33 | const ServiceRecordsCallback& callback, |
| 34 | const ErrorCallback& error_callback) OVERRIDE; |
[email protected] | 0ae9759 | 2012-10-22 22:06:05 | [diff] [blame] | 35 | virtual void ProvidesServiceWithName( |
| 36 | const std::string& name, |
| 37 | const ProvidesServiceCallback& callback) OVERRIDE; |
| 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] | 320447d7 | 2013-04-05 03:32:26 | [diff] [blame] | 69 | protected: |
| 70 | // BluetoothDevice override |
| 71 | virtual uint32 GetBluetoothClass() const OVERRIDE; |
| 72 | virtual std::string GetDeviceName() const OVERRIDE; |
| 73 | |
[email protected] | 0ae9759 | 2012-10-22 22:06:05 | [diff] [blame] | 74 | private: |
[email protected] | d7ba4375 | 2013-02-21 22:27:05 | [diff] [blame] | 75 | friend class BluetoothAdapterWin; |
| 76 | |
[email protected] | 320447d7 | 2013-04-05 03:32:26 | [diff] [blame] | 77 | // Used by BluetoothAdapterWin to update the visible state during |
| 78 | // discovery. |
| 79 | void SetVisible(bool visible); |
| 80 | |
[email protected] | d7ba4375 | 2013-02-21 22:27:05 | [diff] [blame] | 81 | // Computes the fingerprint that can be used to compare the devices. |
| 82 | static uint32 ComputeDeviceFingerprint( |
| 83 | const BluetoothTaskManagerWin::DeviceState& state); |
| 84 | |
| 85 | uint32 device_fingerprint() const { |
| 86 | return device_fingerprint_; |
| 87 | } |
| 88 | |
[email protected] | 320447d7 | 2013-04-05 03:32:26 | [diff] [blame] | 89 | // The Bluetooth class of the device, a bitmask that may be decoded using |
| 90 | // https://www.bluetooth.org/Technical/AssignedNumbers/baseband.htm |
| 91 | uint32 bluetooth_class_; |
| 92 | |
| 93 | // The name of the device, as supplied by the remote device. |
| 94 | std::string name_; |
| 95 | |
| 96 | // The Bluetooth address of the device. |
| 97 | std::string address_; |
| 98 | |
| 99 | // Tracked device state, updated by the adapter managing the lifecyle of |
| 100 | // the device. |
| 101 | bool paired_; |
| 102 | bool connected_; |
| 103 | |
| 104 | // Used to send change notifications when a device disappears during |
| 105 | // discovery. |
| 106 | bool visible_; |
| 107 | |
| 108 | // The services (identified by UUIDs) that this device provides. |
| 109 | ServiceList service_uuids_; |
| 110 | |
[email protected] | d7ba4375 | 2013-02-21 22:27:05 | [diff] [blame] | 111 | // Used to compare the devices. |
| 112 | uint32 device_fingerprint_; |
| 113 | ServiceRecordList service_record_list_; |
[email protected] | d7ba4375 | 2013-02-21 22:27:05 | [diff] [blame] | 114 | |
| 115 | DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceWin); |
[email protected] | 0ae9759 | 2012-10-22 22:06:05 | [diff] [blame] | 116 | }; |
| 117 | |
| 118 | } // namespace device |
| 119 | |
| 120 | #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_WIN_H_ |