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_DBUS_CONTROL_H_
     18 #define SHILL_DBUS_CHROMEOS_DBUS_CONTROL_H_
     19 
     20 #include <memory>
     21 #include <string>
     22 
     23 #include <brillo/dbus/exported_object_manager.h>
     24 
     25 #include "shill/control_interface.h"
     26 
     27 namespace shill {
     28 
     29 class EventDispatcher;
     30 class Manager;
     31 
     32 class ChromeosDBusControl : public ControlInterface {
     33  public:
     34   ChromeosDBusControl(EventDispatcher* dispatcher);
     35   ~ChromeosDBusControl() override;
     36 
     37   void RegisterManagerObject(
     38       Manager* manager,
     39       const base::Closure& registration_done_callback) override;
     40   DeviceAdaptorInterface* CreateDeviceAdaptor(Device* device) override;
     41   IPConfigAdaptorInterface* CreateIPConfigAdaptor(IPConfig* ipconfig) override;
     42   ManagerAdaptorInterface* CreateManagerAdaptor(Manager* manager) override;
     43   ProfileAdaptorInterface* CreateProfileAdaptor(Profile* profile) override;
     44   RPCTaskAdaptorInterface* CreateRPCTaskAdaptor(RPCTask* task) override;
     45   ServiceAdaptorInterface* CreateServiceAdaptor(Service* service) override;
     46 #ifndef DISABLE_VPN
     47   ThirdPartyVpnAdaptorInterface* CreateThirdPartyVpnAdaptor(
     48       ThirdPartyVpnDriver* driver) override;
     49 #endif
     50 
     51   const std::string& NullRPCIdentifier() override;
     52 
     53   // The caller retains ownership of 'delegate'.  It must not be deleted before
     54   // the proxy.
     55   PowerManagerProxyInterface* CreatePowerManagerProxy(
     56       PowerManagerProxyDelegate* delegate,
     57       const base::Closure& service_appeared_callback,
     58       const base::Closure& service_vanished_callback) override;
     59 
     60 #if !defined(DISABLE_WIFI) || !defined(DISABLE_WIRED_8021X)
     61   SupplicantProcessProxyInterface* CreateSupplicantProcessProxy(
     62       const base::Closure& service_appeared_callback,
     63       const base::Closure& service_vanished_callback) override;
     64 
     65   SupplicantInterfaceProxyInterface* CreateSupplicantInterfaceProxy(
     66       SupplicantEventDelegateInterface* delegate,
     67       const std::string& object_path) override;
     68 
     69   SupplicantNetworkProxyInterface* CreateSupplicantNetworkProxy(
     70       const std::string& object_path) override;
     71 #endif  // DISABLE_WIFI || DISABLE_WIRED_8021X
     72 
     73 #if !defined(DISABLE_WIFI)
     74   // See comment in supplicant_bss_proxy.h, about bare pointer.
     75   SupplicantBSSProxyInterface* CreateSupplicantBSSProxy(
     76       WiFiEndpoint* wifi_endpoint,
     77       const std::string& object_path) override;
     78 #endif  // DISABLE_WIFI
     79 
     80   UpstartProxyInterface* CreateUpstartProxy() override;
     81 
     82   DHCPCDListenerInterface* CreateDHCPCDListener(
     83       DHCPProvider* provider) override;
     84 
     85   DHCPProxyInterface* CreateDHCPProxy(const std::string& service) override;
     86 
     87   FirewallProxyInterface* CreateFirewallProxy() override;
     88 
     89 #if !defined(DISABLE_CELLULAR)
     90   DBusPropertiesProxyInterface* CreateDBusPropertiesProxy(
     91       const std::string& path,
     92       const std::string& service) override;
     93 
     94   DBusObjectManagerProxyInterface* CreateDBusObjectManagerProxy(
     95       const std::string& path,
     96       const std::string& service,
     97       const base::Closure& service_appeared_callback,
     98       const base::Closure& service_vanished_callback) override;
     99 
    100   ModemManagerProxyInterface* CreateModemManagerProxy(
    101       ModemManagerClassic* manager,
    102       const std::string& path,
    103       const std::string& service,
    104       const base::Closure& service_appeared_callback,
    105       const base::Closure& service_vanished_callback) override;
    106 
    107   ModemProxyInterface* CreateModemProxy(const std::string& path,
    108                                         const std::string& service) override;
    109 
    110   ModemSimpleProxyInterface* CreateModemSimpleProxy(
    111       const std::string& path,
    112       const std::string& service) override;
    113 
    114   ModemCDMAProxyInterface* CreateModemCDMAProxy(
    115       const std::string& path,
    116       const std::string& service) override;
    117 
    118   ModemGSMCardProxyInterface* CreateModemGSMCardProxy(
    119       const std::string& path,
    120       const std::string& service) override;
    121 
    122   ModemGSMNetworkProxyInterface* CreateModemGSMNetworkProxy(
    123       const std::string& path,
    124       const std::string& service) override;
    125 
    126   ModemGobiProxyInterface* CreateModemGobiProxy(
    127       const std::string& path,
    128       const std::string& service) override;
    129 
    130   // Proxies for ModemManager1 interfaces
    131   mm1::ModemModem3gppProxyInterface* CreateMM1ModemModem3gppProxy(
    132       const std::string& path,
    133       const std::string& service) override;
    134 
    135   mm1::ModemModemCdmaProxyInterface* CreateMM1ModemModemCdmaProxy(
    136       const std::string& path,
    137       const std::string& service) override;
    138 
    139   mm1::ModemProxyInterface* CreateMM1ModemProxy(
    140       const std::string& path,
    141       const std::string& service) override;
    142 
    143   mm1::ModemSimpleProxyInterface* CreateMM1ModemSimpleProxy(
    144       const std::string& path,
    145       const std::string& service) override;
    146 
    147   mm1::SimProxyInterface* CreateSimProxy(
    148       const std::string& path,
    149       const std::string& service) override;
    150 #endif  // DISABLE_CELLULAR
    151 
    152 #if !defined(DISABLE_WIMAX)
    153   WiMaxDeviceProxyInterface* CreateWiMaxDeviceProxy(
    154       const std::string& path) override;
    155   WiMaxManagerProxyInterface* CreateWiMaxManagerProxy(
    156       const base::Closure& service_appeared_callback,
    157       const base::Closure& service_vanished_callback) override;
    158   WiMaxNetworkProxyInterface* CreateWiMaxNetworkProxy(
    159       const std::string& path) override;
    160 #endif  // DISABLE_WIMAX
    161 
    162  private:
    163   template <typename Object, typename AdaptorInterface, typename Adaptor>
    164   AdaptorInterface* CreateAdaptor(Object* object);
    165 
    166   void OnDBusServiceRegistered(
    167       const base::Callback<void(bool)>& completion_action, bool success);
    168   void TakeServiceOwnership(bool success);
    169 
    170   static const char kNullPath[];
    171 
    172   // Use separate bus connection for adaptors and proxies.  This allows the
    173   // proxy to receive all broadcast signal messages that it is interested in.
    174   // Refer to crbug.com/446837 for more info.
    175   scoped_refptr<dbus::Bus> adaptor_bus_;
    176   scoped_refptr<dbus::Bus> proxy_bus_;
    177   EventDispatcher* dispatcher_;
    178   std::string null_identifier_;
    179   base::Closure registration_done_callback_;
    180 };
    181 
    182 }  // namespace shill
    183 
    184 #endif  // SHILL_DBUS_CHROMEOS_DBUS_CONTROL_H_
    185