Home | History | Annotate | Download | only in dbus
      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_MM1_MODEM_SIMPLE_PROXY_H_
     18 #define SHILL_DBUS_CHROMEOS_MM1_MODEM_SIMPLE_PROXY_H_
     19 
     20 #include <string>
     21 
     22 #include "cellular/dbus-proxies.h"
     23 #include "shill/cellular/mm1_modem_simple_proxy_interface.h"
     24 
     25 namespace shill {
     26 namespace mm1 {
     27 
     28 // A proxy to org.freedesktop.ModemManager1.Modem.Simple.
     29 class ChromeosModemSimpleProxy : public ModemSimpleProxyInterface {
     30  public:
     31   // Constructs a org.freedesktop.ModemManager1.Modem.Simple DBus
     32   // object proxy at |path| owned by |service|.
     33   ChromeosModemSimpleProxy(const scoped_refptr<dbus::Bus>& bus,
     34                            const std::string& path,
     35                            const std::string& service);
     36   ~ChromeosModemSimpleProxy() override;
     37 
     38   // Inherited methods from SimpleProxyInterface.
     39   void Connect(
     40       const KeyValueStore& properties,
     41       Error* error,
     42       const RpcIdentifierCallback& callback,
     43       int timeout) override;
     44   void Disconnect(const std::string& bearer,
     45                   Error* error,
     46                   const ResultCallback& callback,
     47                   int timeout) override;
     48   void GetStatus(Error* error,
     49                  const KeyValueStoreCallback& callback,
     50                  int timeout) override;
     51 
     52  private:
     53   // Callbacks for Connect async call.
     54   void OnConnectSuccess(const RpcIdentifierCallback& callback,
     55                         const dbus::ObjectPath& path);
     56   void OnConnectFailure(const RpcIdentifierCallback& callback,
     57                         brillo::Error* error);
     58 
     59   // Callbacks for Disconnect async call.
     60   void OnDisconnectSuccess(const ResultCallback& callback);
     61   void OnDisconnectFailure(const ResultCallback& callbac,
     62                            brillo::Error* dbus_error);
     63 
     64   // Callbacks for GetStatus async call.
     65   void OnGetStatusSuccess(const KeyValueStoreCallback& callback,
     66                           const brillo::VariantDictionary& status);
     67   void OnGetStatusFailure(const KeyValueStoreCallback& callback,
     68                           brillo::Error* error);
     69 
     70   std::unique_ptr<org::freedesktop::ModemManager1::Modem::SimpleProxy> proxy_;
     71 
     72   base::WeakPtrFactory<ChromeosModemSimpleProxy> weak_factory_{this};
     73   DISALLOW_COPY_AND_ASSIGN(ChromeosModemSimpleProxy);
     74 };
     75 
     76 }  // namespace mm1
     77 }  // namespace shill
     78 
     79 #endif  // SHILL_DBUS_CHROMEOS_MM1_MODEM_SIMPLE_PROXY_H_
     80