blob: c5191c64fc5272f61999aa7361cd2c1354f7ce8e [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 Petkovc90fe522011-07-15 13:59:47 -070012#include "shill/modem_manager_proxy.h"
Darin Petkove9d12e02011-07-27 15:09:37 -070013#include "shill/modem_proxy.h"
Darin Petkove604f702011-07-28 15:51:17 -070014#include "shill/modem_simple_proxy.h"
Darin Petkovd1967262011-07-18 14:55:18 -070015#include "shill/supplicant_interface_proxy.h"
16#include "shill/supplicant_process_proxy.h"
Darin Petkovc90fe522011-07-15 13:59:47 -070017
Darin Petkov5c97ac52011-07-19 16:30:49 -070018using std::string;
19
Darin Petkovc90fe522011-07-15 13:59:47 -070020namespace shill {
21
22ProxyFactory *ProxyFactory::factory_ = NULL;
23
24ProxyFactory::ProxyFactory() {}
25
26ProxyFactory::~ProxyFactory() {}
27
Darin Petkovaceede32011-07-18 15:32:38 -070028void 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 Petkov5c97ac52011-07-19 16:30:49 -070034DBusPropertiesProxyInterface *ProxyFactory::CreateDBusPropertiesProxy(
Darin Petkovc5f56562011-08-06 16:40:05 -070035 DBusPropertiesProxyListener *listener,
Darin Petkov5c97ac52011-07-19 16:30:49 -070036 const string &path,
37 const string &service) {
Darin Petkovc5f56562011-08-06 16:40:05 -070038 return new DBusPropertiesProxy(listener, connection(), path, service);
Darin Petkov5c97ac52011-07-19 16:30:49 -070039}
40
Darin Petkovc90fe522011-07-15 13:59:47 -070041ModemManagerProxyInterface *ProxyFactory::CreateModemManagerProxy(
42 ModemManager *manager,
Darin Petkov5c97ac52011-07-19 16:30:49 -070043 const string &path,
44 const string &service) {
Darin Petkovaceede32011-07-18 15:32:38 -070045 return new ModemManagerProxy(connection(), manager, path, service);
Darin Petkovc90fe522011-07-15 13:59:47 -070046}
47
Darin Petkovc5f56562011-08-06 16:40:05 -070048ModemProxyInterface *ProxyFactory::CreateModemProxy(
49 ModemProxyListener *listener,
50 const string &path,
51 const string &service) {
52 return new ModemProxy(listener, connection(), path, service);
Darin Petkove9d12e02011-07-27 15:09:37 -070053}
54
Darin Petkove604f702011-07-28 15:51:17 -070055ModemSimpleProxyInterface *ProxyFactory::CreateModemSimpleProxy(
56 const string &path,
57 const string &service) {
58 return new ModemSimpleProxy(connection(), path, service);
59}
60
Darin Petkovbec79a22011-08-01 14:47:17 -070061ModemCDMAProxyInterface *ProxyFactory::CreateModemCDMAProxy(
Darin Petkovd9661952011-08-03 16:25:42 -070062 ModemCDMAProxyListener *listener,
Darin Petkovbec79a22011-08-01 14:47:17 -070063 const string &path,
64 const string &service) {
Darin Petkovd9661952011-08-03 16:25:42 -070065 return new ModemCDMAProxy(listener, connection(), path, service);
Darin Petkovbec79a22011-08-01 14:47:17 -070066}
67
Darin Petkovaceede32011-07-18 15:32:38 -070068SupplicantProcessProxyInterface *ProxyFactory::CreateSupplicantProcessProxy(
Darin Petkovd1967262011-07-18 14:55:18 -070069 const char *dbus_path,
70 const char *dbus_addr) {
Darin Petkovaceede32011-07-18 15:32:38 -070071 return new SupplicantProcessProxy(connection(), dbus_path, dbus_addr);
Darin Petkovd1967262011-07-18 14:55:18 -070072}
73
Darin Petkovaceede32011-07-18 15:32:38 -070074SupplicantInterfaceProxyInterface *ProxyFactory::CreateSupplicantInterfaceProxy(
Darin Petkovd1967262011-07-18 14:55:18 -070075 const WiFiRefPtr &wifi,
76 const DBus::Path &object_path,
77 const char *dbus_addr) {
Darin Petkovaceede32011-07-18 15:32:38 -070078 return new SupplicantInterfaceProxy(wifi,
79 connection(),
80 object_path,
81 dbus_addr);
82}
83
Darin Petkova7b89492011-07-27 12:48:17 -070084DHCPProxyInterface *ProxyFactory::CreateDHCPProxy(const string &service) {
Darin Petkovaceede32011-07-18 15:32:38 -070085 return new DHCPCDProxy(connection(), service);
Darin Petkovd1967262011-07-18 14:55:18 -070086}
87
Darin Petkovc90fe522011-07-15 13:59:47 -070088} // namespace shill