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

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

Powered by Google App Engine
This is Rietveld 408576698