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 | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 12 | #include "shill/modem_manager_proxy.h" |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 13 | #include "shill/modem_proxy.h" |
Darin Petkov | e604f70 | 2011-07-28 15:51:17 -0700 | [diff] [blame] | 14 | #include "shill/modem_simple_proxy.h" |
Darin Petkov | d196726 | 2011-07-18 14:55:18 -0700 | [diff] [blame] | 15 | #include "shill/supplicant_interface_proxy.h" |
| 16 | #include "shill/supplicant_process_proxy.h" |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 17 | |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 18 | using std::string; |
| 19 | |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 20 | namespace shill { |
| 21 | |
| 22 | ProxyFactory *ProxyFactory::factory_ = NULL; |
| 23 | |
| 24 | ProxyFactory::ProxyFactory() {} |
| 25 | |
| 26 | ProxyFactory::~ProxyFactory() {} |
| 27 | |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 28 | void ProxyFactory::Init() { |
| 29 | CHECK(DBus::default_dispatcher); // Initialized in DBusControl::Init. |
| 30 | CHECK(!connection_.get()); |
| 31 | connection_.reset(new DBus::Connection(DBus::Connection::SystemBus())); |
| 32 | } |
| 33 | |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 34 | DBusPropertiesProxyInterface *ProxyFactory::CreateDBusPropertiesProxy( |
Darin Petkov | c5f5656 | 2011-08-06 16:40:05 -0700 | [diff] [blame] | 35 | DBusPropertiesProxyListener *listener, |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 36 | const string &path, |
| 37 | const string &service) { |
Darin Petkov | c5f5656 | 2011-08-06 16:40:05 -0700 | [diff] [blame] | 38 | return new DBusPropertiesProxy(listener, connection(), path, service); |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 39 | } |
| 40 | |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 41 | ModemManagerProxyInterface *ProxyFactory::CreateModemManagerProxy( |
| 42 | ModemManager *manager, |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 43 | const string &path, |
| 44 | const string &service) { |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 45 | return new ModemManagerProxy(connection(), manager, path, service); |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 46 | } |
| 47 | |
Darin Petkov | c5f5656 | 2011-08-06 16:40:05 -0700 | [diff] [blame] | 48 | ModemProxyInterface *ProxyFactory::CreateModemProxy( |
| 49 | ModemProxyListener *listener, |
| 50 | const string &path, |
| 51 | const string &service) { |
| 52 | return new ModemProxy(listener, connection(), path, service); |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 53 | } |
| 54 | |
Darin Petkov | e604f70 | 2011-07-28 15:51:17 -0700 | [diff] [blame] | 55 | ModemSimpleProxyInterface *ProxyFactory::CreateModemSimpleProxy( |
| 56 | const string &path, |
| 57 | const string &service) { |
| 58 | return new ModemSimpleProxy(connection(), path, service); |
| 59 | } |
| 60 | |
Darin Petkov | bec79a2 | 2011-08-01 14:47:17 -0700 | [diff] [blame] | 61 | ModemCDMAProxyInterface *ProxyFactory::CreateModemCDMAProxy( |
Darin Petkov | d966195 | 2011-08-03 16:25:42 -0700 | [diff] [blame] | 62 | ModemCDMAProxyListener *listener, |
Darin Petkov | bec79a2 | 2011-08-01 14:47:17 -0700 | [diff] [blame] | 63 | const string &path, |
| 64 | const string &service) { |
Darin Petkov | d966195 | 2011-08-03 16:25:42 -0700 | [diff] [blame] | 65 | return new ModemCDMAProxy(listener, connection(), path, service); |
Darin Petkov | bec79a2 | 2011-08-01 14:47:17 -0700 | [diff] [blame] | 66 | } |
| 67 | |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 68 | SupplicantProcessProxyInterface *ProxyFactory::CreateSupplicantProcessProxy( |
Darin Petkov | d196726 | 2011-07-18 14:55:18 -0700 | [diff] [blame] | 69 | const char *dbus_path, |
| 70 | const char *dbus_addr) { |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 71 | return new SupplicantProcessProxy(connection(), dbus_path, dbus_addr); |
Darin Petkov | d196726 | 2011-07-18 14:55:18 -0700 | [diff] [blame] | 72 | } |
| 73 | |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 74 | SupplicantInterfaceProxyInterface *ProxyFactory::CreateSupplicantInterfaceProxy( |
Darin Petkov | d196726 | 2011-07-18 14:55:18 -0700 | [diff] [blame] | 75 | const WiFiRefPtr &wifi, |
| 76 | const DBus::Path &object_path, |
| 77 | const char *dbus_addr) { |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 78 | return new SupplicantInterfaceProxy(wifi, |
| 79 | connection(), |
| 80 | object_path, |
| 81 | dbus_addr); |
| 82 | } |
| 83 | |
Darin Petkov | a7b8949 | 2011-07-27 12:48:17 -0700 | [diff] [blame] | 84 | DHCPProxyInterface *ProxyFactory::CreateDHCPProxy(const string &service) { |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 85 | return new DHCPCDProxy(connection(), service); |
Darin Petkov | d196726 | 2011-07-18 14:55:18 -0700 | [diff] [blame] | 86 | } |
| 87 | |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 88 | } // namespace shill |