Only fsync leveldb's directory when the manifest is being updated.
[chromium-blink-merge.git] / chromeos / dbus / experimental_bluetooth_adapter_client.h
blob19c1382e274f35542de2d7229ab2f742118d6217
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.
5 #ifndef CHROMEOS_DBUS_EXPERIMENTAL_BLUETOOTH_ADAPTER_CLIENT_H_
6 #define CHROMEOS_DBUS_EXPERIMENTAL_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_implementation_type.h"
16 #include "dbus/object_path.h"
17 #include "dbus/property.h"
19 namespace dbus {
20 class Bus;
21 } // namespace dbus
23 namespace chromeos {
25 // ExperimentalBluetoothAdapterClient is used to communicate with Bluetooth
26 // Adapter objects.
27 class CHROMEOS_EXPORT ExperimentalBluetoothAdapterClient {
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;
34 // The Bluetooth system name, generally derived from the hostname.
35 dbus::Property<std::string> name;
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;
42 // The Bluetooth class of the adapter device. Read-only.
43 dbus::Property<uint32> bluetooth_class;
45 // Whether the adapter radio is powered.
46 dbus::Property<bool> powered;
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;
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;
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;
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;
68 // Indicates that the adapter is discovering other Bluetooth Devices.
69 // Read-only. Use StartDiscovery() to begin discovery.
70 dbus::Property<bool> discovering;
72 // List of 128-bit UUIDs that represent the available local services.
73 // Read-only.
74 dbus::Property<std::vector<std::string> > uuids;
76 // Local Device ID information in Linux kernel modalias format. Read-only.
77 dbus::Property<std::string> modalias;
79 Properties(dbus::ObjectProxy* object_proxy,
80 const std::string& interface_name,
81 const PropertyChangedCallback& callback);
82 virtual ~Properties();
85 // Interface for observing changes from a local bluetooth adapter.
86 class Observer {
87 public:
88 virtual ~Observer() {}
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) {}
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) {}
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) {}
104 virtual ~ExperimentalBluetoothAdapterClient();
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;
112 // Returns the list of adapter object paths known to the system.
113 virtual std::vector<dbus::ObjectPath> GetAdapters() = 0;
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;
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;
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;
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;
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;
144 // Creates the instance.
145 static ExperimentalBluetoothAdapterClient* Create(
146 DBusClientImplementationType type,
147 dbus::Bus* bus);
149 // Constants used to indicate exceptional error conditions.
150 static const char kNoResponseError[];
151 static const char kUnknownAdapterError[];
153 protected:
154 ExperimentalBluetoothAdapterClient();
156 private:
157 DISALLOW_COPY_AND_ASSIGN(ExperimentalBluetoothAdapterClient);
160 } // namespace chromeos
162 #endif // CHROMEOS_DBUS_EXPERIMENTAL_BLUETOOTH_ADAPTER_CLIENT_H_