blob: ba60214b709e6ad3daa2e6a82a8883af165d5404 [file] [log] [blame]
Eric Shienbrood5de44ab2011-12-05 10:46:27 -05001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Darin Petkovc90fe522011-07-15 13:59:47 -07002// 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/proxy_factory.h"
6
Darin Petkov5c97ac52011-07-19 16:30:49 -07007#include "shill/dbus_properties_proxy.h"
Darin Petkov18fb2f72012-06-14 09:09:34 +02008#include "shill/dbus_service_proxy.h"
Darin Petkovaceede32011-07-18 15:32:38 -07009#include "shill/dhcpcd_proxy.h"
Christopher Wileyb691efd2012-08-09 13:51:51 -070010#include "shill/logging.h"
Prabhu Kaliamoorthi77e76832015-02-13 15:20:23 +010011#include "shill/permission_broker_proxy.h"
Darin Petkovbd9f33a2013-03-20 10:38:07 +010012#include "shill/power_manager_proxy.h"
Paul Stewart8dc5e7b2014-12-11 19:24:50 -080013#include "shill/shared_dbus_connection.h"
Ben Chanda69ecf2014-11-19 07:44:42 -080014#include "shill/supplicant/supplicant_bss_proxy.h"
15#include "shill/supplicant/supplicant_interface_proxy.h"
16#include "shill/supplicant/supplicant_network_proxy.h"
17#include "shill/supplicant/supplicant_process_proxy.h"
Paul Stewart59a8cba2015-01-09 15:48:19 -080018#include "shill/upstart/upstart_proxy.h"
Darin Petkovbd9f33a2013-03-20 10:38:07 +010019
20#if !defined(DISABLE_CELLULAR)
Ben Chanc54afe52014-11-05 10:28:08 -080021#include "shill/cellular/dbus_objectmanager_proxy.h"
22#include "shill/cellular/mm1_bearer_proxy.h"
23#include "shill/cellular/mm1_modem_location_proxy.h"
24#include "shill/cellular/mm1_modem_modem3gpp_proxy.h"
25#include "shill/cellular/mm1_modem_modemcdma_proxy.h"
26#include "shill/cellular/mm1_modem_proxy.h"
27#include "shill/cellular/mm1_modem_simple_proxy.h"
28#include "shill/cellular/mm1_modem_time_proxy.h"
29#include "shill/cellular/mm1_sim_proxy.h"
30#include "shill/cellular/modem_cdma_proxy.h"
31#include "shill/cellular/modem_gobi_proxy.h"
32#include "shill/cellular/modem_gsm_card_proxy.h"
33#include "shill/cellular/modem_gsm_network_proxy.h"
34#include "shill/cellular/modem_manager_proxy.h"
35#include "shill/cellular/modem_proxy.h"
36#include "shill/cellular/modem_simple_proxy.h"
Darin Petkovbd9f33a2013-03-20 10:38:07 +010037#endif
Darin Petkovc90fe522011-07-15 13:59:47 -070038
Ben Chan520eb172013-10-30 20:51:04 -070039#if !defined(DISABLE_WIMAX)
Ben Chanc3d707d2014-10-31 08:56:05 -070040#include "shill/wimax/wimax_device_proxy.h"
41#include "shill/wimax/wimax_manager_proxy.h"
42#include "shill/wimax/wimax_network_proxy.h"
Ben Chan520eb172013-10-30 20:51:04 -070043#endif
44
Darin Petkov5c97ac52011-07-19 16:30:49 -070045using std::string;
46
Darin Petkovc90fe522011-07-15 13:59:47 -070047namespace shill {
48
Ben Chanbbdef5f2012-04-23 13:58:15 -070049namespace {
50base::LazyInstance<ProxyFactory> g_proxy_factory = LAZY_INSTANCE_INITIALIZER;
51} // namespace
Darin Petkovc90fe522011-07-15 13:59:47 -070052
53ProxyFactory::ProxyFactory() {}
54
55ProxyFactory::~ProxyFactory() {}
56
Darin Petkovab565bb2011-10-06 02:55:51 -070057ProxyFactory *ProxyFactory::GetInstance() {
58 return g_proxy_factory.Pointer();
59}
60
Paul Stewart8dc5e7b2014-12-11 19:24:50 -080061DBus::Connection *ProxyFactory::GetConnection() const {
Paul Stewart04f00c62015-01-08 15:59:10 -080062 return SharedDBusConnection::GetInstance()->GetProxyConnection();
Darin Petkovaceede32011-07-18 15:32:38 -070063}
64
Darin Petkov5c97ac52011-07-19 16:30:49 -070065DBusPropertiesProxyInterface *ProxyFactory::CreateDBusPropertiesProxy(
Darin Petkov5c97ac52011-07-19 16:30:49 -070066 const string &path,
67 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -080068 return new DBusPropertiesProxy(GetConnection(), path, service);
Darin Petkov5c97ac52011-07-19 16:30:49 -070069}
70
Darin Petkov18fb2f72012-06-14 09:09:34 +020071DBusServiceProxyInterface *ProxyFactory::CreateDBusServiceProxy() {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -080072 return new DBusServiceProxy(GetConnection());
Darin Petkov18fb2f72012-06-14 09:09:34 +020073}
74
Darin Petkov75f201f2013-03-19 13:01:28 +010075PowerManagerProxyInterface *ProxyFactory::CreatePowerManagerProxy(
76 PowerManagerProxyDelegate *delegate) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -080077 return new PowerManagerProxy(delegate, GetConnection());
Darin Petkov75f201f2013-03-19 13:01:28 +010078}
79
80SupplicantProcessProxyInterface *ProxyFactory::CreateSupplicantProcessProxy(
81 const char *dbus_path,
82 const char *dbus_addr) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -080083 return new SupplicantProcessProxy(GetConnection(), dbus_path, dbus_addr);
Darin Petkov75f201f2013-03-19 13:01:28 +010084}
85
86SupplicantInterfaceProxyInterface *ProxyFactory::CreateSupplicantInterfaceProxy(
Paul Stewart196f50f2013-03-27 18:02:11 -070087 SupplicantEventDelegateInterface *delegate,
Darin Petkov75f201f2013-03-19 13:01:28 +010088 const DBus::Path &object_path,
89 const char *dbus_addr) {
Paul Stewart196f50f2013-03-27 18:02:11 -070090 return new SupplicantInterfaceProxy(delegate,
Paul Stewart8dc5e7b2014-12-11 19:24:50 -080091 GetConnection(),
Darin Petkov75f201f2013-03-19 13:01:28 +010092 object_path,
93 dbus_addr);
94}
95
96SupplicantNetworkProxyInterface *ProxyFactory::CreateSupplicantNetworkProxy(
97 const DBus::Path &object_path,
98 const char *dbus_addr) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -080099 return new SupplicantNetworkProxy(GetConnection(),
Darin Petkov75f201f2013-03-19 13:01:28 +0100100 object_path,
101 dbus_addr);
102}
103
104SupplicantBSSProxyInterface *ProxyFactory::CreateSupplicantBSSProxy(
105 WiFiEndpoint *wifi_endpoint,
106 const DBus::Path &object_path,
107 const char *dbus_addr) {
108 return new SupplicantBSSProxy(
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800109 wifi_endpoint, GetConnection(), object_path, dbus_addr);
Darin Petkov75f201f2013-03-19 13:01:28 +0100110}
111
112DHCPProxyInterface *ProxyFactory::CreateDHCPProxy(const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800113 return new DHCPCDProxy(GetConnection(), service);
Darin Petkov75f201f2013-03-19 13:01:28 +0100114}
115
Paul Stewart59a8cba2015-01-09 15:48:19 -0800116UpstartProxyInterface *ProxyFactory::CreateUpstartProxy() {
117 return new UpstartProxy(GetConnection());
118}
119
Prabhu Kaliamoorthi77e76832015-02-13 15:20:23 +0100120PermissionBrokerProxyInterface *ProxyFactory::CreatePermissionBrokerProxy() {
121 return new PermissionBrokerProxy(GetConnection());
122}
123
Darin Petkov75f201f2013-03-19 13:01:28 +0100124#if !defined(DISABLE_CELLULAR)
125
Darin Petkovbd9f33a2013-03-20 10:38:07 +0100126DBusObjectManagerProxyInterface *ProxyFactory::CreateDBusObjectManagerProxy(
127 const string &path,
128 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800129 return new DBusObjectManagerProxy(GetConnection(), path, service);
Darin Petkovbd9f33a2013-03-20 10:38:07 +0100130}
131
Darin Petkovc90fe522011-07-15 13:59:47 -0700132ModemManagerProxyInterface *ProxyFactory::CreateModemManagerProxy(
David Rochberg81030ea2012-03-02 15:44:25 -0500133 ModemManagerClassic *manager,
Darin Petkov5c97ac52011-07-19 16:30:49 -0700134 const string &path,
135 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800136 return new ModemManagerProxy(GetConnection(), manager, path, service);
Darin Petkovc90fe522011-07-15 13:59:47 -0700137}
138
Darin Petkovc5f56562011-08-06 16:40:05 -0700139ModemProxyInterface *ProxyFactory::CreateModemProxy(
Darin Petkovc5f56562011-08-06 16:40:05 -0700140 const string &path,
141 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800142 return new ModemProxy(GetConnection(), path, service);
Darin Petkove9d12e02011-07-27 15:09:37 -0700143}
144
Darin Petkove604f702011-07-28 15:51:17 -0700145ModemSimpleProxyInterface *ProxyFactory::CreateModemSimpleProxy(
146 const string &path,
147 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800148 return new ModemSimpleProxy(GetConnection(), path, service);
Darin Petkove604f702011-07-28 15:51:17 -0700149}
150
Darin Petkovbec79a22011-08-01 14:47:17 -0700151ModemCDMAProxyInterface *ProxyFactory::CreateModemCDMAProxy(
152 const string &path,
153 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800154 return new ModemCDMAProxy(GetConnection(), path, service);
Darin Petkovbec79a22011-08-01 14:47:17 -0700155}
156
Darin Petkov975b5e72011-08-30 11:48:08 -0700157ModemGSMCardProxyInterface *ProxyFactory::CreateModemGSMCardProxy(
Darin Petkov975b5e72011-08-30 11:48:08 -0700158 const string &path,
159 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800160 return new ModemGSMCardProxy(GetConnection(), path, service);
Darin Petkov975b5e72011-08-30 11:48:08 -0700161}
162
Darin Petkova1e0a1c2011-08-25 15:08:33 -0700163ModemGSMNetworkProxyInterface *ProxyFactory::CreateModemGSMNetworkProxy(
Darin Petkova1e0a1c2011-08-25 15:08:33 -0700164 const string &path,
165 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800166 return new ModemGSMNetworkProxy(GetConnection(), path, service);
Darin Petkova1e0a1c2011-08-25 15:08:33 -0700167}
168
Darin Petkovc37a9c42012-09-06 15:28:22 +0200169ModemGobiProxyInterface *ProxyFactory::CreateModemGobiProxy(
170 const string &path,
171 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800172 return new ModemGobiProxy(GetConnection(), path, service);
Darin Petkovc37a9c42012-09-06 15:28:22 +0200173}
174
Jason Glasgow9a0be632012-03-30 08:53:35 -0400175// Proxies for ModemManager1 interfaces
176mm1::ModemModem3gppProxyInterface *ProxyFactory::CreateMM1ModemModem3gppProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200177 const string &path,
178 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800179 return new mm1::ModemModem3gppProxy(GetConnection(), path, service);
Jason Glasgow9a0be632012-03-30 08:53:35 -0400180}
181
182mm1::ModemModemCdmaProxyInterface *ProxyFactory::CreateMM1ModemModemCdmaProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200183 const string &path,
184 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800185 return new mm1::ModemModemCdmaProxy(GetConnection(), path, service);
Jason Glasgow9a0be632012-03-30 08:53:35 -0400186}
187
188mm1::ModemProxyInterface *ProxyFactory::CreateMM1ModemProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200189 const string &path,
190 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800191 return new mm1::ModemProxy(GetConnection(), path, service);
Jason Glasgow9a0be632012-03-30 08:53:35 -0400192}
193
194mm1::ModemSimpleProxyInterface *ProxyFactory::CreateMM1ModemSimpleProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200195 const string &path,
196 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800197 return new mm1::ModemSimpleProxy(GetConnection(), path, service);
Jason Glasgow9a0be632012-03-30 08:53:35 -0400198}
199
Arman Uguray618af2b2012-12-11 19:20:42 -0800200mm1::ModemTimeProxyInterface *ProxyFactory::CreateMM1ModemTimeProxy(
201 const string &path,
202 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800203 return new mm1::ModemTimeProxy(GetConnection(), path, service);
Arman Uguray618af2b2012-12-11 19:20:42 -0800204}
205
Arman Uguray2c39fab2012-12-12 16:56:34 -0800206mm1::ModemLocationProxyInterface *ProxyFactory::CreateMM1ModemLocationProxy(
207 const string &path,
208 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800209 return new mm1::ModemLocationProxy(GetConnection(), path, service);
Arman Uguray2c39fab2012-12-12 16:56:34 -0800210}
211
Jason Glasgow9a0be632012-03-30 08:53:35 -0400212mm1::SimProxyInterface *ProxyFactory::CreateSimProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200213 const string &path,
214 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800215 return new mm1::SimProxy(GetConnection(), path, service);
Jason Glasgow9a0be632012-03-30 08:53:35 -0400216}
217
Arman Uguray6e5639f2012-11-15 20:30:19 -0800218mm1::BearerProxyInterface *ProxyFactory::CreateBearerProxy(
219 const string &path,
220 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800221 return new mm1::BearerProxy(GetConnection(), path, service);
Arman Uguray6e5639f2012-11-15 20:30:19 -0800222}
223
Darin Petkov75f201f2013-03-19 13:01:28 +0100224#endif // DISABLE_CELLULAR
Darin Petkovd1967262011-07-18 14:55:18 -0700225
Ben Chan520eb172013-10-30 20:51:04 -0700226#if !defined(DISABLE_WIMAX)
227
228WiMaxDeviceProxyInterface *ProxyFactory::CreateWiMaxDeviceProxy(
229 const string &path) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800230 return new WiMaxDeviceProxy(GetConnection(), path);
Ben Chan520eb172013-10-30 20:51:04 -0700231}
232
233WiMaxManagerProxyInterface *ProxyFactory::CreateWiMaxManagerProxy() {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800234 return new WiMaxManagerProxy(GetConnection());
Ben Chan520eb172013-10-30 20:51:04 -0700235}
236
237WiMaxNetworkProxyInterface *ProxyFactory::CreateWiMaxNetworkProxy(
238 const string &path) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800239 return new WiMaxNetworkProxy(GetConnection(), path);
Ben Chan520eb172013-10-30 20:51:04 -0700240}
241
242#endif // DISABLE_WIMAX
243
Darin Petkovc90fe522011-07-15 13:59:47 -0700244} // namespace shill