Chromium Code Reviews| Index: chromeos/dbus/ap_manager_client.h |
| diff --git a/chromeos/dbus/ap_manager_client.h b/chromeos/dbus/ap_manager_client.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6383de7f93f3b64db114a6e64c18a485c265ba85 |
| --- /dev/null |
| +++ b/chromeos/dbus/ap_manager_client.h |
| @@ -0,0 +1,220 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| +#ifndef CHROMEOS_DBUS_AP_MANAGER_CLIENT_H_ |
| +#define CHROMEOS_DBUS_AP_MANAGER_CLIENT_H_ |
| + |
| +#include <map> |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/callback.h" |
| +#include "base/macros.h" |
| +#include "base/values.h" |
| +#include "chromeos/chromeos_export.h" |
| +#include "chromeos/dbus/dbus_client.h" |
| +#include "chromeos/dbus/dbus_method_call_status.h" |
| +#include "dbus/object_path.h" |
| +#include "dbus/property.h" |
| + |
| +namespace chromeos { |
| + |
| +// ApManagerClient is used to communicate with the |
| +// WiFi AP Manager service. All methods should be called from |
| +// the origin thread which initializes the DBusThreadManager instance. |
| +class CHROMEOS_EXPORT ApManagerClient : public DBusClient { |
| + public: |
| + // Structure of properties associated with a WiFi service AP configuration. |
| + // These properties must be set before Start is called. |
| + struct ConfigProperties : public dbus::PropertySet { |
| + public: |
| + ConfigProperties(dbus::ObjectProxy* object_proxy, |
| + const std::string& interface_name, |
| + const PropertyChangedCallback& callback); |
| + ~ConfigProperties() override; |
| + |
| + // Name of network [required]. |
| + dbus::Property<std::string> ssid; |
| + |
| + // Interface name [optional]. |
| + dbus::Property<std::string> interface_name; |
| + |
| + // Security Mode; "RSN", "None" [optional]. |
| + dbus::Property<std::string> security_mode; |
| + |
| + // Passphrase; [required] when security is not "None". |
| + dbus::Property<std::string> passphrase; |
| + |
| + // HwMode, "802.11a", "802.11b". Default: "802.11g" [optional]. |
| + dbus::Property<std::string> hw_mode; |
| + |
| + // Operation mode, "Bridge" or "Server". Default "Server". [optional]. |
| + dbus::Property<std::string> operation_mode; |
| + |
| + // Operating channel. Default '6' [optional]. |
| + dbus::Property<uint16_t> channel; |
| + |
| + // Hidden network. Default "false". [optional]. |
| + dbus::Property<bool> hidden_network; |
| + |
| + // Bridge interface. [required] if Bridge operation mode set. |
| + dbus::Property<std::string> bridge_interface; |
| + |
| + // The value of x in the following equation; "192.168.x.254". |
| + // This will be the server's IP address. [required] only if |
| + // operation mode set to "Server". |
| + dbus::Property<uint16_t> server_address_index; |
| + }; |
| + |
| + // Structure of properties associated with a WiFi service AP device. |
| + 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.
|
| + public: |
| + DeviceProperties(dbus::ObjectProxy* object_proxy, |
| + const std::string& interface_name, |
| + const PropertyChangedCallback& callback); |
| + ~DeviceProperties() override; |
| + |
| + const std::string& device_name() const { return device_name_.value(); } |
| + bool in_use() const { return in_used_.value(); } |
| + const std::string& preferred_ap_interface() const { |
| + return preferred_ap_interface_.value(); |
| + } |
| + |
| + private: |
| + dbus::Property<std::string> device_name_; |
| + 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.
|
| + 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.
|
| + }; |
| + |
| + // Structure of properties associated with a WiFi service AP service. |
| + class ServiceProperties : public dbus::PropertySet { |
| + public: |
| + ServiceProperties(dbus::ObjectProxy* object_proxy, |
| + const std::string& interface_name, |
| + const PropertyChangedCallback& callback); |
| + ~ServiceProperties() override; |
| + |
| + const dbus::ObjectPath& config_path() const { return config_.value(); } |
| + const std::string& state() const { return state_.value(); } |
| + |
| + private: |
| + dbus::Property<dbus::ObjectPath> config_; |
| + dbus::Property<std::string> state_; |
| + }; |
| + |
| + // Interface for observing changes from a leadership daemon. |
|
stevenjb
2015/03/06 18:22:15
"leadership"?
dtapuska
2015/03/06 19:57:52
Done.
|
| + class Observer { |
| + public: |
| + virtual ~Observer(); |
| + |
| + // Called when the manager has been added. |
| + virtual void ManagerAdded(); |
| + |
| + // Called when the manager has been removed. |
| + virtual void ManagerRemoved(); |
| + |
| + // Called when the config with object path |object_path| is added to the |
| + // system. |
| + virtual void ConfigAdded(const dbus::ObjectPath& object_path); |
| + |
| + // Called when the config with object path |object_path| is removed from |
| + // the system. |
| + virtual void ConfigRemoved(const dbus::ObjectPath& object_path); |
| + |
| + // Called when the device with object path |object_path| is added to the |
| + // system. |
| + virtual void DeviceAdded(const dbus::ObjectPath& object_path); |
| + |
| + // Called when the device with object path |object_path| is removed from |
| + // the system. |
| + virtual void DeviceRemoved(const dbus::ObjectPath& object_path); |
| + |
| + // Called when the device with object path |object_path| is added to the |
| + // system. |
| + virtual void ServiceAdded(const dbus::ObjectPath& object_path); |
| + |
| + // Called when the device with object path |object_path| is removed from |
| + // the system. |
| + virtual void ServiceRemoved(const dbus::ObjectPath& object_path); |
| + |
| + // Called when the adapter with object path |object_path| has a |
| + // change in value of the property named |property_name|. |
| + virtual void ConfigPropertyChanged(const dbus::ObjectPath& object_path, |
| + const std::string& property_name); |
| + |
| + // Called when the adapter with object path |object_path| has a |
| + // change in value of the property named |property_name|. |
| + virtual void DevicePropertyChanged(const dbus::ObjectPath& object_path, |
| + const std::string& property_name); |
| + |
| + // Called when the adapter with object path |object_path| has a |
| + // change in value of the property named |property_name|. |
| + virtual void ServicePropertyChanged(const dbus::ObjectPath& object_path, |
| + const std::string& property_name); |
|
stevenjb
2015/03/06 18:22:15
DISALLOW_COPY_AND_ASSIGN
dtapuska
2015/03/06 19:57:52
Done.
|
| + }; |
| + |
| + ~ApManagerClient() override; |
| + |
| + // Factory function, creates a new instance which is owned by the caller. |
| + // For normal usage, access the singleton via DBusThreadManager::Get(). |
| + static ApManagerClient* Create(); |
| + |
| + // 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.
|
| + // events. Check the |object_path| parameter of observer methods to |
| + // determine which group is issuing the event. |
| + virtual void AddObserver(Observer* observer) = 0; |
| + virtual void RemoveObserver(Observer* observer) = 0; |
| + |
| + // Calls CreateService method. |
| + // |callback| is called with its |call_status| argument set to |
| + // DBUS_METHOD_CALL_SUCCESS if the method call succeeds. Otherwise, |
| + // |callback| is called with |call_status| set to DBUS_METHOD_CALL_FAILURE. |
| + virtual void CreateService(const ObjectPathDBusMethodCallback& callback) = 0; |
| + |
| + // Calls RemoveService method. |
| + // |callback| is called with its |call_status| argument set to |
| + // DBUS_METHOD_CALL_SUCCESS if the method call succeeds. Otherwise, |
| + // |callback| is called with |call_status| set to DBUS_METHOD_CALL_FAILURE. |
| + virtual void RemoveService(const dbus::ObjectPath& object_path, |
| + const VoidDBusMethodCallback& callback) = 0; |
| + |
| + // Calls Service::Start method. |
| + // |callback| is called with its |call_status| argument set to |
| + // DBUS_METHOD_CALL_SUCCESS if the method call succeeds. Otherwise, |
| + // |callback| is called with |call_status| set to DBUS_METHOD_CALL_FAILURE. |
| + virtual void StartService(const dbus::ObjectPath& object_path, |
| + const VoidDBusMethodCallback& callback) = 0; |
| + |
| + // Calls Service::Stop method. |
| + // |callback| is called with its |call_status| argument set to |
| + // DBUS_METHOD_CALL_SUCCESS if the method call succeeds. Otherwise, |
| + // |callback| is called with |call_status| set to DBUS_METHOD_CALL_FAILURE. |
| + virtual void StopService(const dbus::ObjectPath& object_path, |
| + const VoidDBusMethodCallback& callback) = 0; |
| + |
| + // Obtains the properties for the config with object path |object_path|, |
| + // any values should be copied if needed. |
| + virtual ConfigProperties* GetConfigProperties( |
| + const dbus::ObjectPath& object_path) = 0; |
| + |
| + // Obtains the properties for the device with object path |object_path|, |
| + // any values should be copied if needed. |
| + virtual const DeviceProperties* GetDeviceProperties( |
| + const dbus::ObjectPath& object_path) = 0; |
| + |
| + // Obtains the properties for the device with object path |object_path|, |
| + // any values should be copied if needed. |
| + virtual const ServiceProperties* GetServiceProperties( |
| + const dbus::ObjectPath& object_path) = 0; |
| + |
| + protected: |
| + // Create() should be used instead. |
| + ApManagerClient(); |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(ApManagerClient); |
| +}; |
| + |
| +} // namespace chromeos |
| + |
| +#endif // CHROMEOS_DBUS_AP_MANAGER_CLIENT_H_ |