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

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

Powered by Google App Engine
This is Rietveld 408576698