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

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

Issue 12605008: D-Bus Clients for BlueZ 5 API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add service providers 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_ADAPTER_CLIENT_H_
6 #define CHROMEOS_DBUS_EXPERIMENTAL_BLUETOOTH_ADAPTER_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 // ExperimentalBluetoothAdapterClient is used to communicate with Bluetooth
26 // Adapter objects.
27 class CHROMEOS_EXPORT ExperimentalBluetoothAdapterClient {
satorux1 2013/03/22 02:00:12 "Experimental" is a bit vague. Maybe: BluetoothAd
keybuk 2013/03/22 16:48:15 "experimental" matched the flag we picked, and sav
28 public:
29 // Structure of properties associated with bluetooth adapters.
30 struct Properties : public dbus::PropertySet {
31 // The Bluetooth device address of the adapter. Read-only.
32 dbus::Property<std::string> address;
33
34 // The Bluetooth system name, generally derived from the hostname.
35 dbus::Property<std::string> name;
36
37 // The Bluetooth friendly name of the adapter, unlike remote devices,
38 // this property can be changed to change the presentation for when
39 // the adapter is discoverable.
40 dbus::Property<std::string> alias;
41
42 // The Bluetooth class of the adapter device. Read-only.
43 dbus::Property<uint32> bluetooth_class;
44
45 // Whether the adapter radio is powered.
46 dbus::Property<bool> powered;
47
48 // Whether the adapter is discoverable by other Bluetooth devices.
49 // |discovering_timeout| is used to automatically disable after a time
50 // period.
51 dbus::Property<bool> discoverable;
52
53 // Whether the adapter accepts incoming pairing requests from other
54 // Bluetooth devices. |pairable_timeout| is used to automatically disable
55 // after a time period.
56 dbus::Property<bool> pairable;
57
58 // The timeout in seconds to cease accepting incoming pairing requests
59 // after |pairable| is set to true. Zero means adapter remains pairable
60 // forever.
61 dbus::Property<uint32> pairable_timeout;
satorux1 2013/03/22 02:00:12 pairable_timeout_in_secs? It's often helpful to ha
keybuk 2013/03/22 16:48:15 By convention we've been matching the names of the
62
63 // The timeout in seconds to cease the adapter being discoverable by
64 // other Bluetooth devices after |discoverable| is set to true. Zero
65 // means adapter remains discoverable forever.
66 dbus::Property<uint32> discoverable_timeout;
satorux1 2013/03/22 02:00:12 ditto
67
68 // Indicates that the adapter is discovering other Bluetooth Devices.
69 // Read-only. Use StartDiscovery() to begin discovery.
70 dbus::Property<bool> discovering;
71
72 // List of 128-bit UUIDs that represent the available local services.
73 // Read-only.
74 dbus::Property<std::vector<std::string> > uuids;
satorux1 2013/03/22 02:00:12 Is this binary data or hexadecimal strings? would
75
76 // Local Device ID information in Linux kernel modalias format. Read-only.
77 dbus::Property<std::string> modalias;
78
79 Properties(dbus::ObjectProxy* object_proxy,
80 const std::string& interface_name,
81 const 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| is added to the
91 // system.
92 virtual void AdapterAdded(const dbus::ObjectPath& object_path) {}
93
94 // Called when the adapter with object path |object_path| is removed from
95 // the system.
96 virtual void AdapterRemoved(const dbus::ObjectPath& object_path) {}
97
98 // Called when the adapter with object path |object_path| has a
99 // change in value of the property named |property_name|.
100 virtual void AdapterPropertyChanged(const dbus::ObjectPath& object_path,
101 const std::string& property_name) {}
102 };
103
104 virtual ~ExperimentalBluetoothAdapterClient();
105
106 // Adds and removes observers for events on all local bluetooth
107 // adapters. Check the |object_path| parameter of observer methods to
108 // determine which adapter is issuing the event.
109 virtual void AddObserver(Observer* observer) = 0;
110 virtual void RemoveObserver(Observer* observer) = 0;
111
112 // Returns the list of adapter object paths known to the system.
113 virtual std::vector<dbus::ObjectPath> GetAdapters() = 0;
114
115 // Obtain the properties for the adapter with object path |object_path|,
116 // any values should be copied if needed.
117 virtual Properties* GetProperties(const dbus::ObjectPath& object_path) = 0;
118
119 // The ErrorCallback is used by adapter methods to indicate failure.
120 // It receives two arguments: the name of the error in |error_name| and
121 // an optional message in |error_message|.
122 typedef base::Callback<void(const std::string& error_name,
123 const std::string& error_message)> ErrorCallback;
124
125 // Starts a device discovery on the adapter with object path |object_path|.
126 virtual void StartDiscovery(const dbus::ObjectPath& object_path,
127 const base::Closure& callback,
128 const ErrorCallback& error_callback) = 0;
129
130 // Cancels any previous device discovery on the adapter with object path
131 // |object_path|.
132 virtual void StopDiscovery(const dbus::ObjectPath& object_path,
133 const base::Closure& callback,
134 const ErrorCallback& error_callback) = 0;
135
136 // Removes from the adapter with object path |object_path| the remote
137 // device with object path |object_path| from the list of known devices
138 // and discards any pairing information.
139 virtual void RemoveDevice(const dbus::ObjectPath& object_path,
140 const dbus::ObjectPath& device_path,
141 const base::Closure& callback,
142 const ErrorCallback& error_callback) = 0;
143
144 // Creates the instance.
145 static ExperimentalBluetoothAdapterClient* Create(
146 DBusClientImplementationType type,
147 dbus::Bus* bus);
148
149 // Constants used to indicate exceptional error conditions.
150 static const char kNoResponseError[];
151 static const char kUnknownAdapterError[];
152
153 protected:
154 ExperimentalBluetoothAdapterClient();
155
156 private:
157 DISALLOW_COPY_AND_ASSIGN(ExperimentalBluetoothAdapterClient);
158 };
159
160 } // namespace chromeos
161
162 #endif // CHROMEOS_DBUS_EXPERIMENTAL_BLUETOOTH_ADAPTER_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698