Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(656)

Side by Side Diff: chromeos/dbus/bluetooth_adapter_client.h

Issue 15020009: Bluetooth: remove legacy backend (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chromeos/dbus/DEPS ('k') | chromeos/dbus/bluetooth_adapter_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_ADAPTER_CLIENT_H_
6 #define CHROMEOS_DBUS_BLUETOOTH_ADAPTER_CLIENT_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/callback.h"
12 #include "base/observer_list.h"
13 #include "base/values.h"
14 #include "chromeos/chromeos_export.h"
15 #include "chromeos/dbus/bluetooth_device_client.h"
16 #include "chromeos/dbus/bluetooth_property.h"
17 #include "chromeos/dbus/dbus_client_implementation_type.h"
18 #include "dbus/object_path.h"
19
20 namespace dbus {
21 class Bus;
22 } // namespace dbus
23
24 namespace chromeos {
25
26 class BluetoothManagerClient;
27
28 // BluetoothAdapterClient is used to communicate with a bluetooth Adapter
29 // interface.
30 class CHROMEOS_EXPORT BluetoothAdapterClient {
31 public:
32 // Structure of properties associated with bluetooth adapters.
33 struct Properties : public BluetoothPropertySet {
34 // The Bluetooth device address of the adapter. Read-only.
35 dbus::Property<std::string> address;
36
37 // The Bluetooth friendly name of the adapter, unlike remote devices,
38 // this property can be changed to change the presentation for when
39 // the adapter is discoverable.
40 dbus::Property<std::string> name;
41
42 // The Bluetooth class of the adapter device. Read-only.
43 dbus::Property<uint32> bluetooth_class;
44
45 // Whether the adapter radio is powered.
46 dbus::Property<bool> powered;
47
48 // Whether the adapter is discoverable by other Bluetooth devices.
49 // |discovering_timeout| is used to automatically disable after a time
50 // period.
51 dbus::Property<bool> discoverable;
52
53 // Whether the adapter accepts incoming pairing requests from other
54 // Bluetooth devices. |pairable_timeout| is used to automatically disable
55 // after a time period.
56 dbus::Property<bool> pairable;
57
58 // The timeout in seconds to cease accepting incoming pairing requests
59 // after |pairable| is set to true. Zero means adapter remains pairable
60 // forever.
61 dbus::Property<uint32> pairable_timeout;
62
63 // The timeout in seconds to cease the adapter being discoverable by
64 // other Bluetooth devices after |discoverable| is set to true. Zero
65 // means adapter remains discoverable forever.
66 dbus::Property<uint32> discoverable_timeout;
67
68 // Indicates that the adapter is discovering other Bluetooth Devices.
69 // Read-only. Use StartDiscovery() to begin discovery.
70 dbus::Property<bool> discovering;
71
72 // List of object paths of known Bluetooth devices, known devices are
73 // those that have previously been connected or paired or are currently
74 // connected or paired. Read-only.
75 dbus::Property<std::vector<dbus::ObjectPath> > devices;
76
77 // List of 128-bit UUIDs that represent the available local services.
78 // Read-only.
79 dbus::Property<std::vector<std::string> > uuids;
80
81 Properties(dbus::ObjectProxy* object_proxy,
82 const PropertyChangedCallback& callback);
83 virtual ~Properties();
84 };
85
86 // Interface for observing changes from a local bluetooth adapter.
87 class Observer {
88 public:
89 virtual ~Observer() {}
90
91 // Called when the adapter with object path |object_path| has a
92 // change in value of the property named |property_name|.
93 virtual void AdapterPropertyChanged(const dbus::ObjectPath& object_path,
94 const std::string& property_name) {}
95
96 // Called when the adapter with object path |object_path| has a
97 // new known device with object path |object_path|.
98 virtual void DeviceCreated(const dbus::ObjectPath& object_path,
99 const dbus::ObjectPath& device_path) {}
100
101 // Called when the adapter with object path |object_path| removes
102 // the known device with object path |object_path|.
103 virtual void DeviceRemoved(const dbus::ObjectPath& object_path,
104 const dbus::ObjectPath& device_path) {}
105
106 // Called when the adapter with object path |object_path| discovers
107 // a new remote device with address |address| and properties
108 // |properties|, there is no device object path until connected.
109 //
110 // |properties| supports only value() calls, not Get() or Set(), and
111 // should be copied if needed.
112 virtual void DeviceFound(
113 const dbus::ObjectPath& object_path, const std::string& address,
114 const BluetoothDeviceClient::Properties& properties) {}
115
116 // Called when the adapter with object path |object_path| can no
117 // longer communicate with the discovered removed device with
118 // address |address|.
119 virtual void DeviceDisappeared(const dbus::ObjectPath& object_path,
120 const std::string& address) {}
121 };
122
123 virtual ~BluetoothAdapterClient();
124
125 // Adds and removes observers for events on all local bluetooth
126 // adapters. Check the |object_path| parameter of observer methods to
127 // determine which adapter is issuing the event.
128 virtual void AddObserver(Observer* observer) = 0;
129 virtual void RemoveObserver(Observer* observer) = 0;
130
131 // Obtain the properties for the adapter with object path |object_path|,
132 // any values should be copied if needed.
133 virtual Properties* GetProperties(const dbus::ObjectPath& object_path) = 0;
134
135 // The AdapterCallback is used for adapter methods that only return to
136 // indicate success. It receives two arguments, the |object_path| of the
137 // adapter the call was made on and |success| which indicates whether
138 // or not the request succeeded.
139 typedef base::Callback<void(const dbus::ObjectPath&, bool)> AdapterCallback;
140
141 // Request a client session for the adapter with object path |object_path|,
142 // possible mode changes must be confirmed by the user via a registered
143 // agent.
144 virtual void RequestSession(const dbus::ObjectPath& object_path,
145 const AdapterCallback& callback) = 0;
146
147 // Release a previously requested session, restoring the adapter mode to
148 // that prior to the original request.
149 virtual void ReleaseSession(const dbus::ObjectPath& object_path,
150 const AdapterCallback& callback) = 0;
151
152 // Starts a device discovery on the adapter with object path |object_path|.
153 virtual void StartDiscovery(const dbus::ObjectPath& object_path,
154 const AdapterCallback& callback) = 0;
155
156 // Cancels any previous device discovery on the adapter with object path
157 // |object_path|.
158 virtual void StopDiscovery(const dbus::ObjectPath& object_path,
159 const AdapterCallback& callback) = 0;
160
161 // The DeviceCallback is used for adapter methods that return a dbus
162 // object path for a remote device, as well as success. It receives two
163 // arguments, the |object_path| of the device returned by the method and
164 // |success| which indicates whether or not the request succeeded.
165 typedef base::Callback<void(const dbus::ObjectPath&, bool)> DeviceCallback;
166
167 // Retrieves the dbus object path from the adapter with object path
168 // |object_path| for the known device with the address |address|.
169 virtual void FindDevice(const dbus::ObjectPath& object_path,
170 const std::string& address,
171 const DeviceCallback& callback) = 0;
172
173 // The CreateDeviceCallback is used for the CreateDevice and
174 // CreatePairedDevice adapter methods that return a dbus object path for
175 // a remote device on success. It receives a single argument, the
176 // |object_path| of the device returned by the method.
177 typedef base::Callback<void(const dbus::ObjectPath&)> CreateDeviceCallback;
178
179 // The CreateDeviceErrorCallback is used for the CreateDevice and
180 // CreatePairedDevices adapter methods to indicate failure. It receives
181 // two arguments, the name of the error in |error_name| and an optional
182 // message in |error_message|.
183 typedef base::Callback<void(const std::string& error_name,
184 const std::string& error_message)>
185 CreateDeviceErrorCallback;
186
187 // Creates a new dbus object from the adapter with object path |object_path|
188 // to the remote device with address |address|, connecting to it and
189 // retrieving all SDP records. After a successful call, the device is known
190 // and appear's in the adapter's |devices| interface. This is a low-security
191 // connection which may not be accepted by the device.
192 virtual void CreateDevice(
193 const dbus::ObjectPath& object_path,
194 const std::string& address,
195 const CreateDeviceCallback& callback,
196 const CreateDeviceErrorCallback& error_callback) = 0;
197
198 // Creates a new dbus object from the adapter with object path |object_path|
199 // to the remote device with address |address|, connecting to it, retrieving
200 // all SDP records and then initiating a pairing. If CreateDevice() has been
201 // previously called for this device, this only initiates the pairing.
202 //
203 // The dbus object path |agent_path| of an agent within the local process
204 // must be specified to negotiate the pairing, |capability| specifies the
205 // input and display capabilities of that agent and should be one of the
206 // constants declared in the bluetooth_agent:: namespace.
207 virtual void CreatePairedDevice(
208 const dbus::ObjectPath& object_path,
209 const std::string& address,
210 const dbus::ObjectPath& agent_path,
211 const std::string& capability,
212 const CreateDeviceCallback& callback,
213 const CreateDeviceErrorCallback& error_callback) = 0;
214
215 // Cancels the currently in progress call to CreateDevice() or
216 // CreatePairedDevice() on the adapter with object path |object_path|
217 // for the remote device with address |address|.
218 virtual void CancelDeviceCreation(const dbus::ObjectPath& object_path,
219 const std::string& address,
220 const AdapterCallback& callback) = 0;
221
222 // Removes from the adapter with object path |object_path| the remote
223 // device with object path |object_path| from the list of known devices
224 // and discards any pairing information.
225 virtual void RemoveDevice(const dbus::ObjectPath& object_path,
226 const dbus::ObjectPath& device_path,
227 const AdapterCallback& callback) = 0;
228
229 // Registers an adapter-wide agent for the adapter with object path
230 // |object_path|. This agent is used for incoming pairing connections
231 // and confirmation of adapter mode changes. The dbus object path
232 // |agent_path| of an agent within the local process must be specified,
233 // |capability| specifies the input and display capabilities of that
234 // agent and should be one of the constants declared in the
235 // bluetooth_agent:: namespace.
236 virtual void RegisterAgent(const dbus::ObjectPath& object_path,
237 const dbus::ObjectPath& agent_path,
238 const std::string& capability,
239 const AdapterCallback& callback) = 0;
240
241 // Unregisters an adapter-wide agent with object path |agent_path| from
242 // the adapter with object path |object_path|.
243 virtual void UnregisterAgent(const dbus::ObjectPath& object_path,
244 const dbus::ObjectPath& agent_path,
245 const AdapterCallback& callback) = 0;
246
247 // Creates the instance.
248 static BluetoothAdapterClient* Create(DBusClientImplementationType type,
249 dbus::Bus* bus,
250 BluetoothManagerClient* manager_client);
251
252 // Constants used to indicate exceptional error conditions.
253 static const char kNoResponseError[];
254 static const char kBadResponseError[];
255
256 protected:
257 BluetoothAdapterClient();
258
259 private:
260 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterClient);
261 };
262
263 } // namespace chromeos
264
265 #endif // CHROMEOS_DBUS_BLUETOOTH_ADAPTER_CLIENT_H_
OLDNEW
« no previous file with comments | « chromeos/dbus/DEPS ('k') | chromeos/dbus/bluetooth_adapter_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698