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.

347 lines
5.8 KiB

  1. /*++
  2. 1998 Seagate Software, Inc. All rights reserved.
  3. Module Name:
  4. hsmjobcx.cpp
  5. Abstract:
  6. This class contains properties that defines the context in which the job
  7. should be run.
  8. Author:
  9. Chuck Bardeen [cbardeen] 29-Oct-1996
  10. Revision History:
  11. --*/
  12. #include "stdafx.h"
  13. #include "wsb.h"
  14. #include "job.h"
  15. #include "hsmjobcx.h"
  16. #define WSB_TRACE_IS WSB_TRACE_BIT_JOB
  17. static USHORT iCount = 0;
  18. HRESULT
  19. CHsmJobContext::EnumResources(
  20. IWsbEnum** ppEnum
  21. )
  22. /*++
  23. Implements:
  24. IHsmJobContext::EnumResources().
  25. --*/
  26. {
  27. HRESULT hr = S_OK;
  28. try {
  29. WsbAssert(0 != ppEnum, E_POINTER);
  30. WsbAffirmHr(m_pResources->Enum(ppEnum));
  31. } WsbCatch(hr);
  32. return(hr);
  33. }
  34. HRESULT
  35. CHsmJobContext::FinalConstruct(
  36. void
  37. )
  38. /*++
  39. Implements:
  40. CComObjectRoot::FinalConstruct().
  41. --*/
  42. {
  43. HRESULT hr = S_OK;
  44. WsbTraceIn(OLESTR("CHsmJobContext::FinalConstruct"), OLESTR(""));
  45. try {
  46. m_usesAllManaged = FALSE;
  47. //Create the Resources collection (with no items).
  48. WsbAffirmHr(CWsbObject::FinalConstruct());
  49. WsbAffirmHr(CoCreateInstance(CLSID_CWsbOrderedCollection, NULL, CLSCTX_ALL, IID_IWsbCollection, (void**) &m_pResources));
  50. } WsbCatch(hr);
  51. iCount++;
  52. WsbTraceOut(OLESTR("CHsmJobContext::FinalConstruct"), OLESTR("hr = <%ls>, Count is <%d>"),
  53. WsbHrAsString(hr), iCount);
  54. return(hr);
  55. }
  56. void
  57. CHsmJobContext::FinalRelease(
  58. void
  59. )
  60. /*++
  61. Implements:
  62. CHsmJobContext::FinalRelease().
  63. --*/
  64. {
  65. WsbTraceIn(OLESTR("CHsmJobContext::FinalRelease"), OLESTR(""));
  66. CWsbObject::FinalRelease();
  67. iCount--;
  68. WsbTraceOut(OLESTR("CHsmJobContext:FinalRelease"), OLESTR("Count is <%d>"), iCount);
  69. }
  70. HRESULT
  71. CHsmJobContext::GetClassID(
  72. OUT CLSID* pClsid
  73. )
  74. /*++
  75. Implements:
  76. IPersist::GetClassID().
  77. --*/
  78. {
  79. HRESULT hr = S_OK;
  80. WsbTraceIn(OLESTR("CHsmJobContext::GetClassID"), OLESTR(""));
  81. try {
  82. WsbAssert(0 != pClsid, E_POINTER);
  83. *pClsid = CLSID_CHsmJobContext;
  84. } WsbCatch(hr);
  85. WsbTraceOut(OLESTR("CHsmJobContext::GetClassID"), OLESTR("hr = <%ls>, CLSID = <%ls>"), WsbHrAsString(hr), WsbGuidAsString(*pClsid));
  86. return(hr);
  87. }
  88. HRESULT
  89. CHsmJobContext::GetSizeMax(
  90. OUT ULARGE_INTEGER* pSize
  91. )
  92. /*++
  93. Implements:
  94. IPersistStream::GetSizeMax().
  95. --*/
  96. {
  97. HRESULT hr = S_OK;
  98. CComPtr<IPersistStream> pPersistStream;
  99. WsbTraceIn(OLESTR("CHsmJobContext::GetSizeMax"), OLESTR(""));
  100. try {
  101. WsbAffirmHr(m_pResources->QueryInterface(IID_IPersistStream, (void**) &pPersistStream));
  102. WsbAffirmHr(pPersistStream->GetSizeMax(pSize));
  103. pSize->QuadPart += WsbPersistSizeOf(BOOL);
  104. } WsbCatch(hr);
  105. WsbTraceOut(OLESTR("CHsmJobContext::GetSizeMax"), OLESTR("hr = <%ls>, Size = <%ls>"), WsbHrAsString(hr), WsbPtrToUliAsString(pSize));
  106. return(hr);
  107. }
  108. HRESULT
  109. CHsmJobContext::Load(
  110. IN IStream* pStream
  111. )
  112. /*++
  113. Implements:
  114. IPersistStream::Load().
  115. --*/
  116. {
  117. HRESULT hr = S_OK;
  118. CComPtr<IPersistStream> pPersistStream;
  119. WsbTraceIn(OLESTR("CHsmJobContext::Load"), OLESTR(""));
  120. try {
  121. WsbAssert(0 != pStream, E_POINTER);
  122. WsbLoadFromStream(pStream, &m_usesAllManaged);
  123. WsbAffirmHr(m_pResources->QueryInterface(IID_IPersistStream, (void**) &pPersistStream));
  124. WsbAffirmHr(pPersistStream->Load(pStream));
  125. } WsbCatch(hr);
  126. WsbTraceOut(OLESTR("CHsmJobContext::Load"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  127. return(hr);
  128. }
  129. HRESULT
  130. CHsmJobContext::Resources(
  131. IWsbCollection** ppResources
  132. )
  133. /*++
  134. Implements:
  135. IHsmJobContext::Resources().
  136. --*/
  137. {
  138. HRESULT hr = S_OK;
  139. try {
  140. WsbAssert(0 != ppResources, E_POINTER);
  141. *ppResources = m_pResources;
  142. m_pResources.p->AddRef();
  143. } WsbCatch(hr);
  144. return(hr);
  145. }
  146. HRESULT
  147. CHsmJobContext::Save(
  148. IN IStream* pStream,
  149. IN BOOL clearDirty
  150. )
  151. /*++
  152. Implements:
  153. IPersistStream::Save().
  154. --*/
  155. {
  156. HRESULT hr = S_OK;
  157. CComPtr<IPersistStream> pPersistStream;
  158. WsbTraceIn(OLESTR("CHsmJobContext::Save"), OLESTR("clearDirty = <%ls>"), WsbBoolAsString(clearDirty));
  159. try {
  160. WsbAssert(0 != pStream, E_POINTER);
  161. WsbSaveToStream(pStream, m_usesAllManaged);
  162. WsbAffirmHr(m_pResources->QueryInterface(IID_IPersistStream, (void**) &pPersistStream));
  163. WsbAffirmHr(pPersistStream->Save(pStream, clearDirty));
  164. // If we got it saved and we were asked to clear the dirty bit, then
  165. // do so now.
  166. if (clearDirty) {
  167. m_isDirty = FALSE;
  168. }
  169. } WsbCatch(hr);
  170. WsbTraceOut(OLESTR("CHsmJobContext::Save"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  171. return(hr);
  172. }
  173. HRESULT
  174. CHsmJobContext::Test(
  175. USHORT* passed,
  176. USHORT* failed
  177. )
  178. /*++
  179. Implements:
  180. IWsbTestable::Test().
  181. --*/
  182. {
  183. HRESULT hr = S_OK;
  184. try {
  185. WsbAssert(0 != passed, E_POINTER);
  186. WsbAssert(0 != failed, E_POINTER);
  187. *passed = 0;
  188. *failed = 0;
  189. } WsbCatch(hr);
  190. return(hr);
  191. }
  192. HRESULT
  193. CHsmJobContext::SetUsesAllManaged(
  194. IN BOOL usesAllManaged
  195. )
  196. /*++
  197. Implements:
  198. IHsmJobContext::SetUsesAllManaged().
  199. --*/
  200. {
  201. m_usesAllManaged = usesAllManaged;
  202. return(S_OK);
  203. }
  204. HRESULT
  205. CHsmJobContext::UsesAllManaged(
  206. void
  207. )
  208. /*++
  209. Implements:
  210. IHsmJobContext::UsesAllManaged().
  211. --*/
  212. {
  213. return(m_usesAllManaged ? S_OK : S_FALSE);
  214. }