Update V8 to version 4.7.3.
[chromium-blink-merge.git] / chromeos / dbus / ap_manager_client.h
blobf160b037dc2dbb988f2f059abc4d3aa9af548e56
1 // Copyright 2015 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 #ifndef CHROMEOS_DBUS_AP_MANAGER_CLIENT_H_
5 #define CHROMEOS_DBUS_AP_MANAGER_CLIENT_H_
7 #include <map>
8 #include <string>
9 #include <vector>
11 #include "base/callback.h"
12 #include "base/macros.h"
13 #include "base/values.h"
14 #include "chromeos/chromeos_export.h"
15 #include "chromeos/dbus/dbus_client.h"
16 #include "chromeos/dbus/dbus_method_call_status.h"
17 #include "dbus/object_path.h"
18 #include "dbus/property.h"
20 namespace chromeos {
22 // ApManagerClient is used to communicate with the
23 // WiFi AP Manager service. All methods should be called from
24 // the origin thread which initializes the DBusThreadManager instance.
25 class CHROMEOS_EXPORT ApManagerClient : public DBusClient {
26 public:
27 // Structure of properties associated with a WiFi service AP configuration.
28 // These properties must be set before Start is called.
29 class ConfigProperties : public dbus::PropertySet {
30 public:
31 ConfigProperties(dbus::ObjectProxy* object_proxy,
32 const std::string& interface_name,
33 const PropertyChangedCallback& callback);
34 ~ConfigProperties() override;
36 // Name of network [required].
37 const std::string& ssid() const { return ssid_.value(); }
38 void set_ssid(const std::string& ssid, SetCallback callback) {
39 ssid_.Set(ssid, callback);
42 // Interface name [optional].
43 const std::string& interface_name() const {
44 return interface_name_.value();
46 void set_interface_name(const std::string& name, SetCallback callback) {
47 interface_name_.Set(name, callback);
50 // Security Mode; "RSN", "None" [optional].
51 const std::string& security_mode() const { return security_mode_.value(); }
52 void set_security_mode(const std::string& mode, SetCallback callback) {
53 security_mode_.Set(mode, callback);
56 // Passphrase; [required] when security is not "None".
57 const std::string& passphrase() const { return passphrase_.value(); }
58 void set_passphrase(const std::string& passphrase, SetCallback callback) {
59 passphrase_.Set(passphrase, callback);
62 // HwMode, "802.11a", "802.11b". Default: "802.11g" [optional].
63 const std::string& hw_mode() const { return hw_mode_.value(); }
64 void set_hw_mode(const std::string& mode, SetCallback callback) {
65 hw_mode_.Set(mode, callback);
68 // Operation mode, "Bridge" or "Server". Default "Server". [optional].
69 const std::string& operation_mode() const {
70 return operation_mode_.value();
72 void set_operation_mode(const std::string& mode, SetCallback callback) {
73 operation_mode_.Set(mode, callback);
76 // Operating channel. Default '6' [optional].
77 uint16_t channel() const { return channel_.value(); }
78 void set_channel(uint16_t channel, SetCallback callback) {
79 channel_.Set(channel, callback);
82 // Hidden network. Default "false". [optional].
83 bool hidden_network() const { return hidden_network_.value(); }
84 void set_hidden_network(bool hidden, SetCallback callback) {
85 hidden_network_.Set(hidden, callback);
88 // Bridge interface. [required] if Bridge operation mode set.
89 const std::string& bridge_interface() const {
90 return bridge_interface_.value();
92 void set_bridge_interface(const std::string& interface,
93 SetCallback callback) {
94 bridge_interface_.Set(interface, callback);
97 // The value of x in the following equation; "192.168.x.254".
98 // This will be the server's IP address. [required] only if
99 // operation mode set to "Server".
100 uint16_t server_address_index() const {
101 return server_address_index_.value();
103 void set_server_address_index(uint16_t index, SetCallback callback) {
104 server_address_index_.Set(index, callback);
107 private:
108 dbus::Property<std::string> ssid_;
109 dbus::Property<std::string> interface_name_;
110 dbus::Property<std::string> security_mode_;
111 dbus::Property<std::string> passphrase_;
112 dbus::Property<std::string> hw_mode_;
113 dbus::Property<std::string> operation_mode_;
114 dbus::Property<uint16_t> channel_;
115 dbus::Property<bool> hidden_network_;
116 dbus::Property<std::string> bridge_interface_;
117 dbus::Property<uint16_t> server_address_index_;
119 DISALLOW_COPY_AND_ASSIGN(ConfigProperties);
122 // Structure of properties associated with a WiFi service AP device.
123 class DeviceProperties : public dbus::PropertySet {
124 public:
125 DeviceProperties(dbus::ObjectProxy* object_proxy,
126 const std::string& interface_name,
127 const PropertyChangedCallback& callback);
128 ~DeviceProperties() override;
130 // Name of the WiFi device.
131 const std::string& device_name() const { return device_name_.value(); }
133 // Flag indicating if this device is currently in-use by apmanager.
134 bool in_use() const { return in_used_.value(); }
136 // Name of the WiFi interface on the device that’s preferred for starting an
137 // AP serivce.
138 const std::string& preferred_ap_interface() const {
139 return preferred_ap_interface_.value();
142 private:
143 dbus::Property<std::string> device_name_;
144 dbus::Property<bool> in_used_;
145 dbus::Property<std::string> preferred_ap_interface_;
147 DISALLOW_COPY_AND_ASSIGN(DeviceProperties);
150 // Structure of properties associated with a WiFi service AP service.
151 class ServiceProperties : public dbus::PropertySet {
152 public:
153 ServiceProperties(dbus::ObjectProxy* object_proxy,
154 const std::string& interface_name,
155 const PropertyChangedCallback& callback);
156 ~ServiceProperties() override;
158 // DBus path of the config for this service.
159 const dbus::ObjectPath& config_path() const { return config_.value(); }
161 // Current state of service. ["Idle", "Starting", "Started", "Failed"].
162 const std::string& state() const { return state_.value(); }
164 private:
165 dbus::Property<dbus::ObjectPath> config_;
166 dbus::Property<std::string> state_;
168 DISALLOW_COPY_AND_ASSIGN(ServiceProperties);
171 // Interface for observing changes from a apmanager daemon.
172 class Observer {
173 public:
174 virtual ~Observer();
176 // Called when the manager has been added.
177 virtual void ManagerAdded();
179 // Called when the manager has been removed.
180 virtual void ManagerRemoved();
182 // Called when the config with object path |object_path| is added to the
183 // system.
184 virtual void ConfigAdded(const dbus::ObjectPath& object_path);
186 // Called when the config with object path |object_path| is removed from
187 // the system.
188 virtual void ConfigRemoved(const dbus::ObjectPath& object_path);
190 // Called when the device with object path |object_path| is added to the
191 // system.
192 virtual void DeviceAdded(const dbus::ObjectPath& object_path);
194 // Called when the device with object path |object_path| is removed from
195 // the system.
196 virtual void DeviceRemoved(const dbus::ObjectPath& object_path);
198 // Called when the device with object path |object_path| is added to the
199 // system.
200 virtual void ServiceAdded(const dbus::ObjectPath& object_path);
202 // Called when the device with object path |object_path| is removed from
203 // the system.
204 virtual void ServiceRemoved(const dbus::ObjectPath& object_path);
206 // Called when the adapter with object path |object_path| has a
207 // change in value of the property named |property_name|.
208 virtual void ConfigPropertyChanged(const dbus::ObjectPath& object_path,
209 const std::string& property_name);
211 // Called when the adapter with object path |object_path| has a
212 // change in value of the property named |property_name|.
213 virtual void DevicePropertyChanged(const dbus::ObjectPath& object_path,
214 const std::string& property_name);
216 // Called when the adapter with object path |object_path| has a
217 // change in value of the property named |property_name|.
218 virtual void ServicePropertyChanged(const dbus::ObjectPath& object_path,
219 const std::string& property_name);
222 ~ApManagerClient() override;
224 // Factory function, creates a new instance which is owned by the caller.
225 // For normal usage, access the singleton via DBusThreadManager::Get().
226 static ApManagerClient* Create();
228 // Adds and removes observers for events on all apmanager
229 // events. Check the |object_path| parameter of observer methods to
230 // determine which group is issuing the event.
231 virtual void AddObserver(Observer* observer) = 0;
232 virtual void RemoveObserver(Observer* observer) = 0;
234 // Calls CreateService method.
235 // |callback| is called with its |call_status| argument set to
236 // DBUS_METHOD_CALL_SUCCESS if the method call succeeds. Otherwise,
237 // |callback| is called with |call_status| set to DBUS_METHOD_CALL_FAILURE.
238 virtual void CreateService(const ObjectPathDBusMethodCallback& callback) = 0;
240 // Calls RemoveService method.
241 // |callback| is called with its |call_status| argument set to
242 // DBUS_METHOD_CALL_SUCCESS if the method call succeeds. Otherwise,
243 // |callback| is called with |call_status| set to DBUS_METHOD_CALL_FAILURE.
244 virtual void RemoveService(const dbus::ObjectPath& object_path,
245 const VoidDBusMethodCallback& callback) = 0;
247 // Calls Service::Start method.
248 // |callback| is called with its |call_status| argument set to
249 // DBUS_METHOD_CALL_SUCCESS if the method call succeeds. Otherwise,
250 // |callback| is called with |call_status| set to DBUS_METHOD_CALL_FAILURE.
251 virtual void StartService(const dbus::ObjectPath& object_path,
252 const VoidDBusMethodCallback& callback) = 0;
254 // Calls Service::Stop method.
255 // |callback| is called with its |call_status| argument set to
256 // DBUS_METHOD_CALL_SUCCESS if the method call succeeds. Otherwise,
257 // |callback| is called with |call_status| set to DBUS_METHOD_CALL_FAILURE.
258 virtual void StopService(const dbus::ObjectPath& object_path,
259 const VoidDBusMethodCallback& callback) = 0;
261 // Obtains the properties for the config with object path |object_path|,
262 // any values should be copied if needed.
263 virtual ConfigProperties* GetConfigProperties(
264 const dbus::ObjectPath& object_path) = 0;
266 // Obtains the properties for the device with object path |object_path|,
267 // any values should be copied if needed.
268 virtual const DeviceProperties* GetDeviceProperties(
269 const dbus::ObjectPath& object_path) = 0;
271 // Obtains the properties for the device with object path |object_path|,
272 // any values should be copied if needed.
273 virtual const ServiceProperties* GetServiceProperties(
274 const dbus::ObjectPath& object_path) = 0;
276 protected:
277 // Create() should be used instead.
278 ApManagerClient();
280 private:
281 DISALLOW_COPY_AND_ASSIGN(ApManagerClient);
284 } // namespace chromeos
286 #endif // CHROMEOS_DBUS_AP_MANAGER_CLIENT_H_