blob: a4f2adc06edf2825cd93d48ace4c7dc6d2a3296c [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 Petkovaceede32011-07-18 15:32:38 -07007#include <base/logging.h>
8
David Rochberg24c6c622012-03-05 11:30:44 -05009#include "shill/dbus_objectmanager_proxy.h"
Darin Petkov5c97ac52011-07-19 16:30:49 -070010#include "shill/dbus_properties_proxy.h"
Darin Petkov18fb2f72012-06-14 09:09:34 +020011#include "shill/dbus_service_proxy.h"
Darin Petkovaceede32011-07-18 15:32:38 -070012#include "shill/dhcpcd_proxy.h"
Jason Glasgow9a0be632012-03-30 08:53:35 -040013#include "shill/mm1_modem_modem3gpp_proxy.h"
14#include "shill/mm1_modem_modemcdma_proxy.h"
15#include "shill/mm1_modem_proxy.h"
16#include "shill/mm1_modem_simple_proxy.h"
17#include "shill/mm1_sim_proxy.h"
Darin Petkovbec79a22011-08-01 14:47:17 -070018#include "shill/modem_cdma_proxy.h"
Darin Petkov975b5e72011-08-30 11:48:08 -070019#include "shill/modem_gsm_card_proxy.h"
Darin Petkova1e0a1c2011-08-25 15:08:33 -070020#include "shill/modem_gsm_network_proxy.h"
Darin Petkovc90fe522011-07-15 13:59:47 -070021#include "shill/modem_manager_proxy.h"
Darin Petkove9d12e02011-07-27 15:09:37 -070022#include "shill/modem_proxy.h"
Darin Petkove604f702011-07-28 15:51:17 -070023#include "shill/modem_simple_proxy.h"
Darin Petkov394b7d42011-11-03 15:48:02 +010024#include "shill/power_manager_proxy.h"
mukesh agrawalb20776f2012-02-10 16:00:36 -080025#include "shill/supplicant_bss_proxy.h"
Darin Petkovd1967262011-07-18 14:55:18 -070026#include "shill/supplicant_interface_proxy.h"
27#include "shill/supplicant_process_proxy.h"
Darin Petkov096b3472012-05-15 10:26:22 +020028#include "shill/wimax_device_proxy.h"
29#include "shill/wimax_manager_proxy.h"
Darin Petkov9893d9c2012-05-17 15:27:31 -070030#include "shill/wimax_network_proxy.h"
Darin Petkovc90fe522011-07-15 13:59:47 -070031
Darin Petkov5c97ac52011-07-19 16:30:49 -070032using std::string;
33
Darin Petkovc90fe522011-07-15 13:59:47 -070034namespace shill {
35
Ben Chanbbdef5f2012-04-23 13:58:15 -070036namespace {
37base::LazyInstance<ProxyFactory> g_proxy_factory = LAZY_INSTANCE_INITIALIZER;
38} // namespace
Darin Petkovc90fe522011-07-15 13:59:47 -070039
40ProxyFactory::ProxyFactory() {}
41
42ProxyFactory::~ProxyFactory() {}
43
Darin Petkovab565bb2011-10-06 02:55:51 -070044ProxyFactory *ProxyFactory::GetInstance() {
45 return g_proxy_factory.Pointer();
46}
47
Darin Petkovaceede32011-07-18 15:32:38 -070048void ProxyFactory::Init() {
49 CHECK(DBus::default_dispatcher); // Initialized in DBusControl::Init.
50 CHECK(!connection_.get());
51 connection_.reset(new DBus::Connection(DBus::Connection::SystemBus()));
52}
53
David Rochberg24c6c622012-03-05 11:30:44 -050054DBusObjectManagerProxyInterface *ProxyFactory::CreateDBusObjectManagerProxy(
David Rochberg24c6c622012-03-05 11:30:44 -050055 const string &path,
56 const string &service) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050057 return new DBusObjectManagerProxy(connection(), path, service);
David Rochberg24c6c622012-03-05 11:30:44 -050058}
59
Darin Petkov5c97ac52011-07-19 16:30:49 -070060DBusPropertiesProxyInterface *ProxyFactory::CreateDBusPropertiesProxy(
Darin Petkov5c97ac52011-07-19 16:30:49 -070061 const string &path,
62 const string &service) {
Jason Glasgow9c09e362012-04-18 15:16:29 -040063 return new DBusPropertiesProxy(connection(), path, service);
Darin Petkov5c97ac52011-07-19 16:30:49 -070064}
65
Darin Petkov18fb2f72012-06-14 09:09:34 +020066DBusServiceProxyInterface *ProxyFactory::CreateDBusServiceProxy() {
67 return new DBusServiceProxy(connection());
68}
69
Darin Petkovc90fe522011-07-15 13:59:47 -070070ModemManagerProxyInterface *ProxyFactory::CreateModemManagerProxy(
David Rochberg81030ea2012-03-02 15:44:25 -050071 ModemManagerClassic *manager,
Darin Petkov5c97ac52011-07-19 16:30:49 -070072 const string &path,
73 const string &service) {
Darin Petkovaceede32011-07-18 15:32:38 -070074 return new ModemManagerProxy(connection(), manager, path, service);
Darin Petkovc90fe522011-07-15 13:59:47 -070075}
76
Darin Petkovc5f56562011-08-06 16:40:05 -070077ModemProxyInterface *ProxyFactory::CreateModemProxy(
Darin Petkovc5f56562011-08-06 16:40:05 -070078 const string &path,
79 const string &service) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050080 return new ModemProxy(connection(), path, service);
Darin Petkove9d12e02011-07-27 15:09:37 -070081}
82
Darin Petkove604f702011-07-28 15:51:17 -070083ModemSimpleProxyInterface *ProxyFactory::CreateModemSimpleProxy(
84 const string &path,
85 const string &service) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050086 return new ModemSimpleProxy(connection(), path, service);
Darin Petkove604f702011-07-28 15:51:17 -070087}
88
Darin Petkovbec79a22011-08-01 14:47:17 -070089ModemCDMAProxyInterface *ProxyFactory::CreateModemCDMAProxy(
90 const string &path,
91 const string &service) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050092 return new ModemCDMAProxy(connection(), path, service);
Darin Petkovbec79a22011-08-01 14:47:17 -070093}
94
Darin Petkov975b5e72011-08-30 11:48:08 -070095ModemGSMCardProxyInterface *ProxyFactory::CreateModemGSMCardProxy(
Darin Petkov975b5e72011-08-30 11:48:08 -070096 const string &path,
97 const string &service) {
Eric Shienbrood9a245532012-03-07 14:20:39 -050098 return new ModemGSMCardProxy(connection(), path, service);
Darin Petkov975b5e72011-08-30 11:48:08 -070099}
100
Darin Petkova1e0a1c2011-08-25 15:08:33 -0700101ModemGSMNetworkProxyInterface *ProxyFactory::CreateModemGSMNetworkProxy(
Darin Petkova1e0a1c2011-08-25 15:08:33 -0700102 const string &path,
103 const string &service) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500104 return new ModemGSMNetworkProxy(connection(), path, service);
Darin Petkova1e0a1c2011-08-25 15:08:33 -0700105}
106
Jason Glasgow9a0be632012-03-30 08:53:35 -0400107// Proxies for ModemManager1 interfaces
108mm1::ModemModem3gppProxyInterface *ProxyFactory::CreateMM1ModemModem3gppProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200109 const string &path,
110 const string &service) {
Jason Glasgow9a0be632012-03-30 08:53:35 -0400111 return new mm1::ModemModem3gppProxy(connection(), path, service);
112}
113
114mm1::ModemModemCdmaProxyInterface *ProxyFactory::CreateMM1ModemModemCdmaProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200115 const string &path,
116 const string &service) {
Jason Glasgow9a0be632012-03-30 08:53:35 -0400117 return new mm1::ModemModemCdmaProxy(connection(), path, service);
118}
119
120mm1::ModemProxyInterface *ProxyFactory::CreateMM1ModemProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200121 const string &path,
122 const string &service) {
Jason Glasgow9a0be632012-03-30 08:53:35 -0400123 return new mm1::ModemProxy(connection(), path, service);
124}
125
126mm1::ModemSimpleProxyInterface *ProxyFactory::CreateMM1ModemSimpleProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200127 const string &path,
128 const string &service) {
Jason Glasgow9a0be632012-03-30 08:53:35 -0400129 return new mm1::ModemSimpleProxy(connection(), path, service);
130}
131
132mm1::SimProxyInterface *ProxyFactory::CreateSimProxy(
Darin Petkov096b3472012-05-15 10:26:22 +0200133 const string &path,
134 const string &service) {
Jason Glasgow9a0be632012-03-30 08:53:35 -0400135 return new mm1::SimProxy(connection(), path, service);
136}
137
Darin Petkov096b3472012-05-15 10:26:22 +0200138WiMaxDeviceProxyInterface *ProxyFactory::CreateWiMaxDeviceProxy(
139 const string &path) {
140 return new WiMaxDeviceProxy(connection(), path);
141}
142
143WiMaxManagerProxyInterface *ProxyFactory::CreateWiMaxManagerProxy() {
144 return new WiMaxManagerProxy(connection());
145}
146
Darin Petkov9893d9c2012-05-17 15:27:31 -0700147WiMaxNetworkProxyInterface *ProxyFactory::CreateWiMaxNetworkProxy(
148 const string &path) {
149 return new WiMaxNetworkProxy(connection(), path);
150}
151
Darin Petkov394b7d42011-11-03 15:48:02 +0100152PowerManagerProxyInterface *ProxyFactory::CreatePowerManagerProxy(
153 PowerManagerProxyDelegate *delegate) {
154 return new PowerManagerProxy(delegate, connection());
155}
156
Darin Petkovaceede32011-07-18 15:32:38 -0700157SupplicantProcessProxyInterface *ProxyFactory::CreateSupplicantProcessProxy(
Darin Petkovd1967262011-07-18 14:55:18 -0700158 const char *dbus_path,
159 const char *dbus_addr) {
Darin Petkovaceede32011-07-18 15:32:38 -0700160 return new SupplicantProcessProxy(connection(), dbus_path, dbus_addr);
Darin Petkovd1967262011-07-18 14:55:18 -0700161}
162
Darin Petkovaceede32011-07-18 15:32:38 -0700163SupplicantInterfaceProxyInterface *ProxyFactory::CreateSupplicantInterfaceProxy(
Darin Petkovd1967262011-07-18 14:55:18 -0700164 const WiFiRefPtr &wifi,
165 const DBus::Path &object_path,
166 const char *dbus_addr) {
Darin Petkovaceede32011-07-18 15:32:38 -0700167 return new SupplicantInterfaceProxy(wifi,
168 connection(),
169 object_path,
170 dbus_addr);
171}
172
mukesh agrawalb20776f2012-02-10 16:00:36 -0800173SupplicantBSSProxyInterface *ProxyFactory::CreateSupplicantBSSProxy(
174 WiFiEndpoint *wifi_endpoint,
175 const DBus::Path &object_path,
176 const char *dbus_addr) {
177 return new SupplicantBSSProxy(
178 wifi_endpoint, connection(), object_path, dbus_addr);
179}
180
Darin Petkova7b89492011-07-27 12:48:17 -0700181DHCPProxyInterface *ProxyFactory::CreateDHCPProxy(const string &service) {
Darin Petkovaceede32011-07-18 15:32:38 -0700182 return new DHCPCDProxy(connection(), service);
Darin Petkovd1967262011-07-18 14:55:18 -0700183}
184
Darin Petkovc90fe522011-07-15 13:59:47 -0700185} // namespace shill