blob: c202577e6034d1a74eb3314f39973e20ce98455e [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"
Darin Petkovbd9f33a2013-03-20 10:38:07 +010011#include "shill/power_manager_proxy.h"
12#include "shill/supplicant_bss_proxy.h"
13#include "shill/supplicant_interface_proxy.h"
14#include "shill/supplicant_network_proxy.h"
15#include "shill/supplicant_process_proxy.h"
Darin Petkovbd9f33a2013-03-20 10:38:07 +010016
17#if !defined(DISABLE_CELLULAR)
Alex Vakulenkoa41ab512014-07-23 14:24:23 -070018#include "shill/dbus_objectmanager_proxy.h" // NOLINT(build/include_alpha)
Arman Uguray6e5639f2012-11-15 20:30:19 -080019#include "shill/mm1_bearer_proxy.h"
Arman Uguray2c39fab2012-12-12 16:56:34 -080020#include "shill/mm1_modem_location_proxy.h"
Jason Glasgow9a0be632012-03-30 08:53:35 -040021#include "shill/mm1_modem_modem3gpp_proxy.h"
22#include "shill/mm1_modem_modemcdma_proxy.h"
23#include "shill/mm1_modem_proxy.h"
24#include "shill/mm1_modem_simple_proxy.h"
Arman Uguray618af2b2012-12-11 19:20:42 -080025#include "shill/mm1_modem_time_proxy.h"
Jason Glasgow9a0be632012-03-30 08:53:35 -040026#include "shill/mm1_sim_proxy.h"
Darin Petkovbec79a22011-08-01 14:47:17 -070027#include "shill/modem_cdma_proxy.h"
Darin Petkovc37a9c42012-09-06 15:28:22 +020028#include "shill/modem_gobi_proxy.h"
Darin Petkov975b5e72011-08-30 11:48:08 -070029#include "shill/modem_gsm_card_proxy.h"
Darin Petkova1e0a1c2011-08-25 15:08:33 -070030#include "shill/modem_gsm_network_proxy.h"
Darin Petkovc90fe522011-07-15 13:59:47 -070031#include "shill/modem_manager_proxy.h"
Darin Petkove9d12e02011-07-27 15:09:37 -070032#include "shill/modem_proxy.h"
Darin Petkove604f702011-07-28 15:51:17 -070033#include "shill/modem_simple_proxy.h"
Darin Petkovbd9f33a2013-03-20 10:38:07 +010034#endif
Darin Petkovc90fe522011-07-15 13:59:47 -070035
Ben Chan520eb172013-10-30 20:51:04 -070036#if !defined(DISABLE_WIMAX)
37#include "shill/wimax_device_proxy.h"
38#include "shill/wimax_manager_proxy.h"
39#include "shill/wimax_network_proxy.h"
40#endif
41
Darin Petkov5c97ac52011-07-19 16:30:49 -070042using std::string;
43
Darin Petkovc90fe522011-07-15 13:59:47 -070044namespace shill {
45
Ben Chanbbdef5f2012-04-23 13:58:15 -070046namespace {
47base::LazyInstance<ProxyFactory> g_proxy_factory = LAZY_INSTANCE_INITIALIZER;
48} // namespace
Darin Petkovc90fe522011-07-15 13:59:47 -070049
50ProxyFactory::ProxyFactory() {}
51
52ProxyFactory::~ProxyFactory() {}
53
Darin Petkovab565bb2011-10-06 02:55:51 -070054ProxyFactory *ProxyFactory::GetInstance() {
55 return g_proxy_factory.Pointer();
56}
57
Darin Petkovaceede32011-07-18 15:32:38 -070058void ProxyFactory::Init() {
59 CHECK(DBus::default_dispatcher); // Initialized in DBusControl::Init.
60 CHECK(!connection_.get());
61 connection_.reset(new DBus::Connection(DBus::Connection::SystemBus()));
62}
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 Petkov75f201f2013-03-19 13:01:28 +010074PowerManagerProxyInterface *ProxyFactory::CreatePowerManagerProxy(
75 PowerManagerProxyDelegate *delegate) {
76 return new PowerManagerProxy(delegate, connection());
77}
78
79SupplicantProcessProxyInterface *ProxyFactory::CreateSupplicantProcessProxy(
80 const char *dbus_path,
81 const char *dbus_addr) {
82 return new SupplicantProcessProxy(connection(), dbus_path, dbus_addr);
83}
84
85SupplicantInterfaceProxyInterface *ProxyFactory::CreateSupplicantInterfaceProxy(
Paul Stewart196f50f2013-03-27 18:02:11 -070086 SupplicantEventDelegateInterface *delegate,
Darin Petkov75f201f2013-03-19 13:01:28 +010087 const DBus::Path &object_path,
88 const char *dbus_addr) {
Paul Stewart196f50f2013-03-27 18:02:11 -070089 return new SupplicantInterfaceProxy(delegate,
Darin Petkov75f201f2013-03-19 13:01:28 +010090 connection(),
91 object_path,
92 dbus_addr);
93}
94
95SupplicantNetworkProxyInterface *ProxyFactory::CreateSupplicantNetworkProxy(
96 const DBus::Path &object_path,
97 const char *dbus_addr) {
98 return new SupplicantNetworkProxy(connection(),
99 object_path,
100 dbus_addr);
101}
102
103SupplicantBSSProxyInterface *ProxyFactory::CreateSupplicantBSSProxy(
104 WiFiEndpoint *wifi_endpoint,
105 const DBus::Path &object_path,
106 const char *dbus_addr) {
107 return new SupplicantBSSProxy(
108 wifi_endpoint, connection(), object_path, dbus_addr);
109}
110
111DHCPProxyInterface *ProxyFactory::CreateDHCPProxy(const string &service) {
112 return new DHCPCDProxy(connection(), service);
113}
114
115#if !defined(DISABLE_CELLULAR)
116
Darin Petkovbd9f33a2013-03-20 10:38:07 +0100117DBusObjectManagerProxyInterface *ProxyFactory::CreateDBusObjectManagerProxy(
118 const string &path,
119 const string &service) {
120 return new DBusObjectManagerProxy(connection(), path, service);
121}
122
Darin Petkovc90fe522011-07-15 13:59:47 -0700123ModemManagerProxyInterface *ProxyFactory::CreateModemManagerProxy(
David Rochberg81030ea2012-03-02 15:44:25 -0500124 ModemManagerClassic *manager,
Darin Petkov5c97ac52011-07-19 16:30:49 -0700125 const string &path,
126 const string &service) {
Darin Petkovaceede32011-07-18 15:32:38 -0700127 return new ModemManagerProxy(connection(), manager, path, service);
Darin Petkovc90fe522011-07-15 13:59:47 -0700128}
129
Darin Petkovc5f56562011-08-06 16:40:05 -0700130ModemProxyInterface *ProxyFactory::CreateModemProxy(
Darin Petkovc5f56562011-08-06 16:40:05 -0700131 const string &path,
132 const string &service) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500133 return new ModemProxy(connection(), path, service);
Darin Petkove9d12e02011-07-27 15:09:37 -0700134}
135
Darin Petkove604f702011-07-28 15:51:17 -0700136ModemSimpleProxyInterface *ProxyFactory::CreateModemSimpleProxy(
137 const string &path,
138 const string &service) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500139 return new ModemSimpleProxy(connection(), path, service);
Darin Petkove604f702011-07-28 15:51:17 -0700140}
141
Darin Petkovbec79a22011-08-01 14:47:17 -0700142ModemCDMAProxyInterface *ProxyFactory::CreateModemCDMAProxy(
143 const string &path,
144 const string &service) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500145 return new ModemCDMAProxy(connection(), path, service);
Darin Petkovbec79a22011-08-01 14:47:17 -0700146}
147
Darin Petkov975b5e72011-08-30 11:48:08 -0700148ModemGSMCardProxyInterface *ProxyFactory::CreateModemGSMCardProxy(
Darin Petkov975b5e72011-08-30 11:48:08 -0700149 const string &path,
150 const string &service) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500151 return new ModemGSMCardProxy(connection(), path, service);
Darin Petkov975b5e72011-08-30 11:48:08 -0700152}
153
Darin Petkova1e0a1c2011-08-25 15:08:33 -0700154ModemGSMNetworkProxyInterface *ProxyFactory::CreateModemGSMNetworkProxy(
Darin Petkova1e0a1c2011-08-25 15:08:33 -0700155 const string &path,
156 const string &service) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500157 return new ModemGSMNetworkProxy(connection(), path, service);
Darin Petkova1e0a1c2011-08-25 15:08:33 -0700158}
159
Darin Petkovc37a9c42012-09-06 15:28:22 +0200160ModemGobiProxyInterface *ProxyFactory::CreateModemGobiProxy(
161 const string &path,
162 const string &service) {
163 return new ModemGobiProxy(connection(), path, service);
164}
165
Jason Glasgow9a0be632012-03-30 08:53:35 -0400166// Proxies for ModemManager1 interfaces
167mm1::ModemModem3gppProxyInterface *ProxyFactory::CreateMM1ModemModem3gppProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200168 const string &path,
169 const string &service) {
Jason Glasgow9a0be632012-03-30 08:53:35 -0400170 return new mm1::ModemModem3gppProxy(connection(), path, service);
171}
172
173mm1::ModemModemCdmaProxyInterface *ProxyFactory::CreateMM1ModemModemCdmaProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200174 const string &path,
175 const string &service) {
Jason Glasgow9a0be632012-03-30 08:53:35 -0400176 return new mm1::ModemModemCdmaProxy(connection(), path, service);
177}
178
179mm1::ModemProxyInterface *ProxyFactory::CreateMM1ModemProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200180 const string &path,
181 const string &service) {
Jason Glasgow9a0be632012-03-30 08:53:35 -0400182 return new mm1::ModemProxy(connection(), path, service);
183}
184
185mm1::ModemSimpleProxyInterface *ProxyFactory::CreateMM1ModemSimpleProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200186 const string &path,
187 const string &service) {
Jason Glasgow9a0be632012-03-30 08:53:35 -0400188 return new mm1::ModemSimpleProxy(connection(), path, service);
189}
190
Arman Uguray618af2b2012-12-11 19:20:42 -0800191mm1::ModemTimeProxyInterface *ProxyFactory::CreateMM1ModemTimeProxy(
192 const string &path,
193 const string &service) {
194 return new mm1::ModemTimeProxy(connection(), path, service);
195}
196
Arman Uguray2c39fab2012-12-12 16:56:34 -0800197mm1::ModemLocationProxyInterface *ProxyFactory::CreateMM1ModemLocationProxy(
198 const string &path,
199 const string &service) {
200 return new mm1::ModemLocationProxy(connection(), path, service);
201}
202
Jason Glasgow9a0be632012-03-30 08:53:35 -0400203mm1::SimProxyInterface *ProxyFactory::CreateSimProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200204 const string &path,
205 const string &service) {
Jason Glasgow9a0be632012-03-30 08:53:35 -0400206 return new mm1::SimProxy(connection(), path, service);
207}
208
Arman Uguray6e5639f2012-11-15 20:30:19 -0800209mm1::BearerProxyInterface *ProxyFactory::CreateBearerProxy(
210 const string &path,
211 const string &service) {
212 return new mm1::BearerProxy(connection(), path, service);
213}
214
Darin Petkov75f201f2013-03-19 13:01:28 +0100215#endif // DISABLE_CELLULAR
Darin Petkovd1967262011-07-18 14:55:18 -0700216
Ben Chan520eb172013-10-30 20:51:04 -0700217#if !defined(DISABLE_WIMAX)
218
219WiMaxDeviceProxyInterface *ProxyFactory::CreateWiMaxDeviceProxy(
220 const string &path) {
221 return new WiMaxDeviceProxy(connection(), path);
222}
223
224WiMaxManagerProxyInterface *ProxyFactory::CreateWiMaxManagerProxy() {
225 return new WiMaxManagerProxy(connection());
226}
227
228WiMaxNetworkProxyInterface *ProxyFactory::CreateWiMaxNetworkProxy(
229 const string &path) {
230 return new WiMaxNetworkProxy(connection(), path);
231}
232
233#endif // DISABLE_WIMAX
234
Darin Petkovc90fe522011-07-15 13:59:47 -0700235} // namespace shill