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 CHROME_BROWSER_CHROMEOS_DBUS_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_DBUS_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_ | |
7 #pragma once | |
8 | |
9 #include <string> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "base/callback.h" | |
13 #include "dbus/bus.h" | |
14 #include "dbus/object_path.h" | |
15 | |
16 namespace chromeos { | |
17 | |
18 class BluetoothAgentServiceProvider { | |
satorux1
2012/03/12 16:57:27
class comment is missing. what this class is for?
keybuk
2012/03/12 17:30:03
Done.
| |
19 public: | |
20 // Interface for reacting to agent requests. | |
21 class Delegate { | |
22 public: | |
23 virtual ~Delegate() {} | |
24 | |
25 // Possible status values that may be returned to callbacks. Success | |
26 // indicates that a pincode or passkey has been obtained, or permission | |
27 // granted; rejected indicates the user rejected the request or denied | |
28 // permission; cancelled indicates the user cancelled the request | |
29 // without confirming either way. | |
30 enum Status { | |
31 SUCCESS, | |
32 REJECTED, | |
33 CANCELLED | |
34 }; | |
35 | |
36 // Possible values for the |mode| parameter of the ConfirmModeChange() | |
37 // method. Off indicates that the adapter is to be turned off, connectable | |
38 // indicates that the adapter is to be turned on and accept incoming | |
39 // connections, and discoverable indicates the adapter is to be turned | |
40 // on and discoverable by remote devices. | |
41 enum Mode { | |
42 OFF, | |
43 CONNECTABLE, | |
44 DISCOVERABLE | |
45 }; | |
46 | |
47 // The PinCodeCallback is used for the RequestPinCode() method, it should | |
48 // be called with two arguments, the |status| of the request (success, | |
49 // rejected or cancelled) and the |pincode| requested. | |
50 typedef base::Callback<void(Status, const std::string&)> PinCodeCallback; | |
satorux1
2012/03/12 16:57:27
nit: please add parameter names.
base::Callback<v
keybuk
2012/03/12 17:30:03
Chrome style seems to be to NOT use these, there a
satorux1
2012/03/12 17:55:30
Our style guide doesn't say anything about it. My
| |
51 | |
52 // The PasskeyCallback is used for the RequestPasskey() method, it should | |
53 // be called with two arguments, the |status| of the request (success, | |
54 // rejected or cancelled) and the |passkey| requested, a numeric in the | |
55 // range 0-999999, | |
56 typedef base::Callback<void(Status, uint32)> PasskeyCallback; | |
satorux1
2012/03/12 16:57:27
ditto
keybuk
2012/03/12 17:30:03
as above, seems contrary to Chrome style
| |
57 | |
58 // The ConfirmationCallback is used for methods which request confirmation | |
59 // or authorization, it should be called with one argument, the |status| | |
60 // of the request (success, rejected or cancelled). | |
61 typedef base::Callback<void(Status)> ConfirmationCallback; | |
62 | |
63 // This method will be called when the agent is unregistered from the | |
64 // Bluetooth daemon, generally at the end of a pairing request. It may be | |
65 // used to perform cleanup tasks. | |
66 virtual void Release() = 0; | |
67 | |
68 // This method will be called when the Bluetooth daemon requires a | |
69 // PIN Code for authentication of the device with object path |device_path|, | |
70 // the agent should obtain the code from the user and call |callback| | |
71 // to provide it, or indicate rejection or cancellation of the request. | |
72 // | |
73 // PIN Codes are generally required for Bluetooth 2.0 and earlier devices | |
74 // for which there is no automatic pairing or special handling. | |
75 virtual void RequestPinCode(const dbus::ObjectPath& device_path, | |
76 const PinCodeCallback& callback) = 0; | |
77 | |
78 // This method will be called when the Bluetooth daemon requires a | |
79 // Passkey for authentication of the device with object path |device_path|, | |
80 // the agent should obtain the passkey from the user (a numeric in the | |
81 // range 0-999999) and call |callback| to provide it, or indicate | |
82 // rejection or cancellation of the request. | |
83 // | |
84 // Passkeys are generally required for Bluetooth 2.1 and later devices | |
85 // which cannot provide input or display on their own, and don't accept | |
86 // passkey-less pairing. | |
87 virtual void RequestPasskey(const dbus::ObjectPath& device_path, | |
88 const PasskeyCallback& callback) = 0; | |
89 | |
90 // This method will be called when the Bluetooth daemon requires that the | |
91 // user enter the PIN code |pincode| into the device with object path | |
92 // |device_path| so that it may be authenticated. The Cancel() method | |
93 // will be called to dismiss the display once pairing is complete or | |
94 // cancelled. | |
95 // | |
96 // This is used for Bluetooth 2.0 and earlier keyboard devices, the | |
97 // |pincode| will always be a six-digit numeric in the range 000000-999999 | |
98 // for compatibilty with later specifications. | |
99 virtual void DisplayPinCode(const dbus::ObjectPath& device_path, | |
100 const std::string& pincode) = 0; | |
101 | |
102 // This method will be called when the Bluetooth daemon requires that the | |
103 // user enter the Passkey |passkey| into the device with object path | |
104 // |device_path| so that it may be authenticated. The Cancel() method | |
105 // will be called to dismiss the display once pairing is complete or | |
106 // cancelled. | |
107 // | |
108 // This is used for Bluetooth 2.1 and later devices that support input | |
109 // but not display, such as keyboards. The Passkey is a numeric in the | |
110 // range 0-999999 and should be always presented zero-padded to six | |
111 // digits. | |
112 virtual void DisplayPasskey(const dbus::ObjectPath& device_path, | |
113 uint32 passkey) = 0; | |
114 | |
115 // This method will be called when the Bluetooth daemon requires that the | |
116 // user confirm that the Passkey |passkey| is displayed on the screen | |
117 // of the device with object path |object_path| so that it may be | |
118 // authentication. The agent should display to the user and ask for | |
119 // confirmation, then call |callback| to provide their response (success, | |
120 // rejected or cancelled). | |
121 // | |
122 // This is used for Bluetooth 2.1 and later devices that support display, | |
123 // such as other computers or phones. The Passkey is a numeric in the | |
124 // range 0-999999 and should be always present zero-padded to six | |
125 // digits. | |
126 virtual void RequestConfirmation(const dbus::ObjectPath& device_path, | |
127 uint32 passkey, | |
128 const ConfirmationCallback& callback) = 0; | |
129 | |
130 // This method will be called when the Bluetooth daemon requires that the | |
131 // user confirm that the device with object path |object_path| is | |
132 // authorized to connect to the service with UUID |uuid|. The agent should | |
133 // confirm with the user and call |callback| to provide their response | |
134 // (success, rejected or cancelled). | |
135 virtual void Authorize(const dbus::ObjectPath& device_path, | |
136 const std::string& uuid, | |
137 const ConfirmationCallback& callback) = 0; | |
138 | |
139 // This method will be called when the Bluetooth daemon requires that the | |
140 // user confirm that the device adapter may switch to mode |mode|. The | |
141 // agent should confirm with the user and call |callback| to provide | |
142 // their response (success, rejected or cancelled). | |
143 virtual void ConfirmModeChange(Mode mode, | |
144 const ConfirmationCallback& callback) = 0; | |
145 | |
146 // This method will be called by the Bluetooth daemon to indicate that | |
147 // the request failed before a reply was returned from the device. | |
148 virtual void Cancel() = 0; | |
149 }; | |
150 | |
151 virtual ~BluetoothAgentServiceProvider(); | |
152 | |
153 // Creates the instance. | |
154 // TODO(keybuk): docs. | |
satorux1
2012/03/12 16:57:27
fix the todo now?
keybuk
2012/03/12 17:30:03
Done.
| |
155 static BluetoothAgentServiceProvider* Create( | |
156 dbus::Bus* dbus, const dbus::ObjectPath& object_path, Delegate* delegate); | |
157 | |
158 protected: | |
159 BluetoothAgentServiceProvider(); | |
160 | |
161 private: | |
162 DISALLOW_COPY_AND_ASSIGN(BluetoothAgentServiceProvider); | |
163 }; | |
164 | |
165 } // namespace chromeos | |
166 | |
167 #endif // CHROME_BROWSER_CHROMEOS_DBUS_BLUETOOTH_AGENT_SERVICE_PROVIDER_H_ | |
OLD | NEW |