blob: 14c111712ebb95a6f23d15f926a7fb82efe0ffe1 [file] [log] [blame]
Eric Shienbrood5de44ab2011-12-05 10:46:27 -05001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Darin Petkovc90fe522011-07-15 13:59:47 -07002// 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 Petkovaceede32011-07-18 15:32:38 -07007#include <base/logging.h>
8
Darin Petkov5c97ac52011-07-19 16:30:49 -07009#include "shill/dbus_properties_proxy.h"
Darin Petkovaceede32011-07-18 15:32:38 -070010#include "shill/dhcpcd_proxy.h"
Darin Petkovbec79a22011-08-01 14:47:17 -070011#include "shill/modem_cdma_proxy.h"
Darin Petkov975b5e72011-08-30 11:48:08 -070012#include "shill/modem_gsm_card_proxy.h"
Darin Petkova1e0a1c2011-08-25 15:08:33 -070013#include "shill/modem_gsm_network_proxy.h"
Darin Petkovc90fe522011-07-15 13:59:47 -070014#include "shill/modem_manager_proxy.h"
Darin Petkove9d12e02011-07-27 15:09:37 -070015#include "shill/modem_proxy.h"
Darin Petkove604f702011-07-28 15:51:17 -070016#include "shill/modem_simple_proxy.h"
Darin Petkov394b7d42011-11-03 15:48:02 +010017#include "shill/power_manager_proxy.h"
mukesh agrawalb20776f2012-02-10 16:00:36 -080018#include "shill/supplicant_bss_proxy.h"
Darin Petkovd1967262011-07-18 14:55:18 -070019#include "shill/supplicant_interface_proxy.h"
20#include "shill/supplicant_process_proxy.h"
Darin Petkovc90fe522011-07-15 13:59:47 -070021
Darin Petkov5c97ac52011-07-19 16:30:49 -070022using std::string;
23
Darin Petkovc90fe522011-07-15 13:59:47 -070024namespace shill {
25
Darin Petkovab565bb2011-10-06 02:55:51 -070026static base::LazyInstance<ProxyFactory> g_proxy_factory(
27 base::LINKER_INITIALIZED);
Darin Petkovc90fe522011-07-15 13:59:47 -070028
29ProxyFactory::ProxyFactory() {}
30
31ProxyFactory::~ProxyFactory() {}
32
Darin Petkovab565bb2011-10-06 02:55:51 -070033ProxyFactory *ProxyFactory::GetInstance() {
34 return g_proxy_factory.Pointer();
35}
36
Darin Petkovaceede32011-07-18 15:32:38 -070037void ProxyFactory::Init() {
38 CHECK(DBus::default_dispatcher); // Initialized in DBusControl::Init.
39 CHECK(!connection_.get());
40 connection_.reset(new DBus::Connection(DBus::Connection::SystemBus()));
41}
42
Darin Petkov5c97ac52011-07-19 16:30:49 -070043DBusPropertiesProxyInterface *ProxyFactory::CreateDBusPropertiesProxy(
Darin Petkov580c7af2011-10-24 12:32:50 +020044 DBusPropertiesProxyDelegate *delegate,
Darin Petkov5c97ac52011-07-19 16:30:49 -070045 const string &path,
46 const string &service) {
Darin Petkov580c7af2011-10-24 12:32:50 +020047 return new DBusPropertiesProxy(delegate, connection(), path, service);
Darin Petkov5c97ac52011-07-19 16:30:49 -070048}
49
Darin Petkovc90fe522011-07-15 13:59:47 -070050ModemManagerProxyInterface *ProxyFactory::CreateModemManagerProxy(
51 ModemManager *manager,
Darin Petkov5c97ac52011-07-19 16:30:49 -070052 const string &path,
53 const string &service) {
Darin Petkovaceede32011-07-18 15:32:38 -070054 return new ModemManagerProxy(connection(), manager, path, service);
Darin Petkovc90fe522011-07-15 13:59:47 -070055}
56
Darin Petkovc5f56562011-08-06 16:40:05 -070057ModemProxyInterface *ProxyFactory::CreateModemProxy(
Darin Petkov580c7af2011-10-24 12:32:50 +020058 ModemProxyDelegate *delegate,
Darin Petkovc5f56562011-08-06 16:40:05 -070059 const string &path,
60 const string &service) {
Darin Petkov580c7af2011-10-24 12:32:50 +020061 return new ModemProxy(delegate, connection(), path, service);
Darin Petkove9d12e02011-07-27 15:09:37 -070062}
63
Darin Petkove604f702011-07-28 15:51:17 -070064ModemSimpleProxyInterface *ProxyFactory::CreateModemSimpleProxy(
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050065 ModemSimpleProxyDelegate *delegate,
Darin Petkove604f702011-07-28 15:51:17 -070066 const string &path,
67 const string &service) {
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050068 return new ModemSimpleProxy(delegate, connection(), path, service);
Darin Petkove604f702011-07-28 15:51:17 -070069}
70
Darin Petkovbec79a22011-08-01 14:47:17 -070071ModemCDMAProxyInterface *ProxyFactory::CreateModemCDMAProxy(
Darin Petkov580c7af2011-10-24 12:32:50 +020072 ModemCDMAProxyDelegate *delegate,
Darin Petkovbec79a22011-08-01 14:47:17 -070073 const string &path,
74 const string &service) {
Darin Petkov580c7af2011-10-24 12:32:50 +020075 return new ModemCDMAProxy(delegate, connection(), path, service);
Darin Petkovbec79a22011-08-01 14:47:17 -070076}
77
Darin Petkov975b5e72011-08-30 11:48:08 -070078ModemGSMCardProxyInterface *ProxyFactory::CreateModemGSMCardProxy(
Darin Petkov580c7af2011-10-24 12:32:50 +020079 ModemGSMCardProxyDelegate *delegate,
Darin Petkov975b5e72011-08-30 11:48:08 -070080 const string &path,
81 const string &service) {
Darin Petkov580c7af2011-10-24 12:32:50 +020082 return new ModemGSMCardProxy(delegate, connection(), path, service);
Darin Petkov975b5e72011-08-30 11:48:08 -070083}
84
Darin Petkova1e0a1c2011-08-25 15:08:33 -070085ModemGSMNetworkProxyInterface *ProxyFactory::CreateModemGSMNetworkProxy(
Darin Petkov580c7af2011-10-24 12:32:50 +020086 ModemGSMNetworkProxyDelegate *delegate,
Darin Petkova1e0a1c2011-08-25 15:08:33 -070087 const string &path,
88 const string &service) {
Darin Petkov580c7af2011-10-24 12:32:50 +020089 return new ModemGSMNetworkProxy(delegate, connection(), path, service);
Darin Petkova1e0a1c2011-08-25 15:08:33 -070090}
91
Darin Petkov394b7d42011-11-03 15:48:02 +010092PowerManagerProxyInterface *ProxyFactory::CreatePowerManagerProxy(
93 PowerManagerProxyDelegate *delegate) {
94 return new PowerManagerProxy(delegate, connection());
95}
96
Darin Petkovaceede32011-07-18 15:32:38 -070097SupplicantProcessProxyInterface *ProxyFactory::CreateSupplicantProcessProxy(
Darin Petkovd1967262011-07-18 14:55:18 -070098 const char *dbus_path,
99 const char *dbus_addr) {
Darin Petkovaceede32011-07-18 15:32:38 -0700100 return new SupplicantProcessProxy(connection(), dbus_path, dbus_addr);
Darin Petkovd1967262011-07-18 14:55:18 -0700101}
102
Darin Petkovaceede32011-07-18 15:32:38 -0700103SupplicantInterfaceProxyInterface *ProxyFactory::CreateSupplicantInterfaceProxy(
Darin Petkovd1967262011-07-18 14:55:18 -0700104 const WiFiRefPtr &wifi,
105 const DBus::Path &object_path,
106 const char *dbus_addr) {
Darin Petkovaceede32011-07-18 15:32:38 -0700107 return new SupplicantInterfaceProxy(wifi,
108 connection(),
109 object_path,
110 dbus_addr);
111}
112
mukesh agrawalb20776f2012-02-10 16:00:36 -0800113SupplicantBSSProxyInterface *ProxyFactory::CreateSupplicantBSSProxy(
114 WiFiEndpoint *wifi_endpoint,
115 const DBus::Path &object_path,
116 const char *dbus_addr) {
117 return new SupplicantBSSProxy(
118 wifi_endpoint, connection(), object_path, dbus_addr);
119}
120
Darin Petkova7b89492011-07-27 12:48:17 -0700121DHCPProxyInterface *ProxyFactory::CreateDHCPProxy(const string &service) {
Darin Petkovaceede32011-07-18 15:32:38 -0700122 return new DHCPCDProxy(connection(), service);
Darin Petkovd1967262011-07-18 14:55:18 -0700123}
124
Darin Petkovc90fe522011-07-15 13:59:47 -0700125} // namespace shill