OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROMEOS_DBUS_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_ | 5 #ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_ |
6 #define CHROMEOS_DBUS_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_ | 6 #define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "chromeos/chromeos_export.h" | |
13 #include "dbus/bus.h" | 12 #include "dbus/bus.h" |
14 #include "dbus/object_path.h" | 13 #include "dbus/object_path.h" |
| 14 #include "device/bluetooth/bluetooth_export.h" |
15 | 15 |
16 namespace chromeos { | 16 namespace bluez { |
17 | 17 |
18 // BluetoothAgentServiceProvider is used to provide a D-Bus object that | 18 // BluetoothAgentServiceProvider is used to provide a D-Bus object that |
19 // the bluetooth daemon can communicate with during a remote device pairing | 19 // the bluetooth daemon can communicate with during a remote device pairing |
20 // request. | 20 // request. |
21 // | 21 // |
22 // Instantiate with a chosen D-Bus object path and delegate object, and pass | 22 // Instantiate with a chosen D-Bus object path and delegate object, and pass |
23 // the D-Bus object path as the |agent_path| argument to the | 23 // the D-Bus object path as the |agent_path| argument to the |
24 // chromeos::BluetoothAgentManagerClient::RegisterAgent() method. | 24 // chromeos::BluetoothAgentManagerClient::RegisterAgent() method. |
25 // | 25 // |
26 // After initiating the pairing process with a device, using the | 26 // After initiating the pairing process with a device, using the |
27 // chromeos::BluetoothDeviceClient::Pair() method, the Bluetooth daemon will | 27 // chromeos::BluetoothDeviceClient::Pair() method, the Bluetooth daemon will |
28 // make calls to this agent object and they will be passed on to your Delegate | 28 // make calls to this agent object and they will be passed on to your Delegate |
29 // object for handling. Responses should be returned using the callbacks | 29 // object for handling. Responses should be returned using the callbacks |
30 // supplied to those methods. | 30 // supplied to those methods. |
31 class CHROMEOS_EXPORT BluetoothAgentServiceProvider { | 31 class DEVICE_BLUETOOTH_EXPORT BluetoothAgentServiceProvider { |
32 public: | 32 public: |
33 // Interface for reacting to agent requests. | 33 // Interface for reacting to agent requests. |
34 class Delegate { | 34 class Delegate { |
35 public: | 35 public: |
36 virtual ~Delegate() {} | 36 virtual ~Delegate() {} |
37 | 37 |
38 // Possible status values that may be returned to callbacks. Success | 38 // Possible status values that may be returned to callbacks. Success |
39 // indicates that a pincode or passkey has been obtained, or permission | 39 // indicates that a pincode or passkey has been obtained, or permission |
40 // granted; rejected indicates the user rejected the request or denied | 40 // granted; rejected indicates the user rejected the request or denied |
41 // permission; cancelled indicates the user cancelled the request | 41 // permission; cancelled indicates the user cancelled the request |
42 // without confirming either way. | 42 // without confirming either way. |
43 enum Status { | 43 enum Status { SUCCESS, REJECTED, CANCELLED }; |
44 SUCCESS, | |
45 REJECTED, | |
46 CANCELLED | |
47 }; | |
48 | 44 |
49 // The PinCodeCallback is used for the RequestPinCode() method, it should | 45 // The PinCodeCallback is used for the RequestPinCode() method, it should |
50 // be called with two arguments, the |status| of the request (success, | 46 // be called with two arguments, the |status| of the request (success, |
51 // rejected or cancelled) and the |pincode| requested. | 47 // rejected or cancelled) and the |pincode| requested. |
52 typedef base::Callback<void(Status, const std::string&)> PinCodeCallback; | 48 typedef base::Callback<void(Status, const std::string&)> PinCodeCallback; |
53 | 49 |
54 // The PasskeyCallback is used for the RequestPasskey() method, it should | 50 // The PasskeyCallback is used for the RequestPasskey() method, it should |
55 // be called with two arguments, the |status| of the request (success, | 51 // be called with two arguments, the |status| of the request (success, |
56 // rejected or cancelled) and the |passkey| requested, a numeric in the | 52 // rejected or cancelled) and the |passkey| requested, a numeric in the |
57 // range 0-999999, | 53 // range 0-999999, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // cancelled. | 106 // cancelled. |
111 // | 107 // |
112 // This is used for Bluetooth 2.1 and later devices that support input | 108 // This is used for Bluetooth 2.1 and later devices that support input |
113 // but not display, such as keyboards. The Passkey is a numeric in the | 109 // but not display, such as keyboards. The Passkey is a numeric in the |
114 // range 0-999999 and should be always presented zero-padded to six | 110 // range 0-999999 and should be always presented zero-padded to six |
115 // digits. | 111 // digits. |
116 // | 112 // |
117 // As the user enters the passkey onto the device, |entered| will be | 113 // As the user enters the passkey onto the device, |entered| will be |
118 // updated to reflect the number of digits entered so far. | 114 // updated to reflect the number of digits entered so far. |
119 virtual void DisplayPasskey(const dbus::ObjectPath& device_path, | 115 virtual void DisplayPasskey(const dbus::ObjectPath& device_path, |
120 uint32 passkey, uint16 entered) = 0; | 116 uint32 passkey, |
| 117 uint16 entered) = 0; |
121 | 118 |
122 // This method will be called when the Bluetooth daemon requires that the | 119 // This method will be called when the Bluetooth daemon requires that the |
123 // user confirm that the Passkey |passkey| is displayed on the screen | 120 // user confirm that the Passkey |passkey| is displayed on the screen |
124 // of the device with object path |object_path| so that it may be | 121 // of the device with object path |object_path| so that it may be |
125 // authenticated. The agent should display to the user and ask for | 122 // authenticated. The agent should display to the user and ask for |
126 // confirmation, then call |callback| to provide their response (success, | 123 // confirmation, then call |callback| to provide their response (success, |
127 // rejected or cancelled). | 124 // rejected or cancelled). |
128 // | 125 // |
129 // This is used for Bluetooth 2.1 and later devices that support display, | 126 // This is used for Bluetooth 2.1 and later devices that support display, |
130 // such as other computers or phones. The Passkey is a numeric in the | 127 // such as other computers or phones. The Passkey is a numeric in the |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 const dbus::ObjectPath& object_path, | 166 const dbus::ObjectPath& object_path, |
170 Delegate* delegate); | 167 Delegate* delegate); |
171 | 168 |
172 protected: | 169 protected: |
173 BluetoothAgentServiceProvider(); | 170 BluetoothAgentServiceProvider(); |
174 | 171 |
175 private: | 172 private: |
176 DISALLOW_COPY_AND_ASSIGN(BluetoothAgentServiceProvider); | 173 DISALLOW_COPY_AND_ASSIGN(BluetoothAgentServiceProvider); |
177 }; | 174 }; |
178 | 175 |
179 } // namespace chromeos | 176 } // namespace bluez |
180 | 177 |
181 #endif // CHROMEOS_DBUS_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_ | 178 #endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_ |
OLD | NEW |