Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 struct 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 dbus::Property<std::string> ssid; | |
| 38 | |
| 39 // Interface name [optional]. | |
| 40 dbus::Property<std::string> interface_name; | |
| 41 | |
| 42 // Security Mode; "RSN", "None" [optional]. | |
| 43 dbus::Property<std::string> security_mode; | |
| 44 | |
| 45 // Passphrase; [required] when security is not "None". | |
| 46 dbus::Property<std::string> passphrase; | |
| 47 | |
| 48 // HwMode, "802.11a", "802.11b". Default: "802.11g" [optional]. | |
| 49 dbus::Property<std::string> hw_mode; | |
| 50 | |
| 51 // Operation mode, "Bridge" or "Server". Default "Server". [optional]. | |
| 52 dbus::Property<std::string> operation_mode; | |
| 53 | |
| 54 // Operating channel. Default '6' [optional]. | |
| 55 dbus::Property<uint16_t> channel; | |
| 56 | |
| 57 // Hidden network. Default "false". [optional]. | |
| 58 dbus::Property<bool> hidden_network; | |
| 59 | |
| 60 // Bridge interface. [required] if Bridge operation mode set. | |
| 61 dbus::Property<std::string> bridge_interface; | |
| 62 | |
| 63 // The value of x in the following equation; "192.168.x.254". | |
| 64 // This will be the server's IP address. [required] only if | |
| 65 // operation mode set to "Server". | |
| 66 dbus::Property<uint16_t> server_address_index; | |
| 67 }; | |
| 68 | |
| 69 // Structure of properties associated with a WiFi service AP device. | |
| 70 class DeviceProperties : public dbus::PropertySet { | |
|
stevenjb
2015/03/06 18:22:15
We should be consistent and use structs or classes
dtapuska
2015/03/06 18:25:42
So the config is completely mutable; and the class
stevenjb
2015/03/06 19:17:46
I'm not sure I follow. If there is a fundamental d
dtapuska
2015/03/06 19:57:52
Done.
| |
| 71 public: | |
| 72 DeviceProperties(dbus::ObjectProxy* object_proxy, | |
| 73 const std::string& interface_name, | |
| 74 const PropertyChangedCallback& callback); | |
| 75 ~DeviceProperties() override; | |
| 76 | |
| 77 const std::string& device_name() const { return device_name_.value(); } | |
| 78 bool in_use() const { return in_used_.value(); } | |
| 79 const std::string& preferred_ap_interface() const { | |
| 80 return preferred_ap_interface_.value(); | |
| 81 } | |
| 82 | |
| 83 private: | |
| 84 dbus::Property<std::string> device_name_; | |
| 85 dbus::Property<bool> in_used_; | |
|
stevenjb
2015/03/06 19:17:46
Also, these properties should be documented.
dtapuska
2015/03/06 19:57:52
Done.
| |
| 86 dbus::Property<std::string> preferred_ap_interface_; | |
|
stevenjb
2015/03/06 18:22:15
DISALLOW_COPY_AND_ASSIGN for classes
dtapuska
2015/03/06 19:57:52
Done.
| |
| 87 }; | |
| 88 | |
| 89 // Structure of properties associated with a WiFi service AP service. | |
| 90 class ServiceProperties : public dbus::PropertySet { | |
| 91 public: | |
| 92 ServiceProperties(dbus::ObjectProxy* object_proxy, | |
| 93 const std::string& interface_name, | |
| 94 const PropertyChangedCallback& callback); | |
| 95 ~ServiceProperties() override; | |
| 96 | |
| 97 const dbus::ObjectPath& config_path() const { return config_.value(); } | |
| 98 const std::string& state() const { return state_.value(); } | |
| 99 | |
| 100 private: | |
| 101 dbus::Property<dbus::ObjectPath> config_; | |
| 102 dbus::Property<std::string> state_; | |
| 103 }; | |
| 104 | |
| 105 // Interface for observing changes from a leadership daemon. | |
|
stevenjb
2015/03/06 18:22:15
"leadership"?
dtapuska
2015/03/06 19:57:52
Done.
| |
| 106 class Observer { | |
| 107 public: | |
| 108 virtual ~Observer(); | |
| 109 | |
| 110 // Called when the manager has been added. | |
| 111 virtual void ManagerAdded(); | |
| 112 | |
| 113 // Called when the manager has been removed. | |
| 114 virtual void ManagerRemoved(); | |
| 115 | |
| 116 // Called when the config with object path |object_path| is added to the | |
| 117 // system. | |
| 118 virtual void ConfigAdded(const dbus::ObjectPath& object_path); | |
| 119 | |
| 120 // Called when the config with object path |object_path| is removed from | |
| 121 // the system. | |
| 122 virtual void ConfigRemoved(const dbus::ObjectPath& object_path); | |
| 123 | |
| 124 // Called when the device with object path |object_path| is added to the | |
| 125 // system. | |
| 126 virtual void DeviceAdded(const dbus::ObjectPath& object_path); | |
| 127 | |
| 128 // Called when the device with object path |object_path| is removed from | |
| 129 // the system. | |
| 130 virtual void DeviceRemoved(const dbus::ObjectPath& object_path); | |
| 131 | |
| 132 // Called when the device with object path |object_path| is added to the | |
| 133 // system. | |
| 134 virtual void ServiceAdded(const dbus::ObjectPath& object_path); | |
| 135 | |
| 136 // Called when the device with object path |object_path| is removed from | |
| 137 // the system. | |
| 138 virtual void ServiceRemoved(const dbus::ObjectPath& object_path); | |
| 139 | |
| 140 // Called when the adapter with object path |object_path| has a | |
| 141 // change in value of the property named |property_name|. | |
| 142 virtual void ConfigPropertyChanged(const dbus::ObjectPath& object_path, | |
| 143 const std::string& property_name); | |
| 144 | |
| 145 // Called when the adapter with object path |object_path| has a | |
| 146 // change in value of the property named |property_name|. | |
| 147 virtual void DevicePropertyChanged(const dbus::ObjectPath& object_path, | |
| 148 const std::string& property_name); | |
| 149 | |
| 150 // Called when the adapter with object path |object_path| has a | |
| 151 // change in value of the property named |property_name|. | |
| 152 virtual void ServicePropertyChanged(const dbus::ObjectPath& object_path, | |
| 153 const std::string& property_name); | |
|
stevenjb
2015/03/06 18:22:15
DISALLOW_COPY_AND_ASSIGN
dtapuska
2015/03/06 19:57:52
Done.
| |
| 154 }; | |
| 155 | |
| 156 ~ApManagerClient() override; | |
| 157 | |
| 158 // Factory function, creates a new instance which is owned by the caller. | |
| 159 // For normal usage, access the singleton via DBusThreadManager::Get(). | |
| 160 static ApManagerClient* Create(); | |
| 161 | |
| 162 // Adds and removes observers for events on all leadership group | |
|
stevenjb
2015/03/06 18:22:15
"leadership"?
dtapuska
2015/03/06 19:57:52
Done.
| |
| 163 // events. Check the |object_path| parameter of observer methods to | |
| 164 // determine which group is issuing the event. | |
| 165 virtual void AddObserver(Observer* observer) = 0; | |
| 166 virtual void RemoveObserver(Observer* observer) = 0; | |
| 167 | |
| 168 // Calls CreateService method. | |
| 169 // |callback| is called with its |call_status| argument set to | |
| 170 // DBUS_METHOD_CALL_SUCCESS if the method call succeeds. Otherwise, | |
| 171 // |callback| is called with |call_status| set to DBUS_METHOD_CALL_FAILURE. | |
| 172 virtual void CreateService(const ObjectPathDBusMethodCallback& callback) = 0; | |
| 173 | |
| 174 // Calls RemoveService method. | |
| 175 // |callback| is called with its |call_status| argument set to | |
| 176 // DBUS_METHOD_CALL_SUCCESS if the method call succeeds. Otherwise, | |
| 177 // |callback| is called with |call_status| set to DBUS_METHOD_CALL_FAILURE. | |
| 178 virtual void RemoveService(const dbus::ObjectPath& object_path, | |
| 179 const VoidDBusMethodCallback& callback) = 0; | |
| 180 | |
| 181 // Calls Service::Start method. | |
| 182 // |callback| is called with its |call_status| argument set to | |
| 183 // DBUS_METHOD_CALL_SUCCESS if the method call succeeds. Otherwise, | |
| 184 // |callback| is called with |call_status| set to DBUS_METHOD_CALL_FAILURE. | |
| 185 virtual void StartService(const dbus::ObjectPath& object_path, | |
| 186 const VoidDBusMethodCallback& callback) = 0; | |
| 187 | |
| 188 // Calls Service::Stop method. | |
| 189 // |callback| is called with its |call_status| argument set to | |
| 190 // DBUS_METHOD_CALL_SUCCESS if the method call succeeds. Otherwise, | |
| 191 // |callback| is called with |call_status| set to DBUS_METHOD_CALL_FAILURE. | |
| 192 virtual void StopService(const dbus::ObjectPath& object_path, | |
| 193 const VoidDBusMethodCallback& callback) = 0; | |
| 194 | |
| 195 // Obtains the properties for the config with object path |object_path|, | |
| 196 // any values should be copied if needed. | |
| 197 virtual ConfigProperties* GetConfigProperties( | |
| 198 const dbus::ObjectPath& object_path) = 0; | |
| 199 | |
| 200 // Obtains the properties for the device with object path |object_path|, | |
| 201 // any values should be copied if needed. | |
| 202 virtual const DeviceProperties* GetDeviceProperties( | |
| 203 const dbus::ObjectPath& object_path) = 0; | |
| 204 | |
| 205 // Obtains the properties for the device with object path |object_path|, | |
| 206 // any values should be copied if needed. | |
| 207 virtual const ServiceProperties* GetServiceProperties( | |
| 208 const dbus::ObjectPath& object_path) = 0; | |
| 209 | |
| 210 protected: | |
| 211 // Create() should be used instead. | |
| 212 ApManagerClient(); | |
| 213 | |
| 214 private: | |
| 215 DISALLOW_COPY_AND_ASSIGN(ApManagerClient); | |
| 216 }; | |
| 217 | |
| 218 } // namespace chromeos | |
| 219 | |
| 220 #endif // CHROMEOS_DBUS_AP_MANAGER_CLIENT_H_ | |
| OLD | NEW |