1c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// 2c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// Copyright (C) 2015 The Android Open Source Project 3c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// 4c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// Licensed under the Apache License, Version 2.0 (the "License"); 5c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// you may not use this file except in compliance with the License. 6c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// You may obtain a copy of the License at 7c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// 8c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// http://www.apache.org/licenses/LICENSE-2.0 9c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// 10c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// Unless required by applicable law or agreed to in writing, software 11c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// distributed under the License is distributed on an "AS IS" BASIS, 12c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// See the License for the specific language governing permissions and 14c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// limitations under the License. 15c0beca55d290fe0b1c96d78cbbcf94b05c23f5a5Peter Qiu// 1655ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu 1755ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu#ifndef SHILL_DBUS_CHROMEOS_SUPPLICANT_NETWORK_PROXY_H_ 1855ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu#define SHILL_DBUS_CHROMEOS_SUPPLICANT_NETWORK_PROXY_H_ 1955ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu 2055ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu#include <map> 2155ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu#include <string> 2255ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu 2355ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu#include <base/macros.h> 2455ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu 2555ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu#include "shill/refptr_types.h" 2655ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu#include "shill/supplicant/supplicant_network_proxy_interface.h" 2755ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu#include "supplicant/dbus-proxies.h" 2855ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu 2955ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiunamespace shill { 3055ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu 3155ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu// ChromeosSupplicantNetworkProxy. provides access to wpa_supplicant's 3255ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu// network-interface APIs via D-Bus. 3355ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiuclass ChromeosSupplicantNetworkProxy 3455ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu : public SupplicantNetworkProxyInterface { 3555ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu public: 3655ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu ChromeosSupplicantNetworkProxy(const scoped_refptr<dbus::Bus>& bus, 3755ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu const std::string& object_path); 3855ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu ~ChromeosSupplicantNetworkProxy() override; 3955ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu 4055ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu // Implementation of SupplicantNetworkProxyInterface. 4155ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu // This function will always return true, since PropertySet::Set is an 4255ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu // async method. Failures will be logged in the callback. 4355ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu bool SetEnabled(bool enabled) override; 4455ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu 4555ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu private: 4655ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu class PropertySet : public dbus::PropertySet { 4755ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu public: 4855ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu PropertySet(dbus::ObjectProxy* object_proxy, 4955ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu const std::string& interface_name, 5055ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu const PropertyChangedCallback& callback); 5103e6719bae1e0903d94853b896673a033196bcf5Alex Vakulenko brillo::dbus_utils::Property<bool> enabled; 5255ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu 5355ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu private: 5455ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu DISALLOW_COPY_AND_ASSIGN(PropertySet); 5555ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu }; 5655ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu 57d0f54b608798f230eee2e79fd2130cae2f8e70cfPeter Qiu static const char kInterfaceName[]; 5855ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu static const char kPropertyEnabled[]; 5955ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu static const char kPropertyProperties[]; 6055ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu 6155ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu // Signal handlers. 6203e6719bae1e0903d94853b896673a033196bcf5Alex Vakulenko void PropertiesChanged(const brillo::VariantDictionary& properties); 6355ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu 6455ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu // Callback invoked when the value of property |property_name| is changed. 6555ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu void OnPropertyChanged(const std::string& property_name); 6655ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu 6755ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu // Called when signal is connected to the ObjectProxy. 6855ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu void OnSignalConnected(const std::string& interface_name, 6955ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu const std::string& signal_name, 7055ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu bool success); 7155ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu 7255ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu std::unique_ptr<fi::w1::wpa_supplicant1::NetworkProxy> network_proxy_; 7355ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu std::unique_ptr<PropertySet> properties_; 7455ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu 75c34da84ef49b32c27c879c3d37831c7970a8538bPeter Qiu base::WeakPtrFactory<ChromeosSupplicantNetworkProxy> weak_factory_{this}; 7655ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu DISALLOW_COPY_AND_ASSIGN(ChromeosSupplicantNetworkProxy); 7755ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu}; 7855ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu 7955ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu} // namespace shill 8055ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu 8155ce0b668c0096a2a0ae2c6dfe154635e80b169cPeter Qiu#endif // SHILL_DBUS_CHROMEOS_SUPPLICANT_NETWORK_PROXY_H_ 82