Remove old about scheme URL constants.
[chromium-blink-merge.git] / chromeos / dbus / bluetooth_device_client.h
blob11f5a1cb772db7d88f3971a417f4ade59405c27a
1 // Copyright 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.
5 #ifndef CHROMEOS_DBUS_BLUETOOTH_DEVICE_CLIENT_H_
6 #define CHROMEOS_DBUS_BLUETOOTH_DEVICE_CLIENT_H_
8 #include <string>
9 #include <vector>
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.h"
16 #include "dbus/object_path.h"
17 #include "dbus/property.h"
19 namespace chromeos {
21 // BluetoothDeviceClient is used to communicate with objects representing
22 // remote Bluetooth Devices.
23 class CHROMEOS_EXPORT BluetoothDeviceClient : public DBusClient {
24 public:
25 // Structure of properties associated with bluetooth devices.
26 struct Properties : public dbus::PropertySet {
27 // The Bluetooth device address of the device. Read-only.
28 dbus::Property<std::string> address;
30 // The Bluetooth friendly name of the device. Read-only, to give a
31 // different local name, use the |alias| property.
32 dbus::Property<std::string> name;
34 // Proposed icon name for the device according to the freedesktop.org
35 // icon naming specification. Read-only.
36 dbus::Property<std::string> icon;
38 // The Bluetooth class of the device. Read-only.
39 dbus::Property<uint32> bluetooth_class;
41 // The GAP external appearance of the device. Read-only.
42 dbus::Property<uint16> appearance;
44 // Unique numeric identifier for the vendor of the device. Read-only.
45 dbus::Property<uint16> vendor;
47 // List of 128-bit UUIDs that represent the available remote services.
48 // Read-only.
49 dbus::Property<std::vector<std::string> > uuids;
51 // Indicates that the device is currently paired. Read-only.
52 dbus::Property<bool> paired;
54 // Indicates that the device is currently connected. Read-only.
55 dbus::Property<bool> connected;
57 // Whether the device is trusted, and connections should be always
58 // accepted and attempted when the device is visible.
59 dbus::Property<bool> trusted;
61 // Whether the device is blocked, connections will be always rejected
62 // and the device will not be visible.
63 dbus::Property<bool> blocked;
65 // Local alias for the device, if not set, is equal to |name|.
66 dbus::Property<std::string> alias;
68 // Object path of the adapter the device belongs to. Read-only.
69 dbus::Property<dbus::ObjectPath> adapter;
71 // Indicates whether the device is likely to only support pre-2.1
72 // PIN Code pairing rather than 2.1 Secure Simple Pairing, this can
73 // give false positives. Read-only.
74 dbus::Property<bool> legacy_pairing;
76 // Remote Device ID information in Linux kernel modalias format. Read-only.
77 dbus::Property<std::string> modalias;
79 // Received signal strength indicator. Read-only.
80 dbus::Property<int16> rssi;
82 Properties(dbus::ObjectProxy* object_proxy,
83 const std::string& interface_name,
84 const PropertyChangedCallback& callback);
85 virtual ~Properties();
88 // Interface for observing changes from a remote bluetooth device.
89 class Observer {
90 public:
91 virtual ~Observer() {}
93 // Called when the remote device with object path |object_path| is added
94 // to the set of known devices.
95 virtual void DeviceAdded(const dbus::ObjectPath& object_path) {}
97 // Called when the remote device with object path |object_path| is removed
98 // from the set of known devices.
99 virtual void DeviceRemoved(const dbus::ObjectPath& object_path) {}
101 // Called when the device with object path |object_path| has a
102 // change in value of the property named |property_name|.
103 virtual void DevicePropertyChanged(const dbus::ObjectPath& object_path,
104 const std::string& property_name) {}
107 virtual ~BluetoothDeviceClient();
109 // Adds and removes observers for events on all remote bluetooth
110 // devices. Check the |object_path| parameter of observer methods to
111 // determine which device is issuing the event.
112 virtual void AddObserver(Observer* observer) = 0;
113 virtual void RemoveObserver(Observer* observer) = 0;
115 // Returns the list of device object paths associated with the given adapter
116 // identified by the D-Bus object path |adapter_path|.
117 virtual std::vector<dbus::ObjectPath> GetDevicesForAdapter(
118 const dbus::ObjectPath& adapter_path) = 0;
120 // Obtain the properties for the device with object path |object_path|,
121 // any values should be copied if needed.
122 virtual Properties* GetProperties(const dbus::ObjectPath& object_path) = 0;
124 // The ErrorCallback is used by device methods to indicate failure.
125 // It receives two arguments: the name of the error in |error_name| and
126 // an optional message in |error_message|.
127 typedef base::Callback<void(const std::string& error_name,
128 const std::string& error_message)> ErrorCallback;
130 // Connects to the device with object path |object_path|, connecting any
131 // profiles that can be connected to and have been flagged as auto-connected;
132 // may be used to connect additional profiles for an already connected device,
133 // and succeeds if at least one profile is connected.
134 virtual void Connect(const dbus::ObjectPath& object_path,
135 const base::Closure& callback,
136 const ErrorCallback& error_callback) = 0;
138 // Disconnects the device with object path |object_path|, terminating
139 // the low-level ACL connection and any profiles using it.
140 virtual void Disconnect(const dbus::ObjectPath& object_path,
141 const base::Closure& callback,
142 const ErrorCallback& error_callback) = 0;
144 // Connects to the profile |uuid| on the device with object path
145 // |object_path|, provided that the profile has been registered with a
146 // handler on the local device.
147 virtual void ConnectProfile(const dbus::ObjectPath& object_path,
148 const std::string& uuid,
149 const base::Closure& callback,
150 const ErrorCallback& error_callback) = 0;
152 // Disconnects from the profile |uuid| on the device with object path
153 // |object_path|.
154 virtual void DisconnectProfile(const dbus::ObjectPath& object_path,
155 const std::string& uuid,
156 const base::Closure& callback,
157 const ErrorCallback& error_callback) = 0;
159 // Initiates pairing with the device with object path |object_path| and
160 // retrieves all SDP records or GATT primary services. An agent must be
161 // registered to handle the pairing request.
162 virtual void Pair(const dbus::ObjectPath& object_path,
163 const base::Closure& callback,
164 const ErrorCallback& error_callback) = 0;
166 // Cancels an in-progress pairing with the device with object path
167 // |object_path| initiated by Pair().
168 virtual void CancelPairing(const dbus::ObjectPath& object_path,
169 const base::Closure& callback,
170 const ErrorCallback& error_callback) = 0;
172 // Creates the instance.
173 static BluetoothDeviceClient* Create();
175 // Constants used to indicate exceptional error conditions.
176 static const char kNoResponseError[];
177 static const char kUnknownDeviceError[];
179 protected:
180 BluetoothDeviceClient();
182 private:
183 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceClient);
186 } // namespace chromeos
188 #endif // CHROMEOS_DBUS_BLUETOOTH_DEVICE_CLIENT_H_