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

Side by Side Diff: chrome/browser/chromeos/dbus/bluetooth_device_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_DEVICE_CLIENT_H_
6 #define CHROME_BROWSER_CHROMEOS_DBUS_BLUETOOTH_DEVICE_CLIENT_H_
7 #pragma once
8
9 #include <map>
10 #include <string>
11 #include <vector>
12
13 #include "base/callback.h"
14 #include "base/observer_list.h"
15 #include "base/values.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 BluetoothAdapterClient;
26
27 // BluetoothDeviceClient is used to communicate with a bluetooth Device
28 // interface.
29 class BluetoothDeviceClient {
30 public:
31 // Structure of properties associated with bluetooth devices.
32 struct Properties : public BluetoothPropertySet {
33 // The Bluetooth device address of the device. Read-only.
34 BluetoothProperty<std::string> address;
35
36 // The Bluetooth friendly name of the device. Read-only, to give a
37 // different local name, use the |alias| property.
38 BluetoothProperty<std::string> name;
39
40 // Unique numeric identifier for the vendor of the device. Read-only.
41 BluetoothProperty<uint16> vendor;
42
43 // Unique vendor-assigned product identifier for the product of the
44 // device. Read-only.
45 BluetoothProperty<uint16> product;
46
47 // Unique vendor-assigned version identifier for the device. Read-only.
48 BluetoothProperty<uint16> version;
49
50 // Proposed icon name for the device according to the freedesktop.org
51 // icon naming specification. Read-only.
52 BluetoothProperty<std::string> icon;
53
54 // The Bluetooth class of the device. Read-only.
55 BluetoothProperty<uint32> bluetooth_class;
56
57 // List of 128-bit UUIDs that represent the available remote services.
58 // Raed-only.
59 BluetoothProperty<std::vector<std::string> > uuids;
60
61 // List of characteristics-based available remote services. Read-only.
62 BluetoothProperty<std::vector<dbus::ObjectPath> > services;
63
64 // Indicates that the device is currently paired. Read-only.
65 BluetoothProperty<bool> paired;
66
67 // Indicates that the device is currently connected. Read-only.
68 BluetoothProperty<bool> connected;
69
70 // Whether the device is trusted, and connections should be always
71 // accepted and attempted when the device is visible.
72 BluetoothProperty<bool> trusted;
73
74 // Whether the device is blocked, connections will be always rejected
75 // and the device will not be visible.
76 BluetoothProperty<bool> blocked;
77
78 // Local alias for the device, if not set, is equal to |name|.
79 BluetoothProperty<std::string> alias;
80
81 // List of object paths of nodes the device provides. Read-only.
82 BluetoothProperty<std::vector<dbus::ObjectPath> > nodes;
83
84 // Object path of the adapter the device belongs to. Read-only.
85 BluetoothProperty<dbus::ObjectPath> adapter;
86
87 // Indicates whether the device is likely to only support pre-2.1
88 // PIN Code pairing rather than 2.1 Secure Simple Pairing, this can
89 // give false positives. Read-only.
90 BluetoothProperty<bool> legacy_pairing;
91
92 Properties(dbus::ObjectProxy* object_proxy,
93 PropertyChangedCallback callback);
94 virtual ~Properties();
95 };
96
97 // Interface for observing changes from a remote bluetooth device.
98 class Observer {
99 public:
100 virtual ~Observer() {}
101
102 // Called when the device with object path |object_path| has a
103 // change in value of the property named |property_name|.
104 virtual void DevicePropertyChanged(const dbus::ObjectPath& object_path,
105 const std::string& property_name) {}
106
107 // Called when the device with object path |object_path| is about
108 // to be disconnected, giving a chance for application layers to
109 // shut down cleanly.
110 virtual void DisconnectRequested(const dbus::ObjectPath& object_path) {}
111
112 // Called when the device with object path |object_path| has a new
113 // persistent device node with object path |node_path|.
114 virtual void NodeCreated(const dbus::ObjectPath& object_path,
115 const dbus::ObjectPath& node_path) {}
116
117 // Called when the device with object path |object_path| removes
118 // the persistent device node with object path |node_path|.
119 virtual void NodeRemoved(const dbus::ObjectPath& object_path,
120 const dbus::ObjectPath& node_path) {}
121 };
122
123 virtual ~BluetoothDeviceClient();
124
125 // Adds and removes observers for events on all remote bluetooth
126 // devices. Check the |object_path| parameter of observer methods to
127 // determine which device 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 device 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 Services map is used to convey the set of services discovered
136 // on a device. The keys are unique record handles and the values are
137 // XML-formatted service records. Both can be generated using the
138 // spdtool(1) binary distributed with bluetoothd.
139 typedef std::map<const uint32, std::string> ServiceMap;
140
141 // The ServicesCallback is used for the DiscoverServices() method. It
142 // receives three arguments, the |object_path| of the device, the
143 // dictionary of the |services| discovered where the keys are unique
144 // record handles and the values are XML formatted service records,
145 // and |success| which indicates whether or not the request succeded.
146 typedef base::Callback<void(const dbus::ObjectPath&, const ServiceMap&,
147 bool)> ServicesCallback;
148
149 // Starts the service discovery process for the device with object path
150 // |object_path|, the |pattern| paramter can be used to specify specific
151 // UUIDs while an empty string will look for the public browse group.
152 virtual void DiscoverServices(const dbus::ObjectPath& object_path,
153 const std::string& pattern,
154 const ServicesCallback& callback) = 0;
155
156 // The DeviceCallback is used for device methods that only return to
157 // indicate success. It receives two arguments, the |object_path| of the
158 // device the call was made on and |success| which indicates whether or
159 // not the request succeeded.
160 typedef base::Callback<void(const dbus::ObjectPath&, bool)> DeviceCallback;
161
162 // Cancels any previous service discovery processes for the device with
163 // object path |object_path|.
164 virtual void CancelDiscovery(const dbus::ObjectPath& object_path,
165 const DeviceCallback& callback) = 0;
166
167 // Disconnects the device with object path |object_path|, terminating
168 // the low-level ACL connection and any application connections using it.
169 // Actual disconnection takes place after two seconds during which a
170 // DisconnectRequested signal is emitted by the device to allow those
171 // applications to terminate gracefully.
172 virtual void Disconnect(const dbus::ObjectPath& object_path,
173 const DeviceCallback& callback) = 0;
174
175 // The NodeCallback is used for device methods that return a dbus
176 // object path for a persistent device node binding, as well as success.
177 // It receives two arguments, the |object_path| of the persistent device
178 // node binding object returned by the method and |success} which indicates
179 // whether or not the request succeeded.
180 typedef base::Callback<void(const dbus::ObjectPath&, bool)> NodeCallback;
181
182 // Creates a persistent device node binding with the device with object path
183 // |object_path| using the specified service |uuid|. The actual support
184 // depends on the device driver, at the moment only RFCOMM TTY nodes are
185 // supported.
186 virtual void CreateNode(const dbus::ObjectPath& object_path,
187 const std::string& uuid,
188 const NodeCallback& callback) = 0;
189
190 // Removes the persistent device node binding with the dbus object path
191 // |node_path| from the device with object path |object_path|.
192 virtual void RemoveNode(const dbus::ObjectPath& object_path,
193 const dbus::ObjectPath& node_path,
194 const DeviceCallback& callback) = 0;
195
196 // Creates the instance.
197 static BluetoothDeviceClient* Create(dbus::Bus* bus,
198 BluetoothAdapterClient* adapter_client);
199
200 protected:
201 BluetoothDeviceClient();
202
203 private:
204 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceClient);
205 };
206
207 } // namespace chromeos
208
209 #endif // CHROME_BROWSER_CHROMEOS_DBUS_BLUETOOTH_DEVICE_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698