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 | |
David Rochberg | 24c6c62 | 2012-03-05 11:30:44 -0500 | [diff] [blame] | 7 | #include "shill/dbus_objectmanager_proxy.h" |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 8 | #include "shill/dbus_properties_proxy.h" |
Darin Petkov | 18fb2f7 | 2012-06-14 09:09:34 +0200 | [diff] [blame] | 9 | #include "shill/dbus_service_proxy.h" |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 10 | #include "shill/dhcpcd_proxy.h" |
Christopher Wiley | b691efd | 2012-08-09 13:51:51 -0700 | [diff] [blame] | 11 | #include "shill/logging.h" |
Jason Glasgow | 9a0be63 | 2012-03-30 08:53:35 -0400 | [diff] [blame] | 12 | #include "shill/mm1_modem_modem3gpp_proxy.h" |
| 13 | #include "shill/mm1_modem_modemcdma_proxy.h" |
| 14 | #include "shill/mm1_modem_proxy.h" |
| 15 | #include "shill/mm1_modem_simple_proxy.h" |
| 16 | #include "shill/mm1_sim_proxy.h" |
Darin Petkov | bec79a2 | 2011-08-01 14:47:17 -0700 | [diff] [blame] | 17 | #include "shill/modem_cdma_proxy.h" |
Darin Petkov | c37a9c4 | 2012-09-06 15:28:22 +0200 | [diff] [blame] | 18 | #include "shill/modem_gobi_proxy.h" |
Darin Petkov | 975b5e7 | 2011-08-30 11:48:08 -0700 | [diff] [blame] | 19 | #include "shill/modem_gsm_card_proxy.h" |
Darin Petkov | a1e0a1c | 2011-08-25 15:08:33 -0700 | [diff] [blame] | 20 | #include "shill/modem_gsm_network_proxy.h" |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 21 | #include "shill/modem_manager_proxy.h" |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 22 | #include "shill/modem_proxy.h" |
Darin Petkov | e604f70 | 2011-07-28 15:51:17 -0700 | [diff] [blame] | 23 | #include "shill/modem_simple_proxy.h" |
Darin Petkov | 394b7d4 | 2011-11-03 15:48:02 +0100 | [diff] [blame] | 24 | #include "shill/power_manager_proxy.h" |
mukesh agrawal | b20776f | 2012-02-10 16:00:36 -0800 | [diff] [blame] | 25 | #include "shill/supplicant_bss_proxy.h" |
Darin Petkov | d196726 | 2011-07-18 14:55:18 -0700 | [diff] [blame] | 26 | #include "shill/supplicant_interface_proxy.h" |
| 27 | #include "shill/supplicant_process_proxy.h" |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 28 | #include "shill/wimax_device_proxy.h" |
| 29 | #include "shill/wimax_manager_proxy.h" |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 30 | #include "shill/wimax_network_proxy.h" |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 31 | |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 32 | using std::string; |
| 33 | |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 34 | namespace shill { |
| 35 | |
Ben Chan | bbdef5f | 2012-04-23 13:58:15 -0700 | [diff] [blame] | 36 | namespace { |
| 37 | base::LazyInstance<ProxyFactory> g_proxy_factory = LAZY_INSTANCE_INITIALIZER; |
| 38 | } // namespace |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 39 | |
| 40 | ProxyFactory::ProxyFactory() {} |
| 41 | |
| 42 | ProxyFactory::~ProxyFactory() {} |
| 43 | |
Darin Petkov | ab565bb | 2011-10-06 02:55:51 -0700 | [diff] [blame] | 44 | ProxyFactory *ProxyFactory::GetInstance() { |
| 45 | return g_proxy_factory.Pointer(); |
| 46 | } |
| 47 | |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 48 | void 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 Rochberg | 24c6c62 | 2012-03-05 11:30:44 -0500 | [diff] [blame] | 54 | DBusObjectManagerProxyInterface *ProxyFactory::CreateDBusObjectManagerProxy( |
David Rochberg | 24c6c62 | 2012-03-05 11:30:44 -0500 | [diff] [blame] | 55 | const string &path, |
| 56 | const string &service) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 57 | return new DBusObjectManagerProxy(connection(), path, service); |
David Rochberg | 24c6c62 | 2012-03-05 11:30:44 -0500 | [diff] [blame] | 58 | } |
| 59 | |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 60 | DBusPropertiesProxyInterface *ProxyFactory::CreateDBusPropertiesProxy( |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 61 | const string &path, |
| 62 | const string &service) { |
Jason Glasgow | 9c09e36 | 2012-04-18 15:16:29 -0400 | [diff] [blame] | 63 | return new DBusPropertiesProxy(connection(), path, service); |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 64 | } |
| 65 | |
Darin Petkov | 18fb2f7 | 2012-06-14 09:09:34 +0200 | [diff] [blame] | 66 | DBusServiceProxyInterface *ProxyFactory::CreateDBusServiceProxy() { |
| 67 | return new DBusServiceProxy(connection()); |
| 68 | } |
| 69 | |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 70 | ModemManagerProxyInterface *ProxyFactory::CreateModemManagerProxy( |
David Rochberg | 81030ea | 2012-03-02 15:44:25 -0500 | [diff] [blame] | 71 | ModemManagerClassic *manager, |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 72 | const string &path, |
| 73 | const string &service) { |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 74 | return new ModemManagerProxy(connection(), manager, path, service); |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 75 | } |
| 76 | |
Darin Petkov | c5f5656 | 2011-08-06 16:40:05 -0700 | [diff] [blame] | 77 | ModemProxyInterface *ProxyFactory::CreateModemProxy( |
Darin Petkov | c5f5656 | 2011-08-06 16:40:05 -0700 | [diff] [blame] | 78 | const string &path, |
| 79 | const string &service) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 80 | return new ModemProxy(connection(), path, service); |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 81 | } |
| 82 | |
Darin Petkov | e604f70 | 2011-07-28 15:51:17 -0700 | [diff] [blame] | 83 | ModemSimpleProxyInterface *ProxyFactory::CreateModemSimpleProxy( |
| 84 | const string &path, |
| 85 | const string &service) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 86 | return new ModemSimpleProxy(connection(), path, service); |
Darin Petkov | e604f70 | 2011-07-28 15:51:17 -0700 | [diff] [blame] | 87 | } |
| 88 | |
Darin Petkov | bec79a2 | 2011-08-01 14:47:17 -0700 | [diff] [blame] | 89 | ModemCDMAProxyInterface *ProxyFactory::CreateModemCDMAProxy( |
| 90 | const string &path, |
| 91 | const string &service) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 92 | return new ModemCDMAProxy(connection(), path, service); |
Darin Petkov | bec79a2 | 2011-08-01 14:47:17 -0700 | [diff] [blame] | 93 | } |
| 94 | |
Darin Petkov | 975b5e7 | 2011-08-30 11:48:08 -0700 | [diff] [blame] | 95 | ModemGSMCardProxyInterface *ProxyFactory::CreateModemGSMCardProxy( |
Darin Petkov | 975b5e7 | 2011-08-30 11:48:08 -0700 | [diff] [blame] | 96 | const string &path, |
| 97 | const string &service) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 98 | return new ModemGSMCardProxy(connection(), path, service); |
Darin Petkov | 975b5e7 | 2011-08-30 11:48:08 -0700 | [diff] [blame] | 99 | } |
| 100 | |
Darin Petkov | a1e0a1c | 2011-08-25 15:08:33 -0700 | [diff] [blame] | 101 | ModemGSMNetworkProxyInterface *ProxyFactory::CreateModemGSMNetworkProxy( |
Darin Petkov | a1e0a1c | 2011-08-25 15:08:33 -0700 | [diff] [blame] | 102 | const string &path, |
| 103 | const string &service) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 104 | return new ModemGSMNetworkProxy(connection(), path, service); |
Darin Petkov | a1e0a1c | 2011-08-25 15:08:33 -0700 | [diff] [blame] | 105 | } |
| 106 | |
Darin Petkov | c37a9c4 | 2012-09-06 15:28:22 +0200 | [diff] [blame] | 107 | ModemGobiProxyInterface *ProxyFactory::CreateModemGobiProxy( |
| 108 | const string &path, |
| 109 | const string &service) { |
| 110 | return new ModemGobiProxy(connection(), path, service); |
| 111 | } |
| 112 | |
Jason Glasgow | 9a0be63 | 2012-03-30 08:53:35 -0400 | [diff] [blame] | 113 | // Proxies for ModemManager1 interfaces |
| 114 | mm1::ModemModem3gppProxyInterface *ProxyFactory::CreateMM1ModemModem3gppProxy( |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 115 | const string &path, |
| 116 | const string &service) { |
Jason Glasgow | 9a0be63 | 2012-03-30 08:53:35 -0400 | [diff] [blame] | 117 | return new mm1::ModemModem3gppProxy(connection(), path, service); |
| 118 | } |
| 119 | |
| 120 | mm1::ModemModemCdmaProxyInterface *ProxyFactory::CreateMM1ModemModemCdmaProxy( |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 121 | const string &path, |
| 122 | const string &service) { |
Jason Glasgow | 9a0be63 | 2012-03-30 08:53:35 -0400 | [diff] [blame] | 123 | return new mm1::ModemModemCdmaProxy(connection(), path, service); |
| 124 | } |
| 125 | |
| 126 | mm1::ModemProxyInterface *ProxyFactory::CreateMM1ModemProxy( |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 127 | const string &path, |
| 128 | const string &service) { |
Jason Glasgow | 9a0be63 | 2012-03-30 08:53:35 -0400 | [diff] [blame] | 129 | return new mm1::ModemProxy(connection(), path, service); |
| 130 | } |
| 131 | |
| 132 | mm1::ModemSimpleProxyInterface *ProxyFactory::CreateMM1ModemSimpleProxy( |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 133 | const string &path, |
| 134 | const string &service) { |
Jason Glasgow | 9a0be63 | 2012-03-30 08:53:35 -0400 | [diff] [blame] | 135 | return new mm1::ModemSimpleProxy(connection(), path, service); |
| 136 | } |
| 137 | |
| 138 | mm1::SimProxyInterface *ProxyFactory::CreateSimProxy( |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 139 | const string &path, |
| 140 | const string &service) { |
Jason Glasgow | 9a0be63 | 2012-03-30 08:53:35 -0400 | [diff] [blame] | 141 | return new mm1::SimProxy(connection(), path, service); |
| 142 | } |
| 143 | |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 144 | WiMaxDeviceProxyInterface *ProxyFactory::CreateWiMaxDeviceProxy( |
| 145 | const string &path) { |
| 146 | return new WiMaxDeviceProxy(connection(), path); |
| 147 | } |
| 148 | |
| 149 | WiMaxManagerProxyInterface *ProxyFactory::CreateWiMaxManagerProxy() { |
| 150 | return new WiMaxManagerProxy(connection()); |
| 151 | } |
| 152 | |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 153 | WiMaxNetworkProxyInterface *ProxyFactory::CreateWiMaxNetworkProxy( |
| 154 | const string &path) { |
| 155 | return new WiMaxNetworkProxy(connection(), path); |
| 156 | } |
| 157 | |
Darin Petkov | 394b7d4 | 2011-11-03 15:48:02 +0100 | [diff] [blame] | 158 | PowerManagerProxyInterface *ProxyFactory::CreatePowerManagerProxy( |
| 159 | PowerManagerProxyDelegate *delegate) { |
| 160 | return new PowerManagerProxy(delegate, connection()); |
| 161 | } |
| 162 | |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 163 | SupplicantProcessProxyInterface *ProxyFactory::CreateSupplicantProcessProxy( |
Darin Petkov | d196726 | 2011-07-18 14:55:18 -0700 | [diff] [blame] | 164 | const char *dbus_path, |
| 165 | const char *dbus_addr) { |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 166 | return new SupplicantProcessProxy(connection(), dbus_path, dbus_addr); |
Darin Petkov | d196726 | 2011-07-18 14:55:18 -0700 | [diff] [blame] | 167 | } |
| 168 | |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 169 | SupplicantInterfaceProxyInterface *ProxyFactory::CreateSupplicantInterfaceProxy( |
Darin Petkov | d196726 | 2011-07-18 14:55:18 -0700 | [diff] [blame] | 170 | const WiFiRefPtr &wifi, |
| 171 | const DBus::Path &object_path, |
| 172 | const char *dbus_addr) { |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 173 | return new SupplicantInterfaceProxy(wifi, |
| 174 | connection(), |
| 175 | object_path, |
| 176 | dbus_addr); |
| 177 | } |
| 178 | |
mukesh agrawal | b20776f | 2012-02-10 16:00:36 -0800 | [diff] [blame] | 179 | SupplicantBSSProxyInterface *ProxyFactory::CreateSupplicantBSSProxy( |
| 180 | WiFiEndpoint *wifi_endpoint, |
| 181 | const DBus::Path &object_path, |
| 182 | const char *dbus_addr) { |
| 183 | return new SupplicantBSSProxy( |
| 184 | wifi_endpoint, connection(), object_path, dbus_addr); |
| 185 | } |
| 186 | |
Darin Petkov | a7b8949 | 2011-07-27 12:48:17 -0700 | [diff] [blame] | 187 | DHCPProxyInterface *ProxyFactory::CreateDHCPProxy(const string &service) { |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 188 | return new DHCPCDProxy(connection(), service); |
Darin Petkov | d196726 | 2011-07-18 14:55:18 -0700 | [diff] [blame] | 189 | } |
| 190 | |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 191 | } // namespace shill |