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

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

Issue 980973003: apmanager: Add dbus implementation to chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change struct into class Created 5 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
« no previous file with comments | « chromeos/chromeos.gyp ('k') | chromeos/dbus/ap_manager_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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_
6
7 #include <map>
8 #include <string>
9 #include <vector>
10
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"
19
20 namespace chromeos {
21
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;
35
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);
40 }
41
42 // Interface name [optional].
43 const std::string& interface_name() const {
44 return interface_name_.value();
45 }
46 void set_interface_name(const std::string& name, SetCallback callback) {
47 interface_name_.Set(name, callback);
48 }
49
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);
54 }
55
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);
60 }
61
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);
66 }
67
68 // Operation mode, "Bridge" or "Server". Default "Server". [optional].
69 const std::string& operation_mode() const {
70 return operation_mode_.value();
71 }
72 void set_operation_mode(const std::string& mode, SetCallback callback) {
73 operation_mode_.Set(mode, callback);
74 }
75
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);
80 }
81
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);
86 }
87
88 // Bridge interface. [required] if Bridge operation mode set.
89 const std::string& bridge_interface() const {
90 return bridge_interface_.value();
91 }
92 void set_bridge_interface(const std::string& interface,
93 SetCallback callback) {
94 bridge_interface_.Set(interface, callback);
95 }
96
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();
102 }
103 void set_server_address_index(uint16_t index, SetCallback callback) {
104 server_address_index_.Set(index, callback);
105 }
106
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_;
118
119 DISALLOW_COPY_AND_ASSIGN(ConfigProperties);
120 };
121
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;
129
130 // Name of the WiFi device.
131 const std::string& device_name() const { return device_name_.value(); }
132
133 // Flag indicating if this device is currently in-use by apmanager.
134 bool in_use() const { return in_used_.value(); }
135
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();
140 }
141
142 private:
143 dbus::Property<std::string> device_name_;
144 dbus::Property<bool> in_used_;
145 dbus::Property<std::string> preferred_ap_interface_;
146
147 DISALLOW_COPY_AND_ASSIGN(DeviceProperties);
148 };
149
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;
157
158 // DBus path of the config for this service.
159 const dbus::ObjectPath& config_path() const { return config_.value(); }
160
161 // Current state of service. ["Idle", "Starting", "Started", "Failed"].
162 const std::string& state() const { return state_.value(); }
163
164 private:
165 dbus::Property<dbus::ObjectPath> config_;
166 dbus::Property<std::string> state_;
167
168 DISALLOW_COPY_AND_ASSIGN(ServiceProperties);
169 };
170
171 // Interface for observing changes from a apmanager daemon.
172 class Observer {
173 public:
174 virtual ~Observer();
175
176 // Called when the manager has been added.
177 virtual void ManagerAdded();
178
179 // Called when the manager has been removed.
180 virtual void ManagerRemoved();
181
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);
185
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);
189
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);
193
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);
197
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);
201
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);
205
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);
210
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);
215
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);
220 };
221
222 ~ApManagerClient() override;
223
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();
227
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;
233
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;
239
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;
246
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;
253
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;
260
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;
265
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;
270
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;
275
276 protected:
277 // Create() should be used instead.
278 ApManagerClient();
279
280 private:
281 DISALLOW_COPY_AND_ASSIGN(ApManagerClient);
282 };
283
284 } // namespace chromeos
285
286 #endif // CHROMEOS_DBUS_AP_MANAGER_CLIENT_H_
OLDNEW
« no previous file with comments | « chromeos/chromeos.gyp ('k') | chromeos/dbus/ap_manager_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698