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_SERVICE_DBUS_ADAPTOR_H_ 18 #define SHILL_DBUS_CHROMEOS_SERVICE_DBUS_ADAPTOR_H_ 19 20 #include <map> 21 #include <string> 22 #include <vector> 23 24 #include <base/macros.h> 25 26 #include "dbus_bindings/org.chromium.flimflam.Service.h" 27 #include "shill/adaptor_interfaces.h" 28 #include "shill/dbus/chromeos_dbus_adaptor.h" 29 30 namespace shill { 31 32 class Service; 33 34 // Subclass of DBusAdaptor for Service objects 35 // There is a 1:1 mapping between Service and ChromeosServiceDBusAdaptor 36 // instances. Furthermore, the Service owns the ChromeosServiceDBusAdaptor 37 // and manages its lifetime, so we're OK with ChromeosServiceDBusAdaptor 38 // having a bare pointer to its owner service. 39 class ChromeosServiceDBusAdaptor 40 : public org::chromium::flimflam::ServiceAdaptor, 41 public org::chromium::flimflam::ServiceInterface, 42 public ChromeosDBusAdaptor, 43 public ServiceAdaptorInterface { 44 public: 45 static const char kPath[]; 46 47 ChromeosServiceDBusAdaptor(const scoped_refptr<dbus::Bus>& bus, 48 Service* service); 49 ~ChromeosServiceDBusAdaptor() override; 50 51 // Implementation of ServiceAdaptorInterface. 52 const std::string& GetRpcIdentifier() override { return dbus_path().value(); } 53 void EmitBoolChanged(const std::string& name, bool value) override; 54 void EmitUint8Changed(const std::string& name, uint8_t value) override; 55 void EmitUint16Changed(const std::string& name, uint16_t value) override; 56 void EmitUint16sChanged(const std::string& name, 57 const Uint16s& value) override; 58 void EmitUintChanged(const std::string& name, uint32_t value) override; 59 void EmitIntChanged(const std::string& name, int value) override; 60 void EmitRpcIdentifierChanged( 61 const std::string& name, const std::string& value) override; 62 void EmitStringChanged( 63 const std::string& name, const std::string& value) override; 64 void EmitStringmapChanged(const std::string& name, 65 const Stringmap& value) override; 66 67 // Implementation of ServiceAdaptor 68 bool GetProperties(brillo::ErrorPtr* error, 69 brillo::VariantDictionary* properties) override; 70 bool SetProperty(brillo::ErrorPtr* error, 71 const std::string& name, 72 const brillo::Any& value) override; 73 bool SetProperties(brillo::ErrorPtr* error, 74 const brillo::VariantDictionary& properties) override; 75 bool ClearProperty(brillo::ErrorPtr* error, 76 const std::string& name) override; 77 bool ClearProperties(brillo::ErrorPtr* error, 78 const std::vector<std::string>& names, 79 std::vector<bool>* results) override; 80 bool Connect(brillo::ErrorPtr* error) override; 81 bool Disconnect(brillo::ErrorPtr* error) override; 82 bool Remove(brillo::ErrorPtr* error) override; 83 void ActivateCellularModem(DBusMethodResponsePtr<> response, 84 const std::string& carrier) override; 85 bool CompleteCellularActivation(brillo::ErrorPtr* error) override; 86 bool GetLoadableProfileEntries( 87 brillo::ErrorPtr* error, 88 std::map<dbus::ObjectPath, std::string>* entries) override; 89 90 Service* service() const { return service_; } 91 92 private: 93 Service* service_; 94 95 DISALLOW_COPY_AND_ASSIGN(ChromeosServiceDBusAdaptor); 96 }; 97 98 } // namespace shill 99 100 #endif // SHILL_DBUS_CHROMEOS_SERVICE_DBUS_ADAPTOR_H_ 101