blob: 064718adbcce805556157d0643794e8282d3c001 [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"
16#include "shill/wimax_device_proxy.h"
17#include "shill/wimax_manager_proxy.h"
18#include "shill/wimax_network_proxy.h"
19
20#if !defined(DISABLE_CELLULAR)
21#include "shill/dbus_objectmanager_proxy.h"
Arman Uguray6e5639f2012-11-15 20:30:19 -080022#include "shill/mm1_bearer_proxy.h"
Arman Uguray2c39fab2012-12-12 16:56:34 -080023#include "shill/mm1_modem_location_proxy.h"
Jason Glasgow9a0be632012-03-30 08:53:35 -040024#include "shill/mm1_modem_modem3gpp_proxy.h"
25#include "shill/mm1_modem_modemcdma_proxy.h"
26#include "shill/mm1_modem_proxy.h"
27#include "shill/mm1_modem_simple_proxy.h"
Arman Uguray618af2b2012-12-11 19:20:42 -080028#include "shill/mm1_modem_time_proxy.h"
Jason Glasgow9a0be632012-03-30 08:53:35 -040029#include "shill/mm1_sim_proxy.h"
Darin Petkovbec79a22011-08-01 14:47:17 -070030#include "shill/modem_cdma_proxy.h"
Darin Petkovc37a9c42012-09-06 15:28:22 +020031#include "shill/modem_gobi_proxy.h"
Darin Petkov975b5e72011-08-30 11:48:08 -070032#include "shill/modem_gsm_card_proxy.h"
Darin Petkova1e0a1c2011-08-25 15:08:33 -070033#include "shill/modem_gsm_network_proxy.h"
Darin Petkovc90fe522011-07-15 13:59:47 -070034#include "shill/modem_manager_proxy.h"
Darin Petkove9d12e02011-07-27 15:09:37 -070035#include "shill/modem_proxy.h"
Darin Petkove604f702011-07-28 15:51:17 -070036#include "shill/modem_simple_proxy.h"
Darin Petkovbd9f33a2013-03-20 10:38:07 +010037#endif
Darin Petkovc90fe522011-07-15 13:59:47 -070038
Darin Petkov5c97ac52011-07-19 16:30:49 -070039using std::string;
40
Darin Petkovc90fe522011-07-15 13:59:47 -070041namespace shill {
42
Ben Chanbbdef5f2012-04-23 13:58:15 -070043namespace {
44base::LazyInstance<ProxyFactory> g_proxy_factory = LAZY_INSTANCE_INITIALIZER;
45} // namespace
Darin Petkovc90fe522011-07-15 13:59:47 -070046
47ProxyFactory::ProxyFactory() {}
48
49ProxyFactory::~ProxyFactory() {}
50
Darin Petkovab565bb2011-10-06 02:55:51 -070051ProxyFactory *ProxyFactory::GetInstance() {
52 return g_proxy_factory.Pointer();
53}
54
Darin Petkovaceede32011-07-18 15:32:38 -070055void ProxyFactory::Init() {
56 CHECK(DBus::default_dispatcher); // Initialized in DBusControl::Init.
57 CHECK(!connection_.get());
58 connection_.reset(new DBus::Connection(DBus::Connection::SystemBus()));
59}
60
Darin Petkov5c97ac52011-07-19 16:30:49 -070061DBusPropertiesProxyInterface *ProxyFactory::CreateDBusPropertiesProxy(
Darin Petkov5c97ac52011-07-19 16:30:49 -070062 const string &path,
63 const string &service) {
Jason Glasgow9c09e362012-04-18 15:16:29 -040064 return new DBusPropertiesProxy(connection(), path, service);
Darin Petkov5c97ac52011-07-19 16:30:49 -070065}
66
Darin Petkov18fb2f72012-06-14 09:09:34 +020067DBusServiceProxyInterface *ProxyFactory::CreateDBusServiceProxy() {
68 return new DBusServiceProxy(connection());
69}
70
Darin Petkov75f201f2013-03-19 13:01:28 +010071WiMaxDeviceProxyInterface *ProxyFactory::CreateWiMaxDeviceProxy(
72 const string &path) {
73 return new WiMaxDeviceProxy(connection(), path);
74}
75
76WiMaxManagerProxyInterface *ProxyFactory::CreateWiMaxManagerProxy() {
77 return new WiMaxManagerProxy(connection());
78}
79
80WiMaxNetworkProxyInterface *ProxyFactory::CreateWiMaxNetworkProxy(
81 const string &path) {
82 return new WiMaxNetworkProxy(connection(), path);
83}
84
85PowerManagerProxyInterface *ProxyFactory::CreatePowerManagerProxy(
86 PowerManagerProxyDelegate *delegate) {
87 return new PowerManagerProxy(delegate, connection());
88}
89
90SupplicantProcessProxyInterface *ProxyFactory::CreateSupplicantProcessProxy(
91 const char *dbus_path,
92 const char *dbus_addr) {
93 return new SupplicantProcessProxy(connection(), dbus_path, dbus_addr);
94}
95
96SupplicantInterfaceProxyInterface *ProxyFactory::CreateSupplicantInterfaceProxy(
Paul Stewart196f50f2013-03-27 18:02:11 -070097 SupplicantEventDelegateInterface *delegate,
Darin Petkov75f201f2013-03-19 13:01:28 +010098 const DBus::Path &object_path,
99 const char *dbus_addr) {
Paul Stewart196f50f2013-03-27 18:02:11 -0700100 return new SupplicantInterfaceProxy(delegate,
Darin Petkov75f201f2013-03-19 13:01:28 +0100101 connection(),
102 object_path,
103 dbus_addr);
104}
105
106SupplicantNetworkProxyInterface *ProxyFactory::CreateSupplicantNetworkProxy(
107 const DBus::Path &object_path,
108 const char *dbus_addr) {
109 return new SupplicantNetworkProxy(connection(),
110 object_path,
111 dbus_addr);
112}
113
114SupplicantBSSProxyInterface *ProxyFactory::CreateSupplicantBSSProxy(
115 WiFiEndpoint *wifi_endpoint,
116 const DBus::Path &object_path,
117 const char *dbus_addr) {
118 return new SupplicantBSSProxy(
119 wifi_endpoint, connection(), object_path, dbus_addr);
120}
121
122DHCPProxyInterface *ProxyFactory::CreateDHCPProxy(const string &service) {
123 return new DHCPCDProxy(connection(), service);
124}
125
126#if !defined(DISABLE_CELLULAR)
127
Darin Petkovbd9f33a2013-03-20 10:38:07 +0100128DBusObjectManagerProxyInterface *ProxyFactory::CreateDBusObjectManagerProxy(
129 const string &path,
130 const string &service) {
131 return new DBusObjectManagerProxy(connection(), path, service);
132}
133
Darin Petkovc90fe522011-07-15 13:59:47 -0700134ModemManagerProxyInterface *ProxyFactory::CreateModemManagerProxy(
David Rochberg81030ea2012-03-02 15:44:25 -0500135 ModemManagerClassic *manager,
Darin Petkov5c97ac52011-07-19 16:30:49 -0700136 const string &path,
137 const string &service) {
Darin Petkovaceede32011-07-18 15:32:38 -0700138 return new ModemManagerProxy(connection(), manager, path, service);
Darin Petkovc90fe522011-07-15 13:59:47 -0700139}
140
Darin Petkovc5f56562011-08-06 16:40:05 -0700141ModemProxyInterface *ProxyFactory::CreateModemProxy(
Darin Petkovc5f56562011-08-06 16:40:05 -0700142 const string &path,
143 const string &service) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500144 return new ModemProxy(connection(), path, service);
Darin Petkove9d12e02011-07-27 15:09:37 -0700145}
146
Darin Petkove604f702011-07-28 15:51:17 -0700147ModemSimpleProxyInterface *ProxyFactory::CreateModemSimpleProxy(
148 const string &path,
149 const string &service) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500150 return new ModemSimpleProxy(connection(), path, service);
Darin Petkove604f702011-07-28 15:51:17 -0700151}
152
Darin Petkovbec79a22011-08-01 14:47:17 -0700153ModemCDMAProxyInterface *ProxyFactory::CreateModemCDMAProxy(
154 const string &path,
155 const string &service) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500156 return new ModemCDMAProxy(connection(), path, service);
Darin Petkovbec79a22011-08-01 14:47:17 -0700157}
158
Darin Petkov975b5e72011-08-30 11:48:08 -0700159ModemGSMCardProxyInterface *ProxyFactory::CreateModemGSMCardProxy(
Darin Petkov975b5e72011-08-30 11:48:08 -0700160 const string &path,
161 const string &service) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500162 return new ModemGSMCardProxy(connection(), path, service);
Darin Petkov975b5e72011-08-30 11:48:08 -0700163}
164
Darin Petkova1e0a1c2011-08-25 15:08:33 -0700165ModemGSMNetworkProxyInterface *ProxyFactory::CreateModemGSMNetworkProxy(
Darin Petkova1e0a1c2011-08-25 15:08:33 -0700166 const string &path,
167 const string &service) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500168 return new ModemGSMNetworkProxy(connection(), path, service);
Darin Petkova1e0a1c2011-08-25 15:08:33 -0700169}
170
Darin Petkovc37a9c42012-09-06 15:28:22 +0200171ModemGobiProxyInterface *ProxyFactory::CreateModemGobiProxy(
172 const string &path,
173 const string &service) {
174 return new ModemGobiProxy(connection(), path, service);
175}
176
Jason Glasgow9a0be632012-03-30 08:53:35 -0400177// Proxies for ModemManager1 interfaces
178mm1::ModemModem3gppProxyInterface *ProxyFactory::CreateMM1ModemModem3gppProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200179 const string &path,
180 const string &service) {
Jason Glasgow9a0be632012-03-30 08:53:35 -0400181 return new mm1::ModemModem3gppProxy(connection(), path, service);
182}
183
184mm1::ModemModemCdmaProxyInterface *ProxyFactory::CreateMM1ModemModemCdmaProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200185 const string &path,
186 const string &service) {
Jason Glasgow9a0be632012-03-30 08:53:35 -0400187 return new mm1::ModemModemCdmaProxy(connection(), path, service);
188}
189
190mm1::ModemProxyInterface *ProxyFactory::CreateMM1ModemProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200191 const string &path,
192 const string &service) {
Jason Glasgow9a0be632012-03-30 08:53:35 -0400193 return new mm1::ModemProxy(connection(), path, service);
194}
195
196mm1::ModemSimpleProxyInterface *ProxyFactory::CreateMM1ModemSimpleProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200197 const string &path,
198 const string &service) {
Jason Glasgow9a0be632012-03-30 08:53:35 -0400199 return new mm1::ModemSimpleProxy(connection(), path, service);
200}
201
Arman Uguray618af2b2012-12-11 19:20:42 -0800202mm1::ModemTimeProxyInterface *ProxyFactory::CreateMM1ModemTimeProxy(
203 const string &path,
204 const string &service) {
205 return new mm1::ModemTimeProxy(connection(), path, service);
206}
207
Arman Uguray2c39fab2012-12-12 16:56:34 -0800208mm1::ModemLocationProxyInterface *ProxyFactory::CreateMM1ModemLocationProxy(
209 const string &path,
210 const string &service) {
211 return new mm1::ModemLocationProxy(connection(), path, service);
212}
213
Jason Glasgow9a0be632012-03-30 08:53:35 -0400214mm1::SimProxyInterface *ProxyFactory::CreateSimProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200215 const string &path,
216 const string &service) {
Jason Glasgow9a0be632012-03-30 08:53:35 -0400217 return new mm1::SimProxy(connection(), path, service);
218}
219
Arman Uguray6e5639f2012-11-15 20:30:19 -0800220mm1::BearerProxyInterface *ProxyFactory::CreateBearerProxy(
221 const string &path,
222 const string &service) {
223 return new mm1::BearerProxy(connection(), path, service);
224}
225
Darin Petkov75f201f2013-03-19 13:01:28 +0100226#endif // DISABLE_CELLULAR
Darin Petkovd1967262011-07-18 14:55:18 -0700227
Darin Petkovc90fe522011-07-15 13:59:47 -0700228} // namespace shill