1 // 2 // Copyright (C) 2015 The Android Open Source Project 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 // 16 17 #ifndef APMANAGER_DBUS_CONFIG_DBUS_ADAPTOR_H_ 18 #define APMANAGER_DBUS_CONFIG_DBUS_ADAPTOR_H_ 19 20 #include <string> 21 22 #include <base/macros.h> 23 #include <brillo/errors/error.h> 24 #include <dbus_bindings/org.chromium.apmanager.Config.h> 25 26 #include "apmanager/config_adaptor_interface.h" 27 28 namespace apmanager { 29 30 class Config; 31 32 class ConfigDBusAdaptor 33 : public org::chromium::apmanager::ConfigAdaptor, 34 public org::chromium::apmanager::ConfigInterface, 35 public ConfigAdaptorInterface { 36 public: 37 ConfigDBusAdaptor(const scoped_refptr<dbus::Bus>& bus, 38 brillo::dbus_utils::ExportedObjectManager* object_manager, 39 Config* config, 40 int service_identifier); 41 virtual ~ConfigDBusAdaptor(); 42 43 // Implementation of org::chromium::apmanager::ConfigAdaptor. 44 bool ValidateSsid(brillo::ErrorPtr* error, 45 const std::string& value) override; 46 bool ValidateSecurityMode(brillo::ErrorPtr* error, 47 const std::string& value) override; 48 bool ValidatePassphrase(brillo::ErrorPtr* error, 49 const std::string& value) override; 50 bool ValidateHwMode(brillo::ErrorPtr* error, 51 const std::string& value) override; 52 bool ValidateOperationMode(brillo::ErrorPtr* error, 53 const std::string& value) override; 54 bool ValidateChannel(brillo::ErrorPtr* error, 55 const uint16_t& value) override; 56 57 // Implementation of ConfigAdaptorInterface. 58 RPCObjectIdentifier GetRpcObjectIdentifier() override; 59 void SetSsid(const std::string& ssid) override; 60 std::string GetSsid() override; 61 void SetInterfaceName(const std::string& interface_name) override; 62 std::string GetInterfaceName() override; 63 void SetSecurityMode(const std::string& security_mode) override; 64 std::string GetSecurityMode() override; 65 void SetPassphrase(const std::string& passphrase) override; 66 std::string GetPassphrase() override; 67 void SetHwMode(const std::string& hw_mode) override; 68 std::string GetHwMode() override; 69 void SetOperationMode(const std::string& op_mode) override; 70 std::string GetOperationMode() override; 71 void SetChannel(uint16_t channel) override; 72 uint16_t GetChannel() override; 73 void SetHiddenNetwork(bool hidden) override; 74 bool GetHiddenNetwork() override; 75 void SetBridgeInterface(const std::string& interface_name) override; 76 std::string GetBridgeInterface() override; 77 void SetServerAddressIndex(uint16_t) override; 78 uint16_t GetServerAddressIndex() override; 79 void SetFullDeviceControl(bool full_control) override; 80 bool GetFullDeviceControl() override; 81 82 private: 83 dbus::ObjectPath dbus_path_; 84 brillo::dbus_utils::DBusObject dbus_object_; 85 Config* config_; 86 87 DISALLOW_COPY_AND_ASSIGN(ConfigDBusAdaptor); 88 }; 89 90 } // namespace apmanager 91 92 #endif // APMANAGER_DBUS_CONFIG_DBUS_ADAPTOR_H_ 93