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.

507 lines
12 KiB

  1. /*++
  2. 1998 Seagate Software, Inc. All rights reserved.
  3. Module Name:
  4. BagHole.cpp
  5. Abstract:
  6. This component is an object representation of the HSM Metadata bag hole record.
  7. Author:
  8. Cat Brant [cbrant] 26-Nov-1996
  9. Revision History:
  10. --*/
  11. #include "stdafx.h"
  12. #include "metaint.h"
  13. #include "metalib.h"
  14. #include "BagInfo.h"
  15. #undef WSB_TRACE_IS
  16. #define WSB_TRACE_IS WSB_TRACE_BIT_META
  17. static USHORT iCount = 0;
  18. HRESULT
  19. CBagInfo::GetBagInfo(
  20. HSM_BAG_STATUS *pStatus,
  21. GUID* pBagId,
  22. FILETIME *pBirthDate,
  23. LONGLONG *pLen,
  24. USHORT *pType,
  25. GUID *pVolId,
  26. LONGLONG *pDeletedBagAmount,
  27. SHORT *pRemoteDataSet
  28. )
  29. /*++
  30. Routine Description:
  31. See IBagInfo::GetBagInfo
  32. Arguments:
  33. See IBagInfo::GetBagInfo
  34. Return Value:
  35. See IBagInfo::GetBagInfo
  36. --*/
  37. {
  38. HRESULT hr = S_OK;
  39. WsbTraceIn(OLESTR("CBagInfo::GetBagInfo"),OLESTR(""));
  40. try {
  41. //Make sure we can provide data memebers
  42. WsbAssert(0 != pStatus, E_POINTER);
  43. WsbAssert(0 != pBagId, E_POINTER);
  44. WsbAssert(0 != pBirthDate, E_POINTER);
  45. WsbAssert(0 != pLen, E_POINTER);
  46. WsbAssert(0 != pType, E_POINTER);
  47. WsbAssert(0 != pVolId, E_POINTER);
  48. WsbAssert(0 != pDeletedBagAmount, E_POINTER);
  49. WsbAssert(0 != pRemoteDataSet, E_POINTER);
  50. //Provide the data members
  51. *pStatus = m_BagStatus;
  52. *pBagId = m_BagId;
  53. *pBirthDate = m_BirthDate;
  54. *pLen = m_Len;
  55. *pType = m_Type;
  56. *pVolId = m_VolId;
  57. *pDeletedBagAmount = m_DeletedBagAmount;
  58. *pRemoteDataSet = m_RemoteDataSet;
  59. } WsbCatch(hr);
  60. WsbTraceOut(OLESTR("CBagInfo::GetBagInfo"),
  61. OLESTR("hr = <%ls>, status = <%ls>, ID = <%ls>, Birthdate = <%ls>, length = <%ls>, type = <%ls>, volId = <%ls>, deletedAmount = <%ls>, remoteDataSet = <%ls>"),
  62. WsbHrAsString(hr), WsbPtrToUshortAsString((USHORT *)pStatus), WsbPtrToGuidAsString(pBagId), WsbPtrToFiletimeAsString(FALSE, pBirthDate),
  63. WsbPtrToLonglongAsString(pLen), WsbPtrToUshortAsString(pType), WsbPtrToGuidAsString(pVolId), WsbPtrToLonglongAsString(pDeletedBagAmount),
  64. WsbPtrToShortAsString(pRemoteDataSet));
  65. return(hr);
  66. }
  67. HRESULT
  68. CBagInfo::FinalConstruct(
  69. void
  70. )
  71. /*++
  72. Routine Description:
  73. This method does some initialization of the object that is necessary
  74. after construction.
  75. Arguments:
  76. None.
  77. Return Value:
  78. S_OK
  79. Anything returned by CWsbDbEntity::FinalConstruct().
  80. --*/
  81. {
  82. HRESULT hr = S_OK;
  83. WsbTraceIn(OLESTR("CBagInfo::FinalConstruct"),OLESTR(""));
  84. try {
  85. WsbAssertHr(CWsbDbEntity::FinalConstruct());
  86. m_BagStatus = HSM_BAG_STATUS_NONE;
  87. m_BagId = GUID_NULL;
  88. m_BirthDate = WsbLLtoFT(0);
  89. m_Len = 0;
  90. m_Type = 0;
  91. m_VolId = GUID_NULL;
  92. m_DeletedBagAmount = 0;
  93. m_RemoteDataSet = 0;
  94. } WsbCatch(hr);
  95. iCount++;
  96. WsbTraceOut(OLESTR("CBagInfo::FinalConstruct"),OLESTR("hr = <%ls>, Count is <%d>"),
  97. WsbHrAsString(hr), iCount);
  98. return(hr);
  99. }
  100. void
  101. CBagInfo::FinalRelease(
  102. void
  103. )
  104. /*++
  105. Implements:
  106. CBagInfo::FinalRelease().
  107. --*/
  108. {
  109. WsbTraceIn(OLESTR("CBagInfo::FinalRelease"), OLESTR(""));
  110. CWsbDbEntity::FinalRelease();
  111. iCount--;
  112. WsbTraceOut(OLESTR("CBagInfo::FinalRelease"), OLESTR("Count is <%d>"), iCount);
  113. }
  114. HRESULT CBagInfo::GetClassID
  115. (
  116. OUT LPCLSID pclsid
  117. )
  118. /*++
  119. Routine Description:
  120. See IPerist::GetClassID()
  121. Arguments:
  122. See IPerist::GetClassID()
  123. Return Value:
  124. See IPerist::GetClassID()
  125. --*/
  126. {
  127. HRESULT hr = S_OK;
  128. WsbTraceIn(OLESTR("CBagInfo::GetClassID"), OLESTR(""));
  129. try {
  130. WsbAssert(0 != pclsid, E_POINTER);
  131. *pclsid = CLSID_CBagInfo;
  132. } WsbCatch(hr);
  133. WsbTraceOut(OLESTR("CBagInfo::GetClassID"), OLESTR("hr = <%ls>, CLSID = <%ls>"), WsbHrAsString(hr), WsbGuidAsString(*pclsid));
  134. return(hr);
  135. }
  136. HRESULT CBagInfo::GetSizeMax
  137. (
  138. OUT ULARGE_INTEGER* pcbSize
  139. )
  140. /*++
  141. Routine Description:
  142. See IPersistStream::GetSizeMax().
  143. Arguments:
  144. See IPersistStream::GetSizeMax().
  145. Return Value:
  146. See IPersistStream::GetSizeMax().
  147. --*/
  148. {
  149. HRESULT hr = S_OK;
  150. WsbTraceIn(OLESTR("CBagInfo::GetSizeMax"), OLESTR(""));
  151. try {
  152. WsbAssert(0 != pcbSize, E_POINTER);
  153. pcbSize->QuadPart = WsbPersistSizeOf(CBagInfo); //???????
  154. } WsbCatch(hr);
  155. WsbTraceOut(OLESTR("CBagInfo::GetSizeMax"),
  156. OLESTR("hr = <%ls>, Size = <%ls>"), WsbHrAsString(hr),
  157. WsbPtrToUliAsString(pcbSize));
  158. return(hr);
  159. }
  160. HRESULT CBagInfo::Load
  161. (
  162. IN IStream* pStream
  163. )
  164. /*++
  165. Routine Description:
  166. See IPersistStream::Load().
  167. Arguments:
  168. See IPersistStream::Load().
  169. Return Value:
  170. See IPersistStream::Load().
  171. --*/
  172. {
  173. HRESULT hr = S_OK;
  174. WsbTraceIn(OLESTR("CBagInfo::Load"), OLESTR(""));
  175. try {
  176. USHORT tmpUShort;
  177. WsbAssert(0 != pStream, E_POINTER);
  178. WsbAffirmHr(WsbLoadFromStream(pStream, &tmpUShort));
  179. m_BagStatus = (HSM_BAG_STATUS)tmpUShort;
  180. WsbAffirmHr(WsbLoadFromStream(pStream, &m_BagId));
  181. WsbAffirmHr(WsbLoadFromStream(pStream, &m_BirthDate));
  182. WsbAffirmHr(WsbLoadFromStream(pStream, &m_Len));
  183. WsbAffirmHr(WsbLoadFromStream(pStream, &m_Type));
  184. WsbAffirmHr(WsbLoadFromStream(pStream, &m_VolId));
  185. WsbAffirmHr(WsbLoadFromStream(pStream, &m_DeletedBagAmount));
  186. WsbAffirmHr(WsbLoadFromStream(pStream, &m_RemoteDataSet));
  187. } WsbCatch(hr);
  188. WsbTraceOut(OLESTR("CBagInfo::Load"),
  189. OLESTR("hr = <%ls>, status = <%d>, ID = <%ls>, Birthdate = <%ls>, length = <%ls>, type = <%ls>, volId = <%d>, deletedAmount = <%ls>, remoteDataSet = <%d>"),
  190. WsbHrAsString(hr), (USHORT)m_BagStatus, WsbGuidAsString(m_BagId), WsbFiletimeAsString(FALSE, m_BirthDate),
  191. WsbLonglongAsString(m_Len), m_Type, WsbGuidAsString(m_VolId),
  192. WsbLonglongAsString(m_DeletedBagAmount), m_RemoteDataSet);
  193. return(hr);
  194. }
  195. HRESULT CBagInfo::Save
  196. (
  197. IN IStream* pStream,
  198. IN BOOL clearDirty
  199. )
  200. /*++
  201. Routine Description:
  202. See IPersistStream::Save().
  203. Arguments:
  204. See IPersistStream::Save().
  205. Return Value:
  206. See IPersistStream::Save().
  207. --*/
  208. {
  209. HRESULT hr = S_OK;
  210. WsbTraceIn(OLESTR("CBagInfo::Save"),
  211. OLESTR("clearDirty = <%ls>, status = <%d>, ID = <%ls>, Birthdate = <%ls>, length = <%ls>, type = <%d>, volId = <%ls>, deletedAmount = <%ls>, RemoteDataSet = <%d>"),
  212. WsbBoolAsString(clearDirty),
  213. (USHORT)m_BagStatus, WsbGuidAsString(m_BagId), WsbFiletimeAsString(FALSE, m_BirthDate),
  214. WsbLonglongAsString(m_Len), m_Type, WsbGuidAsString(m_VolId),
  215. WsbLonglongAsString(m_DeletedBagAmount), m_RemoteDataSet);
  216. try {
  217. USHORT tmpUShort;
  218. WsbAssert(0 != pStream, E_POINTER);
  219. tmpUShort = (USHORT)m_BagStatus;
  220. WsbAffirmHr(WsbSaveToStream(pStream, tmpUShort));
  221. WsbAffirmHr(WsbSaveToStream(pStream, m_BagId));
  222. WsbAffirmHr(WsbSaveToStream(pStream, m_BirthDate));
  223. WsbAffirmHr(WsbSaveToStream(pStream, m_Len));
  224. WsbAffirmHr(WsbSaveToStream(pStream, m_Type));
  225. WsbAffirmHr(WsbSaveToStream(pStream, m_VolId));
  226. WsbAffirmHr(WsbSaveToStream(pStream, m_DeletedBagAmount));
  227. WsbAffirmHr(WsbSaveToStream(pStream, m_RemoteDataSet));
  228. // If we got it saved and we were asked to clear the dirty bit, then
  229. // do so now.
  230. if (clearDirty) {
  231. m_isDirty = FALSE;
  232. }
  233. } WsbCatch(hr);
  234. WsbTraceOut(OLESTR("CBagInfo::Save"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  235. return(hr);
  236. }
  237. HRESULT
  238. CBagInfo::SetBagInfo(
  239. HSM_BAG_STATUS bagStatus,
  240. GUID bagId,
  241. FILETIME birthDate,
  242. LONGLONG len,
  243. USHORT type,
  244. GUID volId ,
  245. LONGLONG deletedBagAmount,
  246. SHORT remoteDataSet
  247. )
  248. /*++
  249. Routine Description:
  250. See IBagInfo::SetBagInfo().
  251. Arguments:
  252. See IBagInfo::SetBagInfo().
  253. Return Value:
  254. S_OK - Success.
  255. --*/
  256. {
  257. WsbTraceIn(OLESTR("CBagInfo::SetBagInfo"),
  258. OLESTR("status = <%d>, bagId = <%ls>, birthdate = <%ls>, length = <%ls>, type = %d, volId = <%ls>, deletedAmount = <%ls>, remoteDataSet = <%d>"),
  259. bagStatus,
  260. WsbGuidAsString(bagId),
  261. WsbFiletimeAsString(FALSE, birthDate),
  262. WsbLonglongAsString(len),
  263. type,
  264. WsbGuidAsString(volId),
  265. WsbLonglongAsString(deletedBagAmount),
  266. remoteDataSet);
  267. m_isDirty = TRUE;
  268. m_BagStatus = bagStatus;
  269. m_BagId = bagId;
  270. m_BirthDate = birthDate;
  271. m_Len = len;
  272. m_Type = type;
  273. m_VolId = volId;
  274. m_DeletedBagAmount = deletedBagAmount;
  275. m_RemoteDataSet = remoteDataSet;
  276. WsbTraceOut(OLESTR("CBagInfo::SetBagInfo"), OLESTR("hr = <%ls>"),WsbHrAsString(S_OK));
  277. return(S_OK);
  278. }
  279. HRESULT
  280. CBagInfo::Test
  281. (
  282. OUT USHORT *pTestsPassed,
  283. OUT USHORT *pTestsFailed
  284. )
  285. /*++
  286. Routine Description:
  287. See IWsbTestable::Test().
  288. Arguments:
  289. See IWsbTestable::Test().
  290. Return Value:
  291. See IWsbTestable::Test().
  292. --*/
  293. {
  294. HRESULT hr = S_OK;
  295. CComPtr<IBagInfo> pBagInfo1;
  296. CComPtr<IBagInfo> pBagInfo2;
  297. WsbTraceIn(OLESTR("CBagInfo::Test"), OLESTR(""));
  298. *pTestsPassed = *pTestsFailed = 0;
  299. hr = E_NOTIMPL;
  300. WsbTraceOut(OLESTR("CBagInfo::Test"), OLESTR("hr = <%ls>"),WsbHrAsString(hr));
  301. return(S_OK);
  302. }
  303. HRESULT CBagInfo::Print
  304. (
  305. IN IStream* pStream
  306. )
  307. /*++
  308. Implements:
  309. IWsbDbEntity::Print
  310. --*/
  311. {
  312. HRESULT hr = S_OK;
  313. WsbTraceIn(OLESTR("CBagInfo::Print"), OLESTR(""));
  314. try {
  315. WsbAssert(0 != pStream, E_POINTER);
  316. CWsbStringPtr strGuid;
  317. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", Status = %d"),
  318. (USHORT)m_BagStatus));
  319. WsbAffirmHr(WsbSafeGuidAsString(m_BagId, strGuid));
  320. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", BagId = %ls"),
  321. (WCHAR *)strGuid));
  322. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", BirthDate = %ls"),
  323. WsbFiletimeAsString(FALSE, m_BirthDate)));
  324. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", Len = %ls"),
  325. WsbLonglongAsString(m_Len)));
  326. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", Type = %d"),
  327. m_Type));
  328. WsbAffirmHr(WsbSafeGuidAsString(m_VolId, strGuid));
  329. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", VolId = %ls"),
  330. (WCHAR *)strGuid));
  331. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", DeletedAmount = %ls"),
  332. WsbLonglongAsString(m_DeletedBagAmount)));
  333. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", RemoteDataSet = %d"),
  334. m_RemoteDataSet));
  335. WsbAffirmHr(CWsbDbEntity::Print(pStream));
  336. } WsbCatch(hr);
  337. WsbTraceOut(OLESTR("CBagInfo::Print"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  338. return(hr);
  339. }
  340. HRESULT
  341. CBagInfo::UpdateKey(
  342. IWsbDbKey *pKey
  343. )
  344. /*++
  345. Implements:
  346. IWsbDbEntity::UpdateKey
  347. --*/
  348. {
  349. HRESULT hr = S_OK;
  350. try {
  351. WsbAffirmHr(pKey->SetToGuid(m_BagId));
  352. } WsbCatch(hr);
  353. return(hr);
  354. }