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_SIM_PROXY_H_
18 #define SHILL_DBUS_CHROMEOS_MM1_SIM_PROXY_H_
19 
20 #include <string>
21 
22 #include "cellular/dbus-proxies.h"
23 #include "shill/cellular/mm1_sim_proxy_interface.h"
24 
25 namespace shill {
26 namespace mm1 {
27 
28 // A proxy to org.freedesktop.ModemManager1.Sim.
29 class ChromeosSimProxy : public SimProxyInterface {
30  public:
31   // Constructs an org.freedesktop.ModemManager1.Sim DBus object
32   // proxy at |path| owned by |service|.
33   ChromeosSimProxy(const scoped_refptr<dbus::Bus>& bus,
34                    const std::string& path,
35                    const std::string& service);
36   ~ChromeosSimProxy() override;
37 
38   // Inherited methods from SimProxyInterface.
39   void SendPin(const std::string& pin,
40                Error* error,
41                const ResultCallback& callback,
42                int timeout) override;
43   void SendPuk(const std::string& puk,
44                const std::string& pin,
45                Error* error,
46                const ResultCallback& callback,
47                int timeout) override;
48   void EnablePin(const std::string& pin,
49                  const bool enabled,
50                  Error* error,
51                  const ResultCallback& callback,
52                  int timeout) override;
53   void ChangePin(const std::string& old_pin,
54                  const std::string& new_pin,
55                  Error* error,
56                  const ResultCallback& callback,
57                  int timeout) override;
58 
59  private:
60   // Callbacks for async method calls.
61   void OnOperationSuccess(const ResultCallback& callback,
62                           const std::string& operation);
63   void OnOperationFailure(const ResultCallback& callback,
64                           const std::string& operation,
65                           brillo::Error* dbus_error);
66 
67   std::unique_ptr<org::freedesktop::ModemManager1::SimProxy> proxy_;
68 
69   base::WeakPtrFactory<ChromeosSimProxy> weak_factory_{this};
70   DISALLOW_COPY_AND_ASSIGN(ChromeosSimProxy);
71 };
72 
73 }  // namespace mm1
74 }  // namespace shill
75 
76 #endif  // SHILL_DBUS_CHROMEOS_MM1_SIM_PROXY_H_
77