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

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

Issue 12605008: D-Bus Clients for BlueZ 5 API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mock dbus thread manager without gmock? I didn't even know that was a thing! Created 7 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 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_EXPERIMENTAL_BLUETOOTH_DEVICE_CLIENT_H_
6 #define CHROMEOS_DBUS_EXPERIMENTAL_BLUETOOTH_DEVICE_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/dbus_client_implementation_type.h"
16 #include "dbus/object_path.h"
17 #include "dbus/property.h"
18
19 namespace dbus {
20 class Bus;
21 } // namespace dbus
22
23 namespace chromeos {
24
25 // ExperimentalBluetoothDeviceClient is used to communicate with Bluetooth
26 // Device objects.
27 class CHROMEOS_EXPORT ExperimentalBluetoothDeviceClient {
28 public:
29 // Structure of properties associated with bluetooth devices.
30 struct Properties : public dbus::PropertySet {
31 // The Bluetooth device address of the device. Read-only.
32 dbus::Property<std::string> address;
33
34 // The Bluetooth friendly name of the device. Read-only, to give a
35 // different local name, use the |alias| property.
36 dbus::Property<std::string> name;
37
38 // Proposed icon name for the device according to the freedesktop.org
39 // icon naming specification. Read-only.
40 dbus::Property<std::string> icon;
41
42 // The Bluetooth class of the device. Read-only.
43 dbus::Property<uint32> bluetooth_class;
44
45 // The GAP external appearance of the device. Read-only.
46 dbus::Property<uint16> appearance;
47
48 // Unique numeric identifier for the vendor of the device. Read-only.
49 dbus::Property<uint16> vendor;
50
51 // List of 128-bit UUIDs that represent the available remote services.
52 // Read-only.
53 dbus::Property<std::vector<std::string> > uuids;
54
55 // Indicates that the device is currently paired. Read-only.
56 dbus::Property<bool> paired;
57
58 // Indicates that the device is currently connected. Read-only.
59 dbus::Property<bool> connected;
60
61 // Whether the device is trusted, and connections should be always
62 // accepted and attempted when the device is visible.
63 dbus::Property<bool> trusted;
64
65 // Whether the device is blocked, connections will be always rejected
66 // and the device will not be visible.
67 dbus::Property<bool> blocked;
68
69 // Local alias for the device, if not set, is equal to |name|.
70 dbus::Property<std::string> alias;
71
72 // Object path of the adapter the device belongs to. Read-only.
73 dbus::Property<dbus::ObjectPath> adapter;
74
75 // Indicates whether the device is likely to only support pre-2.1
76 // PIN Code pairing rather than 2.1 Secure Simple Pairing, this can
77 // give false positives. Read-only.
78 dbus::Property<bool> legacy_pairing;
79
80 // Remote Device ID information in Linux kernel modalias format. Read-only.
81 dbus::Property<std::string> modalias;
82
83 // Received signal strength indicator. Read-only.
84 dbus::Property<int16> rssi;
85
86 Properties(dbus::ObjectProxy* object_proxy,
87 const std::string& interface_name,
88 const PropertyChangedCallback& callback);
89 virtual ~Properties();
90 };
91
92 // Interface for observing changes from a remote bluetooth device.
93 class Observer {
94 public:
95 virtual ~Observer() {}
96
97 // Called when the remote device with object path |object_path| is added
98 // to the set of known devices.
99 virtual void DeviceAdded(const dbus::ObjectPath& object_path) {}
100
101 // Called when the remote device with object path |object_path| is removed
102 // from the set of known devices.
103 virtual void DeviceRemoved(const dbus::ObjectPath& object_path) {}
104
105 // Called when the device with object path |object_path| has a
106 // change in value of the property named |property_name|.
107 virtual void DevicePropertyChanged(const dbus::ObjectPath& object_path,
108 const std::string& property_name) {}
109 };
110
111 virtual ~ExperimentalBluetoothDeviceClient();
112
113 // Adds and removes observers for events on all remote bluetooth
114 // devices. Check the |object_path| parameter of observer methods to
115 // determine which device is issuing the event.
116 virtual void AddObserver(Observer* observer) = 0;
117 virtual void RemoveObserver(Observer* observer) = 0;
118
119 // Returns the list of device object paths associated with the given adapter
120 // identified by the D-Bus object path |adapter_path|.
121 virtual std::vector<dbus::ObjectPath> GetDevicesForAdapter(
122 const dbus::ObjectPath& adapter_path) = 0;
123
124 // Obtain the properties for the device with object path |object_path|,
125 // any values should be copied if needed.
126 virtual Properties* GetProperties(const dbus::ObjectPath& object_path) = 0;
127
128 // The ErrorCallback is used by device methods to indicate failure.
129 // It receives two arguments: the name of the error in |error_name| and
130 // an optional message in |error_message|.
131 typedef base::Callback<void(const std::string& error_name,
132 const std::string& error_message)> ErrorCallback;
133
134 // Connects to the device with object path |object_path|, connecting any
135 // profiles that can be connected to and have been flagged as auto-connected;
136 // may be used to connect additional profiles for an already connected device,
137 // and succeeds if at least one profile is connected.
138 virtual void Connect(const dbus::ObjectPath& object_path,
139 const base::Closure& callback,
140 const ErrorCallback& error_callback) = 0;
141
142 // Disconnects the device with object path |object_path|, terminating
143 // the low-level ACL connection and any profiles using it.
144 virtual void Disconnect(const dbus::ObjectPath& object_path,
145 const base::Closure& callback,
146 const ErrorCallback& error_callback) = 0;
147
148 // Connects to the profile |uuid| on the device with object path
149 // |object_path|, provided that the profile has been registered with a
150 // handler on the local device.
151 virtual void ConnectProfile(const dbus::ObjectPath& object_path,
152 const std::string& uuid,
153 const base::Closure& callback,
154 const ErrorCallback& error_callback) = 0;
155
156 // Disconnects from the profile |uuid| on the device with object path
157 // |object_path|.
158 virtual void DisconnectProfile(const dbus::ObjectPath& object_path,
159 const std::string& uuid,
160 const base::Closure& callback,
161 const ErrorCallback& error_callback) = 0;
162
163 // Initiates pairing with the device with object path |object_path| and
164 // retrieves all SDP records or GATT primary services. An agent must be
165 // registered to handle the pairing request.
166 virtual void Pair(const dbus::ObjectPath& object_path,
167 const base::Closure& callback,
168 const ErrorCallback& error_callback) = 0;
169
170 // Cancels an in-progress pairing with the device with object path
171 // |object_path| initiated by Pair().
172 virtual void CancelPairing(const dbus::ObjectPath& object_path,
173 const base::Closure& callback,
174 const ErrorCallback& error_callback) = 0;
175
176 // Creates the instance.
177 static ExperimentalBluetoothDeviceClient* Create(
178 DBusClientImplementationType type,
179 dbus::Bus* bus);
180
181 // Constants used to indicate exceptional error conditions.
182 static const char kNoResponseError[];
183 static const char kUnknownDeviceError[];
184
185 protected:
186 ExperimentalBluetoothDeviceClient();
187
188 private:
189 DISALLOW_COPY_AND_ASSIGN(ExperimentalBluetoothDeviceClient);
190 };
191
192 } // namespace chromeos
193
194 #endif // CHROMEOS_DBUS_EXPERIMENTAL_BLUETOOTH_DEVICE_CLIENT_H_
OLDNEW
« no previous file with comments | « chromeos/dbus/experimental_bluetooth_agent_service_provider.cc ('k') | chromeos/dbus/experimental_bluetooth_device_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698