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_WIMAX_NETWORK_PROXY_H_ 18 #define SHILL_DBUS_CHROMEOS_WIMAX_NETWORK_PROXY_H_ 19 20 #include <string> 21 22 #include <base/callback.h> 23 #include <wimax_manager/dbus-proxies.h> 24 25 #include "shill/wimax/wimax_network_proxy_interface.h" 26 27 namespace shill { 28 29 class ChromeosWiMaxNetworkProxy : public WiMaxNetworkProxyInterface { 30 public: 31 // Constructs a WiMaxManager.Network DBus object proxy at |path|. 32 ChromeosWiMaxNetworkProxy(const scoped_refptr<dbus::Bus>& bus, 33 const std::string& rpc_identifier); 34 ~ChromeosWiMaxNetworkProxy() override; 35 36 // Inherited from WiMaxNetwokProxyInterface. 37 RpcIdentifier path() const override; 38 void set_signal_strength_changed_callback( 39 const SignalStrengthChangedCallback& callback) override; 40 uint32_t Identifier(Error* error) override; 41 std::string Name(Error* error) override; 42 int Type(Error* error) override; 43 int CINR(Error* error) override; 44 int RSSI(Error* error) override; 45 int SignalStrength(Error* error) override; 46 47 private: 48 class PropertySet : public dbus::PropertySet { 49 public: 50 PropertySet(dbus::ObjectProxy* object_proxy, 51 const std::string& interface_name, 52 const PropertyChangedCallback& callback); 53 brillo::dbus_utils::Property<uint32_t> identifier; 54 brillo::dbus_utils::Property<std::string> name; 55 brillo::dbus_utils::Property<int32_t> type; 56 brillo::dbus_utils::Property<int32_t> cinr; 57 brillo::dbus_utils::Property<int32_t> rssi; 58 brillo::dbus_utils::Property<int32_t> signal_strength; 59 60 private: 61 DISALLOW_COPY_AND_ASSIGN(PropertySet); 62 }; 63 64 static const char kPropertyIdentifier[]; 65 static const char kPropertyName[]; 66 static const char kPropertyType[]; 67 static const char kPropertyCINR[]; 68 static const char kPropertyRSSI[]; 69 static const char kPropertySignalStrength[]; 70 71 // Signal handler. 72 void SignalStrengthChanged(int32_t signal_strength); 73 74 // Callback invoked when the value of property |property_name| is changed. 75 void OnPropertyChanged(const std::string& property_name); 76 77 // Called when signal is connected to the ObjectProxy. 78 void OnSignalConnected(const std::string& interface_name, 79 const std::string& signal_name, 80 bool success); 81 82 std::unique_ptr<org::chromium::WiMaxManager::NetworkProxy> proxy_; 83 std::unique_ptr<PropertySet> properties_; 84 SignalStrengthChangedCallback signal_strength_changed_callback_; 85 86 base::WeakPtrFactory<ChromeosWiMaxNetworkProxy> weak_factory_{this}; 87 DISALLOW_COPY_AND_ASSIGN(ChromeosWiMaxNetworkProxy); 88 }; 89 90 } // namespace shill 91 92 #endif // SHILL_DBUS_CHROMEOS_WIMAX_NETWORK_PROXY_H_ 93