OLD | NEW |
(Empty) | |
| 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 CHROMEOS_DBUS_BLUETOOTH_OUT_OF_BAND_CLIENT_H_ |
| 6 #define CHROMEOS_DBUS_BLUETOOTH_OUT_OF_BAND_CLIENT_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 |
| 11 #include "base/callback.h" |
| 12 #include "chromeos/chromeos_export.h" |
| 13 #include "chromeos/dbus/dbus_client_implementation_type.h" |
| 14 #include "dbus/object_path.h" |
| 15 |
| 16 namespace dbus { |
| 17 class Bus; |
| 18 } // namespace dbus |
| 19 |
| 20 namespace chromeos { |
| 21 |
| 22 const size_t kBluetoothOutOfBandPairingDataSize = 16; |
| 23 |
| 24 // A simple structure representing the data required to perform Out Of Band |
| 25 // Pairing. See |
| 26 // http://mclean-linsky.net/joel/cv/Simple%20Pairing_WP_V10r00.pdf |
| 27 struct BluetoothOutOfBandPairingData { |
| 28 // Simple Pairing Hash C. |
| 29 uint8_t hash[kBluetoothOutOfBandPairingDataSize]; |
| 30 |
| 31 // Simple Pairing Randomizer R. |
| 32 uint8_t randomizer[kBluetoothOutOfBandPairingDataSize]; |
| 33 }; |
| 34 |
| 35 // BluetoothOutOfBandClient is used to manage Out Of Band Pairing |
| 36 // Data for the local adapter and remote devices. |
| 37 class CHROMEOS_EXPORT BluetoothOutOfBandClient { |
| 38 public: |
| 39 virtual ~BluetoothOutOfBandClient(); |
| 40 |
| 41 typedef base::Callback<void(const BluetoothOutOfBandPairingData& data, |
| 42 bool success)> DataCallback; |
| 43 |
| 44 typedef base::Callback<void(bool success)> SuccessCallback; |
| 45 |
| 46 // Reads the local Out Of Band Pairing Data and return it in |callback|. |
| 47 virtual void ReadLocalData( |
| 48 const dbus::ObjectPath& object_path, |
| 49 const DataCallback& callback) = 0; |
| 50 |
| 51 // Sets the Out Of Band Pairing Data for the device at |address| to |data|, |
| 52 // indicating success via |callback|. Makes a copy of |data|. |
| 53 virtual void AddRemoteData( |
| 54 const dbus::ObjectPath& object_path, |
| 55 const std::string& address, |
| 56 const BluetoothOutOfBandPairingData& data, |
| 57 const SuccessCallback& callback) = 0; |
| 58 |
| 59 // Clears the Out Of Band Pairing Data for the device at |address|, indicating |
| 60 // success via |callback|. |
| 61 virtual void RemoveRemoteData( |
| 62 const dbus::ObjectPath& object_path, |
| 63 const std::string& address, |
| 64 const SuccessCallback& callback) = 0; |
| 65 |
| 66 // Creates the instance. |
| 67 static BluetoothOutOfBandClient* Create( |
| 68 DBusClientImplementationType type, |
| 69 dbus::Bus* bus); |
| 70 |
| 71 protected: |
| 72 BluetoothOutOfBandClient(); |
| 73 |
| 74 private: |
| 75 DISALLOW_COPY_AND_ASSIGN(BluetoothOutOfBandClient); |
| 76 }; |
| 77 |
| 78 } // namespace chromeos |
| 79 |
| 80 #endif // CHROMEOS_DBUS_BLUETOOTH_OUT_OF_BAND_CLIENT_H_ |
OLD | NEW |