Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 2 | // 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 Petkov | ab565bb | 2011-10-06 02:55:51 -0700 | [diff] [blame] | 11 | #include <base/lazy_instance.h> |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 12 | #include <base/memory/scoped_ptr.h> |
Darin Petkov | d196726 | 2011-07-18 14:55:18 -0700 | [diff] [blame] | 13 | #include <dbus-c++/dbus.h> |
| 14 | |
| 15 | #include "shill/refptr_types.h" |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 16 | |
| 17 | namespace shill { |
| 18 | |
David Rochberg | 24c6c62 | 2012-03-05 11:30:44 -0500 | [diff] [blame] | 19 | class DBusObjectManagerProxyInterface; |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 20 | class DBusPropertiesProxyInterface; |
Darin Petkov | 18fb2f7 | 2012-06-14 09:09:34 +0200 | [diff] [blame] | 21 | class DBusServiceProxyInterface; |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 22 | class DHCPProxyInterface; |
Darin Petkov | bec79a2 | 2011-08-01 14:47:17 -0700 | [diff] [blame] | 23 | class ModemCDMAProxyInterface; |
Darin Petkov | 975b5e7 | 2011-08-30 11:48:08 -0700 | [diff] [blame] | 24 | class ModemGSMCardProxyInterface; |
Darin Petkov | a1e0a1c | 2011-08-25 15:08:33 -0700 | [diff] [blame] | 25 | class ModemGSMNetworkProxyInterface; |
David Rochberg | 81030ea | 2012-03-02 15:44:25 -0500 | [diff] [blame] | 26 | class ModemManagerClassic; |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 27 | class ModemManagerProxyInterface; |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 28 | class ModemProxyInterface; |
Darin Petkov | e604f70 | 2011-07-28 15:51:17 -0700 | [diff] [blame] | 29 | class ModemSimpleProxyInterface; |
Darin Petkov | 394b7d4 | 2011-11-03 15:48:02 +0100 | [diff] [blame] | 30 | class PowerManagerProxyDelegate; |
| 31 | class PowerManagerProxyInterface; |
mukesh agrawal | b20776f | 2012-02-10 16:00:36 -0800 | [diff] [blame] | 32 | class SupplicantBSSProxyInterface; |
Darin Petkov | d196726 | 2011-07-18 14:55:18 -0700 | [diff] [blame] | 33 | class SupplicantInterfaceProxyInterface; |
| 34 | class SupplicantProcessProxyInterface; |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 35 | class WiMaxDeviceProxyInterface; |
| 36 | class WiMaxManagerProxyInterface; |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 37 | class WiMaxNetworkProxyInterface; |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 38 | |
Jason Glasgow | 9a0be63 | 2012-03-30 08:53:35 -0400 | [diff] [blame] | 39 | namespace mm1 { |
| 40 | |
| 41 | class ModemModem3gppProxyInterface; |
| 42 | class ModemModemCdmaProxyInterface; |
| 43 | class ModemProxyInterface; |
| 44 | class ModemSimpleProxyInterface; |
| 45 | class SimProxyInterface; |
| 46 | |
| 47 | } // namespace mm1 |
| 48 | |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 49 | // Global DBus proxy factory that can be mocked out in tests. |
| 50 | class ProxyFactory { |
| 51 | public: |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 52 | virtual ~ProxyFactory(); |
| 53 | |
Darin Petkov | ab565bb | 2011-10-06 02:55:51 -0700 | [diff] [blame] | 54 | // Since this is a singleton, use ProxyFactory::GetInstance()->Foo() |
| 55 | static ProxyFactory *GetInstance(); |
| 56 | |
Thieu Le | fb46caf | 2012-03-08 11:57:15 -0800 | [diff] [blame] | 57 | virtual void Init(); |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 58 | |
David Rochberg | 24c6c62 | 2012-03-05 11:30:44 -0500 | [diff] [blame] | 59 | virtual DBusObjectManagerProxyInterface *CreateDBusObjectManagerProxy( |
David Rochberg | 24c6c62 | 2012-03-05 11:30:44 -0500 | [diff] [blame] | 60 | const std::string &path, |
| 61 | const std::string &service); |
| 62 | |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 63 | virtual DBusPropertiesProxyInterface *CreateDBusPropertiesProxy( |
Darin Petkov | 5c97ac5 | 2011-07-19 16:30:49 -0700 | [diff] [blame] | 64 | const std::string &path, |
| 65 | const std::string &service); |
| 66 | |
Darin Petkov | 18fb2f7 | 2012-06-14 09:09:34 +0200 | [diff] [blame] | 67 | virtual DBusServiceProxyInterface *CreateDBusServiceProxy(); |
| 68 | |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 69 | virtual ModemManagerProxyInterface *CreateModemManagerProxy( |
David Rochberg | 81030ea | 2012-03-02 15:44:25 -0500 | [diff] [blame] | 70 | ModemManagerClassic *manager, |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 71 | const std::string &path, |
| 72 | const std::string &service); |
| 73 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 74 | virtual ModemProxyInterface *CreateModemProxy(const std::string &path, |
Darin Petkov | e9d12e0 | 2011-07-27 15:09:37 -0700 | [diff] [blame] | 75 | const std::string &service); |
| 76 | |
Darin Petkov | e604f70 | 2011-07-28 15:51:17 -0700 | [diff] [blame] | 77 | virtual ModemSimpleProxyInterface *CreateModemSimpleProxy( |
| 78 | const std::string &path, |
| 79 | const std::string &service); |
| 80 | |
Darin Petkov | bec79a2 | 2011-08-01 14:47:17 -0700 | [diff] [blame] | 81 | virtual ModemCDMAProxyInterface *CreateModemCDMAProxy( |
| 82 | const std::string &path, |
| 83 | const std::string &service); |
| 84 | |
Darin Petkov | 975b5e7 | 2011-08-30 11:48:08 -0700 | [diff] [blame] | 85 | virtual ModemGSMCardProxyInterface *CreateModemGSMCardProxy( |
Darin Petkov | 975b5e7 | 2011-08-30 11:48:08 -0700 | [diff] [blame] | 86 | const std::string &path, |
| 87 | const std::string &service); |
| 88 | |
Darin Petkov | a1e0a1c | 2011-08-25 15:08:33 -0700 | [diff] [blame] | 89 | virtual ModemGSMNetworkProxyInterface *CreateModemGSMNetworkProxy( |
Darin Petkov | a1e0a1c | 2011-08-25 15:08:33 -0700 | [diff] [blame] | 90 | const std::string &path, |
| 91 | const std::string &service); |
| 92 | |
Jason Glasgow | 9a0be63 | 2012-03-30 08:53:35 -0400 | [diff] [blame] | 93 | // Proxies for ModemManager1 interfaces |
| 94 | virtual mm1::ModemModem3gppProxyInterface *CreateMM1ModemModem3gppProxy( |
| 95 | const std::string &path, |
| 96 | const std::string &service); |
| 97 | |
| 98 | virtual mm1::ModemModemCdmaProxyInterface *CreateMM1ModemModemCdmaProxy( |
| 99 | const std::string &path, |
| 100 | const std::string &service); |
| 101 | |
| 102 | virtual mm1::ModemProxyInterface *CreateMM1ModemProxy( |
| 103 | const std::string &path, |
| 104 | const std::string &service); |
| 105 | |
| 106 | virtual mm1::ModemSimpleProxyInterface *CreateMM1ModemSimpleProxy( |
| 107 | const std::string &path, |
| 108 | const std::string &service); |
| 109 | |
| 110 | virtual mm1::SimProxyInterface *CreateSimProxy( |
| 111 | const std::string &path, |
| 112 | const std::string &service); |
| 113 | |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 114 | virtual WiMaxDeviceProxyInterface *CreateWiMaxDeviceProxy( |
| 115 | const std::string &path); |
| 116 | virtual WiMaxManagerProxyInterface *CreateWiMaxManagerProxy(); |
Darin Petkov | 9893d9c | 2012-05-17 15:27:31 -0700 | [diff] [blame] | 117 | virtual WiMaxNetworkProxyInterface *CreateWiMaxNetworkProxy( |
| 118 | const std::string &path); |
Darin Petkov | 096b347 | 2012-05-15 10:26:22 +0200 | [diff] [blame] | 119 | |
mukesh agrawal | 7c1fece | 2012-01-13 11:31:27 -0800 | [diff] [blame] | 120 | // The caller retains ownership of 'delegate'. It must not be deleted before |
| 121 | // the proxy. |
Darin Petkov | 394b7d4 | 2011-11-03 15:48:02 +0100 | [diff] [blame] | 122 | virtual PowerManagerProxyInterface *CreatePowerManagerProxy( |
| 123 | PowerManagerProxyDelegate *delegate); |
| 124 | |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 125 | virtual SupplicantProcessProxyInterface *CreateSupplicantProcessProxy( |
Darin Petkov | d196726 | 2011-07-18 14:55:18 -0700 | [diff] [blame] | 126 | const char *dbus_path, |
| 127 | const char *dbus_addr); |
| 128 | |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 129 | virtual SupplicantInterfaceProxyInterface *CreateSupplicantInterfaceProxy( |
Darin Petkov | d196726 | 2011-07-18 14:55:18 -0700 | [diff] [blame] | 130 | const WiFiRefPtr &wifi, |
| 131 | const DBus::Path &object_path, |
| 132 | const char *dbus_addr); |
| 133 | |
mukesh agrawal | b20776f | 2012-02-10 16:00:36 -0800 | [diff] [blame] | 134 | // See comment in supplicant_bss_proxy.h, about bare pointer. |
| 135 | virtual SupplicantBSSProxyInterface *CreateSupplicantBSSProxy( |
| 136 | WiFiEndpoint *wifi_endpoint, |
| 137 | const DBus::Path &object_path, |
| 138 | const char *dbus_addr); |
| 139 | |
Darin Petkov | a7b8949 | 2011-07-27 12:48:17 -0700 | [diff] [blame] | 140 | virtual DHCPProxyInterface *CreateDHCPProxy(const std::string &service); |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 141 | |
Darin Petkov | ab565bb | 2011-10-06 02:55:51 -0700 | [diff] [blame] | 142 | DBus::Connection *connection() const { return connection_.get(); } |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 143 | |
Darin Petkov | ab565bb | 2011-10-06 02:55:51 -0700 | [diff] [blame] | 144 | protected: |
| 145 | ProxyFactory(); |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 146 | |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 147 | private: |
Darin Petkov | ab565bb | 2011-10-06 02:55:51 -0700 | [diff] [blame] | 148 | friend struct base::DefaultLazyInstanceTraits<ProxyFactory>; |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 149 | |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 150 | scoped_ptr<DBus::Connection> connection_; |
| 151 | |
Darin Petkov | c90fe52 | 2011-07-15 13:59:47 -0700 | [diff] [blame] | 152 | DISALLOW_COPY_AND_ASSIGN(ProxyFactory); |
| 153 | }; |
| 154 | |
| 155 | } // namespace shill |
| 156 | |
| 157 | #endif // SHILL_PROXY_FACTORY_ |