blob: be0e25782802e11b099b7affa08299fd3451b071 [file] [log] [blame]
[email protected]0ae97592012-10-22 22:06:051// 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]d7ba43752013-02-21 22:27:059#include <vector>
[email protected]0ae97592012-10-22 22:06:0510
11#include "base/basictypes.h"
12#include "device/bluetooth/bluetooth_device.h"
[email protected]d7ba43752013-02-21 22:27:0513#include "device/bluetooth/bluetooth_task_manager_win.h"
[email protected]0ae97592012-10-22 22:06:0514
15namespace device {
16
[email protected]d7ba43752013-02-21 22:27:0517class BluetoothAdapterWin;
18
[email protected]0ae97592012-10-22 22:06:0519class BluetoothDeviceWin : public BluetoothDevice {
20 public:
[email protected]6cc9b8d2013-03-18 21:07:0321 explicit BluetoothDeviceWin(
22 const BluetoothTaskManagerWin::DeviceState& state);
[email protected]0ae97592012-10-22 22:06:0523 virtual ~BluetoothDeviceWin();
24
[email protected]d7ba43752013-02-21 22:27:0525 // BluetoothDevice override
[email protected]320447d72013-04-05 03:32:2626 virtual std::string GetAddress() const OVERRIDE;
[email protected]0ae97592012-10-22 22:06:0527 virtual bool IsPaired() const OVERRIDE;
[email protected]320447d72013-04-05 03:32:2628 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]0ae97592012-10-22 22:06:0532 virtual void GetServiceRecords(
33 const ServiceRecordsCallback& callback,
34 const ErrorCallback& error_callback) OVERRIDE;
[email protected]0ae97592012-10-22 22:06:0535 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]eb72b662012-12-18 06:55:4144 const ConnectErrorCallback& error_callback) OVERRIDE;
[email protected]0ae97592012-10-22 22:06:0545 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]2862df462013-04-19 21:07:2157 virtual void ConnectToProfile(
58 device::BluetoothProfile* profile,
[email protected]476f29d2013-04-24 09:06:5159 const base::Closure& callback,
[email protected]2862df462013-04-19 21:07:2160 const ErrorCallback& error_callback) OVERRIDE;
[email protected]0ae97592012-10-22 22:06:0561 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]320447d72013-04-05 03:32:2669 protected:
70 // BluetoothDevice override
71 virtual uint32 GetBluetoothClass() const OVERRIDE;
72 virtual std::string GetDeviceName() const OVERRIDE;
73
[email protected]0ae97592012-10-22 22:06:0574 private:
[email protected]d7ba43752013-02-21 22:27:0575 friend class BluetoothAdapterWin;
76
[email protected]320447d72013-04-05 03:32:2677 // Used by BluetoothAdapterWin to update the visible state during
78 // discovery.
79 void SetVisible(bool visible);
80
[email protected]d7ba43752013-02-21 22:27:0581 // 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]320447d72013-04-05 03:32:2689 // 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]d7ba43752013-02-21 22:27:05111 // Used to compare the devices.
112 uint32 device_fingerprint_;
113 ServiceRecordList service_record_list_;
[email protected]d7ba43752013-02-21 22:27:05114
115 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceWin);
[email protected]0ae97592012-10-22 22:06:05116};
117
118} // namespace device
119
120#endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_WIN_H_