• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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>
9 #include <vector>
10 
11 #include "base/basictypes.h"
12 #include "device/bluetooth/bluetooth_device.h"
13 #include "device/bluetooth/bluetooth_task_manager_win.h"
14 
15 namespace device {
16 
17 class BluetoothAdapterWin;
18 class BluetoothServiceRecord;
19 
20 class BluetoothDeviceWin : public BluetoothDevice {
21  public:
22   explicit BluetoothDeviceWin(
23       const BluetoothTaskManagerWin::DeviceState& state);
24   virtual ~BluetoothDeviceWin();
25 
26   // BluetoothDevice override
27   virtual uint32 GetBluetoothClass() const OVERRIDE;
28   virtual std::string GetAddress() const OVERRIDE;
29   virtual uint16 GetVendorID() const OVERRIDE;
30   virtual uint16 GetProductID() const OVERRIDE;
31   virtual uint16 GetDeviceID() const OVERRIDE;
32   virtual bool IsPaired() const OVERRIDE;
33   virtual bool IsConnected() const OVERRIDE;
34   virtual bool IsConnectable() const OVERRIDE;
35   virtual bool IsConnecting() const OVERRIDE;
36   virtual ServiceList GetServices() const OVERRIDE;
37   virtual void GetServiceRecords(
38       const ServiceRecordsCallback& callback,
39       const ErrorCallback& error_callback) OVERRIDE;
40   virtual void ProvidesServiceWithName(
41       const std::string& name,
42       const ProvidesServiceCallback& callback) OVERRIDE;
43   virtual bool ExpectingPinCode() const OVERRIDE;
44   virtual bool ExpectingPasskey() const OVERRIDE;
45   virtual bool ExpectingConfirmation() const OVERRIDE;
46   virtual void Connect(
47       PairingDelegate* pairing_delegate,
48       const base::Closure& callback,
49       const ConnectErrorCallback& error_callback) OVERRIDE;
50   virtual void SetPinCode(const std::string& pincode) OVERRIDE;
51   virtual void SetPasskey(uint32 passkey) OVERRIDE;
52   virtual void ConfirmPairing() OVERRIDE;
53   virtual void RejectPairing() OVERRIDE;
54   virtual void CancelPairing() OVERRIDE;
55   virtual void Disconnect(
56       const base::Closure& callback,
57       const ErrorCallback& error_callback) OVERRIDE;
58   virtual void Forget(const ErrorCallback& error_callback) OVERRIDE;
59   virtual void ConnectToService(
60       const std::string& service_uuid,
61       const SocketCallback& callback) OVERRIDE;
62   virtual void ConnectToProfile(
63       device::BluetoothProfile* profile,
64       const base::Closure& callback,
65       const ErrorCallback& error_callback) OVERRIDE;
66   virtual void SetOutOfBandPairingData(
67       const BluetoothOutOfBandPairingData& data,
68       const base::Closure& callback,
69       const ErrorCallback& error_callback) OVERRIDE;
70   virtual void ClearOutOfBandPairingData(
71       const base::Closure& callback,
72       const ErrorCallback& error_callback) OVERRIDE;
73 
74   const BluetoothServiceRecord* GetServiceRecord(const std::string& uuid) const;
75 
76  protected:
77   // BluetoothDevice override
78   virtual std::string GetDeviceName() const OVERRIDE;
79 
80  private:
81   friend class BluetoothAdapterWin;
82 
83   // Used by BluetoothAdapterWin to update the visible state during
84   // discovery.
85   void SetVisible(bool visible);
86 
87   // The Bluetooth class of the device, a bitmask that may be decoded using
88   // https://www.bluetooth.org/Technical/AssignedNumbers/baseband.htm
89   uint32 bluetooth_class_;
90 
91   // The name of the device, as supplied by the remote device.
92   std::string name_;
93 
94   // The Bluetooth address of the device.
95   std::string address_;
96 
97   // Tracked device state, updated by the adapter managing the lifecycle of
98   // the device.
99   bool paired_;
100   bool connected_;
101 
102   // Used to send change notifications when a device disappears during
103   // discovery.
104   bool visible_;
105 
106   // The services (identified by UUIDs) that this device provides.
107   ServiceList service_uuids_;
108   ServiceRecordList service_record_list_;
109 
110   DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceWin);
111 };
112 
113 }  // namespace device
114 
115 #endif  // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_WIN_H_
116