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_DBUS_PROPERTIES_PROXY_H_
18 #define SHILL_DBUS_CHROMEOS_DBUS_PROPERTIES_PROXY_H_
19 
20 #include <string>
21 #include <vector>
22 
23 #include <base/macros.h>
24 
25 #include "cellular/dbus-proxies.h"
26 #include "shill/dbus_properties_proxy_interface.h"
27 
28 namespace shill {
29 
30 // DBusPropertiesProxyInterface is a cellular-specific interface, refer to its
31 // header for more info.
32 class ChromeosDBusPropertiesProxy : public DBusPropertiesProxyInterface {
33  public:
34   ChromeosDBusPropertiesProxy(const scoped_refptr<dbus::Bus>& bus,
35                               const std::string& path,
36                               const std::string& service);
37   ~ChromeosDBusPropertiesProxy() override;
38 
39   // Inherited from DBusPropertiesProxyInterface.
40   KeyValueStore GetAll(const std::string& interface_name) override;
41   brillo::Any Get(const std::string& interface_name,
42                   const std::string& property) override;
43 
set_properties_changed_callback(const PropertiesChangedCallback & callback)44   void set_properties_changed_callback(
45       const PropertiesChangedCallback& callback) override {
46     properties_changed_callback_ = callback;
47   }
48 
set_modem_manager_properties_changed_callback(const ModemManagerPropertiesChangedCallback & callback)49   void set_modem_manager_properties_changed_callback(
50       const ModemManagerPropertiesChangedCallback& callback) override {
51     mm_properties_changed_callback_ = callback;
52   }
53 
54  private:
55   // Signal handlers.
56   void MmPropertiesChanged(
57       const std::string& interface,
58       const brillo::VariantDictionary& properties);
59   void PropertiesChanged(
60       const std::string& interface,
61       const brillo::VariantDictionary& changed_properties,
62       const std::vector<std::string>& invalidated_properties);
63 
64   // Called when signal is connected to the ObjectProxy.
65   void OnSignalConnected(const std::string& interface_name,
66                          const std::string& signal_name,
67                          bool success);
68 
69   PropertiesChangedCallback properties_changed_callback_;
70   ModemManagerPropertiesChangedCallback mm_properties_changed_callback_;
71 
72   std::unique_ptr<org::freedesktop::DBus::PropertiesProxy> proxy_;
73 
74   base::WeakPtrFactory<ChromeosDBusPropertiesProxy> weak_factory_{this};
75   DISALLOW_COPY_AND_ASSIGN(ChromeosDBusPropertiesProxy);
76 };
77 
78 }  // namespace shill
79 
80 #endif  // SHILL_DBUS_CHROMEOS_DBUS_PROPERTIES_PROXY_H_
81