blob: ecae477d02ec7e89c2a50b1e62e24bb22af28261 [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
David Rochberg24c6c622012-03-05 11:30:44 -05007#include "shill/dbus_objectmanager_proxy.h"
Darin Petkov5c97ac52011-07-19 16:30:49 -07008#include "shill/dbus_properties_proxy.h"
Darin Petkov18fb2f72012-06-14 09:09:34 +02009#include "shill/dbus_service_proxy.h"
Darin Petkovaceede32011-07-18 15:32:38 -070010#include "shill/dhcpcd_proxy.h"
Christopher Wileyb691efd2012-08-09 13:51:51 -070011#include "shill/logging.h"
Arman Uguray6e5639f2012-11-15 20:30:19 -080012#include "shill/mm1_bearer_proxy.h"
Arman Uguray2c39fab2012-12-12 16:56:34 -080013#include "shill/mm1_modem_location_proxy.h"
Jason Glasgow9a0be632012-03-30 08:53:35 -040014#include "shill/mm1_modem_modem3gpp_proxy.h"
15#include "shill/mm1_modem_modemcdma_proxy.h"
16#include "shill/mm1_modem_proxy.h"
17#include "shill/mm1_modem_simple_proxy.h"
Arman Uguray618af2b2012-12-11 19:20:42 -080018#include "shill/mm1_modem_time_proxy.h"
Jason Glasgow9a0be632012-03-30 08:53:35 -040019#include "shill/mm1_sim_proxy.h"
Darin Petkovbec79a22011-08-01 14:47:17 -070020#include "shill/modem_cdma_proxy.h"
Darin Petkovc37a9c42012-09-06 15:28:22 +020021#include "shill/modem_gobi_proxy.h"
Darin Petkov975b5e72011-08-30 11:48:08 -070022#include "shill/modem_gsm_card_proxy.h"
Darin Petkova1e0a1c2011-08-25 15:08:33 -070023#include "shill/modem_gsm_network_proxy.h"
Darin Petkovc90fe522011-07-15 13:59:47 -070024#include "shill/modem_manager_proxy.h"
Darin Petkove9d12e02011-07-27 15:09:37 -070025#include "shill/modem_proxy.h"
Darin Petkove604f702011-07-28 15:51:17 -070026#include "shill/modem_simple_proxy.h"
Darin Petkov394b7d42011-11-03 15:48:02 +010027#include "shill/power_manager_proxy.h"
mukesh agrawalb20776f2012-02-10 16:00:36 -080028#include "shill/supplicant_bss_proxy.h"
Darin Petkovd1967262011-07-18 14:55:18 -070029#include "shill/supplicant_interface_proxy.h"
Paul Stewart835934a2012-12-06 19:27:09 -080030#include "shill/supplicant_network_proxy.h"
Darin Petkovd1967262011-07-18 14:55:18 -070031#include "shill/supplicant_process_proxy.h"
Darin Petkov096b3472012-05-15 10:26:22 +020032#include "shill/wimax_device_proxy.h"
33#include "shill/wimax_manager_proxy.h"
Darin Petkov9893d9c2012-05-17 15:27:31 -070034#include "shill/wimax_network_proxy.h"
Darin Petkovc90fe522011-07-15 13:59:47 -070035
Darin Petkov5c97ac52011-07-19 16:30:49 -070036using std::string;
37
Darin Petkovc90fe522011-07-15 13:59:47 -070038namespace shill {
39
Ben Chanbbdef5f2012-04-23 13:58:15 -070040namespace {
41base::LazyInstance<ProxyFactory> g_proxy_factory = LAZY_INSTANCE_INITIALIZER;
42} // namespace
Darin Petkovc90fe522011-07-15 13:59:47 -070043
44ProxyFactory::ProxyFactory() {}
45
46ProxyFactory::~ProxyFactory() {}
47
Darin Petkovab565bb2011-10-06 02:55:51 -070048ProxyFactory *ProxyFactory::GetInstance() {
49 return g_proxy_factory.Pointer();
50}
51
Darin Petkovaceede32011-07-18 15:32:38 -070052void ProxyFactory::Init() {
53 CHECK(DBus::default_dispatcher); // Initialized in DBusControl::Init.
54 CHECK(!connection_.get());
55 connection_.reset(new DBus::Connection(DBus::Connection::SystemBus()));
56}
57
David Rochberg24c6c622012-03-05 11:30:44 -050058DBusObjectManagerProxyInterface *ProxyFactory::CreateDBusObjectManagerProxy(
David Rochberg24c6c622012-03-05 11:30:44 -050059 const string &path,
60 const string &service) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050061 return new DBusObjectManagerProxy(connection(), path, service);
David Rochberg24c6c622012-03-05 11:30:44 -050062}
63
Darin Petkov5c97ac52011-07-19 16:30:49 -070064DBusPropertiesProxyInterface *ProxyFactory::CreateDBusPropertiesProxy(
Darin Petkov5c97ac52011-07-19 16:30:49 -070065 const string &path,
66 const string &service) {
Jason Glasgow9c09e362012-04-18 15:16:29 -040067 return new DBusPropertiesProxy(connection(), path, service);
Darin Petkov5c97ac52011-07-19 16:30:49 -070068}
69
Darin Petkov18fb2f72012-06-14 09:09:34 +020070DBusServiceProxyInterface *ProxyFactory::CreateDBusServiceProxy() {
71 return new DBusServiceProxy(connection());
72}
73
Darin Petkovc90fe522011-07-15 13:59:47 -070074ModemManagerProxyInterface *ProxyFactory::CreateModemManagerProxy(
David Rochberg81030ea2012-03-02 15:44:25 -050075 ModemManagerClassic *manager,
Darin Petkov5c97ac52011-07-19 16:30:49 -070076 const string &path,
77 const string &service) {
Darin Petkovaceede32011-07-18 15:32:38 -070078 return new ModemManagerProxy(connection(), manager, path, service);
Darin Petkovc90fe522011-07-15 13:59:47 -070079}
80
Darin Petkovc5f56562011-08-06 16:40:05 -070081ModemProxyInterface *ProxyFactory::CreateModemProxy(
Darin Petkovc5f56562011-08-06 16:40:05 -070082 const string &path,
83 const string &service) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050084 return new ModemProxy(connection(), path, service);
Darin Petkove9d12e02011-07-27 15:09:37 -070085}
86
Darin Petkove604f702011-07-28 15:51:17 -070087ModemSimpleProxyInterface *ProxyFactory::CreateModemSimpleProxy(
88 const string &path,
89 const string &service) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050090 return new ModemSimpleProxy(connection(), path, service);
Darin Petkove604f702011-07-28 15:51:17 -070091}
92
Darin Petkovbec79a22011-08-01 14:47:17 -070093ModemCDMAProxyInterface *ProxyFactory::CreateModemCDMAProxy(
94 const string &path,
95 const string &service) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050096 return new ModemCDMAProxy(connection(), path, service);
Darin Petkovbec79a22011-08-01 14:47:17 -070097}
98
Darin Petkov975b5e72011-08-30 11:48:08 -070099ModemGSMCardProxyInterface *ProxyFactory::CreateModemGSMCardProxy(
Darin Petkov975b5e72011-08-30 11:48:08 -0700100 const string &path,
101 const string &service) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500102 return new ModemGSMCardProxy(connection(), path, service);
Darin Petkov975b5e72011-08-30 11:48:08 -0700103}
104
Darin Petkova1e0a1c2011-08-25 15:08:33 -0700105ModemGSMNetworkProxyInterface *ProxyFactory::CreateModemGSMNetworkProxy(
Darin Petkova1e0a1c2011-08-25 15:08:33 -0700106 const string &path,
107 const string &service) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500108 return new ModemGSMNetworkProxy(connection(), path, service);
Darin Petkova1e0a1c2011-08-25 15:08:33 -0700109}
110
Darin Petkovc37a9c42012-09-06 15:28:22 +0200111ModemGobiProxyInterface *ProxyFactory::CreateModemGobiProxy(
112 const string &path,
113 const string &service) {
114 return new ModemGobiProxy(connection(), path, service);
115}
116
Jason Glasgow9a0be632012-03-30 08:53:35 -0400117// Proxies for ModemManager1 interfaces
118mm1::ModemModem3gppProxyInterface *ProxyFactory::CreateMM1ModemModem3gppProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200119 const string &path,
120 const string &service) {
Jason Glasgow9a0be632012-03-30 08:53:35 -0400121 return new mm1::ModemModem3gppProxy(connection(), path, service);
122}
123
124mm1::ModemModemCdmaProxyInterface *ProxyFactory::CreateMM1ModemModemCdmaProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200125 const string &path,
126 const string &service) {
Jason Glasgow9a0be632012-03-30 08:53:35 -0400127 return new mm1::ModemModemCdmaProxy(connection(), path, service);
128}
129
130mm1::ModemProxyInterface *ProxyFactory::CreateMM1ModemProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200131 const string &path,
132 const string &service) {
Jason Glasgow9a0be632012-03-30 08:53:35 -0400133 return new mm1::ModemProxy(connection(), path, service);
134}
135
136mm1::ModemSimpleProxyInterface *ProxyFactory::CreateMM1ModemSimpleProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200137 const string &path,
138 const string &service) {
Jason Glasgow9a0be632012-03-30 08:53:35 -0400139 return new mm1::ModemSimpleProxy(connection(), path, service);
140}
141
Arman Uguray618af2b2012-12-11 19:20:42 -0800142mm1::ModemTimeProxyInterface *ProxyFactory::CreateMM1ModemTimeProxy(
143 const string &path,
144 const string &service) {
145 return new mm1::ModemTimeProxy(connection(), path, service);
146}
147
Arman Uguray2c39fab2012-12-12 16:56:34 -0800148mm1::ModemLocationProxyInterface *ProxyFactory::CreateMM1ModemLocationProxy(
149 const string &path,
150 const string &service) {
151 return new mm1::ModemLocationProxy(connection(), path, service);
152}
153
Jason Glasgow9a0be632012-03-30 08:53:35 -0400154mm1::SimProxyInterface *ProxyFactory::CreateSimProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200155 const string &path,
156 const string &service) {
Jason Glasgow9a0be632012-03-30 08:53:35 -0400157 return new mm1::SimProxy(connection(), path, service);
158}
159
Arman Uguray6e5639f2012-11-15 20:30:19 -0800160mm1::BearerProxyInterface *ProxyFactory::CreateBearerProxy(
161 const string &path,
162 const string &service) {
163 return new mm1::BearerProxy(connection(), path, service);
164}
165
Darin Petkov096b3472012-05-15 10:26:22 +0200166WiMaxDeviceProxyInterface *ProxyFactory::CreateWiMaxDeviceProxy(
167 const string &path) {
168 return new WiMaxDeviceProxy(connection(), path);
169}
170
171WiMaxManagerProxyInterface *ProxyFactory::CreateWiMaxManagerProxy() {
172 return new WiMaxManagerProxy(connection());
173}
174
Darin Petkov9893d9c2012-05-17 15:27:31 -0700175WiMaxNetworkProxyInterface *ProxyFactory::CreateWiMaxNetworkProxy(
176 const string &path) {
177 return new WiMaxNetworkProxy(connection(), path);
178}
179
Darin Petkov394b7d42011-11-03 15:48:02 +0100180PowerManagerProxyInterface *ProxyFactory::CreatePowerManagerProxy(
181 PowerManagerProxyDelegate *delegate) {
182 return new PowerManagerProxy(delegate, connection());
183}
184
Darin Petkovaceede32011-07-18 15:32:38 -0700185SupplicantProcessProxyInterface *ProxyFactory::CreateSupplicantProcessProxy(
Darin Petkovd1967262011-07-18 14:55:18 -0700186 const char *dbus_path,
187 const char *dbus_addr) {
Darin Petkovaceede32011-07-18 15:32:38 -0700188 return new SupplicantProcessProxy(connection(), dbus_path, dbus_addr);
Darin Petkovd1967262011-07-18 14:55:18 -0700189}
190
Darin Petkovaceede32011-07-18 15:32:38 -0700191SupplicantInterfaceProxyInterface *ProxyFactory::CreateSupplicantInterfaceProxy(
Darin Petkovd1967262011-07-18 14:55:18 -0700192 const WiFiRefPtr &wifi,
193 const DBus::Path &object_path,
194 const char *dbus_addr) {
Darin Petkovaceede32011-07-18 15:32:38 -0700195 return new SupplicantInterfaceProxy(wifi,
196 connection(),
197 object_path,
198 dbus_addr);
199}
200
Paul Stewart835934a2012-12-06 19:27:09 -0800201SupplicantNetworkProxyInterface *ProxyFactory::CreateSupplicantNetworkProxy(
202 const DBus::Path &object_path,
203 const char *dbus_addr) {
204 return new SupplicantNetworkProxy(connection(),
205 object_path,
206 dbus_addr);
207}
208
mukesh agrawalb20776f2012-02-10 16:00:36 -0800209SupplicantBSSProxyInterface *ProxyFactory::CreateSupplicantBSSProxy(
210 WiFiEndpoint *wifi_endpoint,
211 const DBus::Path &object_path,
212 const char *dbus_addr) {
213 return new SupplicantBSSProxy(
214 wifi_endpoint, connection(), object_path, dbus_addr);
215}
216
Darin Petkova7b89492011-07-27 12:48:17 -0700217DHCPProxyInterface *ProxyFactory::CreateDHCPProxy(const string &service) {
Darin Petkovaceede32011-07-18 15:32:38 -0700218 return new DHCPCDProxy(connection(), service);
Darin Petkovd1967262011-07-18 14:55:18 -0700219}
220
Darin Petkovc90fe522011-07-15 13:59:47 -0700221} // namespace shill