Use PlaybackToMemory for BitmapRasterWorkerPool playback
[chromium-blink-merge.git] / chromeos / dbus / bluetooth_adapter_client.h
blob298c4af8a15be8f64336c4e9dbd7b5710cce743d
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_ADAPTER_CLIENT_H_
6 #define CHROMEOS_DBUS_BLUETOOTH_ADAPTER_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 // BluetoothAdapterClient is used to communicate with objects representing
22 // local Bluetooth Adapters.
23 class CHROMEOS_EXPORT BluetoothAdapterClient : public DBusClient {
24 public:
25 // Structure of properties associated with bluetooth adapters.
26 struct Properties : public dbus::PropertySet {
27 // The Bluetooth device address of the adapter. Read-only.
28 dbus::Property<std::string> address;
30 // The Bluetooth system name, generally derived from the hostname.
31 dbus::Property<std::string> name;
33 // The Bluetooth friendly name of the adapter, unlike remote devices,
34 // this property can be changed to change the presentation for when
35 // the adapter is discoverable.
36 dbus::Property<std::string> alias;
38 // The Bluetooth class of the adapter device. Read-only.
39 dbus::Property<uint32> bluetooth_class;
41 // Whether the adapter radio is powered.
42 dbus::Property<bool> powered;
44 // Whether the adapter is discoverable by other Bluetooth devices.
45 // |discovering_timeout| is used to automatically disable after a time
46 // period.
47 dbus::Property<bool> discoverable;
49 // Whether the adapter accepts incoming pairing requests from other
50 // Bluetooth devices. |pairable_timeout| is used to automatically disable
51 // after a time period.
52 dbus::Property<bool> pairable;
54 // The timeout in seconds to cease accepting incoming pairing requests
55 // after |pairable| is set to true. Zero means adapter remains pairable
56 // forever.
57 dbus::Property<uint32> pairable_timeout;
59 // The timeout in seconds to cease the adapter being discoverable by
60 // other Bluetooth devices after |discoverable| is set to true. Zero
61 // means adapter remains discoverable forever.
62 dbus::Property<uint32> discoverable_timeout;
64 // Indicates that the adapter is discovering other Bluetooth Devices.
65 // Read-only. Use StartDiscovery() to begin discovery.
66 dbus::Property<bool> discovering;
68 // List of 128-bit UUIDs that represent the available local services.
69 // Read-only.
70 dbus::Property<std::vector<std::string> > uuids;
72 // Local Device ID information in Linux kernel modalias format. Read-only.
73 dbus::Property<std::string> modalias;
75 Properties(dbus::ObjectProxy* object_proxy,
76 const std::string& interface_name,
77 const PropertyChangedCallback& callback);
78 virtual ~Properties();
81 // Interface for observing changes from a local bluetooth adapter.
82 class Observer {
83 public:
84 virtual ~Observer() {}
86 // Called when the adapter with object path |object_path| is added to the
87 // system.
88 virtual void AdapterAdded(const dbus::ObjectPath& object_path) {}
90 // Called when the adapter with object path |object_path| is removed from
91 // the system.
92 virtual void AdapterRemoved(const dbus::ObjectPath& object_path) {}
94 // Called when the adapter with object path |object_path| has a
95 // change in value of the property named |property_name|.
96 virtual void AdapterPropertyChanged(const dbus::ObjectPath& object_path,
97 const std::string& property_name) {}
100 virtual ~BluetoothAdapterClient();
102 // Adds and removes observers for events on all local bluetooth
103 // adapters. Check the |object_path| parameter of observer methods to
104 // determine which adapter is issuing the event.
105 virtual void AddObserver(Observer* observer) = 0;
106 virtual void RemoveObserver(Observer* observer) = 0;
108 // Returns the list of adapter object paths known to the system.
109 virtual std::vector<dbus::ObjectPath> GetAdapters() = 0;
111 // Obtain the properties for the adapter with object path |object_path|,
112 // any values should be copied if needed.
113 virtual Properties* GetProperties(const dbus::ObjectPath& object_path) = 0;
115 // The ErrorCallback is used by adapter methods to indicate failure.
116 // It receives two arguments: the name of the error in |error_name| and
117 // an optional message in |error_message|.
118 typedef base::Callback<void(const std::string& error_name,
119 const std::string& error_message)> ErrorCallback;
121 // Starts a device discovery on the adapter with object path |object_path|.
122 virtual void StartDiscovery(const dbus::ObjectPath& object_path,
123 const base::Closure& callback,
124 const ErrorCallback& error_callback) = 0;
126 // Cancels any previous device discovery on the adapter with object path
127 // |object_path|.
128 virtual void StopDiscovery(const dbus::ObjectPath& object_path,
129 const base::Closure& callback,
130 const ErrorCallback& error_callback) = 0;
132 // Removes from the adapter with object path |object_path| the remote
133 // device with object path |object_path| from the list of known devices
134 // and discards any pairing information.
135 virtual void RemoveDevice(const dbus::ObjectPath& object_path,
136 const dbus::ObjectPath& device_path,
137 const base::Closure& callback,
138 const ErrorCallback& error_callback) = 0;
140 // Creates the instance.
141 static BluetoothAdapterClient* Create();
143 // Constants used to indicate exceptional error conditions.
144 static const char kNoResponseError[];
145 static const char kUnknownAdapterError[];
147 protected:
148 BluetoothAdapterClient();
150 private:
151 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterClient);
154 } // namespace chromeos
156 #endif // CHROMEOS_DBUS_BLUETOOTH_ADAPTER_CLIENT_H_