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 SHILL_DBUS_CHROMEOS_SUPPLICANT_NETWORK_PROXY_H_ 18 #define SHILL_DBUS_CHROMEOS_SUPPLICANT_NETWORK_PROXY_H_ 19 20 #include <map> 21 #include <string> 22 23 #include <base/macros.h> 24 25 #include "shill/refptr_types.h" 26 #include "shill/supplicant/supplicant_network_proxy_interface.h" 27 #include "supplicant/dbus-proxies.h" 28 29 namespace shill { 30 31 // ChromeosSupplicantNetworkProxy. provides access to wpa_supplicant's 32 // network-interface APIs via D-Bus. 33 class ChromeosSupplicantNetworkProxy 34 : public SupplicantNetworkProxyInterface { 35 public: 36 ChromeosSupplicantNetworkProxy(const scoped_refptr<dbus::Bus>& bus, 37 const std::string& object_path); 38 ~ChromeosSupplicantNetworkProxy() override; 39 40 // Implementation of SupplicantNetworkProxyInterface. 41 // This function will always return true, since PropertySet::Set is an 42 // async method. Failures will be logged in the callback. 43 bool SetEnabled(bool enabled) override; 44 45 private: 46 class PropertySet : public dbus::PropertySet { 47 public: 48 PropertySet(dbus::ObjectProxy* object_proxy, 49 const std::string& interface_name, 50 const PropertyChangedCallback& callback); 51 brillo::dbus_utils::Property<bool> enabled; 52 53 private: 54 DISALLOW_COPY_AND_ASSIGN(PropertySet); 55 }; 56 57 static const char kInterfaceName[]; 58 static const char kPropertyEnabled[]; 59 static const char kPropertyProperties[]; 60 61 // Signal handlers. 62 void PropertiesChanged(const brillo::VariantDictionary& properties); 63 64 // Callback invoked when the value of property |property_name| is changed. 65 void OnPropertyChanged(const std::string& property_name); 66 67 // Called when signal is connected to the ObjectProxy. 68 void OnSignalConnected(const std::string& interface_name, 69 const std::string& signal_name, 70 bool success); 71 72 std::unique_ptr<fi::w1::wpa_supplicant1::NetworkProxy> network_proxy_; 73 std::unique_ptr<PropertySet> properties_; 74 75 base::WeakPtrFactory<ChromeosSupplicantNetworkProxy> weak_factory_{this}; 76 DISALLOW_COPY_AND_ASSIGN(ChromeosSupplicantNetworkProxy); 77 }; 78 79 } // namespace shill 80 81 #endif // SHILL_DBUS_CHROMEOS_SUPPLICANT_NETWORK_PROXY_H_ 82