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_MODEM_SIMPLE_PROXY_H_ 18 #define SHILL_DBUS_CHROMEOS_MODEM_SIMPLE_PROXY_H_ 19 20 #include <string> 21 22 #include <base/macros.h> 23 24 #include "cellular/dbus-proxies.h" 25 #include "shill/cellular/modem_simple_proxy_interface.h" 26 27 namespace shill { 28 29 // A proxy to (old) ModemManager.Modem.Simple. 30 class ChromeosModemSimpleProxy : public ModemSimpleProxyInterface { 31 public: 32 // Constructs a ModemManager.Modem.Simple DBus object proxy at 33 // |path| owned by |service|. 34 ChromeosModemSimpleProxy(const scoped_refptr<dbus::Bus>& bus, 35 const std::string& path, 36 const std::string& service); 37 ~ChromeosModemSimpleProxy() override; 38 39 // Inherited from ModemSimpleProxyInterface. 40 void GetModemStatus(Error* error, 41 const KeyValueStoreCallback& callback, 42 int timeout) override; 43 void Connect(const KeyValueStore& properties, 44 Error* error, 45 const ResultCallback& callback, 46 int timeout) override; 47 48 private: 49 // Callbacks for GetStatus async call. 50 void OnGetStatusSuccess(const KeyValueStoreCallback& callback, 51 const brillo::VariantDictionary& props); 52 void OnGetStatusFailure(const KeyValueStoreCallback& callback, 53 brillo::Error* dbus_error); 54 55 // Callbacks for Connect async call. 56 void OnConnectSuccess(const ResultCallback& callback); 57 void OnConnectFailure(const ResultCallback& callback, 58 brillo::Error* dbus_error); 59 60 std::unique_ptr<org::freedesktop::ModemManager::Modem::SimpleProxy> proxy_; 61 62 base::WeakPtrFactory<ChromeosModemSimpleProxy> weak_factory_{this}; 63 DISALLOW_COPY_AND_ASSIGN(ChromeosModemSimpleProxy); 64 }; 65 66 } // namespace shill 67 68 #endif // SHILL_DBUS_CHROMEOS_MODEM_SIMPLE_PROXY_H_ 69