blob: 0921b5d519299f174123502a666f66fb1044c4b9 [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#ifndef SHILL_PROXY_FACTORY_
6#define SHILL_PROXY_FACTORY_
7
8#include <string>
9
10#include <base/basictypes.h>
Darin Petkovab565bb2011-10-06 02:55:51 -070011#include <base/lazy_instance.h>
Darin Petkovaceede32011-07-18 15:32:38 -070012#include <base/memory/scoped_ptr.h>
Darin Petkovd1967262011-07-18 14:55:18 -070013#include <dbus-c++/dbus.h>
14
15#include "shill/refptr_types.h"
Darin Petkovc90fe522011-07-15 13:59:47 -070016
17namespace shill {
18
David Rochberg24c6c622012-03-05 11:30:44 -050019class DBusObjectManagerProxyInterface;
Darin Petkov580c7af2011-10-24 12:32:50 +020020class DBusPropertiesProxyDelegate;
Darin Petkov5c97ac52011-07-19 16:30:49 -070021class DBusPropertiesProxyInterface;
Darin Petkovaceede32011-07-18 15:32:38 -070022class DHCPProxyInterface;
Darin Petkovbec79a22011-08-01 14:47:17 -070023class ModemCDMAProxyInterface;
Darin Petkov975b5e72011-08-30 11:48:08 -070024class ModemGSMCardProxyInterface;
Darin Petkova1e0a1c2011-08-25 15:08:33 -070025class ModemGSMNetworkProxyInterface;
David Rochberg81030ea2012-03-02 15:44:25 -050026class ModemManagerClassic;
Darin Petkovc90fe522011-07-15 13:59:47 -070027class ModemManagerProxyInterface;
Darin Petkove9d12e02011-07-27 15:09:37 -070028class ModemProxyInterface;
Darin Petkove604f702011-07-28 15:51:17 -070029class ModemSimpleProxyInterface;
Darin Petkov394b7d42011-11-03 15:48:02 +010030class PowerManagerProxyDelegate;
31class PowerManagerProxyInterface;
mukesh agrawalb20776f2012-02-10 16:00:36 -080032class SupplicantBSSProxyInterface;
Darin Petkovd1967262011-07-18 14:55:18 -070033class SupplicantInterfaceProxyInterface;
34class SupplicantProcessProxyInterface;
Darin Petkovc90fe522011-07-15 13:59:47 -070035
Jason Glasgow9a0be632012-03-30 08:53:35 -040036namespace mm1 {
37
38class ModemModem3gppProxyInterface;
39class ModemModemCdmaProxyInterface;
40class ModemProxyInterface;
41class ModemSimpleProxyInterface;
42class SimProxyInterface;
43
44} // namespace mm1
45
Darin Petkovc90fe522011-07-15 13:59:47 -070046// Global DBus proxy factory that can be mocked out in tests.
47class ProxyFactory {
48 public:
Darin Petkovc90fe522011-07-15 13:59:47 -070049 virtual ~ProxyFactory();
50
Darin Petkovab565bb2011-10-06 02:55:51 -070051 // Since this is a singleton, use ProxyFactory::GetInstance()->Foo()
52 static ProxyFactory *GetInstance();
53
Thieu Lefb46caf2012-03-08 11:57:15 -080054 virtual void Init();
Darin Petkovaceede32011-07-18 15:32:38 -070055
David Rochberg24c6c622012-03-05 11:30:44 -050056 virtual DBusObjectManagerProxyInterface *CreateDBusObjectManagerProxy(
David Rochberg24c6c622012-03-05 11:30:44 -050057 const std::string &path,
58 const std::string &service);
59
Darin Petkov5c97ac52011-07-19 16:30:49 -070060 virtual DBusPropertiesProxyInterface *CreateDBusPropertiesProxy(
Darin Petkov580c7af2011-10-24 12:32:50 +020061 DBusPropertiesProxyDelegate *delegate,
Darin Petkov5c97ac52011-07-19 16:30:49 -070062 const std::string &path,
63 const std::string &service);
64
Darin Petkovc90fe522011-07-15 13:59:47 -070065 virtual ModemManagerProxyInterface *CreateModemManagerProxy(
David Rochberg81030ea2012-03-02 15:44:25 -050066 ModemManagerClassic *manager,
Darin Petkovc90fe522011-07-15 13:59:47 -070067 const std::string &path,
68 const std::string &service);
69
Eric Shienbrood9a245532012-03-07 14:20:39 -050070 virtual ModemProxyInterface *CreateModemProxy(const std::string &path,
Darin Petkove9d12e02011-07-27 15:09:37 -070071 const std::string &service);
72
Darin Petkove604f702011-07-28 15:51:17 -070073 virtual ModemSimpleProxyInterface *CreateModemSimpleProxy(
74 const std::string &path,
75 const std::string &service);
76
Darin Petkovbec79a22011-08-01 14:47:17 -070077 virtual ModemCDMAProxyInterface *CreateModemCDMAProxy(
78 const std::string &path,
79 const std::string &service);
80
Darin Petkov975b5e72011-08-30 11:48:08 -070081 virtual ModemGSMCardProxyInterface *CreateModemGSMCardProxy(
Darin Petkov975b5e72011-08-30 11:48:08 -070082 const std::string &path,
83 const std::string &service);
84
Darin Petkova1e0a1c2011-08-25 15:08:33 -070085 virtual ModemGSMNetworkProxyInterface *CreateModemGSMNetworkProxy(
Darin Petkova1e0a1c2011-08-25 15:08:33 -070086 const std::string &path,
87 const std::string &service);
88
Jason Glasgow9a0be632012-03-30 08:53:35 -040089 // Proxies for ModemManager1 interfaces
90 virtual mm1::ModemModem3gppProxyInterface *CreateMM1ModemModem3gppProxy(
91 const std::string &path,
92 const std::string &service);
93
94 virtual mm1::ModemModemCdmaProxyInterface *CreateMM1ModemModemCdmaProxy(
95 const std::string &path,
96 const std::string &service);
97
98 virtual mm1::ModemProxyInterface *CreateMM1ModemProxy(
99 const std::string &path,
100 const std::string &service);
101
102 virtual mm1::ModemSimpleProxyInterface *CreateMM1ModemSimpleProxy(
103 const std::string &path,
104 const std::string &service);
105
106 virtual mm1::SimProxyInterface *CreateSimProxy(
107 const std::string &path,
108 const std::string &service);
109
mukesh agrawal7c1fece2012-01-13 11:31:27 -0800110 // The caller retains ownership of 'delegate'. It must not be deleted before
111 // the proxy.
Darin Petkov394b7d42011-11-03 15:48:02 +0100112 virtual PowerManagerProxyInterface *CreatePowerManagerProxy(
113 PowerManagerProxyDelegate *delegate);
114
Darin Petkovaceede32011-07-18 15:32:38 -0700115 virtual SupplicantProcessProxyInterface *CreateSupplicantProcessProxy(
Darin Petkovd1967262011-07-18 14:55:18 -0700116 const char *dbus_path,
117 const char *dbus_addr);
118
Darin Petkovaceede32011-07-18 15:32:38 -0700119 virtual SupplicantInterfaceProxyInterface *CreateSupplicantInterfaceProxy(
Darin Petkovd1967262011-07-18 14:55:18 -0700120 const WiFiRefPtr &wifi,
121 const DBus::Path &object_path,
122 const char *dbus_addr);
123
mukesh agrawalb20776f2012-02-10 16:00:36 -0800124 // See comment in supplicant_bss_proxy.h, about bare pointer.
125 virtual SupplicantBSSProxyInterface *CreateSupplicantBSSProxy(
126 WiFiEndpoint *wifi_endpoint,
127 const DBus::Path &object_path,
128 const char *dbus_addr);
129
Darin Petkova7b89492011-07-27 12:48:17 -0700130 virtual DHCPProxyInterface *CreateDHCPProxy(const std::string &service);
Darin Petkovaceede32011-07-18 15:32:38 -0700131
Darin Petkovab565bb2011-10-06 02:55:51 -0700132 DBus::Connection *connection() const { return connection_.get(); }
Darin Petkovc90fe522011-07-15 13:59:47 -0700133
Darin Petkovab565bb2011-10-06 02:55:51 -0700134 protected:
135 ProxyFactory();
Darin Petkovaceede32011-07-18 15:32:38 -0700136
Darin Petkovc90fe522011-07-15 13:59:47 -0700137 private:
Darin Petkovab565bb2011-10-06 02:55:51 -0700138 friend struct base::DefaultLazyInstanceTraits<ProxyFactory>;
Darin Petkovc90fe522011-07-15 13:59:47 -0700139
Darin Petkovaceede32011-07-18 15:32:38 -0700140 scoped_ptr<DBus::Connection> connection_;
141
Darin Petkovc90fe522011-07-15 13:59:47 -0700142 DISALLOW_COPY_AND_ASSIGN(ProxyFactory);
143};
144
145} // namespace shill
146
147#endif // SHILL_PROXY_FACTORY_