blob: 7800f8ec4641cfd1c9b5a7aa0972ef060e90457c [file] [log] [blame]
Peter Qiu72e7e252015-06-26 16:23:46 -07001// Copyright 2015 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "shill/dbus/chromeos_dbus_control.h"
6
7#include "shill/dbus/chromeos_device_dbus_adaptor.h"
Peter Qiu484261a2015-07-07 13:42:58 -07008#include "shill/dbus/chromeos_ipconfig_dbus_adaptor.h"
9#include "shill/dbus/chromeos_manager_dbus_adaptor.h"
10#include "shill/dbus/chromeos_profile_dbus_adaptor.h"
11#include "shill/dbus/chromeos_rpc_task_dbus_adaptor.h"
12#include "shill/dbus/chromeos_service_dbus_adaptor.h"
13#include "shill/dbus/chromeos_third_party_vpn_dbus_adaptor.h"
Peter Qiu72e7e252015-06-26 16:23:46 -070014
Peter Qiuc00d1fa2015-08-13 15:00:55 -070015#include "shill/dbus/chromeos_dhcpcd_listener.h"
16#include "shill/dbus/chromeos_dhcpcd_proxy.h"
17#include "shill/dbus/chromeos_permission_broker_proxy.h"
18#include "shill/dbus/chromeos_power_manager_proxy.h"
19#include "shill/dbus/chromeos_supplicant_bss_proxy.h"
20#include "shill/dbus/chromeos_supplicant_interface_proxy.h"
21#include "shill/dbus/chromeos_supplicant_network_proxy.h"
22#include "shill/dbus/chromeos_supplicant_process_proxy.h"
23#include "shill/dbus/chromeos_upstart_proxy.h"
24
25#include "shill/dbus/chromeos_dbus_service_watcher.h"
26
Peter Qiuda6745b2015-08-17 16:32:34 -070027#if !defined(DISABLE_CELLULAR)
28#include "shill/dbus/chromeos_dbus_objectmanager_proxy.h"
29#include "shill/dbus/chromeos_dbus_properties_proxy.h"
Peter Qiu28af1072015-08-19 13:26:57 -070030#include "shill/dbus/chromeos_mm1_modem_modem3gpp_proxy.h"
31#include "shill/dbus/chromeos_mm1_modem_modemcdma_proxy.h"
32#include "shill/dbus/chromeos_mm1_modem_proxy.h"
33#include "shill/dbus/chromeos_mm1_modem_simple_proxy.h"
34#include "shill/dbus/chromeos_mm1_sim_proxy.h"
Peter Qiuf576f1b2015-08-19 09:14:41 -070035#include "shill/dbus/chromeos_modem_cdma_proxy.h"
36#include "shill/dbus/chromeos_modem_gobi_proxy.h"
37#include "shill/dbus/chromeos_modem_gsm_card_proxy.h"
38#include "shill/dbus/chromeos_modem_gsm_network_proxy.h"
39#include "shill/dbus/chromeos_modem_manager_proxy.h"
40#include "shill/dbus/chromeos_modem_proxy.h"
41#include "shill/dbus/chromeos_modem_simple_proxy.h"
Peter Qiuda6745b2015-08-17 16:32:34 -070042#endif // DISABLE_CELLULAR
43
Peter Qiuc00d1fa2015-08-13 15:00:55 -070044#if !defined(DISABLE_WIMAX)
45#include "shill/dbus/chromeos_wimax_device_proxy.h"
46#include "shill/dbus/chromeos_wimax_manager_proxy.h"
47#include "shill/dbus/chromeos_wimax_network_proxy.h"
48#endif // DISABLE_WIMAX
49
Peter Qiu72e7e252015-06-26 16:23:46 -070050using chromeos::dbus_utils::ExportedObjectManager;
Peter Qiu0d8b91f2015-07-30 16:35:26 -070051using std::string;
Peter Qiu72e7e252015-06-26 16:23:46 -070052
53namespace shill {
54
Peter Qiuc00d1fa2015-08-13 15:00:55 -070055// static.
56const char ChromeosDBusControl::kNullPath[] = "/";
57
Peter Qiu72e7e252015-06-26 16:23:46 -070058ChromeosDBusControl::ChromeosDBusControl(
Peter Qiuc00d1fa2015-08-13 15:00:55 -070059 const scoped_refptr<dbus::Bus>& bus,
60 EventDispatcher* dispatcher)
Peter Qiu526ed5f2015-08-25 13:30:47 -070061 : adaptor_bus_(bus),
Peter Qiuc00d1fa2015-08-13 15:00:55 -070062 dispatcher_(dispatcher),
Peter Qiu526ed5f2015-08-25 13:30:47 -070063 null_identifier_(kNullPath) {
64 dbus::Bus::Options options;
65 options.bus_type = dbus::Bus::SYSTEM;
Peter Qiu72e7e252015-06-26 16:23:46 -070066
Peter Qiu526ed5f2015-08-25 13:30:47 -070067 proxy_bus_ = new dbus::Bus(options);
68 CHECK(proxy_bus_->Connect());
69}
70
71ChromeosDBusControl::~ChromeosDBusControl() {
72 if (proxy_bus_) {
73 proxy_bus_->ShutdownAndBlock();
74 }
75}
Peter Qiu72e7e252015-06-26 16:23:46 -070076
Peter Qiuc00d1fa2015-08-13 15:00:55 -070077const string& ChromeosDBusControl::NullRPCIdentifier() {
78 return null_identifier_;
79}
80
Peter Qiu72e7e252015-06-26 16:23:46 -070081template <typename Object, typename AdaptorInterface, typename Adaptor>
82AdaptorInterface* ChromeosDBusControl::CreateAdaptor(Object* object) {
Peter Qiu526ed5f2015-08-25 13:30:47 -070083 return new Adaptor(adaptor_bus_, object);
Peter Qiu72e7e252015-06-26 16:23:46 -070084}
85
86DeviceAdaptorInterface* ChromeosDBusControl::CreateDeviceAdaptor(
87 Device* device) {
88 return
89 CreateAdaptor<Device, DeviceAdaptorInterface, ChromeosDeviceDBusAdaptor>(
90 device);
91}
92
Peter Qiu24b34a02015-06-30 10:22:26 -070093IPConfigAdaptorInterface* ChromeosDBusControl::CreateIPConfigAdaptor(
94 IPConfig* config) {
Peter Qiu484261a2015-07-07 13:42:58 -070095 return
96 CreateAdaptor<IPConfig, IPConfigAdaptorInterface,
97 ChromeosIPConfigDBusAdaptor>(config);
Peter Qiu24b34a02015-06-30 10:22:26 -070098}
99
100ManagerAdaptorInterface* ChromeosDBusControl::CreateManagerAdaptor(
101 Manager* manager) {
Peter Qiu484261a2015-07-07 13:42:58 -0700102 return
103 CreateAdaptor<Manager, ManagerAdaptorInterface,
104 ChromeosManagerDBusAdaptor>(manager);
Peter Qiu24b34a02015-06-30 10:22:26 -0700105}
106
107ProfileAdaptorInterface* ChromeosDBusControl::CreateProfileAdaptor(
108 Profile* profile) {
Peter Qiu484261a2015-07-07 13:42:58 -0700109 return
110 CreateAdaptor<Profile, ProfileAdaptorInterface,
111 ChromeosProfileDBusAdaptor>(profile);
Peter Qiu24b34a02015-06-30 10:22:26 -0700112}
113
114RPCTaskAdaptorInterface* ChromeosDBusControl::CreateRPCTaskAdaptor(
115 RPCTask* task) {
Peter Qiu484261a2015-07-07 13:42:58 -0700116 return
117 CreateAdaptor<RPCTask, RPCTaskAdaptorInterface,
118 ChromeosRPCTaskDBusAdaptor>(task);
Peter Qiu24b34a02015-06-30 10:22:26 -0700119}
120
121ServiceAdaptorInterface* ChromeosDBusControl::CreateServiceAdaptor(
122 Service* service) {
Peter Qiu484261a2015-07-07 13:42:58 -0700123 return
124 CreateAdaptor<Service, ServiceAdaptorInterface,
125 ChromeosServiceDBusAdaptor>(service);
Peter Qiu24b34a02015-06-30 10:22:26 -0700126}
127
128#ifndef DISABLE_VPN
129ThirdPartyVpnAdaptorInterface* ChromeosDBusControl::CreateThirdPartyVpnAdaptor(
130 ThirdPartyVpnDriver* driver) {
Peter Qiu484261a2015-07-07 13:42:58 -0700131 return
132 CreateAdaptor<ThirdPartyVpnDriver, ThirdPartyVpnAdaptorInterface,
133 ChromeosThirdPartyVpnDBusAdaptor>(driver);
Peter Qiu24b34a02015-06-30 10:22:26 -0700134}
135#endif
136
Peter Qiuc00d1fa2015-08-13 15:00:55 -0700137RPCServiceWatcherInterface* ChromeosDBusControl::CreateRPCServiceWatcher(
138 const std::string& connection_name,
139 const base::Closure& on_connection_vanished) {
Peter Qiu526ed5f2015-08-25 13:30:47 -0700140 return new ChromeosDBusServiceWatcher(proxy_bus_,
Peter Qiuc00d1fa2015-08-13 15:00:55 -0700141 connection_name,
142 on_connection_vanished);
143}
144
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700145DBusServiceProxyInterface* ChromeosDBusControl::CreateDBusServiceProxy() {
146 return nullptr;
147}
148
149PowerManagerProxyInterface* ChromeosDBusControl::CreatePowerManagerProxy(
Peter Qiuc00d1fa2015-08-13 15:00:55 -0700150 PowerManagerProxyDelegate* delegate,
151 const base::Closure& service_appeared_callback,
152 const base::Closure& service_vanished_callback) {
153 return new ChromeosPowerManagerProxy(dispatcher_,
Peter Qiu526ed5f2015-08-25 13:30:47 -0700154 proxy_bus_,
Peter Qiuc00d1fa2015-08-13 15:00:55 -0700155 delegate,
156 service_appeared_callback,
157 service_vanished_callback);
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700158}
159
160#if !defined(DISABLE_WIFI) || !defined(DISABLE_WIRED_8021X)
161SupplicantProcessProxyInterface*
162 ChromeosDBusControl::CreateSupplicantProcessProxy(
Peter Qiuc00d1fa2015-08-13 15:00:55 -0700163 const base::Closure& service_appeared_callback,
164 const base::Closure& service_vanished_callback) {
Peter Qiu526ed5f2015-08-25 13:30:47 -0700165 return new ChromeosSupplicantProcessProxy(dispatcher_,
166 proxy_bus_,
167 service_appeared_callback,
168 service_vanished_callback);
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700169}
170
171SupplicantInterfaceProxyInterface*
172 ChromeosDBusControl::CreateSupplicantInterfaceProxy(
173 SupplicantEventDelegateInterface* delegate,
Peter Qiuc00d1fa2015-08-13 15:00:55 -0700174 const string& object_path) {
Peter Qiu526ed5f2015-08-25 13:30:47 -0700175 return new ChromeosSupplicantInterfaceProxy(
176 proxy_bus_, object_path, delegate);
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700177}
178
179SupplicantNetworkProxyInterface*
180 ChromeosDBusControl::CreateSupplicantNetworkProxy(
Peter Qiuc00d1fa2015-08-13 15:00:55 -0700181 const string& object_path) {
Peter Qiu526ed5f2015-08-25 13:30:47 -0700182 return new ChromeosSupplicantNetworkProxy(proxy_bus_, object_path);
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700183}
184#endif // DISABLE_WIFI || DISABLE_WIRED_8021X
185
186#if !defined(DISABLE_WIFI)
187SupplicantBSSProxyInterface* ChromeosDBusControl::CreateSupplicantBSSProxy(
188 WiFiEndpoint* wifi_endpoint,
Peter Qiuc00d1fa2015-08-13 15:00:55 -0700189 const string& object_path) {
Peter Qiu526ed5f2015-08-25 13:30:47 -0700190 return new ChromeosSupplicantBSSProxy(proxy_bus_, object_path, wifi_endpoint);
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700191}
192#endif // DISABLE_WIFI
193
Peter Qiu82001242015-07-31 10:06:42 -0700194DHCPCDListenerInterface* ChromeosDBusControl::CreateDHCPCDListener(
195 DHCPProvider* provider) {
Peter Qiu526ed5f2015-08-25 13:30:47 -0700196 return new ChromeosDHCPCDListener(proxy_bus_, dispatcher_, provider);
Peter Qiu82001242015-07-31 10:06:42 -0700197}
198
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700199DHCPProxyInterface* ChromeosDBusControl::CreateDHCPProxy(
200 const string& service) {
Peter Qiu526ed5f2015-08-25 13:30:47 -0700201 return new ChromeosDHCPCDProxy(proxy_bus_, service);
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700202}
203
204UpstartProxyInterface* ChromeosDBusControl::CreateUpstartProxy() {
Peter Qiu526ed5f2015-08-25 13:30:47 -0700205 return new ChromeosUpstartProxy(proxy_bus_);
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700206}
207
208PermissionBrokerProxyInterface*
209 ChromeosDBusControl::CreatePermissionBrokerProxy() {
Peter Qiu526ed5f2015-08-25 13:30:47 -0700210 return new ChromeosPermissionBrokerProxy(proxy_bus_);
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700211}
212
213#if !defined(DISABLE_CELLULAR)
Peter Qiu607796a2015-08-27 12:37:04 -0700214DBusPropertiesProxyInterface* ChromeosDBusControl::CreateDBusPropertiesProxy(
215 const string& path,
216 const string& service) {
217 return new ChromeosDBusPropertiesProxy(proxy_bus_, path, service);
218}
219
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700220DBusObjectManagerProxyInterface*
221 ChromeosDBusControl::CreateDBusObjectManagerProxy(
222 const string& path,
Peter Qiu05d87e32015-08-14 23:46:21 -0700223 const string& service,
224 const base::Closure& service_appeared_callback,
225 const base::Closure& service_vanished_callback) {
Peter Qiuda6745b2015-08-17 16:32:34 -0700226 return new ChromeosDBusObjectManagerProxy(dispatcher_,
Peter Qiu526ed5f2015-08-25 13:30:47 -0700227 proxy_bus_,
Peter Qiuda6745b2015-08-17 16:32:34 -0700228 path,
229 service,
230 service_appeared_callback,
231 service_vanished_callback);
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700232}
233
234ModemManagerProxyInterface*
235 ChromeosDBusControl::CreateModemManagerProxy(
236 ModemManagerClassic* manager,
237 const string& path,
Peter Qiu05d87e32015-08-14 23:46:21 -0700238 const string& service,
Peter Qiuf576f1b2015-08-19 09:14:41 -0700239 const base::Closure& service_appeared_callback,
240 const base::Closure& service_vanished_callback) {
241 return new ChromeosModemManagerProxy(dispatcher_,
Peter Qiu526ed5f2015-08-25 13:30:47 -0700242 proxy_bus_,
Peter Qiuf576f1b2015-08-19 09:14:41 -0700243 manager,
244 path,
245 service,
246 service_appeared_callback,
247 service_vanished_callback);
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700248}
249
250ModemProxyInterface* ChromeosDBusControl::CreateModemProxy(
251 const string& path,
252 const string& service) {
Peter Qiu526ed5f2015-08-25 13:30:47 -0700253 return new ChromeosModemProxy(proxy_bus_, path, service);
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700254}
255
256ModemSimpleProxyInterface* ChromeosDBusControl::CreateModemSimpleProxy(
257 const string& path,
258 const string& service) {
Peter Qiu526ed5f2015-08-25 13:30:47 -0700259 return new ChromeosModemSimpleProxy(proxy_bus_, path, service);
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700260}
261
262ModemCDMAProxyInterface* ChromeosDBusControl::CreateModemCDMAProxy(
263 const string& path,
264 const string& service) {
Peter Qiu526ed5f2015-08-25 13:30:47 -0700265 return new ChromeosModemCDMAProxy(proxy_bus_, path, service);
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700266}
267
268ModemGSMCardProxyInterface* ChromeosDBusControl::CreateModemGSMCardProxy(
269 const string& path,
270 const string& service) {
Peter Qiu526ed5f2015-08-25 13:30:47 -0700271 return new ChromeosModemGSMCardProxy(proxy_bus_, path, service);
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700272}
273
274ModemGSMNetworkProxyInterface* ChromeosDBusControl::CreateModemGSMNetworkProxy(
275 const string& path,
276 const string& service) {
Peter Qiu526ed5f2015-08-25 13:30:47 -0700277 return new ChromeosModemGSMNetworkProxy(proxy_bus_, path, service);
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700278}
279
280ModemGobiProxyInterface* ChromeosDBusControl::CreateModemGobiProxy(
281 const string& path,
282 const string& service) {
Peter Qiu526ed5f2015-08-25 13:30:47 -0700283 return new ChromeosModemGobiProxy(proxy_bus_, path, service);
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700284}
285
286// Proxies for ModemManager1 interfaces
287mm1::ModemModem3gppProxyInterface*
288 ChromeosDBusControl::CreateMM1ModemModem3gppProxy(
289 const string& path,
290 const string& service) {
Peter Qiu526ed5f2015-08-25 13:30:47 -0700291 return new mm1::ChromeosModemModem3gppProxy(proxy_bus_, path, service);
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700292}
293
294mm1::ModemModemCdmaProxyInterface*
295 ChromeosDBusControl::CreateMM1ModemModemCdmaProxy(
296 const string& path,
297 const string& service) {
Peter Qiu526ed5f2015-08-25 13:30:47 -0700298 return new mm1::ChromeosModemModemCdmaProxy(proxy_bus_, path, service);
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700299}
300
301mm1::ModemProxyInterface* ChromeosDBusControl::CreateMM1ModemProxy(
302 const string& path,
303 const string& service) {
Peter Qiu526ed5f2015-08-25 13:30:47 -0700304 return new mm1::ChromeosModemProxy(proxy_bus_, path, service);
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700305}
306
307mm1::ModemSimpleProxyInterface* ChromeosDBusControl::CreateMM1ModemSimpleProxy(
308 const string& path,
309 const string& service) {
Peter Qiu526ed5f2015-08-25 13:30:47 -0700310 return new mm1::ChromeosModemSimpleProxy(proxy_bus_, path, service);
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700311}
312
313mm1::SimProxyInterface* ChromeosDBusControl::CreateSimProxy(
314 const string& path,
315 const string& service) {
Peter Qiu526ed5f2015-08-25 13:30:47 -0700316 return new mm1::ChromeosSimProxy(proxy_bus_, path, service);
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700317}
318#endif // DISABLE_CELLULAR
319
320#if !defined(DISABLE_WIMAX)
321WiMaxDeviceProxyInterface* ChromeosDBusControl::CreateWiMaxDeviceProxy(
322 const string& path) {
Peter Qiu526ed5f2015-08-25 13:30:47 -0700323 return new ChromeosWiMaxDeviceProxy(proxy_bus_, path);
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700324}
325
Peter Qiuc00d1fa2015-08-13 15:00:55 -0700326WiMaxManagerProxyInterface* ChromeosDBusControl::CreateWiMaxManagerProxy(
327 const base::Closure& service_appeared_callback,
328 const base::Closure& service_vanished_callback) {
329 return new ChromeosWiMaxManagerProxy(dispatcher_,
Peter Qiu526ed5f2015-08-25 13:30:47 -0700330 proxy_bus_,
Peter Qiuc00d1fa2015-08-13 15:00:55 -0700331 service_appeared_callback,
332 service_vanished_callback);
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700333}
334
335WiMaxNetworkProxyInterface* ChromeosDBusControl::CreateWiMaxNetworkProxy(
336 const string& path) {
Peter Qiu526ed5f2015-08-25 13:30:47 -0700337 return new ChromeosWiMaxNetworkProxy(proxy_bus_, path);
Peter Qiu0d8b91f2015-07-30 16:35:26 -0700338}
339#endif // DISABLE_WIMAX
340
Peter Qiu72e7e252015-06-26 16:23:46 -0700341} // namespace shill