Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 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 | |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 9 | #include "shill/dbus_properties_proxy.h" |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 10 | #include "shill/dhcpcd_proxy.h" |
Darin Petkov | bec79a2 | 2011-08-01 14:47:17 -0700 | [diff] [blame] | 11 | #include "shill/modem_cdma_proxy.h" |
Darin Petkov | 975b5e7 | 2011-08-30 11:48:08 -0700 | [diff] [blame] | 12 | #include "shill/modem_gsm_card_proxy.h" |
Darin Petkov | a1e0a1c | 2011-08-25 15:08:33 -0700 | [diff] [blame] | 13 | #include "shill/modem_gsm_network_proxy.h" |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 14 | #include "shill/modem_manager_proxy.h" |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 15 | #include "shill/modem_proxy.h" |
Darin Petkov | e604f70 | 2011-07-28 15:51:17 -0700 | [diff] [blame] | 16 | #include "shill/modem_simple_proxy.h" |
Darin Petkov | 394b7d4 | 2011-11-03 15:48:02 +0100 | [diff] [blame] | 17 | #include "shill/power_manager_proxy.h" |
Darin Petkov | d196726 | 2011-07-18 14:55:18 -0700 | [diff] [blame] | 18 | #include "shill/supplicant_interface_proxy.h" |
| 19 | #include "shill/supplicant_process_proxy.h" |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 20 | |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 21 | using std::string; |
| 22 | |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 23 | namespace shill { |
| 24 | |
Darin Petkov | ab565bb | 2011-10-06 02:55:51 -0700 | [diff] [blame] | 25 | static base::LazyInstance<ProxyFactory> g_proxy_factory( |
| 26 | base::LINKER_INITIALIZED); |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 27 | |
| 28 | ProxyFactory::ProxyFactory() {} |
| 29 | |
| 30 | ProxyFactory::~ProxyFactory() {} |
| 31 | |
Darin Petkov | ab565bb | 2011-10-06 02:55:51 -0700 | [diff] [blame] | 32 | ProxyFactory *ProxyFactory::GetInstance() { |
| 33 | return g_proxy_factory.Pointer(); |
| 34 | } |
| 35 | |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 36 | void ProxyFactory::Init() { |
| 37 | CHECK(DBus::default_dispatcher); // Initialized in DBusControl::Init. |
| 38 | CHECK(!connection_.get()); |
| 39 | connection_.reset(new DBus::Connection(DBus::Connection::SystemBus())); |
| 40 | } |
| 41 | |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 42 | DBusPropertiesProxyInterface *ProxyFactory::CreateDBusPropertiesProxy( |
Darin Petkov | 580c7af | 2011-10-24 12:32:50 +0200 | [diff] [blame] | 43 | DBusPropertiesProxyDelegate *delegate, |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 44 | const string &path, |
| 45 | const string &service) { |
Darin Petkov | 580c7af | 2011-10-24 12:32:50 +0200 | [diff] [blame] | 46 | return new DBusPropertiesProxy(delegate, connection(), path, service); |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 47 | } |
| 48 | |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 49 | ModemManagerProxyInterface *ProxyFactory::CreateModemManagerProxy( |
| 50 | ModemManager *manager, |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 51 | const string &path, |
| 52 | const string &service) { |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 53 | return new ModemManagerProxy(connection(), manager, path, service); |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 54 | } |
| 55 | |
Darin Petkov | c5f5656 | 2011-08-06 16:40:05 -0700 | [diff] [blame] | 56 | ModemProxyInterface *ProxyFactory::CreateModemProxy( |
Darin Petkov | 580c7af | 2011-10-24 12:32:50 +0200 | [diff] [blame] | 57 | ModemProxyDelegate *delegate, |
Darin Petkov | c5f5656 | 2011-08-06 16:40:05 -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 ModemProxy(delegate, connection(), path, service); |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 61 | } |
| 62 | |
Darin Petkov | e604f70 | 2011-07-28 15:51:17 -0700 | [diff] [blame] | 63 | ModemSimpleProxyInterface *ProxyFactory::CreateModemSimpleProxy( |
| 64 | const string &path, |
| 65 | const string &service) { |
| 66 | return new ModemSimpleProxy(connection(), path, service); |
| 67 | } |
| 68 | |
Darin Petkov | bec79a2 | 2011-08-01 14:47:17 -0700 | [diff] [blame] | 69 | ModemCDMAProxyInterface *ProxyFactory::CreateModemCDMAProxy( |
Darin Petkov | 580c7af | 2011-10-24 12:32:50 +0200 | [diff] [blame] | 70 | ModemCDMAProxyDelegate *delegate, |
Darin Petkov | bec79a2 | 2011-08-01 14:47:17 -0700 | [diff] [blame] | 71 | const string &path, |
| 72 | const string &service) { |
Darin Petkov | 580c7af | 2011-10-24 12:32:50 +0200 | [diff] [blame] | 73 | return new ModemCDMAProxy(delegate, connection(), path, service); |
Darin Petkov | bec79a2 | 2011-08-01 14:47:17 -0700 | [diff] [blame] | 74 | } |
| 75 | |
Darin Petkov | 975b5e7 | 2011-08-30 11:48:08 -0700 | [diff] [blame] | 76 | ModemGSMCardProxyInterface *ProxyFactory::CreateModemGSMCardProxy( |
Darin Petkov | 580c7af | 2011-10-24 12:32:50 +0200 | [diff] [blame] | 77 | ModemGSMCardProxyDelegate *delegate, |
Darin Petkov | 975b5e7 | 2011-08-30 11:48:08 -0700 | [diff] [blame] | 78 | const string &path, |
| 79 | const string &service) { |
Darin Petkov | 580c7af | 2011-10-24 12:32:50 +0200 | [diff] [blame] | 80 | return new ModemGSMCardProxy(delegate, connection(), path, service); |
Darin Petkov | 975b5e7 | 2011-08-30 11:48:08 -0700 | [diff] [blame] | 81 | } |
| 82 | |
Darin Petkov | a1e0a1c | 2011-08-25 15:08:33 -0700 | [diff] [blame] | 83 | ModemGSMNetworkProxyInterface *ProxyFactory::CreateModemGSMNetworkProxy( |
Darin Petkov | 580c7af | 2011-10-24 12:32:50 +0200 | [diff] [blame] | 84 | ModemGSMNetworkProxyDelegate *delegate, |
Darin Petkov | a1e0a1c | 2011-08-25 15:08:33 -0700 | [diff] [blame] | 85 | const string &path, |
| 86 | const string &service) { |
Darin Petkov | 580c7af | 2011-10-24 12:32:50 +0200 | [diff] [blame] | 87 | return new ModemGSMNetworkProxy(delegate, connection(), path, service); |
Darin Petkov | a1e0a1c | 2011-08-25 15:08:33 -0700 | [diff] [blame] | 88 | } |
| 89 | |
Darin Petkov | 394b7d4 | 2011-11-03 15:48:02 +0100 | [diff] [blame] | 90 | PowerManagerProxyInterface *ProxyFactory::CreatePowerManagerProxy( |
| 91 | PowerManagerProxyDelegate *delegate) { |
| 92 | return new PowerManagerProxy(delegate, connection()); |
| 93 | } |
| 94 | |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 95 | SupplicantProcessProxyInterface *ProxyFactory::CreateSupplicantProcessProxy( |
Darin Petkov | d196726 | 2011-07-18 14:55:18 -0700 | [diff] [blame] | 96 | const char *dbus_path, |
| 97 | const char *dbus_addr) { |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 98 | return new SupplicantProcessProxy(connection(), dbus_path, dbus_addr); |
Darin Petkov | d196726 | 2011-07-18 14:55:18 -0700 | [diff] [blame] | 99 | } |
| 100 | |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 101 | SupplicantInterfaceProxyInterface *ProxyFactory::CreateSupplicantInterfaceProxy( |
Darin Petkov | d196726 | 2011-07-18 14:55:18 -0700 | [diff] [blame] | 102 | const WiFiRefPtr &wifi, |
| 103 | const DBus::Path &object_path, |
| 104 | const char *dbus_addr) { |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 105 | return new SupplicantInterfaceProxy(wifi, |
| 106 | connection(), |
| 107 | object_path, |
| 108 | dbus_addr); |
| 109 | } |
| 110 | |
Darin Petkov | a7b8949 | 2011-07-27 12:48:17 -0700 | [diff] [blame] | 111 | DHCPProxyInterface *ProxyFactory::CreateDHCPProxy(const string &service) { |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 112 | return new DHCPCDProxy(connection(), service); |
Darin Petkov | d196726 | 2011-07-18 14:55:18 -0700 | [diff] [blame] | 113 | } |
| 114 | |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 115 | } // namespace shill |