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