Source code of Windows XP (NT5)
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.

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