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