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_MODEMCDMA_PROXY_H_
18 #define SHILL_DBUS_CHROMEOS_MM1_MODEM_MODEMCDMA_PROXY_H_
19 
20 #include <string>
21 
22 #include "cellular/dbus-proxies.h"
23 #include "shill/cellular/mm1_modem_modemcdma_proxy_interface.h"
24 
25 namespace shill {
26 namespace mm1 {
27 
28 // A proxy to org.freedesktop.ModemManager1.Modem.ModemCdma.
29 class ChromeosModemModemCdmaProxy : public ModemModemCdmaProxyInterface {
30  public:
31   // Constructs a org.freedesktop.ModemManager1.Modem.ModemCdma DBus
32   // object proxy at |path| owned by |service|.
33   ChromeosModemModemCdmaProxy(const scoped_refptr<dbus::Bus>& bus,
34                               const std::string& path,
35                               const std::string& service);
36   ~ChromeosModemModemCdmaProxy() override;
37 
38   // Inherited methods from ModemModemCdmaProxyInterface.
39   void Activate(const std::string& carrier,
40                 Error* error,
41                 const ResultCallback& callback,
42                 int timeout) override;
43   void ActivateManual(
44       const KeyValueStore& properties,
45       Error* error,
46       const ResultCallback& callback,
47       int timeout) override;
48 
set_activation_state_callback(const ActivationStateSignalCallback & callback)49   void set_activation_state_callback(
50       const ActivationStateSignalCallback& callback) override {
51     activation_state_callback_ = callback;
52   }
53 
54  private:
55   // Signal handler.
56   void ActivationStateChanged(
57         uint32_t activation_state,
58         uint32_t activation_error,
59         const brillo::VariantDictionary& status_changes);
60 
61   // Callbacks for async calls that uses ResultCallback.
62   void OnOperationSuccess(const ResultCallback& callback,
63                           const std::string& operation);
64   void OnOperationFailure(const ResultCallback& callback,
65                           const std::string& operation,
66                           brillo::Error* dbus_error);
67 
68   // Called when signal is connected to the ObjectProxy.
69   void OnSignalConnected(const std::string& interface_name,
70                          const std::string& signal_name,
71                          bool success);
72 
73   ActivationStateSignalCallback activation_state_callback_;
74 
75   std::unique_ptr<org::freedesktop::ModemManager1::Modem::ModemCdmaProxy>
76       proxy_;
77 
78   base::WeakPtrFactory<ChromeosModemModemCdmaProxy> weak_factory_{this};
79   DISALLOW_COPY_AND_ASSIGN(ChromeosModemModemCdmaProxy);
80 };
81 
82 }  // namespace mm1
83 }  // namespace shill
84 
85 #endif  // SHILL_DBUS_CHROMEOS_MM1_MODEM_MODEMCDMA_PROXY_H_
86