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_DEVICE_DBUS_ADAPTOR_H_
     18 #define SHILL_DBUS_CHROMEOS_DEVICE_DBUS_ADAPTOR_H_
     19 
     20 #include <string>
     21 #include <vector>
     22 
     23 #include <base/macros.h>
     24 
     25 #include "dbus_bindings/org.chromium.flimflam.Device.h"
     26 #include "shill/adaptor_interfaces.h"
     27 #include "shill/dbus/chromeos_dbus_adaptor.h"
     28 
     29 namespace shill {
     30 
     31 class Device;
     32 
     33 // There is a 1:1 mapping between Device and DeviceDBusAdaptor instances.
     34 // Furthermore, the Device owns the DeviceDBusAdaptor and manages its lifetime,
     35 // so we're OK with DeviceDBusAdaptor having a bare pointer to its owner device.
     36 class ChromeosDeviceDBusAdaptor
     37     : public org::chromium::flimflam::DeviceAdaptor,
     38       public org::chromium::flimflam::DeviceInterface,
     39       public ChromeosDBusAdaptor,
     40       public DeviceAdaptorInterface {
     41  public:
     42   static const char kPath[];
     43 
     44   ChromeosDeviceDBusAdaptor(
     45       const scoped_refptr<dbus::Bus>& bus,
     46       Device* device);
     47   ~ChromeosDeviceDBusAdaptor() override;
     48 
     49   // Implementation of DeviceAdaptorInterface.
     50   const std::string& GetRpcIdentifier() override;
     51   void EmitBoolChanged(const std::string& name, bool value) override;
     52   void EmitUintChanged(const std::string& name, uint32_t value) override;
     53   void EmitUint16Changed(const std::string& name, uint16_t value) override;
     54   void EmitIntChanged(const std::string& name, int value) override;
     55   void EmitStringChanged(const std::string& name,
     56                          const std::string& value) override;
     57   void EmitStringmapChanged(const std::string& name,
     58                             const Stringmap& value) override;
     59   void EmitStringmapsChanged(const std::string& name,
     60                              const Stringmaps& value) override;
     61   void EmitStringsChanged(const std::string& name,
     62                           const Strings& value) override;
     63   void EmitKeyValueStoreChanged(const std::string& name,
     64                                 const KeyValueStore& value) override;
     65   void EmitRpcIdentifierChanged(const std::string& name,
     66                                 const std::string& value) override;
     67   void EmitRpcIdentifierArrayChanged(
     68       const std::string& name, const std::vector<std::string>& value) override;
     69 
     70   // Implementation of DeviceAdaptor.
     71   bool GetProperties(brillo::ErrorPtr* error,
     72                      brillo::VariantDictionary* out_properties) override;
     73   bool SetProperty(brillo::ErrorPtr* error,
     74                    const std::string& name,
     75                    const brillo::Any& value) override;
     76   bool ClearProperty(brillo::ErrorPtr* error,
     77                      const std::string& name) override;
     78   void Enable(DBusMethodResponsePtr<> response) override;
     79   void Disable(DBusMethodResponsePtr<> response) override;
     80   bool ProposeScan(brillo::ErrorPtr* error) override;
     81   bool AddIPConfig(brillo::ErrorPtr* error,
     82                    const std::string& method,
     83                    dbus::ObjectPath* out_path) override;
     84   void Register(DBusMethodResponsePtr<> response,
     85                 const std::string& network_id) override;
     86   void RequirePin(DBusMethodResponsePtr<> response,
     87                   const std::string& pin,
     88                   bool require) override;
     89   void EnterPin(DBusMethodResponsePtr<> response,
     90                 const std::string& pin) override;
     91   void UnblockPin(DBusMethodResponsePtr<> response,
     92                   const std::string& unblock_code,
     93                   const std::string& pin) override;
     94   void ChangePin(DBusMethodResponsePtr<> response,
     95                  const std::string& old_pin,
     96                  const std::string& new_pin) override;
     97   bool PerformTDLSOperation(brillo::ErrorPtr* error,
     98                             const std::string& operation,
     99                             const std::string& peer,
    100                             std::string* out_state) override;
    101   void Reset(DBusMethodResponsePtr<> response) override;
    102   bool ResetByteCounters(brillo::ErrorPtr* error) override;
    103   bool RequestRoam(brillo::ErrorPtr* error,
    104                    const std::string& addr) override;
    105   void SetCarrier(DBusMethodResponsePtr<> response,
    106                   const std::string& carrierr) override;
    107   bool AddWakeOnPacketConnection(brillo::ErrorPtr* error,
    108                                  const std::string& ip_endpoint) override;
    109   bool RemoveWakeOnPacketConnection(brillo::ErrorPtr* error,
    110                                     const std::string& ip_endpoint) override;
    111   bool RemoveAllWakeOnPacketConnections(brillo::ErrorPtr* error) override;
    112 
    113   Device* device() const { return device_; }
    114 
    115  private:
    116   Device* device_;
    117 
    118   DISALLOW_COPY_AND_ASSIGN(ChromeosDeviceDBusAdaptor);
    119 };
    120 
    121 }  // namespace shill
    122 
    123 #endif  // SHILL_DBUS_CHROMEOS_DEVICE_DBUS_ADAPTOR_H_
    124