[NETSHELL] Change Turkish translation.
[reactos.git] / dll / shellext / netshell / classfactory.cpp
1 #include "precomp.h"
2
3 class CNetshellClassFactory final :
4 public IClassFactory
5 {
6 public:
7 CNetshellClassFactory(REFCLSID rclsid);
8
9 /* IUnknown */
10 virtual HRESULT WINAPI QueryInterface(REFIID riid, LPVOID *ppvOut);
11 virtual ULONG WINAPI AddRef();
12 virtual ULONG WINAPI Release();
13
14 /* IClassFactory */
15 virtual HRESULT WINAPI CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject);
16 virtual HRESULT WINAPI LockServer(BOOL fLock);
17
18 private:
19 LONG m_ref;
20 CLSID m_clsid;
21 };
22
23 CNetshellClassFactory::CNetshellClassFactory(REFCLSID rclsid) :
24 m_ref(0),
25 m_clsid(rclsid)
26 {
27 }
28
29 HRESULT
30 WINAPI
31 CNetshellClassFactory::QueryInterface(
32 REFIID riid,
33 LPVOID *ppvObj)
34 {
35 *ppvObj = NULL;
36 if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory))
37 {
38 *ppvObj = static_cast<IClassFactory*>(this);
39 AddRef();
40 return S_OK;
41 }
42 return E_NOINTERFACE;
43 }
44
45 ULONG
46 WINAPI
47 CNetshellClassFactory::AddRef()
48 {
49 ULONG refCount = InterlockedIncrement(&m_ref);
50
51 return refCount;
52 }
53
54 ULONG
55 WINAPI
56 CNetshellClassFactory::Release()
57 {
58 ULONG refCount = InterlockedDecrement(&m_ref);
59
60 if (!refCount)
61 delete this;
62
63 return refCount;
64 }
65
66 HRESULT
67 WINAPI
68 CNetshellClassFactory::CreateInstance(
69 LPUNKNOWN pUnkOuter,
70 REFIID riid,
71 LPVOID *ppvObject)
72 {
73 *ppvObject = NULL;
74
75 if (IsEqualCLSID(m_clsid, CLSID_ConnectionFolder))
76 return ISF_NetConnect_Constructor(pUnkOuter, riid, ppvObject);
77 else if (IsEqualCLSID(m_clsid, CLSID_ConnectionManager))
78 return INetConnectionManager_Constructor(pUnkOuter, riid, ppvObject);
79 else if (IsEqualCLSID(m_clsid, CLSID_LanConnectionUi))
80 return LanConnectUI_Constructor(pUnkOuter, riid, ppvObject);
81 else if (IsEqualCLSID(m_clsid, CLSID_ConnectionTray))
82 return LanConnectStatusUI_Constructor(pUnkOuter, riid, ppvObject);
83
84 return E_NOINTERFACE;
85 }
86
87 HRESULT
88 WINAPI
89 CNetshellClassFactory::LockServer(BOOL fLock)
90 {
91 return E_NOTIMPL;
92 }
93
94 HRESULT IClassFactory_fnConstructor(REFCLSID rclsid, REFIID riid, LPVOID *ppvOut)
95 {
96 CNetshellClassFactory *pClsFactory = new CNetshellClassFactory(rclsid);
97 if (!pClsFactory)
98 return E_OUTOFMEMORY;
99
100 pClsFactory->AddRef();
101 HRESULT hr = pClsFactory->QueryInterface(riid, ppvOut);
102 pClsFactory->Release();
103
104 return hr;
105 }