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