blob: 08a7e227f9a7bc4579129d53228907f4b9e38e2f [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"
Paul Stewart8dc5e7b2014-12-11 19:24:50 -080012#include "shill/shared_dbus_connection.h"
Ben Chanda69ecf2014-11-19 07:44:42 -080013#include "shill/supplicant/supplicant_bss_proxy.h"
14#include "shill/supplicant/supplicant_interface_proxy.h"
15#include "shill/supplicant/supplicant_network_proxy.h"
16#include "shill/supplicant/supplicant_process_proxy.h"
Darin Petkovbd9f33a2013-03-20 10:38:07 +010017
18#if !defined(DISABLE_CELLULAR)
Ben Chanc54afe52014-11-05 10:28:08 -080019#include "shill/cellular/dbus_objectmanager_proxy.h"
20#include "shill/cellular/mm1_bearer_proxy.h"
21#include "shill/cellular/mm1_modem_location_proxy.h"
22#include "shill/cellular/mm1_modem_modem3gpp_proxy.h"
23#include "shill/cellular/mm1_modem_modemcdma_proxy.h"
24#include "shill/cellular/mm1_modem_proxy.h"
25#include "shill/cellular/mm1_modem_simple_proxy.h"
26#include "shill/cellular/mm1_modem_time_proxy.h"
27#include "shill/cellular/mm1_sim_proxy.h"
28#include "shill/cellular/modem_cdma_proxy.h"
29#include "shill/cellular/modem_gobi_proxy.h"
30#include "shill/cellular/modem_gsm_card_proxy.h"
31#include "shill/cellular/modem_gsm_network_proxy.h"
32#include "shill/cellular/modem_manager_proxy.h"
33#include "shill/cellular/modem_proxy.h"
34#include "shill/cellular/modem_simple_proxy.h"
Darin Petkovbd9f33a2013-03-20 10:38:07 +010035#endif
Darin Petkovc90fe522011-07-15 13:59:47 -070036
Ben Chan520eb172013-10-30 20:51:04 -070037#if !defined(DISABLE_WIMAX)
Ben Chanc3d707d2014-10-31 08:56:05 -070038#include "shill/wimax/wimax_device_proxy.h"
39#include "shill/wimax/wimax_manager_proxy.h"
40#include "shill/wimax/wimax_network_proxy.h"
Ben Chan520eb172013-10-30 20:51:04 -070041#endif
42
Darin Petkov5c97ac52011-07-19 16:30:49 -070043using std::string;
44
Darin Petkovc90fe522011-07-15 13:59:47 -070045namespace shill {
46
Ben Chanbbdef5f2012-04-23 13:58:15 -070047namespace {
48base::LazyInstance<ProxyFactory> g_proxy_factory = LAZY_INSTANCE_INITIALIZER;
49} // namespace
Darin Petkovc90fe522011-07-15 13:59:47 -070050
51ProxyFactory::ProxyFactory() {}
52
53ProxyFactory::~ProxyFactory() {}
54
Darin Petkovab565bb2011-10-06 02:55:51 -070055ProxyFactory *ProxyFactory::GetInstance() {
56 return g_proxy_factory.Pointer();
57}
58
Paul Stewart8dc5e7b2014-12-11 19:24:50 -080059DBus::Connection *ProxyFactory::GetConnection() const {
Paul Stewart04f00c62015-01-08 15:59:10 -080060 return SharedDBusConnection::GetInstance()->GetProxyConnection();
Darin Petkovaceede32011-07-18 15:32:38 -070061}
62
Darin Petkov5c97ac52011-07-19 16:30:49 -070063DBusPropertiesProxyInterface *ProxyFactory::CreateDBusPropertiesProxy(
Darin Petkov5c97ac52011-07-19 16:30:49 -070064 const string &path,
65 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -080066 return new DBusPropertiesProxy(GetConnection(), path, service);
Darin Petkov5c97ac52011-07-19 16:30:49 -070067}
68
Darin Petkov18fb2f72012-06-14 09:09:34 +020069DBusServiceProxyInterface *ProxyFactory::CreateDBusServiceProxy() {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -080070 return new DBusServiceProxy(GetConnection());
Darin Petkov18fb2f72012-06-14 09:09:34 +020071}
72
Darin Petkov75f201f2013-03-19 13:01:28 +010073PowerManagerProxyInterface *ProxyFactory::CreatePowerManagerProxy(
74 PowerManagerProxyDelegate *delegate) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -080075 return new PowerManagerProxy(delegate, GetConnection());
Darin Petkov75f201f2013-03-19 13:01:28 +010076}
77
78SupplicantProcessProxyInterface *ProxyFactory::CreateSupplicantProcessProxy(
79 const char *dbus_path,
80 const char *dbus_addr) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -080081 return new SupplicantProcessProxy(GetConnection(), dbus_path, dbus_addr);
Darin Petkov75f201f2013-03-19 13:01:28 +010082}
83
84SupplicantInterfaceProxyInterface *ProxyFactory::CreateSupplicantInterfaceProxy(
Paul Stewart196f50f2013-03-27 18:02:11 -070085 SupplicantEventDelegateInterface *delegate,
Darin Petkov75f201f2013-03-19 13:01:28 +010086 const DBus::Path &object_path,
87 const char *dbus_addr) {
Paul Stewart196f50f2013-03-27 18:02:11 -070088 return new SupplicantInterfaceProxy(delegate,
Paul Stewart8dc5e7b2014-12-11 19:24:50 -080089 GetConnection(),
Darin Petkov75f201f2013-03-19 13:01:28 +010090 object_path,
91 dbus_addr);
92}
93
94SupplicantNetworkProxyInterface *ProxyFactory::CreateSupplicantNetworkProxy(
95 const DBus::Path &object_path,
96 const char *dbus_addr) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -080097 return new SupplicantNetworkProxy(GetConnection(),
Darin Petkov75f201f2013-03-19 13:01:28 +010098 object_path,
99 dbus_addr);
100}
101
102SupplicantBSSProxyInterface *ProxyFactory::CreateSupplicantBSSProxy(
103 WiFiEndpoint *wifi_endpoint,
104 const DBus::Path &object_path,
105 const char *dbus_addr) {
106 return new SupplicantBSSProxy(
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800107 wifi_endpoint, GetConnection(), object_path, dbus_addr);
Darin Petkov75f201f2013-03-19 13:01:28 +0100108}
109
110DHCPProxyInterface *ProxyFactory::CreateDHCPProxy(const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800111 return new DHCPCDProxy(GetConnection(), service);
Darin Petkov75f201f2013-03-19 13:01:28 +0100112}
113
114#if !defined(DISABLE_CELLULAR)
115
Darin Petkovbd9f33a2013-03-20 10:38:07 +0100116DBusObjectManagerProxyInterface *ProxyFactory::CreateDBusObjectManagerProxy(
117 const string &path,
118 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800119 return new DBusObjectManagerProxy(GetConnection(), path, service);
Darin Petkovbd9f33a2013-03-20 10:38:07 +0100120}
121
Darin Petkovc90fe522011-07-15 13:59:47 -0700122ModemManagerProxyInterface *ProxyFactory::CreateModemManagerProxy(
David Rochberg81030ea2012-03-02 15:44:25 -0500123 ModemManagerClassic *manager,
Darin Petkov5c97ac52011-07-19 16:30:49 -0700124 const string &path,
125 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800126 return new ModemManagerProxy(GetConnection(), manager, path, service);
Darin Petkovc90fe522011-07-15 13:59:47 -0700127}
128
Darin Petkovc5f56562011-08-06 16:40:05 -0700129ModemProxyInterface *ProxyFactory::CreateModemProxy(
Darin Petkovc5f56562011-08-06 16:40:05 -0700130 const string &path,
131 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800132 return new ModemProxy(GetConnection(), path, service);
Darin Petkove9d12e02011-07-27 15:09:37 -0700133}
134
Darin Petkove604f702011-07-28 15:51:17 -0700135ModemSimpleProxyInterface *ProxyFactory::CreateModemSimpleProxy(
136 const string &path,
137 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800138 return new ModemSimpleProxy(GetConnection(), path, service);
Darin Petkove604f702011-07-28 15:51:17 -0700139}
140
Darin Petkovbec79a22011-08-01 14:47:17 -0700141ModemCDMAProxyInterface *ProxyFactory::CreateModemCDMAProxy(
142 const string &path,
143 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800144 return new ModemCDMAProxy(GetConnection(), path, service);
Darin Petkovbec79a22011-08-01 14:47:17 -0700145}
146
Darin Petkov975b5e72011-08-30 11:48:08 -0700147ModemGSMCardProxyInterface *ProxyFactory::CreateModemGSMCardProxy(
Darin Petkov975b5e72011-08-30 11:48:08 -0700148 const string &path,
149 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800150 return new ModemGSMCardProxy(GetConnection(), path, service);
Darin Petkov975b5e72011-08-30 11:48:08 -0700151}
152
Darin Petkova1e0a1c2011-08-25 15:08:33 -0700153ModemGSMNetworkProxyInterface *ProxyFactory::CreateModemGSMNetworkProxy(
Darin Petkova1e0a1c2011-08-25 15:08:33 -0700154 const string &path,
155 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800156 return new ModemGSMNetworkProxy(GetConnection(), path, service);
Darin Petkova1e0a1c2011-08-25 15:08:33 -0700157}
158
Darin Petkovc37a9c42012-09-06 15:28:22 +0200159ModemGobiProxyInterface *ProxyFactory::CreateModemGobiProxy(
160 const string &path,
161 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800162 return new ModemGobiProxy(GetConnection(), path, service);
Darin Petkovc37a9c42012-09-06 15:28:22 +0200163}
164
Jason Glasgow9a0be632012-03-30 08:53:35 -0400165// Proxies for ModemManager1 interfaces
166mm1::ModemModem3gppProxyInterface *ProxyFactory::CreateMM1ModemModem3gppProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200167 const string &path,
168 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800169 return new mm1::ModemModem3gppProxy(GetConnection(), path, service);
Jason Glasgow9a0be632012-03-30 08:53:35 -0400170}
171
172mm1::ModemModemCdmaProxyInterface *ProxyFactory::CreateMM1ModemModemCdmaProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200173 const string &path,
174 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800175 return new mm1::ModemModemCdmaProxy(GetConnection(), path, service);
Jason Glasgow9a0be632012-03-30 08:53:35 -0400176}
177
178mm1::ModemProxyInterface *ProxyFactory::CreateMM1ModemProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200179 const string &path,
180 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800181 return new mm1::ModemProxy(GetConnection(), path, service);
Jason Glasgow9a0be632012-03-30 08:53:35 -0400182}
183
184mm1::ModemSimpleProxyInterface *ProxyFactory::CreateMM1ModemSimpleProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200185 const string &path,
186 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800187 return new mm1::ModemSimpleProxy(GetConnection(), path, service);
Jason Glasgow9a0be632012-03-30 08:53:35 -0400188}
189
Arman Uguray618af2b2012-12-11 19:20:42 -0800190mm1::ModemTimeProxyInterface *ProxyFactory::CreateMM1ModemTimeProxy(
191 const string &path,
192 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800193 return new mm1::ModemTimeProxy(GetConnection(), path, service);
Arman Uguray618af2b2012-12-11 19:20:42 -0800194}
195
Arman Uguray2c39fab2012-12-12 16:56:34 -0800196mm1::ModemLocationProxyInterface *ProxyFactory::CreateMM1ModemLocationProxy(
197 const string &path,
198 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800199 return new mm1::ModemLocationProxy(GetConnection(), path, service);
Arman Uguray2c39fab2012-12-12 16:56:34 -0800200}
201
Jason Glasgow9a0be632012-03-30 08:53:35 -0400202mm1::SimProxyInterface *ProxyFactory::CreateSimProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200203 const string &path,
204 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800205 return new mm1::SimProxy(GetConnection(), path, service);
Jason Glasgow9a0be632012-03-30 08:53:35 -0400206}
207
Arman Uguray6e5639f2012-11-15 20:30:19 -0800208mm1::BearerProxyInterface *ProxyFactory::CreateBearerProxy(
209 const string &path,
210 const string &service) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800211 return new mm1::BearerProxy(GetConnection(), path, service);
Arman Uguray6e5639f2012-11-15 20:30:19 -0800212}
213
Darin Petkov75f201f2013-03-19 13:01:28 +0100214#endif // DISABLE_CELLULAR
Darin Petkovd1967262011-07-18 14:55:18 -0700215
Ben Chan520eb172013-10-30 20:51:04 -0700216#if !defined(DISABLE_WIMAX)
217
218WiMaxDeviceProxyInterface *ProxyFactory::CreateWiMaxDeviceProxy(
219 const string &path) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800220 return new WiMaxDeviceProxy(GetConnection(), path);
Ben Chan520eb172013-10-30 20:51:04 -0700221}
222
223WiMaxManagerProxyInterface *ProxyFactory::CreateWiMaxManagerProxy() {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800224 return new WiMaxManagerProxy(GetConnection());
Ben Chan520eb172013-10-30 20:51:04 -0700225}
226
227WiMaxNetworkProxyInterface *ProxyFactory::CreateWiMaxNetworkProxy(
228 const string &path) {
Paul Stewart8dc5e7b2014-12-11 19:24:50 -0800229 return new WiMaxNetworkProxy(GetConnection(), path);
Ben Chan520eb172013-10-30 20:51:04 -0700230}
231
232#endif // DISABLE_WIMAX
233
Darin Petkovc90fe522011-07-15 13:59:47 -0700234} // namespace shill