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

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

Issue 9838085: Move files inside chrome/browser/chromeos/dbus to chromeos/dbus (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase Created 8 years, 8 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
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 CHROME_BROWSER_CHROMEOS_DBUS_BLUETOOTH_ADAPTER_CLIENT_H_
6 #define CHROME_BROWSER_CHROMEOS_DBUS_BLUETOOTH_ADAPTER_CLIENT_H_
7 #pragma once
8
9 #include <string>
10 #include <vector>
11
12 #include "base/callback.h"
13 #include "base/observer_list.h"
14 #include "base/values.h"
15 #include "chrome/browser/chromeos/dbus/bluetooth_device_client.h"
16 #include "chrome/browser/chromeos/dbus/bluetooth_property.h"
17 #include "chrome/browser/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 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 BluetoothProperty<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 BluetoothProperty<std::string> name;
41
42 // The Bluetooth class of the adapter device. Read-only.
43 BluetoothProperty<uint32> bluetooth_class;
44
45 // Whether the adapter radio is powered.
46 BluetoothProperty<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 BluetoothProperty<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 BluetoothProperty<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 BluetoothProperty<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 BluetoothProperty<uint32> discoverable_timeout;
67
68 // Indicates that the adapter is discovering other Bluetooth Devices.
69 // Read-only. Use StartDiscovery() to begin discovery.
70 BluetoothProperty<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 BluetoothProperty<std::vector<dbus::ObjectPath> > devices;
76
77 // List of 128-bit UUIDs that represent the available local services.
78 // Read-only.
79 BluetoothProperty<std::vector<std::string> > uuids;
80
81 Properties(dbus::ObjectProxy* object_proxy,
82 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 // Creates a new dbus object from the adapter with object path |object_path|
174 // to the remote device with address |address|, connecting to it and
175 // retrieving all SDP records. After a successful call, the device is known
176 // and appear's in the adapter's |devices| interface. This is a low-security
177 // connection which may not be accepted by the device.
178 virtual void CreateDevice(const dbus::ObjectPath& object_path,
179 const std::string& address,
180 const DeviceCallback& callback) = 0;
181
182 // Creates a new dbus object from the adapter with object path |object_path|
183 // to the remote device with address |address|, connecting to it, retrieving
184 // all SDP records and then initiating a pairing. If CreateDevice() has been
185 // previously called for this device, this only initiates the pairing.
186 //
187 // The dbus object path |agent_path| of an agent within the local process
188 // must be specified to negotiate the pairing, |capability| specifies the
189 // input and display capabilities of that agent and should be one of the
190 // constants declared in the bluetooth_agent:: namespace.
191 virtual void CreatePairedDevice(const dbus::ObjectPath& object_path,
192 const std::string& address,
193 const dbus::ObjectPath& agent_path,
194 const std::string& capability,
195 const DeviceCallback& callback) = 0;
196
197 // Cancels the currently in progress call to CreateDevice() or
198 // CreatePairedDevice() on the adapter with object path |object_path|
199 // for the remote device with address |address|.
200 virtual void CancelDeviceCreation(const dbus::ObjectPath& object_path,
201 const std::string& address,
202 const AdapterCallback& callback) = 0;
203
204 // Removes from the adapter with object path |object_path| the remote
205 // device with object path |object_path| from the list of known devices
206 // and discards any pairing information.
207 virtual void RemoveDevice(const dbus::ObjectPath& object_path,
208 const dbus::ObjectPath& device_path,
209 const AdapterCallback& callback) = 0;
210
211 // Registers an adapter-wide agent for the adapter with object path
212 // |object_path|. This agent is used for incoming pairing connections
213 // and confirmation of adapter mode changes. The dbus object path
214 // |agent_path| of an agent within the local process must be specified,
215 // |capability| specifies the input and display capabilities of that
216 // agent and should be one of the constants declared in the
217 // bluetooth_agent:: namespace.
218 virtual void RegisterAgent(const dbus::ObjectPath& object_path,
219 const dbus::ObjectPath& agent_path,
220 const std::string& capability,
221 const AdapterCallback& callback) = 0;
222
223 // Unregisters an adapter-wide agent with object path |agent_path| from
224 // the adapter with object path |object_path|.
225 virtual void UnregisterAgent(const dbus::ObjectPath& object_path,
226 const dbus::ObjectPath& agent_path,
227 const AdapterCallback& callback) = 0;
228
229 // Creates the instance.
230 static BluetoothAdapterClient* Create(DBusClientImplementationType type,
231 dbus::Bus* bus,
232 BluetoothManagerClient* manager_client);
233
234 protected:
235 BluetoothAdapterClient();
236
237 private:
238 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterClient);
239 };
240
241 } // namespace chromeos
242
243 #endif // CHROME_BROWSER_CHROMEOS_DBUS_BLUETOOTH_ADAPTER_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698