Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

280 lines
6.1 KiB

  1. //____________________________________________________________________________
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1995 - 1995.
  5. //
  6. // File: ole.cxx
  7. //
  8. // Contents: IUnknown & IClassFactory for all OLE objects
  9. //
  10. // History: 1/4/1996 RaviR Created
  11. //
  12. //____________________________________________________________________________
  13. #include "..\pch\headers.hxx"
  14. #pragma hdrstop
  15. #include "dbg.h"
  16. #include "macros.h"
  17. #include "guids.h"
  18. #include "dll.hxx"
  19. #include <mstask.h> // Necessary for util.hxx/schedui.hxx inclusion.
  20. #include "util.hxx"
  21. #include "..\schedui\schedui.hxx"
  22. #include <StrSafe.h>
  23. //____________________________________________________________________________
  24. //
  25. // Class: CJobFolderCF
  26. //
  27. // Purpose: Class factory to create CJobFolder.
  28. //
  29. // History: 1/24/1996 RaviR Created
  30. //____________________________________________________________________________
  31. class CJobFolderCF : public IClassFactory
  32. {
  33. public:
  34. // IUnknown methods
  35. DECLARE_IUNKNOWN_METHODS;
  36. // IClassFactory methods
  37. STDMETHOD(CreateInstance)(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObj);
  38. STDMETHOD(LockServer)(BOOL fLock);
  39. };
  40. STDMETHODIMP
  41. CJobFolderCF::QueryInterface(REFIID riid, LPVOID* ppvObj)
  42. {
  43. if (IsEqualIID(IID_IUnknown, riid) ||
  44. IsEqualIID(IID_IClassFactory, riid))
  45. {
  46. *ppvObj = (IUnknown*)(IClassFactory*) this;
  47. this->AddRef();
  48. return S_OK;
  49. }
  50. *ppvObj = NULL;
  51. return E_NOINTERFACE;
  52. }
  53. STDMETHODIMP_(ULONG)
  54. CJobFolderCF::AddRef()
  55. {
  56. return CDll::AddRef();
  57. }
  58. STDMETHODIMP_(ULONG)
  59. CJobFolderCF::Release()
  60. {
  61. return CDll::Release();
  62. }
  63. STDMETHODIMP
  64. CJobFolderCF::CreateInstance(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObj)
  65. {
  66. if (pUnkOuter != NULL)
  67. {
  68. return E_NOTIMPL; // don't support aggregation
  69. }
  70. return JFGetJobFolder(riid, ppvObj);
  71. }
  72. STDMETHODIMP
  73. CJobFolderCF::LockServer(BOOL fLock)
  74. {
  75. CDll::LockServer(fLock);
  76. return S_OK;
  77. }
  78. //____________________________________________________________________________
  79. //
  80. // Class: CSchedObjExtCF
  81. //
  82. // Purpose: Class factory to create CSchedObjExt.
  83. //
  84. // History: 4/25/1996 RaviR Created
  85. //____________________________________________________________________________
  86. class CSchedObjExtCF : public IClassFactory
  87. {
  88. public:
  89. // IUnknown methods
  90. DECLARE_IUNKNOWN_METHODS;
  91. // IClassFactory methods
  92. STDMETHOD(CreateInstance)(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObj);
  93. STDMETHOD(LockServer)(BOOL fLock);
  94. };
  95. STDMETHODIMP
  96. CSchedObjExtCF::QueryInterface(REFIID riid, LPVOID* ppvObj)
  97. {
  98. if (IsEqualIID(IID_IUnknown, riid) ||
  99. IsEqualIID(IID_IClassFactory, riid))
  100. {
  101. *ppvObj = (IUnknown*)(IClassFactory*) this;
  102. this->AddRef();
  103. return S_OK;
  104. }
  105. *ppvObj = NULL;
  106. return E_NOINTERFACE;
  107. }
  108. STDMETHODIMP_(ULONG)
  109. CSchedObjExtCF::AddRef()
  110. {
  111. return CDll::AddRef();
  112. }
  113. STDMETHODIMP_(ULONG)
  114. CSchedObjExtCF::Release()
  115. {
  116. return CDll::Release();
  117. }
  118. STDMETHODIMP
  119. CSchedObjExtCF::CreateInstance(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObj)
  120. {
  121. if (pUnkOuter != NULL)
  122. {
  123. return E_NOTIMPL; // don't support aggregation
  124. }
  125. return JFGetSchedObjExt(riid, ppvObj);
  126. }
  127. STDMETHODIMP
  128. CSchedObjExtCF::LockServer(BOOL fLock)
  129. {
  130. CDll::LockServer(fLock);
  131. return S_OK;
  132. }
  133. //////////////////////////////////////////////////////////////////////////////
  134. JF_IMPLEMENT_CLASSFACTORY(CTaskIconExt);
  135. STDMETHODIMP
  136. CTaskIconExtCF::CreateInstance(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObj)
  137. {
  138. if (pUnkOuter != NULL)
  139. {
  140. return E_NOTIMPL; // don't support aggregation
  141. }
  142. return JFGetTaskIconExt(riid, ppvObj);
  143. }
  144. //////////////////////////////////////////////////////////////////////////////
  145. //////////////////////////////////////////////////////////////////////////////
  146. //////////////////////////////////////////////////////////////////////////////
  147. //////////////////////////////////////////////////////////////////////////////
  148. CJobFolderCF * pcfJobFolder = NULL;
  149. CSchedObjExtCF * pcfSchedObjExt = NULL;
  150. CTaskIconExtCF * pcfTaskIconExt = NULL;
  151. HRESULT
  152. JFGetClassObject(
  153. REFCLSID cid,
  154. REFIID riid,
  155. LPVOID * ppvObj)
  156. {
  157. CDllRef DllRef; // don't nuke me now!
  158. if (IsEqualCLSID(cid, CLSID_CJobFolder))
  159. {
  160. if (pcfJobFolder != NULL)
  161. {
  162. return pcfJobFolder->QueryInterface(riid, ppvObj);
  163. }
  164. else
  165. {
  166. return E_FAIL;
  167. }
  168. }
  169. else if (IsEqualCLSID(cid, CLSID_CSchedObjExt))
  170. {
  171. if (pcfSchedObjExt != NULL)
  172. {
  173. return pcfSchedObjExt->QueryInterface(riid, ppvObj);
  174. }
  175. else
  176. {
  177. return E_FAIL;
  178. }
  179. }
  180. else if (IsEqualCLSID(cid, CLSID_CTaskIconExt))
  181. {
  182. if (pcfTaskIconExt != NULL)
  183. {
  184. return pcfTaskIconExt->QueryInterface(riid, ppvObj);
  185. }
  186. else
  187. {
  188. return E_FAIL;
  189. }
  190. }
  191. return E_NOINTERFACE;
  192. }
  193. HRESULT
  194. AllocFolderCFs(void)
  195. {
  196. pcfJobFolder = new CJobFolderCF;
  197. if (pcfJobFolder == NULL)
  198. {
  199. return E_OUTOFMEMORY;
  200. }
  201. pcfSchedObjExt = new CSchedObjExtCF;
  202. if (pcfSchedObjExt == NULL)
  203. {
  204. delete pcfJobFolder;
  205. pcfJobFolder = NULL;
  206. return E_OUTOFMEMORY;
  207. }
  208. pcfTaskIconExt = new CTaskIconExtCF;
  209. if (pcfTaskIconExt == NULL)
  210. {
  211. delete pcfJobFolder;
  212. pcfJobFolder = NULL;
  213. delete pcfSchedObjExt;
  214. pcfSchedObjExt = NULL;
  215. return E_OUTOFMEMORY;
  216. }
  217. return S_OK;
  218. }
  219. void
  220. FreeFolderCFs(void)
  221. {
  222. if (pcfJobFolder != NULL)
  223. {
  224. delete pcfJobFolder;
  225. pcfJobFolder = NULL;
  226. }
  227. if (pcfSchedObjExt != NULL)
  228. {
  229. delete pcfSchedObjExt;
  230. pcfSchedObjExt = NULL;
  231. }
  232. if (pcfTaskIconExt != NULL)
  233. {
  234. delete pcfTaskIconExt;
  235. pcfTaskIconExt = NULL;
  236. }
  237. }