blob: 39763641c02ead394222cd401967cf8a4c9ccaba [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
Darin Petkov580c7af2011-10-24 12:32:50 +020019class DBusPropertiesProxyDelegate;
Darin Petkov5c97ac52011-07-19 16:30:49 -070020class DBusPropertiesProxyInterface;
Darin Petkovaceede32011-07-18 15:32:38 -070021class DHCPProxyInterface;
Darin Petkov580c7af2011-10-24 12:32:50 +020022class ModemCDMAProxyDelegate;
Darin Petkovbec79a22011-08-01 14:47:17 -070023class ModemCDMAProxyInterface;
Darin Petkov580c7af2011-10-24 12:32:50 +020024class ModemGSMCardProxyDelegate;
Darin Petkov975b5e72011-08-30 11:48:08 -070025class ModemGSMCardProxyInterface;
Darin Petkov580c7af2011-10-24 12:32:50 +020026class ModemGSMNetworkProxyDelegate;
Darin Petkova1e0a1c2011-08-25 15:08:33 -070027class ModemGSMNetworkProxyInterface;
Darin Petkovc90fe522011-07-15 13:59:47 -070028class ModemManager;
29class ModemManagerProxyInterface;
Darin Petkov580c7af2011-10-24 12:32:50 +020030class ModemProxyDelegate;
Darin Petkove9d12e02011-07-27 15:09:37 -070031class ModemProxyInterface;
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050032class ModemSimpleProxyDelegate;
Darin Petkove604f702011-07-28 15:51:17 -070033class ModemSimpleProxyInterface;
Darin Petkov394b7d42011-11-03 15:48:02 +010034class PowerManagerProxyDelegate;
35class PowerManagerProxyInterface;
Darin Petkovd1967262011-07-18 14:55:18 -070036class SupplicantInterfaceProxyInterface;
37class SupplicantProcessProxyInterface;
Darin Petkovc90fe522011-07-15 13:59:47 -070038
39// Global DBus proxy factory that can be mocked out in tests.
40class ProxyFactory {
41 public:
Darin Petkovc90fe522011-07-15 13:59:47 -070042 virtual ~ProxyFactory();
43
Darin Petkovab565bb2011-10-06 02:55:51 -070044 // Since this is a singleton, use ProxyFactory::GetInstance()->Foo()
45 static ProxyFactory *GetInstance();
46
Darin Petkovaceede32011-07-18 15:32:38 -070047 void Init();
48
Darin Petkov5c97ac52011-07-19 16:30:49 -070049 virtual DBusPropertiesProxyInterface *CreateDBusPropertiesProxy(
Darin Petkov580c7af2011-10-24 12:32:50 +020050 DBusPropertiesProxyDelegate *delegate,
Darin Petkov5c97ac52011-07-19 16:30:49 -070051 const std::string &path,
52 const std::string &service);
53
Darin Petkovc90fe522011-07-15 13:59:47 -070054 virtual ModemManagerProxyInterface *CreateModemManagerProxy(
55 ModemManager *manager,
56 const std::string &path,
57 const std::string &service);
58
Darin Petkov580c7af2011-10-24 12:32:50 +020059 virtual ModemProxyInterface *CreateModemProxy(ModemProxyDelegate *delegate,
Darin Petkovc5f56562011-08-06 16:40:05 -070060 const std::string &path,
Darin Petkove9d12e02011-07-27 15:09:37 -070061 const std::string &service);
62
Darin Petkove604f702011-07-28 15:51:17 -070063 virtual ModemSimpleProxyInterface *CreateModemSimpleProxy(
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050064 ModemSimpleProxyDelegate *delegate,
Darin Petkove604f702011-07-28 15:51:17 -070065 const std::string &path,
66 const std::string &service);
67
Darin Petkovbec79a22011-08-01 14:47:17 -070068 virtual ModemCDMAProxyInterface *CreateModemCDMAProxy(
Darin Petkov580c7af2011-10-24 12:32:50 +020069 ModemCDMAProxyDelegate *delegate,
Darin Petkovbec79a22011-08-01 14:47:17 -070070 const std::string &path,
71 const std::string &service);
72
Darin Petkov975b5e72011-08-30 11:48:08 -070073 virtual ModemGSMCardProxyInterface *CreateModemGSMCardProxy(
Darin Petkov580c7af2011-10-24 12:32:50 +020074 ModemGSMCardProxyDelegate *delegate,
Darin Petkov975b5e72011-08-30 11:48:08 -070075 const std::string &path,
76 const std::string &service);
77
Darin Petkova1e0a1c2011-08-25 15:08:33 -070078 virtual ModemGSMNetworkProxyInterface *CreateModemGSMNetworkProxy(
Darin Petkov580c7af2011-10-24 12:32:50 +020079 ModemGSMNetworkProxyDelegate *delegate,
Darin Petkova1e0a1c2011-08-25 15:08:33 -070080 const std::string &path,
81 const std::string &service);
82
mukesh agrawal7c1fece2012-01-13 11:31:27 -080083 // The caller retains ownership of 'delegate'. It must not be deleted before
84 // the proxy.
Darin Petkov394b7d42011-11-03 15:48:02 +010085 virtual PowerManagerProxyInterface *CreatePowerManagerProxy(
86 PowerManagerProxyDelegate *delegate);
87
Darin Petkovaceede32011-07-18 15:32:38 -070088 virtual SupplicantProcessProxyInterface *CreateSupplicantProcessProxy(
Darin Petkovd1967262011-07-18 14:55:18 -070089 const char *dbus_path,
90 const char *dbus_addr);
91
Darin Petkovaceede32011-07-18 15:32:38 -070092 virtual SupplicantInterfaceProxyInterface *CreateSupplicantInterfaceProxy(
Darin Petkovd1967262011-07-18 14:55:18 -070093 const WiFiRefPtr &wifi,
94 const DBus::Path &object_path,
95 const char *dbus_addr);
96
Darin Petkova7b89492011-07-27 12:48:17 -070097 virtual DHCPProxyInterface *CreateDHCPProxy(const std::string &service);
Darin Petkovaceede32011-07-18 15:32:38 -070098
Darin Petkovab565bb2011-10-06 02:55:51 -070099 DBus::Connection *connection() const { return connection_.get(); }
Darin Petkovc90fe522011-07-15 13:59:47 -0700100
Darin Petkovab565bb2011-10-06 02:55:51 -0700101 protected:
102 ProxyFactory();
Darin Petkovaceede32011-07-18 15:32:38 -0700103
Darin Petkovc90fe522011-07-15 13:59:47 -0700104 private:
Darin Petkovab565bb2011-10-06 02:55:51 -0700105 friend struct base::DefaultLazyInstanceTraits<ProxyFactory>;
Darin Petkovc90fe522011-07-15 13:59:47 -0700106
Darin Petkovaceede32011-07-18 15:32:38 -0700107 scoped_ptr<DBus::Connection> connection_;
108
Darin Petkovc90fe522011-07-15 13:59:47 -0700109 DISALLOW_COPY_AND_ASSIGN(ProxyFactory);
110};
111
112} // namespace shill
113
114#endif // SHILL_PROXY_FACTORY_