Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 2 | // 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 Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 7 | #include "shill/dbus_properties_proxy.h" |
Darin Petkov | 18fb2f7 | 2012-06-14 09:09:34 +0200 | [diff] [blame] | 8 | #include "shill/dbus_service_proxy.h" |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 9 | #include "shill/dhcpcd_proxy.h" |
Christopher Wiley | b691efd | 2012-08-09 13:51:51 -0700 | [diff] [blame] | 10 | #include "shill/logging.h" |
Darin Petkov | bd9f33a | 2013-03-20 10:38:07 +0100 | [diff] [blame] | 11 | #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 Petkov | bd9f33a | 2013-03-20 10:38:07 +0100 | [diff] [blame] | 16 | |
| 17 | #if !defined(DISABLE_CELLULAR) |
Alex Vakulenko | a41ab51 | 2014-07-23 14:24:23 -0700 | [diff] [blame] | 18 | #include "shill/dbus_objectmanager_proxy.h" // NOLINT(build/include_alpha) |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 19 | #include "shill/mm1_bearer_proxy.h" |
Arman Uguray | 2c39fab | 2012-12-12 16:56:34 -0800 | [diff] [blame] | 20 | #include "shill/mm1_modem_location_proxy.h" |
Jason Glasgow | 9a0be63 | 2012-03-30 08:53:35 -0400 | [diff] [blame] | 21 | #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 Uguray | 618af2b | 2012-12-11 19:20:42 -0800 | [diff] [blame] | 25 | #include "shill/mm1_modem_time_proxy.h" |
Jason Glasgow | 9a0be63 | 2012-03-30 08:53:35 -0400 | [diff] [blame] | 26 | #include "shill/mm1_sim_proxy.h" |
Darin Petkov | bec79a2 | 2011-08-01 14:47:17 -0700 | [diff] [blame] | 27 | #include "shill/modem_cdma_proxy.h" |
Darin Petkov | c37a9c4 | 2012-09-06 15:28:22 +0200 | [diff] [blame] | 28 | #include "shill/modem_gobi_proxy.h" |
Darin Petkov | 975b5e7 | 2011-08-30 11:48:08 -0700 | [diff] [blame] | 29 | #include "shill/modem_gsm_card_proxy.h" |
Darin Petkov | a1e0a1c | 2011-08-25 15:08:33 -0700 | [diff] [blame] | 30 | #include "shill/modem_gsm_network_proxy.h" |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 31 | #include "shill/modem_manager_proxy.h" |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 32 | #include "shill/modem_proxy.h" |
Darin Petkov | e604f70 | 2011-07-28 15:51:17 -0700 | [diff] [blame] | 33 | #include "shill/modem_simple_proxy.h" |
Darin Petkov | bd9f33a | 2013-03-20 10:38:07 +0100 | [diff] [blame] | 34 | #endif |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 35 | |
Ben Chan | 520eb17 | 2013-10-30 20:51:04 -0700 | [diff] [blame] | 36 | #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 Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 42 | using std::string; |
| 43 | |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 44 | namespace shill { |
| 45 | |
Ben Chan | bbdef5f | 2012-04-23 13:58:15 -0700 | [diff] [blame] | 46 | namespace { |
| 47 | base::LazyInstance<ProxyFactory> g_proxy_factory = LAZY_INSTANCE_INITIALIZER; |
| 48 | } // namespace |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 49 | |
| 50 | ProxyFactory::ProxyFactory() {} |
| 51 | |
| 52 | ProxyFactory::~ProxyFactory() {} |
| 53 | |
Darin Petkov | ab565bb | 2011-10-06 02:55:51 -0700 | [diff] [blame] | 54 | ProxyFactory *ProxyFactory::GetInstance() { |
| 55 | return g_proxy_factory.Pointer(); |
| 56 | } |
| 57 | |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 58 | void 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 Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 64 | DBusPropertiesProxyInterface *ProxyFactory::CreateDBusPropertiesProxy( |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 65 | const string &path, |
| 66 | const string &service) { |
Jason Glasgow | 9c09e36 | 2012-04-18 15:16:29 -0400 | [diff] [blame] | 67 | return new DBusPropertiesProxy(connection(), path, service); |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 68 | } |
| 69 | |
Darin Petkov | 18fb2f7 | 2012-06-14 09:09:34 +0200 | [diff] [blame] | 70 | DBusServiceProxyInterface *ProxyFactory::CreateDBusServiceProxy() { |
| 71 | return new DBusServiceProxy(connection()); |
| 72 | } |
| 73 | |
Darin Petkov | 75f201f | 2013-03-19 13:01:28 +0100 | [diff] [blame] | 74 | PowerManagerProxyInterface *ProxyFactory::CreatePowerManagerProxy( |
| 75 | PowerManagerProxyDelegate *delegate) { |
| 76 | return new PowerManagerProxy(delegate, connection()); |
| 77 | } |
| 78 | |
| 79 | SupplicantProcessProxyInterface *ProxyFactory::CreateSupplicantProcessProxy( |
| 80 | const char *dbus_path, |
| 81 | const char *dbus_addr) { |
| 82 | return new SupplicantProcessProxy(connection(), dbus_path, dbus_addr); |
| 83 | } |
| 84 | |
| 85 | SupplicantInterfaceProxyInterface *ProxyFactory::CreateSupplicantInterfaceProxy( |
Paul Stewart | 196f50f | 2013-03-27 18:02:11 -0700 | [diff] [blame] | 86 | SupplicantEventDelegateInterface *delegate, |
Darin Petkov | 75f201f | 2013-03-19 13:01:28 +0100 | [diff] [blame] | 87 | const DBus::Path &object_path, |
| 88 | const char *dbus_addr) { |
Paul Stewart | 196f50f | 2013-03-27 18:02:11 -0700 | [diff] [blame] | 89 | return new SupplicantInterfaceProxy(delegate, |
Darin Petkov | 75f201f | 2013-03-19 13:01:28 +0100 | [diff] [blame] | 90 | connection(), |
| 91 | object_path, |
| 92 | dbus_addr); |
| 93 | } |
| 94 | |
| 95 | SupplicantNetworkProxyInterface *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 | |
| 103 | SupplicantBSSProxyInterface *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 | |
| 111 | DHCPProxyInterface *ProxyFactory::CreateDHCPProxy(const string &service) { |
| 112 | return new DHCPCDProxy(connection(), service); |
| 113 | } |
| 114 | |
| 115 | #if !defined(DISABLE_CELLULAR) |
| 116 | |
Darin Petkov | bd9f33a | 2013-03-20 10:38:07 +0100 | [diff] [blame] | 117 | DBusObjectManagerProxyInterface *ProxyFactory::CreateDBusObjectManagerProxy( |
| 118 | const string &path, |
| 119 | const string &service) { |
| 120 | return new DBusObjectManagerProxy(connection(), path, service); |
| 121 | } |
| 122 | |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 123 | ModemManagerProxyInterface *ProxyFactory::CreateModemManagerProxy( |
David Rochberg | 81030ea | 2012-03-02 15:44:25 -0500 | [diff] [blame] | 124 | ModemManagerClassic *manager, |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 125 | const string &path, |
| 126 | const string &service) { |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 127 | return new ModemManagerProxy(connection(), manager, path, service); |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 128 | } |
| 129 | |
Darin Petkov | c5f5656 | 2011-08-06 16:40:05 -0700 | [diff] [blame] | 130 | ModemProxyInterface *ProxyFactory::CreateModemProxy( |
Darin Petkov | c5f5656 | 2011-08-06 16:40:05 -0700 | [diff] [blame] | 131 | const string &path, |
| 132 | const string &service) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 133 | return new ModemProxy(connection(), path, service); |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 134 | } |
| 135 | |
Darin Petkov | e604f70 | 2011-07-28 15:51:17 -0700 | [diff] [blame] | 136 | ModemSimpleProxyInterface *ProxyFactory::CreateModemSimpleProxy( |
| 137 | const string &path, |
| 138 | const string &service) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 139 | return new ModemSimpleProxy(connection(), path, service); |
Darin Petkov | e604f70 | 2011-07-28 15:51:17 -0700 | [diff] [blame] | 140 | } |
| 141 | |
Darin Petkov | bec79a2 | 2011-08-01 14:47:17 -0700 | [diff] [blame] | 142 | ModemCDMAProxyInterface *ProxyFactory::CreateModemCDMAProxy( |
| 143 | const string &path, |
| 144 | const string &service) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 145 | return new ModemCDMAProxy(connection(), path, service); |
Darin Petkov | bec79a2 | 2011-08-01 14:47:17 -0700 | [diff] [blame] | 146 | } |
| 147 | |
Darin Petkov | 975b5e7 | 2011-08-30 11:48:08 -0700 | [diff] [blame] | 148 | ModemGSMCardProxyInterface *ProxyFactory::CreateModemGSMCardProxy( |
Darin Petkov | 975b5e7 | 2011-08-30 11:48:08 -0700 | [diff] [blame] | 149 | const string &path, |
| 150 | const string &service) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 151 | return new ModemGSMCardProxy(connection(), path, service); |
Darin Petkov | 975b5e7 | 2011-08-30 11:48:08 -0700 | [diff] [blame] | 152 | } |
| 153 | |
Darin Petkov | a1e0a1c | 2011-08-25 15:08:33 -0700 | [diff] [blame] | 154 | ModemGSMNetworkProxyInterface *ProxyFactory::CreateModemGSMNetworkProxy( |
Darin Petkov | a1e0a1c | 2011-08-25 15:08:33 -0700 | [diff] [blame] | 155 | const string &path, |
| 156 | const string &service) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 157 | return new ModemGSMNetworkProxy(connection(), path, service); |
Darin Petkov | a1e0a1c | 2011-08-25 15:08:33 -0700 | [diff] [blame] | 158 | } |
| 159 | |
Darin Petkov | c37a9c4 | 2012-09-06 15:28:22 +0200 | [diff] [blame] | 160 | ModemGobiProxyInterface *ProxyFactory::CreateModemGobiProxy( |
| 161 | const string &path, |
| 162 | const string &service) { |
| 163 | return new ModemGobiProxy(connection(), path, service); |
| 164 | } |
| 165 | |
Jason Glasgow | 9a0be63 | 2012-03-30 08:53:35 -0400 | [diff] [blame] | 166 | // Proxies for ModemManager1 interfaces |
| 167 | mm1::ModemModem3gppProxyInterface *ProxyFactory::CreateMM1ModemModem3gppProxy( |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 168 | const string &path, |
| 169 | const string &service) { |
Jason Glasgow | 9a0be63 | 2012-03-30 08:53:35 -0400 | [diff] [blame] | 170 | return new mm1::ModemModem3gppProxy(connection(), path, service); |
| 171 | } |
| 172 | |
| 173 | mm1::ModemModemCdmaProxyInterface *ProxyFactory::CreateMM1ModemModemCdmaProxy( |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 174 | const string &path, |
| 175 | const string &service) { |
Jason Glasgow | 9a0be63 | 2012-03-30 08:53:35 -0400 | [diff] [blame] | 176 | return new mm1::ModemModemCdmaProxy(connection(), path, service); |
| 177 | } |
| 178 | |
| 179 | mm1::ModemProxyInterface *ProxyFactory::CreateMM1ModemProxy( |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 180 | const string &path, |
| 181 | const string &service) { |
Jason Glasgow | 9a0be63 | 2012-03-30 08:53:35 -0400 | [diff] [blame] | 182 | return new mm1::ModemProxy(connection(), path, service); |
| 183 | } |
| 184 | |
| 185 | mm1::ModemSimpleProxyInterface *ProxyFactory::CreateMM1ModemSimpleProxy( |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 186 | const string &path, |
| 187 | const string &service) { |
Jason Glasgow | 9a0be63 | 2012-03-30 08:53:35 -0400 | [diff] [blame] | 188 | return new mm1::ModemSimpleProxy(connection(), path, service); |
| 189 | } |
| 190 | |
Arman Uguray | 618af2b | 2012-12-11 19:20:42 -0800 | [diff] [blame] | 191 | mm1::ModemTimeProxyInterface *ProxyFactory::CreateMM1ModemTimeProxy( |
| 192 | const string &path, |
| 193 | const string &service) { |
| 194 | return new mm1::ModemTimeProxy(connection(), path, service); |
| 195 | } |
| 196 | |
Arman Uguray | 2c39fab | 2012-12-12 16:56:34 -0800 | [diff] [blame] | 197 | mm1::ModemLocationProxyInterface *ProxyFactory::CreateMM1ModemLocationProxy( |
| 198 | const string &path, |
| 199 | const string &service) { |
| 200 | return new mm1::ModemLocationProxy(connection(), path, service); |
| 201 | } |
| 202 | |
Jason Glasgow | 9a0be63 | 2012-03-30 08:53:35 -0400 | [diff] [blame] | 203 | mm1::SimProxyInterface *ProxyFactory::CreateSimProxy( |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 204 | const string &path, |
| 205 | const string &service) { |
Jason Glasgow | 9a0be63 | 2012-03-30 08:53:35 -0400 | [diff] [blame] | 206 | return new mm1::SimProxy(connection(), path, service); |
| 207 | } |
| 208 | |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 209 | mm1::BearerProxyInterface *ProxyFactory::CreateBearerProxy( |
| 210 | const string &path, |
| 211 | const string &service) { |
| 212 | return new mm1::BearerProxy(connection(), path, service); |
| 213 | } |
| 214 | |
Darin Petkov | 75f201f | 2013-03-19 13:01:28 +0100 | [diff] [blame] | 215 | #endif // DISABLE_CELLULAR |
Darin Petkov | d196726 | 2011-07-18 14:55:18 -0700 | [diff] [blame] | 216 | |
Ben Chan | 520eb17 | 2013-10-30 20:51:04 -0700 | [diff] [blame] | 217 | #if !defined(DISABLE_WIMAX) |
| 218 | |
| 219 | WiMaxDeviceProxyInterface *ProxyFactory::CreateWiMaxDeviceProxy( |
| 220 | const string &path) { |
| 221 | return new WiMaxDeviceProxy(connection(), path); |
| 222 | } |
| 223 | |
| 224 | WiMaxManagerProxyInterface *ProxyFactory::CreateWiMaxManagerProxy() { |
| 225 | return new WiMaxManagerProxy(connection()); |
| 226 | } |
| 227 | |
| 228 | WiMaxNetworkProxyInterface *ProxyFactory::CreateWiMaxNetworkProxy( |
| 229 | const string &path) { |
| 230 | return new WiMaxNetworkProxy(connection(), path); |
| 231 | } |
| 232 | |
| 233 | #endif // DISABLE_WIMAX |
| 234 | |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 235 | } // namespace shill |