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_MODEM_GSM_CARD_PROXY_H_
     18 #define SHILL_DBUS_CHROMEOS_MODEM_GSM_CARD_PROXY_H_
     19 
     20 #include <string>
     21 
     22 #include <base/macros.h>
     23 
     24 #include "cellular/dbus-proxies.h"
     25 #include "shill/cellular/modem_gsm_card_proxy_interface.h"
     26 
     27 namespace shill {
     28 
     29 // A proxy to (old) ModemManager.Modem.Gsm.Card.
     30 class ChromeosModemGSMCardProxy : public ModemGSMCardProxyInterface {
     31  public:
     32   // Constructs a ModemManager.Modem.Gsm.Card DBus
     33   // object proxy at |path| owned by |service|.
     34   ChromeosModemGSMCardProxy(const scoped_refptr<dbus::Bus>& bus,
     35                             const std::string& path,
     36                             const std::string& service);
     37   ~ChromeosModemGSMCardProxy() override;
     38 
     39   // Inherited from ModemGSMCardProxyInterface.
     40   void GetIMEI(Error* error,
     41                const GSMIdentifierCallback& callback,
     42                int timeout) override;
     43   void GetIMSI(Error* error,
     44                const GSMIdentifierCallback& callback,
     45                int timeout) override;
     46   void GetSPN(Error* error,
     47               const GSMIdentifierCallback& callback,
     48               int timeout) override;
     49   void GetMSISDN(Error* error,
     50                  const GSMIdentifierCallback& callback,
     51                  int timeout) override;
     52   void EnablePIN(const std::string& pin,
     53                  bool enabled,
     54                  Error* error,
     55                  const ResultCallback& callback,
     56                  int timeout) override;
     57   void SendPIN(const std::string& pin,
     58                Error* error,
     59                const ResultCallback& callback,
     60                int timeout) override;
     61   void SendPUK(const std::string& puk,
     62                const std::string& pin,
     63                Error* error,
     64                const ResultCallback& callback,
     65                int timeout) override;
     66   void ChangePIN(const std::string& old_pin,
     67                  const std::string& new_pin,
     68                  Error* error,
     69                  const ResultCallback& callback,
     70                  int timeout) override;
     71   uint32_t EnabledFacilityLocks() override;
     72 
     73  private:
     74   class PropertySet : public dbus::PropertySet {
     75    public:
     76     PropertySet(dbus::ObjectProxy* object_proxy,
     77                 const std::string& interface_name,
     78                 const PropertyChangedCallback& callback);
     79     brillo::dbus_utils::Property<uint32_t> enabled_facility_locks;
     80 
     81    private:
     82     DISALLOW_COPY_AND_ASSIGN(PropertySet);
     83   };
     84 
     85   static const char kPropertyEnabledFacilityLocks[];
     86 
     87   // Callbacks for various GSMIdentifier Get async calls.
     88   void OnGetGSMIdentifierSuccess(const GSMIdentifierCallback& callback,
     89                                  const std::string& identifier_name,
     90                                  const std::string& identifier_value);
     91   void OnGetGSMIdentifierFailure(const GSMIdentifierCallback& callback,
     92                                  const std::string& identifier_name,
     93                                  brillo::Error* dbus_error);
     94   void OnOperationSuccess(const ResultCallback& callback,
     95                           const std::string& operation_name);
     96   void OnOperationFailure(const ResultCallback& callback,
     97                           const std::string& operation_name,
     98                           brillo::Error* dbus_error);
     99 
    100   // Callback invoked when the value of property |property_name| is changed.
    101   void OnPropertyChanged(const std::string& property_name);
    102 
    103   std::unique_ptr<org::freedesktop::ModemManager::Modem::Gsm::CardProxy> proxy_;
    104   std::unique_ptr<PropertySet> properties_;
    105 
    106   base::WeakPtrFactory<ChromeosModemGSMCardProxy> weak_factory_{this};
    107   DISALLOW_COPY_AND_ASSIGN(ChromeosModemGSMCardProxy);
    108 };
    109 
    110 }  // namespace shill
    111 
    112 #endif  // SHILL_DBUS_CHROMEOS_MODEM_GSM_CARD_PROXY_H_
    113