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_RPC_TASK_DBUS_ADAPTOR_H_
     18 #define SHILL_DBUS_CHROMEOS_RPC_TASK_DBUS_ADAPTOR_H_
     19 
     20 #include <map>
     21 #include <string>
     22 
     23 #include <base/macros.h>
     24 
     25 #include "dbus_bindings/org.chromium.flimflam.Task.h"
     26 #include "shill/adaptor_interfaces.h"
     27 #include "shill/dbus/chromeos_dbus_adaptor.h"
     28 
     29 namespace shill {
     30 
     31 class RPCTask;
     32 
     33 // Subclass of DBusAdaptor for RPCTask objects. There is a 1:1 mapping between
     34 // RPCTask and ChromeosRPCTaskDBusAdaptor instances. Furthermore, the RPCTask
     35 // owns the ChromeosRPCTaskDBusAdaptor and manages its lifetime, so we're OK
     36 // with RPCTaskDBusAdaptor having a bare pointer to its owner task.
     37 class ChromeosRPCTaskDBusAdaptor
     38     : public org::chromium::flimflam::TaskAdaptor,
     39       public org::chromium::flimflam::TaskInterface,
     40       public ChromeosDBusAdaptor,
     41       public RPCTaskAdaptorInterface {
     42  public:
     43   static const char kPath[];
     44 
     45   ChromeosRPCTaskDBusAdaptor(const scoped_refptr<dbus::Bus>& bus,
     46                              RPCTask* task);
     47   ~ChromeosRPCTaskDBusAdaptor() override;
     48 
     49   // Implementation of RPCTaskAdaptorInterface.
     50   const std::string& GetRpcIdentifier() override;
     51   const std::string& GetRpcConnectionIdentifier() override;
     52 
     53   // Implementation of TaskAdaptor
     54   bool getsec(brillo::ErrorPtr* error,
     55               std::string* user,
     56               std::string* password) override;
     57   bool notify(brillo::ErrorPtr* error,
     58               const std::string& reason,
     59               const std::map<std::string, std::string>& dict) override;
     60 
     61  private:
     62   RPCTask* task_;
     63   const std::string connection_name_;
     64 
     65   DISALLOW_COPY_AND_ASSIGN(ChromeosRPCTaskDBusAdaptor);
     66 };
     67 
     68 }  // namespace shill
     69 
     70 #endif  // SHILL_DBUS_CHROMEOS_RPC_TASK_DBUS_ADAPTOR_H_
     71