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 | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 7 | #include <base/logging.h> |
| 8 | |
David Rochberg | 24c6c62 | 2012-03-05 11:30:44 -0500 | [diff] [blame] | 9 | #include "shill/dbus_objectmanager_proxy.h" |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 10 | #include "shill/dbus_properties_proxy.h" |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 11 | #include "shill/dhcpcd_proxy.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 | 975b5e7 | 2011-08-30 11:48:08 -0700 | [diff] [blame] | 18 | #include "shill/modem_gsm_card_proxy.h" |
Darin Petkov | a1e0a1c | 2011-08-25 15:08:33 -0700 | [diff] [blame] | 19 | #include "shill/modem_gsm_network_proxy.h" |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 20 | #include "shill/modem_manager_proxy.h" |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 21 | #include "shill/modem_proxy.h" |
Darin Petkov | e604f70 | 2011-07-28 15:51:17 -0700 | [diff] [blame] | 22 | #include "shill/modem_simple_proxy.h" |
Darin Petkov | 394b7d4 | 2011-11-03 15:48:02 +0100 | [diff] [blame] | 23 | #include "shill/power_manager_proxy.h" |
mukesh agrawal | b20776f | 2012-02-10 16:00:36 -0800 | [diff] [blame] | 24 | #include "shill/supplicant_bss_proxy.h" |
Darin Petkov | d196726 | 2011-07-18 14:55:18 -0700 | [diff] [blame] | 25 | #include "shill/supplicant_interface_proxy.h" |
| 26 | #include "shill/supplicant_process_proxy.h" |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 27 | |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 28 | using std::string; |
| 29 | |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 30 | namespace shill { |
| 31 | |
Eric Shienbrood | 3e20a23 | 2012-02-16 11:35:56 -0500 | [diff] [blame] | 32 | // TODO(ers): not using LAZY_INSTANCE_INITIALIZER |
| 33 | // because of http://crbug.com/114828 |
| 34 | static base::LazyInstance<ProxyFactory> g_proxy_factory = {0, {{0}}}; |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 35 | |
| 36 | ProxyFactory::ProxyFactory() {} |
| 37 | |
| 38 | ProxyFactory::~ProxyFactory() {} |
| 39 | |
Darin Petkov | ab565bb | 2011-10-06 02:55:51 -0700 | [diff] [blame] | 40 | ProxyFactory *ProxyFactory::GetInstance() { |
| 41 | return g_proxy_factory.Pointer(); |
| 42 | } |
| 43 | |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 44 | void ProxyFactory::Init() { |
| 45 | CHECK(DBus::default_dispatcher); // Initialized in DBusControl::Init. |
| 46 | CHECK(!connection_.get()); |
| 47 | connection_.reset(new DBus::Connection(DBus::Connection::SystemBus())); |
| 48 | } |
| 49 | |
David Rochberg | 24c6c62 | 2012-03-05 11:30:44 -0500 | [diff] [blame] | 50 | DBusObjectManagerProxyInterface *ProxyFactory::CreateDBusObjectManagerProxy( |
David Rochberg | 24c6c62 | 2012-03-05 11:30:44 -0500 | [diff] [blame] | 51 | const string &path, |
| 52 | const string &service) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 53 | return new DBusObjectManagerProxy(connection(), path, service); |
David Rochberg | 24c6c62 | 2012-03-05 11:30:44 -0500 | [diff] [blame] | 54 | } |
| 55 | |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 56 | DBusPropertiesProxyInterface *ProxyFactory::CreateDBusPropertiesProxy( |
Darin Petkov | 580c7af | 2011-10-24 12:32:50 +0200 | [diff] [blame] | 57 | DBusPropertiesProxyDelegate *delegate, |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 58 | const string &path, |
| 59 | const string &service) { |
Darin Petkov | 580c7af | 2011-10-24 12:32:50 +0200 | [diff] [blame] | 60 | return new DBusPropertiesProxy(delegate, connection(), path, service); |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 61 | } |
| 62 | |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 63 | ModemManagerProxyInterface *ProxyFactory::CreateModemManagerProxy( |
David Rochberg | 81030ea | 2012-03-02 15:44:25 -0500 | [diff] [blame] | 64 | ModemManagerClassic *manager, |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 65 | const string &path, |
| 66 | const string &service) { |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 67 | return new ModemManagerProxy(connection(), manager, path, service); |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 68 | } |
| 69 | |
Darin Petkov | c5f5656 | 2011-08-06 16:40:05 -0700 | [diff] [blame] | 70 | ModemProxyInterface *ProxyFactory::CreateModemProxy( |
Darin Petkov | c5f5656 | 2011-08-06 16:40:05 -0700 | [diff] [blame] | 71 | const string &path, |
| 72 | const string &service) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 73 | return new ModemProxy(connection(), path, service); |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 74 | } |
| 75 | |
Darin Petkov | e604f70 | 2011-07-28 15:51:17 -0700 | [diff] [blame] | 76 | ModemSimpleProxyInterface *ProxyFactory::CreateModemSimpleProxy( |
| 77 | const string &path, |
| 78 | const string &service) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 79 | return new ModemSimpleProxy(connection(), path, service); |
Darin Petkov | e604f70 | 2011-07-28 15:51:17 -0700 | [diff] [blame] | 80 | } |
| 81 | |
Darin Petkov | bec79a2 | 2011-08-01 14:47:17 -0700 | [diff] [blame] | 82 | ModemCDMAProxyInterface *ProxyFactory::CreateModemCDMAProxy( |
| 83 | const string &path, |
| 84 | const string &service) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 85 | return new ModemCDMAProxy(connection(), path, service); |
Darin Petkov | bec79a2 | 2011-08-01 14:47:17 -0700 | [diff] [blame] | 86 | } |
| 87 | |
Darin Petkov | 975b5e7 | 2011-08-30 11:48:08 -0700 | [diff] [blame] | 88 | ModemGSMCardProxyInterface *ProxyFactory::CreateModemGSMCardProxy( |
Darin Petkov | 975b5e7 | 2011-08-30 11:48:08 -0700 | [diff] [blame] | 89 | const string &path, |
| 90 | const string &service) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 91 | return new ModemGSMCardProxy(connection(), path, service); |
Darin Petkov | 975b5e7 | 2011-08-30 11:48:08 -0700 | [diff] [blame] | 92 | } |
| 93 | |
Darin Petkov | a1e0a1c | 2011-08-25 15:08:33 -0700 | [diff] [blame] | 94 | ModemGSMNetworkProxyInterface *ProxyFactory::CreateModemGSMNetworkProxy( |
Darin Petkov | a1e0a1c | 2011-08-25 15:08:33 -0700 | [diff] [blame] | 95 | const string &path, |
| 96 | const string &service) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 97 | return new ModemGSMNetworkProxy(connection(), path, service); |
Darin Petkov | a1e0a1c | 2011-08-25 15:08:33 -0700 | [diff] [blame] | 98 | } |
| 99 | |
Jason Glasgow | 9a0be63 | 2012-03-30 08:53:35 -0400 | [diff] [blame] | 100 | // Proxies for ModemManager1 interfaces |
| 101 | mm1::ModemModem3gppProxyInterface *ProxyFactory::CreateMM1ModemModem3gppProxy( |
| 102 | const std::string &path, |
| 103 | const std::string &service) { |
| 104 | return new mm1::ModemModem3gppProxy(connection(), path, service); |
| 105 | } |
| 106 | |
| 107 | mm1::ModemModemCdmaProxyInterface *ProxyFactory::CreateMM1ModemModemCdmaProxy( |
| 108 | const std::string &path, |
| 109 | const std::string &service) { |
| 110 | return new mm1::ModemModemCdmaProxy(connection(), path, service); |
| 111 | } |
| 112 | |
| 113 | mm1::ModemProxyInterface *ProxyFactory::CreateMM1ModemProxy( |
| 114 | const std::string &path, |
| 115 | const std::string &service) { |
| 116 | return new mm1::ModemProxy(connection(), path, service); |
| 117 | } |
| 118 | |
| 119 | mm1::ModemSimpleProxyInterface *ProxyFactory::CreateMM1ModemSimpleProxy( |
| 120 | const std::string &path, |
| 121 | const std::string &service) { |
| 122 | return new mm1::ModemSimpleProxy(connection(), path, service); |
| 123 | } |
| 124 | |
| 125 | mm1::SimProxyInterface *ProxyFactory::CreateSimProxy( |
| 126 | const std::string &path, |
| 127 | const std::string &service) { |
| 128 | return new mm1::SimProxy(connection(), path, service); |
| 129 | } |
| 130 | |
Darin Petkov | 394b7d4 | 2011-11-03 15:48:02 +0100 | [diff] [blame] | 131 | PowerManagerProxyInterface *ProxyFactory::CreatePowerManagerProxy( |
| 132 | PowerManagerProxyDelegate *delegate) { |
| 133 | return new PowerManagerProxy(delegate, connection()); |
| 134 | } |
| 135 | |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 136 | SupplicantProcessProxyInterface *ProxyFactory::CreateSupplicantProcessProxy( |
Darin Petkov | d196726 | 2011-07-18 14:55:18 -0700 | [diff] [blame] | 137 | const char *dbus_path, |
| 138 | const char *dbus_addr) { |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 139 | return new SupplicantProcessProxy(connection(), dbus_path, dbus_addr); |
Darin Petkov | d196726 | 2011-07-18 14:55:18 -0700 | [diff] [blame] | 140 | } |
| 141 | |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 142 | SupplicantInterfaceProxyInterface *ProxyFactory::CreateSupplicantInterfaceProxy( |
Darin Petkov | d196726 | 2011-07-18 14:55:18 -0700 | [diff] [blame] | 143 | const WiFiRefPtr &wifi, |
| 144 | const DBus::Path &object_path, |
| 145 | const char *dbus_addr) { |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 146 | return new SupplicantInterfaceProxy(wifi, |
| 147 | connection(), |
| 148 | object_path, |
| 149 | dbus_addr); |
| 150 | } |
| 151 | |
mukesh agrawal | b20776f | 2012-02-10 16:00:36 -0800 | [diff] [blame] | 152 | SupplicantBSSProxyInterface *ProxyFactory::CreateSupplicantBSSProxy( |
| 153 | WiFiEndpoint *wifi_endpoint, |
| 154 | const DBus::Path &object_path, |
| 155 | const char *dbus_addr) { |
| 156 | return new SupplicantBSSProxy( |
| 157 | wifi_endpoint, connection(), object_path, dbus_addr); |
| 158 | } |
| 159 | |
Darin Petkov | a7b8949 | 2011-07-27 12:48:17 -0700 | [diff] [blame] | 160 | DHCPProxyInterface *ProxyFactory::CreateDHCPProxy(const string &service) { |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 161 | return new DHCPCDProxy(connection(), service); |
Darin Petkov | d196726 | 2011-07-18 14:55:18 -0700 | [diff] [blame] | 162 | } |
| 163 | |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 164 | } // namespace shill |