1 //
2 // Copyright (C) 2012 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_CONTROL_INTERFACE_H_
18 #define SHILL_CONTROL_INTERFACE_H_
19 
20 #include <algorithm>
21 #include <string>
22 
23 #include <base/callback.h>
24 
25 #include "shill/logging.h"
26 
27 namespace shill {
28 
29 class Device;
30 class DeviceAdaptorInterface;
31 class IPConfig;
32 class IPConfigAdaptorInterface;
33 class Manager;
34 class ManagerAdaptorInterface;
35 class Profile;
36 class ProfileAdaptorInterface;
37 class RPCTask;
38 class RPCTaskAdaptorInterface;
39 class Service;
40 class ServiceAdaptorInterface;
41 class ThirdPartyVpnDriver;
42 class ThirdPartyVpnAdaptorInterface;
43 
44 class DBusObjectManagerProxyInterface;
45 class DBusPropertiesProxyInterface;
46 class DHCPCDListenerInterface;
47 class DHCPProvider;
48 class DHCPProxyInterface;
49 class FirewallProxyInterface;
50 class ModemCDMAProxyInterface;
51 class ModemGSMCardProxyInterface;
52 class ModemGSMNetworkProxyInterface;
53 class ModemGobiProxyInterface;
54 class ModemManagerClassic;
55 class ModemManagerProxyInterface;
56 class ModemProxyInterface;
57 class ModemSimpleProxyInterface;
58 class PowerManagerProxyDelegate;
59 class PowerManagerProxyInterface;
60 class UpstartProxyInterface;
61 class WiMaxDeviceProxyInterface;
62 class WiMaxManagerProxyInterface;
63 class WiMaxNetworkProxyInterface;
64 
65 #if !defined(DISABLE_WIFI)
66 class SupplicantBSSProxyInterface;
67 class WiFiEndpoint;
68 #endif  // DISABLE_WIFI
69 
70 #if !defined(DISABLE_WIFI) || !defined(DISABLE_WIRED_8021X)
71 class SupplicantEventDelegateInterface;
72 class SupplicantInterfaceProxyInterface;
73 class SupplicantNetworkProxyInterface;
74 class SupplicantProcessProxyInterface;
75 #endif  // DISABLE_WIFI || DISABLE_WIRED_8021X
76 
77 namespace mm1 {
78 
79 class ModemModem3gppProxyInterface;
80 class ModemModemCdmaProxyInterface;
81 class ModemProxyInterface;
82 class ModemSimpleProxyInterface;
83 class SimProxyInterface;
84 
85 }  // namespace mm1
86 
87 class RPCServiceWatcherInterface;
88 
89 // This is the Interface for an object factory that creates adaptor/proxy
90 // objects
91 class ControlInterface {
92  public:
~ControlInterface()93   virtual ~ControlInterface() {}
94   virtual void RegisterManagerObject(
95       Manager* manager, const base::Closure& registration_done_callback) = 0;
96   virtual DeviceAdaptorInterface* CreateDeviceAdaptor(Device* device) = 0;
97   virtual IPConfigAdaptorInterface* CreateIPConfigAdaptor(
98       IPConfig* ipconfig) = 0;
99   virtual ManagerAdaptorInterface* CreateManagerAdaptor(Manager* manager) = 0;
100   virtual ProfileAdaptorInterface* CreateProfileAdaptor(Profile* profile) = 0;
101   virtual ServiceAdaptorInterface* CreateServiceAdaptor(Service* service) = 0;
102   virtual RPCTaskAdaptorInterface* CreateRPCTaskAdaptor(RPCTask* task) = 0;
103 #ifndef DISABLE_VPN
104   virtual ThirdPartyVpnAdaptorInterface* CreateThirdPartyVpnAdaptor(
105       ThirdPartyVpnDriver* driver) = 0;
106 #endif
107 
108   virtual const std::string& NullRPCIdentifier() = 0;
109 
110   // The caller retains ownership of 'delegate'.  It must not be deleted before
111   // the proxy.
112   virtual PowerManagerProxyInterface* CreatePowerManagerProxy(
113       PowerManagerProxyDelegate* delegate,
114       const base::Closure& service_appeared_callback,
115       const base::Closure& service_vanished_callback) = 0;
116 
117 #if !defined(DISABLE_WIFI) || !defined(DISABLE_WIRED_8021X)
118   virtual SupplicantProcessProxyInterface* CreateSupplicantProcessProxy(
119       const base::Closure& service_appeared_callback,
120       const base::Closure& service_vanished_callback) = 0;
121 
122   virtual SupplicantInterfaceProxyInterface* CreateSupplicantInterfaceProxy(
123       SupplicantEventDelegateInterface* delegate,
124       const std::string& object_path) = 0;
125 
126   virtual SupplicantNetworkProxyInterface* CreateSupplicantNetworkProxy(
127       const std::string& object_path) = 0;
128 #endif  // DISABLE_WIFI || DISABLE_WIRED_8021X
129 
130 #if !defined(DISABLE_WIFI)
131   // See comment in supplicant_bss_proxy.h, about bare pointer.
132   virtual SupplicantBSSProxyInterface* CreateSupplicantBSSProxy(
133       WiFiEndpoint* wifi_endpoint,
134       const std::string& object_path) = 0;
135 #endif  // DISABLE_WIFI
136 
137   virtual UpstartProxyInterface* CreateUpstartProxy() = 0;
138 
139   virtual DHCPCDListenerInterface* CreateDHCPCDListener(
140       DHCPProvider* provider) = 0;
141 
142   virtual DHCPProxyInterface* CreateDHCPProxy(const std::string& service) = 0;
143 
144   virtual FirewallProxyInterface* CreateFirewallProxy() = 0;
145 
146 #if !defined(DISABLE_CELLULAR)
147   virtual DBusPropertiesProxyInterface* CreateDBusPropertiesProxy(
148       const std::string& path,
149       const std::string& service) = 0;
150 
151   virtual DBusObjectManagerProxyInterface* CreateDBusObjectManagerProxy(
152       const std::string& path,
153       const std::string& service,
154       const base::Closure& service_appeared_callback,
155       const base::Closure& service_vanished_callback) = 0;
156 
157   virtual ModemManagerProxyInterface* CreateModemManagerProxy(
158       ModemManagerClassic* manager,
159       const std::string& path,
160       const std::string& service,
161       const base::Closure& service_appeared_callback,
162       const base::Closure& service_vanished_callback) = 0;
163 
164   virtual ModemProxyInterface* CreateModemProxy(const std::string& path,
165                                                 const std::string& service) = 0;
166 
167   virtual ModemSimpleProxyInterface* CreateModemSimpleProxy(
168       const std::string& path,
169       const std::string& service) = 0;
170 
171   virtual ModemCDMAProxyInterface* CreateModemCDMAProxy(
172       const std::string& path,
173       const std::string& service) = 0;
174 
175   virtual ModemGSMCardProxyInterface* CreateModemGSMCardProxy(
176       const std::string& path,
177       const std::string& service) = 0;
178 
179   virtual ModemGSMNetworkProxyInterface* CreateModemGSMNetworkProxy(
180       const std::string& path,
181       const std::string& service) = 0;
182 
183   virtual ModemGobiProxyInterface* CreateModemGobiProxy(
184       const std::string& path,
185       const std::string& service) = 0;
186 
187   // Proxies for ModemManager1 interfaces
188   virtual mm1::ModemModem3gppProxyInterface* CreateMM1ModemModem3gppProxy(
189       const std::string& path,
190       const std::string& service) = 0;
191 
192   virtual mm1::ModemModemCdmaProxyInterface* CreateMM1ModemModemCdmaProxy(
193       const std::string& path,
194       const std::string& service) = 0;
195 
196   virtual mm1::ModemProxyInterface* CreateMM1ModemProxy(
197       const std::string& path,
198       const std::string& service) = 0;
199 
200   virtual mm1::ModemSimpleProxyInterface* CreateMM1ModemSimpleProxy(
201       const std::string& path,
202       const std::string& service) = 0;
203 
204   virtual mm1::SimProxyInterface* CreateSimProxy(
205       const std::string& path,
206       const std::string& service) = 0;
207 #endif  // DISABLE_CELLULAR
208 
209 #if !defined(DISABLE_WIMAX)
210   virtual WiMaxDeviceProxyInterface* CreateWiMaxDeviceProxy(
211       const std::string& path) = 0;
212   virtual WiMaxManagerProxyInterface* CreateWiMaxManagerProxy(
213       const base::Closure& service_appeared_callback,
214       const base::Closure& service_vanished_callback) = 0;
215   virtual WiMaxNetworkProxyInterface* CreateWiMaxNetworkProxy(
216       const std::string& path) = 0;
217 #endif  // DISABLE_WIMAX
218 
RpcIdToStorageId(std::string * rpc_id)219   static void RpcIdToStorageId(std::string* rpc_id) {
220     CHECK(rpc_id);
221     DCHECK_EQ(rpc_id->at(0), '/');
222     rpc_id->erase(0, 1);
223     std::replace(rpc_id->begin(), rpc_id->end(), '/', '_');
224   }
225 };
226 
227 }  // namespace shill
228 
229 #endif  // SHILL_CONTROL_INTERFACE_H_
230