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_CHROMEOS_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H_ |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 // The BluetoothDeviceChromeOS class is an implementation of BluetoothDevice | 33 // The BluetoothDeviceChromeOS class is an implementation of BluetoothDevice |
34 // for Chrome OS platform. | 34 // for Chrome OS platform. |
35 class BluetoothDeviceChromeOS | 35 class BluetoothDeviceChromeOS |
36 : public device::BluetoothDevice, | 36 : public device::BluetoothDevice, |
37 public BluetoothDeviceClient::Observer, | 37 public BluetoothDeviceClient::Observer, |
38 public BluetoothAgentServiceProvider::Delegate { | 38 public BluetoothAgentServiceProvider::Delegate { |
39 public: | 39 public: |
40 virtual ~BluetoothDeviceChromeOS(); | 40 virtual ~BluetoothDeviceChromeOS(); |
41 | 41 |
42 // BluetoothDevice override | 42 // BluetoothDevice override |
| 43 virtual std::string GetAddress() const OVERRIDE; |
43 virtual bool IsPaired() const OVERRIDE; | 44 virtual bool IsPaired() const OVERRIDE; |
44 virtual const ServiceList& GetServices() const OVERRIDE; | 45 virtual bool IsConnected() const OVERRIDE; |
| 46 virtual bool IsConnectable() const OVERRIDE; |
| 47 virtual bool IsConnecting() const OVERRIDE; |
| 48 virtual ServiceList GetServices() const OVERRIDE; |
45 virtual void GetServiceRecords( | 49 virtual void GetServiceRecords( |
46 const ServiceRecordsCallback& callback, | 50 const ServiceRecordsCallback& callback, |
47 const ErrorCallback& error_callback) OVERRIDE; | 51 const ErrorCallback& error_callback) OVERRIDE; |
48 virtual void ProvidesServiceWithName( | 52 virtual void ProvidesServiceWithName( |
49 const std::string& name, | 53 const std::string& name, |
50 const ProvidesServiceCallback& callback) OVERRIDE; | 54 const ProvidesServiceCallback& callback) OVERRIDE; |
51 virtual bool ExpectingPinCode() const OVERRIDE; | 55 virtual bool ExpectingPinCode() const OVERRIDE; |
52 virtual bool ExpectingPasskey() const OVERRIDE; | 56 virtual bool ExpectingPasskey() const OVERRIDE; |
53 virtual bool ExpectingConfirmation() const OVERRIDE; | 57 virtual bool ExpectingConfirmation() const OVERRIDE; |
54 virtual void Connect( | 58 virtual void Connect( |
(...skipping 13 matching lines...) Expand all Loading... |
68 const std::string& service_uuid, | 72 const std::string& service_uuid, |
69 const SocketCallback& callback) OVERRIDE; | 73 const SocketCallback& callback) OVERRIDE; |
70 virtual void SetOutOfBandPairingData( | 74 virtual void SetOutOfBandPairingData( |
71 const device::BluetoothOutOfBandPairingData& data, | 75 const device::BluetoothOutOfBandPairingData& data, |
72 const base::Closure& callback, | 76 const base::Closure& callback, |
73 const ErrorCallback& error_callback) OVERRIDE; | 77 const ErrorCallback& error_callback) OVERRIDE; |
74 virtual void ClearOutOfBandPairingData( | 78 virtual void ClearOutOfBandPairingData( |
75 const base::Closure& callback, | 79 const base::Closure& callback, |
76 const ErrorCallback& error_callback) OVERRIDE; | 80 const ErrorCallback& error_callback) OVERRIDE; |
77 | 81 |
| 82 protected: |
| 83 // BluetoothDevice override |
| 84 virtual uint32 GetBluetoothClass() const OVERRIDE; |
| 85 virtual std::string GetDeviceName() const OVERRIDE; |
| 86 |
78 private: | 87 private: |
79 friend class BluetoothAdapterChromeOS; | 88 friend class BluetoothAdapterChromeOS; |
80 friend class device::MockBluetoothDevice; | 89 friend class device::MockBluetoothDevice; |
81 | 90 |
82 explicit BluetoothDeviceChromeOS(BluetoothAdapterChromeOS* adapter); | 91 explicit BluetoothDeviceChromeOS(BluetoothAdapterChromeOS* adapter); |
83 | 92 |
| 93 // Returns whether this device has an object path. |
| 94 bool HasObjectPath() const { return !object_path_.value().empty(); } |
| 95 |
84 // Sets the dbus object path for the device to |object_path|, indicating | 96 // Sets the dbus object path for the device to |object_path|, indicating |
85 // that the device has gone from being discovered to paired or bonded. | 97 // that the device has gone from being discovered to paired or connected. |
86 void SetObjectPath(const dbus::ObjectPath& object_path); | 98 void SetObjectPath(const dbus::ObjectPath& object_path); |
87 | 99 |
88 // Removes the dbus object path from the device, indicating that the | 100 // Removes the dbus object path from the device, indicating that the |
89 // device is no longer paired or bonded, but perhaps still visible. | 101 // device is no longer paired or connected, but perhaps still visible. |
90 void RemoveObjectPath(); | 102 void RemoveObjectPath(); |
91 | 103 |
92 // Sets whether the device is visible to the owning adapter to |visible|. | 104 // Returns whether this was a discovered device. |
93 void SetVisible(bool visible) { visible_ = visible; } | 105 bool WasDiscovered() const { return discovered_; } |
| 106 |
| 107 // Sets whether the device was discovered. |
| 108 void SetDiscovered(bool discovered) { discovered_ = discovered; } |
94 | 109 |
95 // Updates device information from the properties in |properties|, device | 110 // Updates device information from the properties in |properties|, device |
96 // state properties such as |paired_| and |connected_| are ignored unless | 111 // state properties such as |paired_| and |connected_| are ignored unless |
97 // |update_state| is true. | 112 // |update_state| is true. |
98 void Update(const BluetoothDeviceClient::Properties* properties, | 113 void Update(const BluetoothDeviceClient::Properties* properties, |
99 bool update_state); | 114 bool update_state); |
100 | 115 |
101 // Called by BluetoothAdapterClient when a call to CreateDevice() or | 116 // Called by BluetoothAdapterClient when a call to CreateDevice() or |
102 // CreatePairedDevice() succeeds, provides the new object path for the remote | 117 // CreatePairedDevice() succeeds, provides the new object path for the remote |
103 // device in |device_path|. |callback| and |error_callback| are the callbacks | 118 // device in |device_path|. |callback| and |error_callback| are the callbacks |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 // |adapter|. | 379 // |adapter|. |
365 static BluetoothDeviceChromeOS* Create(BluetoothAdapterChromeOS* adapter); | 380 static BluetoothDeviceChromeOS* Create(BluetoothAdapterChromeOS* adapter); |
366 | 381 |
367 // The adapter that owns this device instance. | 382 // The adapter that owns this device instance. |
368 BluetoothAdapterChromeOS* adapter_; | 383 BluetoothAdapterChromeOS* adapter_; |
369 | 384 |
370 // The dbus object path of the device, will be empty if the device has only | 385 // The dbus object path of the device, will be empty if the device has only |
371 // been discovered and not yet paired with. | 386 // been discovered and not yet paired with. |
372 dbus::ObjectPath object_path_; | 387 dbus::ObjectPath object_path_; |
373 | 388 |
| 389 // The Bluetooth class of the device, a bitmask that may be decoded using |
| 390 // https://www.bluetooth.org/Technical/AssignedNumbers/baseband.htm |
| 391 uint32 bluetooth_class_; |
| 392 |
| 393 // The name of the device, as supplied by the remote device. |
| 394 std::string name_; |
| 395 |
| 396 // The Bluetooth address of the device. |
| 397 std::string address_; |
| 398 |
| 399 // Tracked device state, updated by the adapter managing the lifecyle of |
| 400 // the device. |
| 401 bool paired_; |
| 402 bool connected_; |
| 403 |
| 404 // Indicates whether the device normally accepts connections initiated from |
| 405 // the adapter once paired. |
| 406 bool connectable_; |
| 407 |
| 408 // Indicated whether the device is in a connecting status. |
| 409 bool connecting_; |
| 410 |
| 411 // Used by BluetoothAdapterChromeOS (a friend) to avoid removing discovered |
| 412 // devices when they are unpaired. |
| 413 bool discovered_; |
| 414 |
374 // The services (identified by UUIDs) that this device provides. | 415 // The services (identified by UUIDs) that this device provides. |
375 std::vector<std::string> service_uuids_; | 416 ServiceList service_uuids_; |
376 | 417 |
377 // During pairing this is set to an object that we don't own, but on which | 418 // During pairing this is set to an object that we don't own, but on which |
378 // we can make method calls to request, display or confirm PIN Codes and | 419 // we can make method calls to request, display or confirm PIN Codes and |
379 // Passkeys. Generally it is the object that owns this one. | 420 // Passkeys. Generally it is the object that owns this one. |
380 device::BluetoothDevice::PairingDelegate* pairing_delegate_; | 421 device::BluetoothDevice::PairingDelegate* pairing_delegate_; |
381 | 422 |
382 // During pairing this is set to an instance of a D-Bus agent object | 423 // During pairing this is set to an instance of a D-Bus agent object |
383 // intialized with our own class as its delegate. | 424 // intialized with our own class as its delegate. |
384 scoped_ptr<BluetoothAgentServiceProvider> agent_; | 425 scoped_ptr<BluetoothAgentServiceProvider> agent_; |
385 | 426 |
(...skipping 20 matching lines...) Expand all Loading... |
406 // Note: This should remain the last member so it'll be destroyed and | 447 // Note: This should remain the last member so it'll be destroyed and |
407 // invalidate its weak pointers before any other members are destroyed. | 448 // invalidate its weak pointers before any other members are destroyed. |
408 base::WeakPtrFactory<BluetoothDeviceChromeOS> weak_ptr_factory_; | 449 base::WeakPtrFactory<BluetoothDeviceChromeOS> weak_ptr_factory_; |
409 | 450 |
410 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceChromeOS); | 451 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceChromeOS); |
411 }; | 452 }; |
412 | 453 |
413 } // namespace chromeos | 454 } // namespace chromeos |
414 | 455 |
415 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H_ | 456 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H_ |
OLD | NEW |