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_IPCONFIG_DBUS_ADAPTOR_H_
     18 #define SHILL_DBUS_CHROMEOS_IPCONFIG_DBUS_ADAPTOR_H_
     19 
     20 #include <string>
     21 #include <vector>
     22 
     23 #include <base/macros.h>
     24 
     25 #include "dbus_bindings/org.chromium.flimflam.IPConfig.h"
     26 #include "shill/adaptor_interfaces.h"
     27 #include "shill/dbus/chromeos_dbus_adaptor.h"
     28 
     29 namespace shill {
     30 
     31 class IPConfig;
     32 
     33 // Subclass of DBusAdaptor for IPConfig objects
     34 // There is a 1:1 mapping between IPConfig and ChromeosIPConfigDBusAdaptor
     35 // instances.  Furthermore, the IPConfig owns the ChromeosIPConfigDBusAdaptor
     36 // and manages its lifetime, so we're OK with ChromeosIPConfigDBusAdaptor
     37 // having a bare pointer to its owner ipconfig.
     38 class ChromeosIPConfigDBusAdaptor
     39     : public org::chromium::flimflam::IPConfigAdaptor,
     40       public org::chromium::flimflam::IPConfigInterface,
     41       public ChromeosDBusAdaptor,
     42       public IPConfigAdaptorInterface {
     43  public:
     44   static const char kInterfaceName[];
     45   static const char kPath[];
     46 
     47   ChromeosIPConfigDBusAdaptor(const scoped_refptr<dbus::Bus>& bus,
     48                               IPConfig* ipconfig);
     49   ~ChromeosIPConfigDBusAdaptor() override;
     50 
     51   // Implementation of IPConfigAdaptorInterface.
     52   const std::string& GetRpcIdentifier() override { return dbus_path().value(); }
     53   void EmitBoolChanged(const std::string& name, bool value) override;
     54   void EmitUintChanged(const std::string& name, uint32_t value) override;
     55   void EmitIntChanged(const std::string& name, int value) override;
     56   void EmitStringChanged(const std::string& name,
     57                          const std::string& value) override;
     58   void EmitStringsChanged(const std::string& name,
     59                           const std::vector<std::string>& value) override;
     60 
     61   // Implementation of IPConfigAdaptor
     62   bool GetProperties(brillo::ErrorPtr* error,
     63                      brillo::VariantDictionary* properties) override;
     64   bool SetProperty(brillo::ErrorPtr* error,
     65                    const std::string& name,
     66                    const brillo::Any& value) override;
     67   bool ClearProperty(brillo::ErrorPtr* error,
     68                      const std::string& name) override;
     69   bool Remove(brillo::ErrorPtr* error) override;
     70   bool Refresh(brillo::ErrorPtr* error) override;
     71 
     72  private:
     73   IPConfig* ipconfig_;
     74   DISALLOW_COPY_AND_ASSIGN(ChromeosIPConfigDBusAdaptor);
     75 };
     76 
     77 }  // namespace shill
     78 
     79 #endif  // SHILL_DBUS_CHROMEOS_IPCONFIG_DBUS_ADAPTOR_H_
     80