blob: 387ad3d26bf3339649acaa99d9ef714ed344e294 [file] [log] [blame]
Darin Petkovc90fe522011-07-15 13:59:47 -07001// 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 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"
Darin Petkovd1967262011-07-18 14:55:18 -070018#include "shill/supplicant_interface_proxy.h"
19#include "shill/supplicant_process_proxy.h"
Darin Petkovc90fe522011-07-15 13:59:47 -070020
Darin Petkov5c97ac52011-07-19 16:30:49 -070021using std::string;
22
Darin Petkovc90fe522011-07-15 13:59:47 -070023namespace shill {
24
Darin Petkovab565bb2011-10-06 02:55:51 -070025static base::LazyInstance<ProxyFactory> g_proxy_factory(
26 base::LINKER_INITIALIZED);
Darin Petkovc90fe522011-07-15 13:59:47 -070027
28ProxyFactory::ProxyFactory() {}
29
30ProxyFactory::~ProxyFactory() {}
31
Darin Petkovab565bb2011-10-06 02:55:51 -070032ProxyFactory *ProxyFactory::GetInstance() {
33 return g_proxy_factory.Pointer();
34}
35
Darin Petkovaceede32011-07-18 15:32:38 -070036void 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 Petkov5c97ac52011-07-19 16:30:49 -070042DBusPropertiesProxyInterface *ProxyFactory::CreateDBusPropertiesProxy(
Darin Petkov580c7af2011-10-24 12:32:50 +020043 DBusPropertiesProxyDelegate *delegate,
Darin Petkov5c97ac52011-07-19 16:30:49 -070044 const string &path,
45 const string &service) {
Darin Petkov580c7af2011-10-24 12:32:50 +020046 return new DBusPropertiesProxy(delegate, connection(), path, service);
Darin Petkov5c97ac52011-07-19 16:30:49 -070047}
48
Darin Petkovc90fe522011-07-15 13:59:47 -070049ModemManagerProxyInterface *ProxyFactory::CreateModemManagerProxy(
50 ModemManager *manager,
Darin Petkov5c97ac52011-07-19 16:30:49 -070051 const string &path,
52 const string &service) {
Darin Petkovaceede32011-07-18 15:32:38 -070053 return new ModemManagerProxy(connection(), manager, path, service);
Darin Petkovc90fe522011-07-15 13:59:47 -070054}
55
Darin Petkovc5f56562011-08-06 16:40:05 -070056ModemProxyInterface *ProxyFactory::CreateModemProxy(
Darin Petkov580c7af2011-10-24 12:32:50 +020057 ModemProxyDelegate *delegate,
Darin Petkovc5f56562011-08-06 16:40:05 -070058 const string &path,
59 const string &service) {
Darin Petkov580c7af2011-10-24 12:32:50 +020060 return new ModemProxy(delegate, connection(), path, service);
Darin Petkove9d12e02011-07-27 15:09:37 -070061}
62
Darin Petkove604f702011-07-28 15:51:17 -070063ModemSimpleProxyInterface *ProxyFactory::CreateModemSimpleProxy(
64 const string &path,
65 const string &service) {
66 return new ModemSimpleProxy(connection(), path, service);
67}
68
Darin Petkovbec79a22011-08-01 14:47:17 -070069ModemCDMAProxyInterface *ProxyFactory::CreateModemCDMAProxy(
Darin Petkov580c7af2011-10-24 12:32:50 +020070 ModemCDMAProxyDelegate *delegate,
Darin Petkovbec79a22011-08-01 14:47:17 -070071 const string &path,
72 const string &service) {
Darin Petkov580c7af2011-10-24 12:32:50 +020073 return new ModemCDMAProxy(delegate, connection(), path, service);
Darin Petkovbec79a22011-08-01 14:47:17 -070074}
75
Darin Petkov975b5e72011-08-30 11:48:08 -070076ModemGSMCardProxyInterface *ProxyFactory::CreateModemGSMCardProxy(
Darin Petkov580c7af2011-10-24 12:32:50 +020077 ModemGSMCardProxyDelegate *delegate,
Darin Petkov975b5e72011-08-30 11:48:08 -070078 const string &path,
79 const string &service) {
Darin Petkov580c7af2011-10-24 12:32:50 +020080 return new ModemGSMCardProxy(delegate, connection(), path, service);
Darin Petkov975b5e72011-08-30 11:48:08 -070081}
82
Darin Petkova1e0a1c2011-08-25 15:08:33 -070083ModemGSMNetworkProxyInterface *ProxyFactory::CreateModemGSMNetworkProxy(
Darin Petkov580c7af2011-10-24 12:32:50 +020084 ModemGSMNetworkProxyDelegate *delegate,
Darin Petkova1e0a1c2011-08-25 15:08:33 -070085 const string &path,
86 const string &service) {
Darin Petkov580c7af2011-10-24 12:32:50 +020087 return new ModemGSMNetworkProxy(delegate, connection(), path, service);
Darin Petkova1e0a1c2011-08-25 15:08:33 -070088}
89
Darin Petkov394b7d42011-11-03 15:48:02 +010090PowerManagerProxyInterface *ProxyFactory::CreatePowerManagerProxy(
91 PowerManagerProxyDelegate *delegate) {
92 return new PowerManagerProxy(delegate, connection());
93}
94
Darin Petkovaceede32011-07-18 15:32:38 -070095SupplicantProcessProxyInterface *ProxyFactory::CreateSupplicantProcessProxy(
Darin Petkovd1967262011-07-18 14:55:18 -070096 const char *dbus_path,
97 const char *dbus_addr) {
Darin Petkovaceede32011-07-18 15:32:38 -070098 return new SupplicantProcessProxy(connection(), dbus_path, dbus_addr);
Darin Petkovd1967262011-07-18 14:55:18 -070099}
100
Darin Petkovaceede32011-07-18 15:32:38 -0700101SupplicantInterfaceProxyInterface *ProxyFactory::CreateSupplicantInterfaceProxy(
Darin Petkovd1967262011-07-18 14:55:18 -0700102 const WiFiRefPtr &wifi,
103 const DBus::Path &object_path,
104 const char *dbus_addr) {
Darin Petkovaceede32011-07-18 15:32:38 -0700105 return new SupplicantInterfaceProxy(wifi,
106 connection(),
107 object_path,
108 dbus_addr);
109}
110
Darin Petkova7b89492011-07-27 12:48:17 -0700111DHCPProxyInterface *ProxyFactory::CreateDHCPProxy(const string &service) {
Darin Petkovaceede32011-07-18 15:32:38 -0700112 return new DHCPCDProxy(connection(), service);
Darin Petkovd1967262011-07-18 14:55:18 -0700113}
114
Darin Petkovc90fe522011-07-15 13:59:47 -0700115} // namespace shill