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