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.

3101 lines
51 KiB

  1. /*++
  2. 1998 Seagate Software, Inc. All rights reserved.
  3. Module Name:
  4. hsmcrit.cpp
  5. Abstract:
  6. This component represents the criteria that can be used to determine
  7. whether a given scanItem should have a policy applied to it.
  8. Author:
  9. Chuck Bardeen [cbardeen] 29-Oct-1996
  10. Revision History:
  11. --*/
  12. #include "stdafx.h"
  13. #include "mapiutil.h"
  14. #include "wsb.h"
  15. #include "job.h"
  16. #include "hsmcrit.h"
  17. #define WSB_TRACE_IS WSB_TRACE_BIT_JOB
  18. HRESULT
  19. CHsmCriteria::FinalConstruct(
  20. void
  21. )
  22. /*++
  23. Implements:
  24. CComObjectRoot::FinalConstruct().
  25. --*/
  26. {
  27. HRESULT hr = S_OK;
  28. try {
  29. WsbAffirmHr(CWsbObject::FinalConstruct());
  30. m_isIgnored = FALSE;
  31. m_isNegated = FALSE;
  32. } WsbCatch(hr);
  33. return(hr);
  34. }
  35. HRESULT
  36. CHsmCriteria::GetName(
  37. OUT OLECHAR** pName,
  38. IN ULONG bufferSize
  39. )
  40. /*++
  41. Implements:
  42. IHsmCriteria::GetName().
  43. --*/
  44. {
  45. HRESULT hr = S_OK;
  46. CWsbStringPtr tmpString;
  47. try {
  48. WsbAssert(0 != pName, E_POINTER);
  49. WsbAffirmHr(tmpString.LoadFromRsc(_Module.m_hInst, m_nameId));
  50. WsbAffirmHr(tmpString.CopyTo(pName, bufferSize));
  51. } WsbCatch(hr);
  52. return(hr);
  53. }
  54. HRESULT
  55. CHsmCriteria::GetSizeMax(
  56. OUT ULARGE_INTEGER* pSize
  57. )
  58. /*++
  59. Implements:
  60. IPersistStream::GetSizeMax().
  61. --*/
  62. {
  63. HRESULT hr = S_OK;
  64. WsbTraceIn(OLESTR("CHsmCriteria::GetSizeMax"), OLESTR(""));
  65. try {
  66. WsbAssert(0 != pSize, E_POINTER);
  67. pSize->QuadPart = WsbPersistSizeOf(GUID) + WsbPersistSizeOf(BOOL) + WsbPersistSizeOf(BOOL);
  68. } WsbCatch(hr);
  69. WsbTraceOut(OLESTR("CHsmCriteria::GetSizeMax"), OLESTR("hr = <%ls>, Size = <%ls>"), WsbHrAsString(hr), WsbPtrToUliAsString(pSize));
  70. return(hr);
  71. }
  72. HRESULT
  73. CHsmCriteria::IsIgnored(
  74. void
  75. )
  76. /*++
  77. Implements:
  78. IHsmCriteria::IsIgnored().
  79. --*/
  80. {
  81. return(m_isIgnored ? S_OK : S_FALSE);
  82. }
  83. HRESULT
  84. CHsmCriteria::IsNegated(
  85. void
  86. )
  87. /*++
  88. Implements:
  89. IHsmCriteria::IsNegated().
  90. --*/
  91. {
  92. return(m_isNegated ? S_OK : S_FALSE);
  93. }
  94. HRESULT
  95. CHsmCriteria::Load(
  96. IN IStream* pStream
  97. )
  98. /*++
  99. Implements:
  100. IPersistStream::Load().
  101. --*/
  102. {
  103. HRESULT hr = S_OK;
  104. WsbTraceIn(OLESTR("CHsmCriteria::Load"), OLESTR(""));
  105. try {
  106. WsbAssert(0 != pStream, E_POINTER);
  107. WsbAffirmHr(WsbLoadFromStream(pStream, &m_nameId));
  108. WsbAffirmHr(WsbLoadFromStream(pStream, &m_isIgnored));
  109. WsbAffirmHr(WsbLoadFromStream(pStream, &m_isNegated));
  110. } WsbCatch(hr);
  111. WsbTraceOut(OLESTR("CHsmCriteria::Load"), OLESTR("hr = <%ls>, nameId = <%lu>"), WsbHrAsString(hr), m_nameId);
  112. return(hr);
  113. }
  114. HRESULT
  115. CHsmCriteria::Save(
  116. IN IStream* pStream,
  117. IN BOOL clearDirty
  118. )
  119. /*++
  120. Implements:
  121. IPersistStream::Save().
  122. --*/
  123. {
  124. HRESULT hr = S_OK;
  125. WsbTraceIn(OLESTR("CHsmCriteria::Save"), OLESTR("clearDirty = <%ls>"), WsbBoolAsString(clearDirty));
  126. try {
  127. WsbAssert(0 != pStream, E_POINTER);
  128. WsbAffirmHr(WsbSaveToStream(pStream, m_nameId));
  129. WsbAffirmHr(WsbSaveToStream(pStream, m_isIgnored));
  130. WsbAffirmHr(WsbSaveToStream(pStream, m_isNegated));
  131. // If we got it saved and we were asked to clear the dirty bit, then
  132. // do so now.
  133. if (clearDirty) {
  134. m_isDirty = FALSE;
  135. }
  136. } WsbCatch(hr);
  137. WsbTraceOut(OLESTR("CHsmCriteria::Save"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  138. return(hr);
  139. }
  140. HRESULT
  141. CHsmCriteria::SetIsIgnored(
  142. IN BOOL isIgnored
  143. )
  144. /*++
  145. Implements:
  146. IHsmCriteria::SetIsIgnored().
  147. --*/
  148. {
  149. m_isIgnored = isIgnored;
  150. m_isDirty = TRUE;
  151. return(S_OK);
  152. }
  153. HRESULT
  154. CHsmCriteria::SetIsNegated(
  155. IN BOOL isNegated
  156. )
  157. /*++
  158. Implements:
  159. IHsmCriteria::SetIsNegated().
  160. --*/
  161. {
  162. m_isNegated = isNegated;
  163. m_isDirty = TRUE;
  164. return(S_OK);
  165. }
  166. HRESULT
  167. CHsmCriteria::Test(
  168. USHORT* passed,
  169. USHORT* failed
  170. )
  171. /*++
  172. Implements:
  173. IWsbTestable::Test().
  174. --*/
  175. {
  176. HRESULT hr = S_OK;
  177. try {
  178. WsbAssert(0 != passed, E_POINTER);
  179. WsbAssert(0 != failed, E_POINTER);
  180. *passed = 0;
  181. *failed = 0;
  182. } WsbCatch(hr);
  183. return(hr);
  184. }
  185. HRESULT
  186. CHsmRelativeCriteria::ComparatorAsString(
  187. OUT OLECHAR** pComparator,
  188. IN ULONG bufferSize
  189. )
  190. /*++
  191. Implements:
  192. IHsmRelativeCriteria::ComparatorAsString().
  193. --*/
  194. {
  195. HRESULT hr = S_OK;
  196. try {
  197. WsbAssert(0 != pComparator, E_POINTER);
  198. WsbAffirmHr(WsbLoadComString(_Module.m_hInst, IDS_HSM_CRITERIACOMPARATOR_NOTSET + m_comparator, pComparator, bufferSize));
  199. } WsbCatch(hr);
  200. return(hr);
  201. }
  202. HRESULT
  203. CHsmRelativeCriteria::ComparatorIsBinary(
  204. void
  205. )
  206. /*++
  207. Implements:
  208. IHsmRelativeCriteria::ComparatorIsBinary().
  209. --*/
  210. {
  211. HRESULT hr = S_FALSE;
  212. if ((m_comparator == HSM_CRITERIACOMPARATOR_BETWEEN) ||
  213. (m_comparator == HSM_CRITERIACOMPARATOR_OUTSIDE)) {
  214. hr = S_OK;
  215. }
  216. return(hr);
  217. }
  218. HRESULT
  219. CHsmRelativeCriteria::FinalConstruct(
  220. void
  221. )
  222. /*++
  223. Implements:
  224. CComObjectRoot::FinalConstruct().
  225. --*/
  226. {
  227. HRESULT hr = S_OK;
  228. try {
  229. WsbAffirmHr(CHsmCriteria::FinalConstruct());
  230. m_comparator = HSM_CRITERIACOMPARATOR_NOTSET;
  231. m_arg1 = 0;
  232. m_arg2 = 0;
  233. } WsbCatch(hr);
  234. return(hr);
  235. }
  236. void
  237. CHsmRelativeCriteria::FinalRelease(
  238. void
  239. )
  240. /*++
  241. Implements:
  242. CComObjectRoot::FinalRelease().
  243. --*/
  244. {
  245. // Free the memory used by the arg1 string.
  246. if (0 != m_arg1) {
  247. WsbFree(m_arg1);
  248. m_arg1 = 0;
  249. }
  250. // Free the memory used by the arg2 string.
  251. if (0 != m_arg2) {
  252. WsbFree(m_arg2);
  253. m_arg2 = 0;
  254. }
  255. // Let the parent class do his thing.
  256. CWsbObject::FinalRelease();
  257. }
  258. HRESULT
  259. CHsmRelativeCriteria::GetArg1(
  260. OUT OLECHAR** pArg,
  261. IN ULONG bufferSize
  262. )
  263. /*++
  264. Implements:
  265. IHsmRelativeCriteria::GetArg1().
  266. --*/
  267. {
  268. HRESULT hr = S_OK;
  269. try {
  270. WsbAssert(0 != pArg, E_POINTER);
  271. WsbAffirmHr(WsbAllocAndCopyComString(pArg, m_arg1, bufferSize));
  272. } WsbCatch(hr);
  273. return(hr);
  274. }
  275. HRESULT
  276. CHsmRelativeCriteria::GetArg2(
  277. OUT OLECHAR** pArg,
  278. IN ULONG bufferSize
  279. )
  280. /*++
  281. Implements:
  282. IHsmRelativeCriteria::GetArg2().
  283. --*/
  284. {
  285. HRESULT hr = S_OK;
  286. try {
  287. WsbAssert(0 != pArg, E_POINTER);
  288. WsbAffirmHr(WsbAllocAndCopyComString(pArg, m_arg2, bufferSize));
  289. } WsbCatch(hr);
  290. return(hr);
  291. }
  292. HRESULT
  293. CHsmRelativeCriteria::GetComparator(
  294. OUT HSM_CRITERIACOMPARATOR* pComparator
  295. )
  296. /*++
  297. Implements:
  298. IHsmRelativeCriteria::GetComparator().
  299. --*/
  300. {
  301. HRESULT hr = S_OK;
  302. try {
  303. WsbAssert(0 != pComparator, E_POINTER);
  304. *pComparator = m_comparator;
  305. } WsbCatch(hr);
  306. return(hr);
  307. }
  308. HRESULT
  309. CHsmRelativeCriteria::GetSizeMax(
  310. OUT ULARGE_INTEGER* pSize
  311. )
  312. /*++
  313. Implements:
  314. IPersistStream::GetSizeMax().
  315. --*/
  316. {
  317. HRESULT hr = S_OK;
  318. WsbTraceIn(OLESTR("CHsmRelativeCriteria::GetSizeMax"), OLESTR(""));
  319. try {
  320. WsbAssert(0 != pSize, E_POINTER);
  321. pSize->QuadPart = WsbPersistSizeOf(GUID) + WsbPersistSizeOf(BOOL) + WsbPersistSizeOf(BOOL) + WsbPersistSize((wcslen(m_arg1) + 1) * sizeof(OLECHAR)) + WsbPersistSize((wcslen(m_arg2) + 1) * sizeof(OLECHAR));
  322. } WsbCatch(hr);
  323. WsbTraceOut(OLESTR("CHsmRelativeCriteria::GetSizeMax"), OLESTR("hr = <%ls>, Size = <%ls>"), WsbHrAsString(hr), WsbPtrToUliAsString(pSize));
  324. return(hr);
  325. }
  326. HRESULT
  327. CHsmRelativeCriteria::Load(
  328. IN IStream* pStream
  329. )
  330. /*++
  331. Implements:
  332. IPersistStream::Load().
  333. --*/
  334. {
  335. HRESULT hr = S_OK;
  336. CWsbStringPtr tmp;
  337. WsbTraceIn(OLESTR("CHsmRelativeCriteria::Load"), OLESTR(""));
  338. try {
  339. WsbAssert(0 != pStream, E_POINTER);
  340. WsbAffirmHr(WsbLoadFromStream(pStream, &m_nameId));
  341. WsbAffirmHr(WsbLoadFromStream(pStream, &m_isIgnored));
  342. WsbAffirmHr(WsbLoadFromStream(pStream, &m_isNegated));
  343. WsbAffirmHr(WsbLoadFromStream(pStream, &tmp, 0));
  344. WsbAffirmHr(SetArg1(tmp));
  345. WsbAffirmHr(WsbLoadFromStream(pStream, &tmp, 0));
  346. WsbAffirmHr(SetArg2(tmp));
  347. } WsbCatch(hr);
  348. WsbTraceOut(OLESTR("CHsmRelativeCriteria::Load"), OLESTR("hr = <%ls>, nameId = <%lu>"), WsbHrAsString(hr), m_nameId);
  349. return(hr);
  350. }
  351. HRESULT
  352. CHsmRelativeCriteria::Save(
  353. IN IStream* pStream,
  354. IN BOOL clearDirty
  355. )
  356. /*++
  357. Implements:
  358. IPersistStream::Save().
  359. --*/
  360. {
  361. HRESULT hr = S_OK;
  362. WsbTraceIn(OLESTR("CHsmRelativeCriteria::Save"), OLESTR("clearDirty = <%ls>"), WsbBoolAsString(clearDirty));
  363. try {
  364. WsbAssert(0 != pStream, E_POINTER);
  365. WsbAffirmHr(WsbSaveToStream(pStream, m_nameId));
  366. WsbAffirmHr(WsbSaveToStream(pStream, m_isIgnored));
  367. WsbAffirmHr(WsbSaveToStream(pStream, m_isNegated));
  368. WsbAffirmHr(WsbSaveToStream(pStream, m_arg1));
  369. WsbAffirmHr(WsbSaveToStream(pStream, m_arg2));
  370. // If we got it saved and we were asked to clear the dirty bit, then
  371. // do so now.
  372. if (clearDirty) {
  373. m_isDirty = FALSE;
  374. }
  375. } WsbCatch(hr);
  376. WsbTraceOut(OLESTR("CHsmRelativeCriteria::Save"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  377. return(hr);
  378. }
  379. HRESULT
  380. CHsmRelativeCriteria::SetArg1(
  381. IN OLECHAR* arg
  382. )
  383. /*++
  384. Implements:
  385. IHsmRelativeCriteria::SetArg1().
  386. --*/
  387. {
  388. HRESULT hr = S_OK;
  389. hr = WsbAllocAndCopyComString(&m_arg1, arg, 0);
  390. return(hr);
  391. }
  392. HRESULT
  393. CHsmRelativeCriteria::SetArg2(
  394. IN OLECHAR* arg
  395. )
  396. /*++
  397. Implements:
  398. IHsmRelativeCriteria::SetArg2().
  399. --*/
  400. {
  401. HRESULT hr = S_OK;
  402. hr = WsbAllocAndCopyComString(&m_arg2, arg, 0);
  403. return(hr);
  404. }
  405. HRESULT
  406. CHsmRelativeCriteria::SetComparator(
  407. IN HSM_CRITERIACOMPARATOR comparator
  408. )
  409. /*++
  410. Implements:
  411. IHsmRelativeCriteria::SetComparator().
  412. --*/
  413. {
  414. m_comparator = comparator;
  415. return(S_OK);
  416. }
  417. HRESULT
  418. CHsmCritAlways::FinalConstruct(
  419. void
  420. )
  421. /*++
  422. Implements:
  423. CComObjectRoot::FinalConstruct().
  424. --*/
  425. {
  426. HRESULT hr = S_OK;
  427. try {
  428. WsbAffirmHr(CHsmCriteria::FinalConstruct());
  429. m_nameId = IDS_HSMCRITALWAYS_ID;
  430. } WsbCatch(hr);
  431. return(hr);
  432. }
  433. HRESULT
  434. CHsmCritAlways::GetClassID(
  435. OUT CLSID* pClsid
  436. )
  437. /*++
  438. Implements:
  439. IPersist::GetClassID().
  440. --*/
  441. {
  442. HRESULT hr = S_OK;
  443. WsbTraceIn(OLESTR("CHsmCritAlways::GetClassID"), OLESTR(""));
  444. try {
  445. WsbAssert(0 != pClsid, E_POINTER);
  446. *pClsid = CLSID_CHsmCritAlways;
  447. } WsbCatch(hr);
  448. WsbTraceOut(OLESTR("CHsmCritAlways::GetClassID"), OLESTR("hr = <%ls>, CLSID = <%ls>"), WsbHrAsString(hr), WsbGuidAsString(*pClsid));
  449. return(hr);
  450. }
  451. HRESULT
  452. CHsmCritAlways::ShouldDo(
  453. IN IFsaScanItem* /*pScanItem*/,
  454. IN USHORT /*scale*/
  455. )
  456. /*++
  457. Implements:
  458. IHsmCriteria::ShouldDo().
  459. --*/
  460. {
  461. HRESULT hr = S_OK;
  462. WsbTraceIn(OLESTR("CHsmCritAlways::ShouldDo"), OLESTR(""));
  463. hr = m_isNegated ? S_FALSE : S_OK;
  464. WsbTraceOut(OLESTR("CHsmCritAlways::ShouldDo"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  465. return(hr);
  466. }
  467. HRESULT
  468. CHsmCritAlways::Test(
  469. USHORT* passed,
  470. USHORT* failed
  471. )
  472. /*++
  473. Implements:
  474. IWsbTestable::Test().
  475. --*/
  476. {
  477. HRESULT hr = S_OK;
  478. OLECHAR* name = 0;
  479. try {
  480. WsbAssert(0 != passed, E_POINTER);
  481. WsbAssert(0 != failed, E_POINTER);
  482. *passed = 0;
  483. *failed = 0;
  484. try {
  485. WsbAssertHr(GetName(&name, 0));
  486. WsbAssert(wcscmp(name, OLESTR("Always")) == 0, E_FAIL);
  487. (*passed)++;
  488. } WsbCatchAndDo(hr, (*failed)++;);
  489. } WsbCatch(hr);
  490. if (0 != name) {
  491. WsbFree(name);
  492. }
  493. return(hr);
  494. }
  495. HRESULT
  496. CHsmCritAlways::Value(
  497. IN IFsaScanItem* pScanItem,
  498. OUT OLECHAR** pValue,
  499. IN ULONG bufferSize
  500. )
  501. /*++
  502. Implements:
  503. IHsmCriteria::Value().
  504. --*/
  505. {
  506. HRESULT hr = S_OK;
  507. try {
  508. WsbAssert(0 != pScanItem, E_POINTER);
  509. WsbAssert(0 != pValue, E_POINTER);
  510. hr = WsbLoadComString(_Module.m_hInst, IDS_HSMCRITALWAYS_VALUE_T, pValue, bufferSize);
  511. } WsbCatch(hr);
  512. return(hr);
  513. }
  514. HRESULT
  515. CHsmCritCompressed::FinalConstruct(
  516. void
  517. )
  518. /*++
  519. Implements:
  520. CComObjectRoot::FinalConstruct().
  521. --*/
  522. {
  523. HRESULT hr = S_OK;
  524. try {
  525. WsbAffirmHr(CHsmCriteria::FinalConstruct());
  526. m_nameId = IDS_HSMCRITCOMPRESSED_ID;
  527. } WsbCatch(hr);
  528. return(hr);
  529. }
  530. HRESULT
  531. CHsmCritCompressed::GetClassID(
  532. OUT CLSID* pClsid
  533. )
  534. /*++
  535. Implements:
  536. IPersist::GetClassID().
  537. --*/
  538. {
  539. HRESULT hr = S_OK;
  540. WsbTraceIn(OLESTR("CHsmCritCompressed::GetClassID"), OLESTR(""));
  541. try {
  542. WsbAssert(0 != pClsid, E_POINTER);
  543. *pClsid = CLSID_CHsmCritAlways;
  544. } WsbCatch(hr);
  545. WsbTraceOut(OLESTR("CHsmCritCompressed::GetClassID"), OLESTR("hr = <%ls>, CLSID = <%ls>"), WsbHrAsString(hr), WsbGuidAsString(*pClsid));
  546. return(hr);
  547. }
  548. HRESULT
  549. CHsmCritCompressed::ShouldDo(
  550. IN IFsaScanItem* pScanItem,
  551. IN USHORT /*scale*/
  552. )
  553. /*++
  554. Implements:
  555. IHsmCriteria::ShouldDo().
  556. --*/
  557. {
  558. HRESULT hr = S_OK;
  559. WsbTraceIn(OLESTR("CHsmCritCompressed::ShouldDo"), OLESTR(""));
  560. try {
  561. WsbAssert(0 != pScanItem, E_POINTER);
  562. hr = pScanItem->IsCompressed();
  563. if (SUCCEEDED(hr) && m_isNegated) {
  564. if (S_OK == hr) {
  565. hr = S_FALSE;
  566. } else {
  567. hr = S_OK;
  568. }
  569. }
  570. } WsbCatch(hr);
  571. WsbTraceOut(OLESTR("CHsmCritCompressed::ShouldDo"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  572. return(hr);
  573. }
  574. HRESULT
  575. CHsmCritCompressed::Value(
  576. IN IFsaScanItem* pScanItem,
  577. OUT OLECHAR** pValue,
  578. IN ULONG bufferSize
  579. )
  580. /*++
  581. Implements:
  582. IHsmCriteria::Value().
  583. --*/
  584. {
  585. HRESULT hr = S_OK;
  586. try {
  587. WsbAssert(0 != pScanItem, E_POINTER);
  588. WsbAssert(0 != pValue, E_POINTER);
  589. hr = pScanItem->IsCompressed();
  590. if (S_OK == hr) {
  591. hr = WsbLoadComString(_Module.m_hInst, IDS_HSMCRITCOMPRESSED_VALUE_T, pValue, bufferSize);
  592. } else {
  593. hr = WsbLoadComString(_Module.m_hInst, IDS_HSMCRITCOMPRESSED_VALUE_F, pValue, bufferSize);
  594. }
  595. } WsbCatch(hr);
  596. return(hr);
  597. }
  598. HRESULT
  599. CHsmCritLinked::FinalConstruct(
  600. void
  601. )
  602. /*++
  603. Implements:
  604. CComObjectRoot::FinalConstruct().
  605. --*/
  606. {
  607. HRESULT hr = S_OK;
  608. try {
  609. WsbAffirmHr(CHsmCriteria::FinalConstruct());
  610. m_nameId = IDS_HSMCRITLINKED_ID;
  611. } WsbCatch(hr);
  612. return(hr);
  613. }
  614. HRESULT
  615. CHsmCritLinked::GetClassID(
  616. OUT CLSID* pClsid
  617. )
  618. /*++
  619. Implements:
  620. IPersist::GetClassID().
  621. --*/
  622. {
  623. HRESULT hr = S_OK;
  624. WsbTraceIn(OLESTR("CHsmCritLinked::GetClassID"), OLESTR(""));
  625. try {
  626. WsbAssert(0 != pClsid, E_POINTER);
  627. *pClsid = CLSID_CHsmCritLinked;
  628. } WsbCatch(hr);
  629. WsbTraceOut(OLESTR("CHsmCritLinked::GetClassID"), OLESTR("hr = <%ls>, CLSID = <%ls>"), WsbHrAsString(hr), WsbGuidAsString(*pClsid));
  630. return(hr);
  631. }
  632. HRESULT
  633. CHsmCritLinked::ShouldDo(
  634. IN IFsaScanItem* pScanItem,
  635. IN USHORT /*scale*/
  636. )
  637. /*++
  638. Implements:
  639. IHsmCriteria::ShouldDo().
  640. --*/
  641. {
  642. HRESULT hr = S_OK;
  643. WsbTraceIn(OLESTR("CHsmCritLinked::ShouldDo"), OLESTR(""));
  644. try {
  645. WsbAssert(0 != pScanItem, E_POINTER);
  646. hr = pScanItem->IsALink();
  647. if (SUCCEEDED(hr) && m_isNegated) {
  648. if (S_OK == hr) {
  649. hr = S_FALSE;
  650. } else {
  651. hr = S_OK;
  652. }
  653. }
  654. } WsbCatch(hr);
  655. WsbTraceOut(OLESTR("CHsmCritLinked::ShouldDo"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  656. return(hr);
  657. }
  658. HRESULT
  659. CHsmCritLinked::Value(
  660. IN IFsaScanItem* pScanItem,
  661. OUT OLECHAR** pValue,
  662. IN ULONG bufferSize
  663. )
  664. /*++
  665. Implements:
  666. IHsmCriteria::Value().
  667. --*/
  668. {
  669. HRESULT hr = S_OK;
  670. try {
  671. WsbAssert(0 != pScanItem, E_POINTER);
  672. WsbAssert(0 != pValue, E_POINTER);
  673. hr = pScanItem->IsALink();
  674. if (S_OK == hr) {
  675. hr = WsbLoadComString(_Module.m_hInst, IDS_HSMCRITLINKED_VALUE_T, pValue, bufferSize);
  676. } else {
  677. hr = WsbLoadComString(_Module.m_hInst, IDS_HSMCRITLINKED_VALUE_F, pValue, bufferSize);
  678. }
  679. } WsbCatch(hr);
  680. return(hr);
  681. }
  682. HRESULT
  683. CHsmCritMbit::FinalConstruct(
  684. void
  685. )
  686. /*++
  687. Implements:
  688. CComObjectRoot::FinalConstruct().
  689. --*/
  690. {
  691. HRESULT hr = S_OK;
  692. try {
  693. WsbAffirmHr(CHsmCriteria::FinalConstruct());
  694. m_nameId = IDS_HSMCRITMBIT_ID;
  695. } WsbCatch(hr);
  696. return(hr);
  697. }
  698. HRESULT
  699. CHsmCritMbit::GetClassID(
  700. OUT CLSID* pClsid
  701. )
  702. /*++
  703. Implements:
  704. IPersist::GetClassID().
  705. --*/
  706. {
  707. HRESULT hr = S_OK;
  708. WsbTraceIn(OLESTR("CHsmCritMbit::GetClassID"), OLESTR(""));
  709. try {
  710. WsbAssert(0 != pClsid, E_POINTER);
  711. *pClsid = CLSID_CHsmCritMbit;
  712. } WsbCatch(hr);
  713. WsbTraceOut(OLESTR("CHsmCritMbit::GetClassID"), OLESTR("hr = <%ls>, CLSID = <%ls>"), WsbHrAsString(hr), WsbGuidAsString(*pClsid));
  714. return(hr);
  715. }
  716. HRESULT
  717. CHsmCritMbit::ShouldDo(
  718. IN IFsaScanItem* pScanItem,
  719. IN USHORT /*scale*/
  720. )
  721. /*++
  722. Implements:
  723. IHsmCriteria::ShouldDo().
  724. --*/
  725. {
  726. HRESULT hr = S_OK;
  727. WsbTraceIn(OLESTR("CHsmCritMbit::ShouldDo"), OLESTR(""));
  728. try {
  729. WsbAssert(0 != pScanItem, E_POINTER);
  730. hr = pScanItem->IsMbit();
  731. if (SUCCEEDED(hr) && m_isNegated) {
  732. if (S_OK == hr) {
  733. hr = S_FALSE;
  734. } else {
  735. hr = S_OK;
  736. }
  737. }
  738. } WsbCatch(hr);
  739. WsbTraceOut(OLESTR("CHsmCritMbit::ShouldDo"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  740. return(hr);
  741. }
  742. HRESULT
  743. CHsmCritMbit::Value(
  744. IN IFsaScanItem* pScanItem,
  745. OUT OLECHAR** pValue,
  746. IN ULONG bufferSize
  747. )
  748. /*++
  749. Implements:
  750. IHsmCriteria::Value().
  751. --*/
  752. {
  753. HRESULT hr = S_OK;
  754. try {
  755. WsbAssert(0 != pScanItem, E_POINTER);
  756. WsbAssert(0 != pValue, E_POINTER);
  757. hr = pScanItem->IsMbit();
  758. if (S_OK == hr) {
  759. hr = WsbLoadComString(_Module.m_hInst, IDS_HSMCRITMBIT_VALUE_T, pValue, bufferSize);
  760. } else {
  761. hr = WsbLoadComString(_Module.m_hInst, IDS_HSMCRITMBIT_VALUE_F, pValue, bufferSize);
  762. }
  763. } WsbCatch(hr);
  764. return(hr);
  765. }
  766. HRESULT
  767. CHsmCritManageable::FinalConstruct(
  768. void
  769. )
  770. /*++
  771. Implements:
  772. CComObjectRoot::FinalConstruct().
  773. --*/
  774. {
  775. HRESULT hr = S_OK;
  776. try {
  777. WsbAffirmHr(CHsmCriteria::FinalConstruct());
  778. m_nameId = IDS_HSMCRITMANAGEABLE_ID;
  779. } WsbCatch(hr);
  780. return(hr);
  781. }
  782. HRESULT
  783. CHsmCritManageable::GetClassID(
  784. OUT CLSID* pClsid
  785. )
  786. /*++
  787. Implements:
  788. IPersist::GetClassID().
  789. --*/
  790. {
  791. HRESULT hr = S_OK;
  792. WsbTraceIn(OLESTR("CHsmCritManageable::GetClassID"), OLESTR(""));
  793. try {
  794. WsbAssert(0 != pClsid, E_POINTER);
  795. *pClsid = CLSID_CHsmCritManageable;
  796. } WsbCatch(hr);
  797. WsbTraceOut(OLESTR("CHsmCritManageable::GetClassID"), OLESTR("hr = <%ls>, CLSID = <%ls>"), WsbHrAsString(hr), WsbGuidAsString(*pClsid));
  798. return(hr);
  799. }
  800. HRESULT
  801. CHsmCritManageable::ShouldDo(
  802. IN IFsaScanItem* pScanItem,
  803. IN USHORT /*scale*/
  804. )
  805. /*++
  806. Implements:
  807. IHsmCriteria::ShouldDo().
  808. --*/
  809. {
  810. HRESULT hr = S_OK;
  811. LONGLONG size;
  812. WsbTraceIn(OLESTR("CHsmCritManageable::ShouldDo"), OLESTR(""));
  813. try {
  814. WsbAssert(0 != pScanItem, E_POINTER);
  815. WsbAffirmHr(pScanItem->GetLogicalSize(&size));
  816. hr = pScanItem->IsManageable(0, size);
  817. if (SUCCEEDED(hr) && m_isNegated) {
  818. if (S_OK == hr) {
  819. hr = S_FALSE;
  820. } else {
  821. hr = S_OK;
  822. }
  823. }
  824. } WsbCatch(hr);
  825. WsbTraceOut(OLESTR("CHsmCritManageable::ShouldDo"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  826. return(hr);
  827. }
  828. HRESULT
  829. CHsmCritManageable::Value(
  830. IN IFsaScanItem* pScanItem,
  831. OUT OLECHAR** pValue,
  832. IN ULONG bufferSize
  833. )
  834. /*++
  835. Implements:
  836. IHsmCriteria::Value().
  837. --*/
  838. {
  839. HRESULT hr = S_OK;
  840. LONGLONG size;
  841. try {
  842. WsbAssert(0 != pScanItem, E_POINTER);
  843. WsbAssert(0 != pValue, E_POINTER);
  844. WsbAffirmHr(pScanItem->GetLogicalSize(&size));
  845. hr = pScanItem->IsManageable(0, size);
  846. if (S_OK == hr) {
  847. hr = WsbLoadComString(_Module.m_hInst, IDS_HSMCRITMANAGEABLE_VALUE_T, pValue, bufferSize);
  848. } else {
  849. hr = WsbLoadComString(_Module.m_hInst, IDS_HSMCRITMANAGEABLE_VALUE_F, pValue, bufferSize);
  850. }
  851. } WsbCatch(hr);
  852. return(hr);
  853. }
  854. HRESULT
  855. CHsmCritMigrated::FinalConstruct(
  856. void
  857. )
  858. /*++
  859. Implements:
  860. CComObjectRoot::FinalConstruct().
  861. --*/
  862. {
  863. HRESULT hr = S_OK;
  864. try {
  865. WsbAffirmHr(CHsmCriteria::FinalConstruct());
  866. m_nameId = IDS_HSMCRITMIGRATED_ID;
  867. } WsbCatch(hr);
  868. return(hr);
  869. }
  870. HRESULT
  871. CHsmCritMigrated::GetClassID(
  872. OUT CLSID* pClsid
  873. )
  874. /*++
  875. Implements:
  876. IPersist::GetClassID().
  877. --*/
  878. {
  879. HRESULT hr = S_OK;
  880. WsbTraceIn(OLESTR("CHsmCritMigrated::GetClassID"), OLESTR(""));
  881. try {
  882. WsbAssert(0 != pClsid, E_POINTER);
  883. *pClsid = CLSID_CHsmCritMigrated;
  884. } WsbCatch(hr);
  885. WsbTraceOut(OLESTR("CHsmCritMigrated::GetClassID"), OLESTR("hr = <%ls>, CLSID = <%ls>"), WsbHrAsString(hr), WsbGuidAsString(*pClsid));
  886. return(hr);
  887. }
  888. HRESULT
  889. CHsmCritMigrated::ShouldDo(
  890. IN IFsaScanItem* pScanItem,
  891. IN USHORT /*scale*/
  892. )
  893. /*++
  894. Implements:
  895. IHsmCriteria::ShouldDo().
  896. --*/
  897. {
  898. HRESULT hr = S_OK;
  899. LONGLONG size;
  900. WsbTraceIn(OLESTR("CHsmCritMigrated::ShouldDo"), OLESTR(""));
  901. try {
  902. WsbAssert(0 != pScanItem, E_POINTER);
  903. WsbAffirmHr(pScanItem->GetLogicalSize(&size));
  904. hr = pScanItem->IsTruncated(0, size);
  905. if (SUCCEEDED(hr) && m_isNegated) {
  906. if (S_OK == hr) {
  907. hr = S_FALSE;
  908. } else {
  909. hr = S_OK;
  910. }
  911. }
  912. } WsbCatch(hr);
  913. WsbTraceOut(OLESTR("CHsmCritMigrated::ShouldDo"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  914. return(hr);
  915. }
  916. HRESULT
  917. CHsmCritMigrated::Value(
  918. IN IFsaScanItem* pScanItem,
  919. OUT OLECHAR** pValue,
  920. IN ULONG bufferSize
  921. )
  922. /*++
  923. Implements:
  924. IHsmCriteria::Value().
  925. --*/
  926. {
  927. HRESULT hr = S_OK;
  928. LONGLONG size;
  929. try {
  930. WsbAssert(0 != pScanItem, E_POINTER);
  931. WsbAssert(0 != pValue, E_POINTER);
  932. WsbAffirmHr(pScanItem->GetLogicalSize(&size));
  933. hr = pScanItem->IsTruncated(0, size);
  934. if (S_OK == hr) {
  935. hr = WsbLoadComString(_Module.m_hInst, IDS_HSMCRITMIGRATED_VALUE_T, pValue, bufferSize);
  936. } else {
  937. hr = WsbLoadComString(_Module.m_hInst, IDS_HSMCRITMIGRATED_VALUE_F, pValue, bufferSize);
  938. }
  939. } WsbCatch(hr);
  940. return(hr);
  941. }
  942. HRESULT
  943. CHsmCritPremigrated::FinalConstruct(
  944. void
  945. )
  946. /*++
  947. Implements:
  948. CComObjectRoot::FinalConstruct().
  949. --*/
  950. {
  951. HRESULT hr = S_OK;
  952. try {
  953. WsbAffirmHr(CHsmCriteria::FinalConstruct());
  954. m_nameId = IDS_HSMCRITPREMIGRATED_ID;
  955. } WsbCatch(hr);
  956. return(hr);
  957. }
  958. HRESULT
  959. CHsmCritPremigrated::GetClassID(
  960. OUT CLSID* pClsid
  961. )
  962. /*++
  963. Implements:
  964. IPersist::GetClassID().
  965. --*/
  966. {
  967. HRESULT hr = S_OK;
  968. WsbTraceIn(OLESTR("CHsmCritPremigrated::GetClassID"), OLESTR(""));
  969. try {
  970. WsbAssert(0 != pClsid, E_POINTER);
  971. *pClsid = CLSID_CHsmCritPremigrated;
  972. } WsbCatch(hr);
  973. WsbTraceOut(OLESTR("CHsmCritPremigrated::GetClassID"), OLESTR("hr = <%ls>, CLSID = <%ls>"), WsbHrAsString(hr), WsbGuidAsString(*pClsid));
  974. return(hr);
  975. }
  976. HRESULT
  977. CHsmCritPremigrated::ShouldDo(
  978. IN IFsaScanItem* pScanItem,
  979. IN USHORT /*scale*/
  980. )
  981. /*++
  982. Implements:
  983. IHsmCriteria::ShouldDo().
  984. --*/
  985. {
  986. HRESULT hr = S_OK;
  987. LONGLONG size;
  988. WsbTraceIn(OLESTR("CHsmCritPremigrated::ShouldDo"), OLESTR(""));
  989. try {
  990. WsbAssert(0 != pScanItem, E_POINTER);
  991. WsbAffirmHr(pScanItem->GetLogicalSize(&size));
  992. hr = pScanItem->IsPremigrated(0, size);
  993. if (SUCCEEDED(hr) && m_isNegated) {
  994. if (S_OK == hr) {
  995. hr = S_FALSE;
  996. } else {
  997. hr = S_OK;
  998. }
  999. }
  1000. } WsbCatch(hr);
  1001. WsbTraceOut(OLESTR("CHsmCritPremigrated::ShouldDo"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  1002. return(hr);
  1003. }
  1004. HRESULT
  1005. CHsmCritPremigrated::Value(
  1006. IN IFsaScanItem* pScanItem,
  1007. OUT OLECHAR** pValue,
  1008. IN ULONG bufferSize
  1009. )
  1010. /*++
  1011. Implements:
  1012. IHsmCriteria::Value().
  1013. --*/
  1014. {
  1015. HRESULT hr = S_OK;
  1016. LONGLONG size;
  1017. try {
  1018. WsbAssert(0 != pScanItem, E_POINTER);
  1019. WsbAssert(0 != pValue, E_POINTER);
  1020. WsbAffirmHr(pScanItem->GetLogicalSize(&size));
  1021. hr = pScanItem->IsPremigrated(0, size);
  1022. if (S_OK == hr) {
  1023. hr = WsbLoadComString(_Module.m_hInst, IDS_HSMCRITPREMIGRATED_VALUE_T, pValue, bufferSize);
  1024. } else {
  1025. hr = WsbLoadComString(_Module.m_hInst, IDS_HSMCRITPREMIGRATED_VALUE_F, pValue, bufferSize);
  1026. }
  1027. } WsbCatch(hr);
  1028. return(hr);
  1029. }
  1030. HRESULT
  1031. CHsmCritAccessTime::FinalConstruct(
  1032. void
  1033. )
  1034. /*++
  1035. Implements:
  1036. CComObjectRoot::FinalConstruct().
  1037. --*/
  1038. {
  1039. HRESULT hr = S_OK;
  1040. try {
  1041. WsbAffirmHr(CHsmRelativeCriteria::FinalConstruct());
  1042. m_nameId = IDS_HSMCRITACCESSTIME_ID;
  1043. } WsbCatch(hr);
  1044. return(hr);
  1045. }
  1046. HRESULT
  1047. CHsmCritAccessTime::GetClassID(
  1048. OUT CLSID* pClsid
  1049. )
  1050. /*++
  1051. Implements:
  1052. IPersist::GetClassID().
  1053. --*/
  1054. {
  1055. HRESULT hr = S_OK;
  1056. WsbTraceIn(OLESTR("CHsmCritAccessTime::GetClassID"), OLESTR(""));
  1057. try {
  1058. WsbAssert(0 != pClsid, E_POINTER);
  1059. *pClsid = CLSID_CHsmCritAccessTime;
  1060. } WsbCatch(hr);
  1061. WsbTraceOut(OLESTR("CHsmCritAccessTime::GetClassID"), OLESTR("hr = <%ls>, CLSID = <%ls>"), WsbHrAsString(hr), WsbGuidAsString(*pClsid));
  1062. return(hr);
  1063. }
  1064. HRESULT
  1065. CHsmCritAccessTime::SetArg1(
  1066. IN OLECHAR* arg
  1067. )
  1068. /*++
  1069. Implements:
  1070. IHsmCriteria::SetArg1().
  1071. --*/
  1072. {
  1073. HRESULT hr = S_OK;
  1074. try {
  1075. WsbAffirmHr(WsbWCStoFT(arg, &m_isRelative, &m_value1));
  1076. WsbAffirmHr(CHsmRelativeCriteria::SetArg1(arg));
  1077. } WsbCatch(hr);
  1078. return(hr);
  1079. }
  1080. HRESULT
  1081. CHsmCritAccessTime::SetArg2(
  1082. IN OLECHAR* arg
  1083. )
  1084. /*++
  1085. Implements:
  1086. IHsmCriteria::SetArg2().
  1087. --*/
  1088. {
  1089. HRESULT hr = S_OK;
  1090. try {
  1091. WsbAffirmHr(WsbWCStoFT(arg, &m_isRelative, &m_value2));
  1092. WsbAffirmHr(CHsmRelativeCriteria::SetArg2(arg));
  1093. } WsbCatch(hr);
  1094. return(hr);
  1095. }
  1096. HRESULT
  1097. CHsmCritAccessTime::ShouldDo(
  1098. IN IFsaScanItem* pScanItem,
  1099. IN USHORT /*scale*/
  1100. )
  1101. /*++
  1102. Implements:
  1103. IHsmCriteria::ShouldDo().
  1104. --*/
  1105. {
  1106. HRESULT hr = S_OK;
  1107. FILETIME time;
  1108. FILETIME value1 = m_value1;
  1109. FILETIME value2 = m_value2;
  1110. LONG timeCompare1;
  1111. LONG timeCompare2;
  1112. WsbTraceIn(OLESTR("CHsmCritAccessTime::ShouldDo"), OLESTR(""));
  1113. try {
  1114. WsbAssert(0 != pScanItem, E_POINTER);
  1115. WsbAssert(0 != m_arg1, E_INVALIDARG);
  1116. // Get the time.
  1117. WsbAffirmHr(pScanItem->GetAccessTime(&time));
  1118. // If this is a relative time (i.e. and age), then we need
  1119. // to know the present time before we can do the comparrison.
  1120. if (m_isRelative) {
  1121. FILETIME present;
  1122. WsbAffirmHr(CoFileTimeNow(&present));
  1123. value1 = WsbFtSubFt(present, m_value1);
  1124. value2 = WsbFtSubFt(present, m_value2);
  1125. }
  1126. // Compare the first arg.
  1127. timeCompare1 = CompareFileTime(&value1, &time);
  1128. // Now interpret the result based on the type of comparisson.
  1129. hr = S_FALSE;
  1130. switch (m_comparator) {
  1131. default:
  1132. case HSM_CRITERIACOMPARATOR_NOTSET:
  1133. hr = E_INVALIDARG;
  1134. break;
  1135. case HSM_CRITERIACOMPARATOR_LT:
  1136. if (timeCompare1 < 0) {
  1137. hr = S_OK;
  1138. }
  1139. break;
  1140. case HSM_CRITERIACOMPARATOR_LTE:
  1141. if (timeCompare1 <= 0) {
  1142. hr = S_OK;
  1143. }
  1144. break;
  1145. case HSM_CRITERIACOMPARATOR_EQL:
  1146. if (timeCompare1 == 0) {
  1147. hr = S_OK;
  1148. }
  1149. break;
  1150. case HSM_CRITERIACOMPARATOR_NEQL:
  1151. if (timeCompare1 != 0) {
  1152. hr = S_OK;
  1153. }
  1154. break;
  1155. case HSM_CRITERIACOMPARATOR_GTE:
  1156. if (timeCompare1 >= 0) {
  1157. hr = S_OK;
  1158. }
  1159. break;
  1160. case HSM_CRITERIACOMPARATOR_GT:
  1161. if (timeCompare1 > 0) {
  1162. hr = S_OK;
  1163. }
  1164. break;
  1165. case HSM_CRITERIACOMPARATOR_BETWEEN:
  1166. WsbAssert(0 != m_arg2, E_INVALIDARG);
  1167. timeCompare2 = CompareFileTime(&value2, &time);
  1168. if ((timeCompare1 >= 0) && (timeCompare2 <= 0)) {
  1169. hr = S_OK;
  1170. }
  1171. break;
  1172. case HSM_CRITERIACOMPARATOR_OUTSIDE:
  1173. WsbAssert(0 != m_arg2, E_INVALIDARG);
  1174. timeCompare2 = CompareFileTime(&value2, &time);
  1175. if ((timeCompare1 < 0) || (timeCompare2 > 0)) {
  1176. hr = S_OK;
  1177. }
  1178. break;
  1179. }
  1180. if (SUCCEEDED(hr) && m_isNegated) {
  1181. if (S_OK == hr) {
  1182. hr = S_FALSE;
  1183. } else {
  1184. hr = S_OK;
  1185. }
  1186. }
  1187. } WsbCatch(hr);
  1188. WsbTraceOut(OLESTR("CHsmCritAccessTime::ShouldDo"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  1189. return(hr);
  1190. }
  1191. HRESULT
  1192. CHsmCritAccessTime::Value(
  1193. IN IFsaScanItem* pScanItem,
  1194. OUT OLECHAR** pValue,
  1195. IN ULONG bufferSize
  1196. )
  1197. /*++
  1198. Implements:
  1199. IHsmCriteria::Value().
  1200. --*/
  1201. {
  1202. HRESULT hr = S_OK;
  1203. FILETIME time;
  1204. try {
  1205. WsbAssert(0 != pScanItem, E_POINTER);
  1206. WsbAssert(0 != pValue, E_POINTER);
  1207. WsbAffirmHr(pScanItem->GetAccessTime(&time));
  1208. // If this is a relative time (i.e. and age), then we need
  1209. // to know the present time before we can do the comparrison.
  1210. if (m_isRelative) {
  1211. FILETIME present;
  1212. WsbAffirmHr(CoFileTimeNow(&present));
  1213. time = WsbFtSubFt(present, time);
  1214. }
  1215. hr = WsbFTtoWCS(m_isRelative, time, pValue, bufferSize);
  1216. } WsbCatch(hr);
  1217. return(hr);
  1218. }
  1219. HRESULT
  1220. CHsmCritGroup::FinalConstruct(
  1221. void
  1222. )
  1223. /*++
  1224. Implements:
  1225. CComObjectRoot::FinalConstruct().
  1226. --*/
  1227. {
  1228. HRESULT hr = S_OK;
  1229. try {
  1230. WsbAffirmHr(CHsmRelativeCriteria::FinalConstruct());
  1231. m_nameId = IDS_HSMCRITGROUP_ID;
  1232. } WsbCatch(hr);
  1233. return(hr);
  1234. }
  1235. HRESULT
  1236. CHsmCritGroup::GetClassID(
  1237. OUT CLSID* pClsid
  1238. )
  1239. /*++
  1240. Implements:
  1241. IPersist::GetClassID().
  1242. --*/
  1243. {
  1244. HRESULT hr = S_OK;
  1245. WsbTraceIn(OLESTR("CHsmCritGroup::GetClassID"), OLESTR(""));
  1246. try {
  1247. WsbAssert(0 != pClsid, E_POINTER);
  1248. *pClsid = CLSID_CHsmCritGroup;
  1249. } WsbCatch(hr);
  1250. WsbTraceOut(OLESTR("CHsmCritGroup::GetClassID"), OLESTR("hr = <%ls>, CLSID = <%ls>"), WsbHrAsString(hr), WsbGuidAsString(*pClsid));
  1251. return(hr);
  1252. }
  1253. HRESULT
  1254. CHsmCritGroup::ShouldDo(
  1255. IN IFsaScanItem* pScanItem,
  1256. IN USHORT /*scale*/
  1257. )
  1258. /*++
  1259. Implements:
  1260. IHsmCriteria::ShouldDo().
  1261. --*/
  1262. {
  1263. HRESULT hr = S_OK;
  1264. OLECHAR* group = 0;
  1265. int stringCompare1;
  1266. int stringCompare2;
  1267. WsbTraceIn(OLESTR("CHsmCritGroup::ShouldDo"), OLESTR(""));
  1268. try {
  1269. // We at least need one argument to be able to do a comparisson.
  1270. WsbAssert(0 != m_arg1, E_INVALIDARG);
  1271. // Get the Group's name.
  1272. WsbAffirmHr(pScanItem->GetGroup(&group, 0));
  1273. hr = S_FALSE;
  1274. stringCompare1 = wcscmp(m_arg1, group);
  1275. switch (m_comparator) {
  1276. default:
  1277. case HSM_CRITERIACOMPARATOR_NOTSET:
  1278. hr = E_INVALIDARG;
  1279. break;
  1280. case HSM_CRITERIACOMPARATOR_LT:
  1281. if (stringCompare1 < 0) {
  1282. hr = S_OK;
  1283. }
  1284. break;
  1285. case HSM_CRITERIACOMPARATOR_LTE:
  1286. if (stringCompare1 <= 0) {
  1287. hr = S_OK;
  1288. }
  1289. break;
  1290. case HSM_CRITERIACOMPARATOR_EQL:
  1291. if (stringCompare1 == 0) {
  1292. hr = S_OK;
  1293. }
  1294. break;
  1295. case HSM_CRITERIACOMPARATOR_NEQL:
  1296. if (stringCompare1 != 0) {
  1297. hr = S_OK;
  1298. }
  1299. break;
  1300. case HSM_CRITERIACOMPARATOR_GTE:
  1301. if (stringCompare1 >= 0) {
  1302. hr = S_OK;
  1303. }
  1304. break;
  1305. case HSM_CRITERIACOMPARATOR_GT:
  1306. if (stringCompare1 > 0) {
  1307. hr = S_OK;
  1308. }
  1309. break;
  1310. case HSM_CRITERIACOMPARATOR_BETWEEN:
  1311. WsbAssert( 0 != m_arg2, E_INVALIDARG);
  1312. stringCompare2 = wcscmp(m_arg2, group);
  1313. if ((stringCompare1 >= 0) && (stringCompare2 <= 0)) {
  1314. hr = S_OK;
  1315. }
  1316. break;
  1317. case HSM_CRITERIACOMPARATOR_OUTSIDE:
  1318. WsbAssert( 0 != m_arg2, E_INVALIDARG);
  1319. stringCompare2 = wcscmp(m_arg2, group);
  1320. if ((stringCompare1 < 0) || (stringCompare2 > 0)) {
  1321. hr = S_OK;
  1322. }
  1323. break;
  1324. case HSM_CRITERIACOMPARATOR_MEMBEROF:
  1325. hr = pScanItem->IsGroupMemberOf(m_arg1);
  1326. break;
  1327. }
  1328. WsbFree(group);
  1329. if (SUCCEEDED(hr) && m_isNegated) {
  1330. if (S_OK == hr) {
  1331. hr = S_FALSE;
  1332. } else {
  1333. hr = S_OK;
  1334. }
  1335. }
  1336. } WsbCatch(hr);
  1337. WsbTraceOut(OLESTR("CHsmCritGroup::ShouldDo"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  1338. return(hr);
  1339. }
  1340. HRESULT
  1341. CHsmCritGroup::Value(
  1342. IN IFsaScanItem* pScanItem,
  1343. OUT OLECHAR** pValue,
  1344. IN ULONG bufferSize
  1345. )
  1346. /*++
  1347. Implements:
  1348. IHsmCriteria::Value().
  1349. --*/
  1350. {
  1351. HRESULT hr = S_OK;
  1352. try {
  1353. WsbAssert(0 != pScanItem, E_POINTER);
  1354. WsbAssert(0 != pValue, E_POINTER);
  1355. WsbAffirmHr(pScanItem->GetGroup(pValue, bufferSize));
  1356. } WsbCatch(hr);
  1357. return(hr);
  1358. }
  1359. HRESULT
  1360. CHsmCritLogicalSize::FinalConstruct(
  1361. void
  1362. )
  1363. /*++
  1364. Implements:
  1365. CComObjectRoot::FinalConstruct().
  1366. --*/
  1367. {
  1368. HRESULT hr = S_OK;
  1369. try {
  1370. WsbAffirmHr(CHsmRelativeCriteria::FinalConstruct());
  1371. m_nameId = IDS_HSMCRITLOGICALSIZE_ID;
  1372. } WsbCatch(hr);
  1373. return(hr);
  1374. }
  1375. HRESULT
  1376. CHsmCritLogicalSize::GetClassID(
  1377. OUT CLSID* pClsid
  1378. )
  1379. /*++
  1380. Implements:
  1381. IPersist::GetClassID().
  1382. --*/
  1383. {
  1384. HRESULT hr = S_OK;
  1385. WsbTraceIn(OLESTR("CHsmCritLogicalSize::GetClassID"), OLESTR(""));
  1386. try {
  1387. WsbAssert(0 != pClsid, E_POINTER);
  1388. *pClsid = CLSID_CHsmCritLogicalSize;
  1389. } WsbCatch(hr);
  1390. WsbTraceOut(OLESTR("CHsmCritLogicalSize::GetClassID"), OLESTR("hr = <%ls>, CLSID = <%ls>"), WsbHrAsString(hr), WsbGuidAsString(*pClsid));
  1391. return(hr);
  1392. }
  1393. HRESULT
  1394. CHsmCritLogicalSize::SetArg1(
  1395. IN OLECHAR* arg
  1396. )
  1397. /*++
  1398. Implements:
  1399. IHsmCriteria::SetArg2().
  1400. --*/
  1401. {
  1402. HRESULT hr = S_OK;
  1403. try {
  1404. WsbAffirmHr(WsbWCStoLL(arg, &m_value1));
  1405. WsbAffirmHr(CHsmRelativeCriteria::SetArg1(arg));
  1406. } WsbCatch(hr);
  1407. return(hr);
  1408. }
  1409. HRESULT
  1410. CHsmCritLogicalSize::SetArg2(
  1411. IN OLECHAR* arg
  1412. )
  1413. /*++
  1414. Implements:
  1415. IHsmCriteria::SetArg2().
  1416. --*/
  1417. {
  1418. HRESULT hr = S_OK;
  1419. try {
  1420. WsbAffirmHr(WsbWCStoLL(arg, &m_value2));
  1421. WsbAffirmHr(CHsmRelativeCriteria::SetArg2(arg));
  1422. } WsbCatch(hr);
  1423. return(hr);
  1424. }
  1425. HRESULT
  1426. CHsmCritLogicalSize::ShouldDo(
  1427. IN IFsaScanItem* pScanItem,
  1428. IN USHORT /*scale*/
  1429. )
  1430. /*++
  1431. Implements:
  1432. IHsmCriteria::ShouldDo().
  1433. --*/
  1434. {
  1435. HRESULT hr = S_OK;
  1436. LONGLONG size;
  1437. WsbTraceIn(OLESTR("CHsmCritLogicalSize::ShouldDo"), OLESTR(""));
  1438. try {
  1439. // We at least need one argument to be able to do a comparisson.
  1440. WsbAssert(0 != m_arg1, E_INVALIDARG);
  1441. // Get the size.
  1442. WsbAffirmHr(pScanItem->GetLogicalSize(&size));
  1443. // See how it compares.
  1444. hr = S_FALSE;
  1445. switch (m_comparator) {
  1446. default:
  1447. case HSM_CRITERIACOMPARATOR_NOTSET:
  1448. hr = E_INVALIDARG;
  1449. break;
  1450. case HSM_CRITERIACOMPARATOR_LT:
  1451. if (size < m_value1) {
  1452. hr = S_OK;
  1453. }
  1454. break;
  1455. case HSM_CRITERIACOMPARATOR_LTE:
  1456. if (size <= m_value1) {
  1457. hr = S_OK;
  1458. }
  1459. break;
  1460. case HSM_CRITERIACOMPARATOR_EQL:
  1461. if (size == m_value1) {
  1462. hr = S_OK;
  1463. }
  1464. break;
  1465. case HSM_CRITERIACOMPARATOR_NEQL:
  1466. if (size != m_value1) {
  1467. hr = S_OK;
  1468. }
  1469. break;
  1470. case HSM_CRITERIACOMPARATOR_GTE:
  1471. if (size >= m_value1) {
  1472. hr = S_OK;
  1473. }
  1474. break;
  1475. case HSM_CRITERIACOMPARATOR_GT:
  1476. if (size > m_value1) {
  1477. hr = S_OK;
  1478. }
  1479. break;
  1480. case HSM_CRITERIACOMPARATOR_BETWEEN:
  1481. WsbAssert(0 != m_arg2, E_INVALIDARG);
  1482. if ((m_value1 <= size) && (size <= m_value2)) {
  1483. hr = S_OK;
  1484. }
  1485. break;
  1486. case HSM_CRITERIACOMPARATOR_OUTSIDE:
  1487. WsbAssert(0 != m_arg2, E_INVALIDARG);
  1488. if ((size < m_value1) || (m_value2 > size)) {
  1489. hr = S_OK;
  1490. }
  1491. break;
  1492. }
  1493. if (SUCCEEDED(hr) && m_isNegated) {
  1494. if (S_OK == hr) {
  1495. hr = S_FALSE;
  1496. } else {
  1497. hr = S_OK;
  1498. }
  1499. }
  1500. } WsbCatch(hr);
  1501. WsbTraceOut(OLESTR("CHsmCritLogicalSize::ShouldDo"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  1502. return(hr);
  1503. }
  1504. HRESULT
  1505. CHsmCritLogicalSize::Value(
  1506. IN IFsaScanItem* pScanItem,
  1507. OUT OLECHAR** pValue,
  1508. IN ULONG bufferSize
  1509. )
  1510. /*++
  1511. Implements:
  1512. IHsmCriteria::Value().
  1513. --*/
  1514. {
  1515. HRESULT hr = S_OK;
  1516. LONGLONG size;
  1517. try {
  1518. WsbAssert(0 != pScanItem, E_POINTER);
  1519. WsbAssert(0 != pValue, E_POINTER);
  1520. WsbAffirmHr(pScanItem->GetLogicalSize(&size));
  1521. WsbAffirmHr(WsbLLtoWCS(size, pValue, bufferSize));
  1522. } WsbCatch(hr);
  1523. return(hr);
  1524. }
  1525. HRESULT
  1526. CHsmCritModifyTime::FinalConstruct(
  1527. void
  1528. )
  1529. /*++
  1530. Implements:
  1531. CComObjectRoot::FinalConstruct().
  1532. --*/
  1533. {
  1534. HRESULT hr = S_OK;
  1535. try {
  1536. WsbAffirmHr(CHsmRelativeCriteria::FinalConstruct());
  1537. m_nameId = IDS_HSMCRITMODIFYTIME_ID;
  1538. } WsbCatch(hr);
  1539. return(hr);
  1540. }
  1541. HRESULT
  1542. CHsmCritModifyTime::GetClassID(
  1543. OUT CLSID* pClsid
  1544. )
  1545. /*++
  1546. Implements:
  1547. IPersist::GetClassID().
  1548. --*/
  1549. {
  1550. HRESULT hr = S_OK;
  1551. WsbTraceIn(OLESTR("CHsmCritModifyTime::GetClassID"), OLESTR(""));
  1552. try {
  1553. WsbAssert(0 != pClsid, E_POINTER);
  1554. *pClsid = CLSID_CHsmCritModifyTime;
  1555. } WsbCatch(hr);
  1556. WsbTraceOut(OLESTR("CHsmCritModifyTime::GetClassID"), OLESTR("hr = <%ls>, CLSID = <%ls>"), WsbHrAsString(hr), WsbGuidAsString(*pClsid));
  1557. return(hr);
  1558. }
  1559. HRESULT
  1560. CHsmCritModifyTime::SetArg1(
  1561. IN OLECHAR* arg
  1562. )
  1563. /*++
  1564. Implements:
  1565. IHsmCriteria::SetArg1().
  1566. --*/
  1567. {
  1568. HRESULT hr = S_OK;
  1569. try {
  1570. WsbAffirmHr(WsbWCStoFT(arg, &m_isRelative, &m_value1));
  1571. WsbAffirmHr(CHsmRelativeCriteria::SetArg1(arg));
  1572. } WsbCatch(hr);
  1573. return(hr);
  1574. }
  1575. HRESULT
  1576. CHsmCritModifyTime::SetArg2(
  1577. IN OLECHAR* arg
  1578. )
  1579. /*++
  1580. Implements:
  1581. IHsmCriteria::SetArg2().
  1582. --*/
  1583. {
  1584. HRESULT hr = S_OK;
  1585. try {
  1586. WsbAffirmHr(WsbWCStoFT(arg, &m_isRelative, &m_value2));
  1587. WsbAffirmHr(CHsmRelativeCriteria::SetArg2(arg));
  1588. } WsbCatch(hr);
  1589. return(hr);
  1590. }
  1591. HRESULT
  1592. CHsmCritModifyTime::ShouldDo(
  1593. IN IFsaScanItem* pScanItem,
  1594. IN USHORT /*scale*/
  1595. )
  1596. /*++
  1597. Implements:
  1598. IHsmCriteria::ShouldDo().
  1599. --*/
  1600. {
  1601. HRESULT hr = S_OK;
  1602. FILETIME time;
  1603. FILETIME value1 = m_value1;
  1604. FILETIME value2 = m_value2;
  1605. LONG timeCompare1;
  1606. LONG timeCompare2;
  1607. WsbTraceIn(OLESTR("CHsmCritModifyTime::ShouldDo"), OLESTR(""));
  1608. try {
  1609. WsbAssert(0 != pScanItem, E_POINTER);
  1610. WsbAssert(0 != m_arg1, E_INVALIDARG);
  1611. // Get the time.
  1612. WsbAffirmHr(pScanItem->GetModifyTime(&time));
  1613. // If this is a relative time (i.e. and age), then we need
  1614. // to know the present time before we can do the comparrison.
  1615. if (m_isRelative) {
  1616. FILETIME present;
  1617. WsbAffirmHr(CoFileTimeNow(&present));
  1618. value1 = WsbFtSubFt(present, m_value1);
  1619. value2 = WsbFtSubFt(present, m_value2);
  1620. }
  1621. // Compare the first arg.
  1622. timeCompare1 = CompareFileTime(&value1, &time);
  1623. // Now interpret the result based on the type of comparisson.
  1624. hr = S_FALSE;
  1625. switch (m_comparator) {
  1626. default:
  1627. case HSM_CRITERIACOMPARATOR_NOTSET:
  1628. hr = E_INVALIDARG;
  1629. break;
  1630. case HSM_CRITERIACOMPARATOR_LT:
  1631. if (timeCompare1 < 0) {
  1632. hr = S_OK;
  1633. }
  1634. break;
  1635. case HSM_CRITERIACOMPARATOR_LTE:
  1636. if (timeCompare1 <= 0) {
  1637. hr = S_OK;
  1638. }
  1639. break;
  1640. case HSM_CRITERIACOMPARATOR_EQL:
  1641. if (timeCompare1 == 0) {
  1642. hr = S_OK;
  1643. }
  1644. break;
  1645. case HSM_CRITERIACOMPARATOR_NEQL:
  1646. if (timeCompare1 != 0) {
  1647. hr = S_OK;
  1648. }
  1649. break;
  1650. case HSM_CRITERIACOMPARATOR_GTE:
  1651. if (timeCompare1 >= 0) {
  1652. hr = S_OK;
  1653. }
  1654. break;
  1655. case HSM_CRITERIACOMPARATOR_GT:
  1656. if (timeCompare1 > 0) {
  1657. hr = S_OK;
  1658. }
  1659. break;
  1660. case HSM_CRITERIACOMPARATOR_BETWEEN:
  1661. WsbAssert(0 != m_arg2, E_INVALIDARG);
  1662. timeCompare2 = CompareFileTime(&value2, &time);
  1663. if ((timeCompare1 >= 0) && (timeCompare2 <= 0)) {
  1664. hr = S_OK;
  1665. }
  1666. break;
  1667. case HSM_CRITERIACOMPARATOR_OUTSIDE:
  1668. WsbAssert(0 != m_arg2, E_INVALIDARG);
  1669. timeCompare2 = CompareFileTime(&value2, &time);
  1670. if ((timeCompare1 < 0) || (timeCompare2 > 0)) {
  1671. hr = S_OK;
  1672. }
  1673. break;
  1674. }
  1675. if (SUCCEEDED(hr) && m_isNegated) {
  1676. if (S_OK == hr) {
  1677. hr = S_FALSE;
  1678. } else {
  1679. hr = S_OK;
  1680. }
  1681. }
  1682. } WsbCatch(hr);
  1683. WsbTraceOut(OLESTR("CHsmCritModifyTime::ShouldDo"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  1684. return(hr);
  1685. }
  1686. HRESULT
  1687. CHsmCritModifyTime::Value(
  1688. IN IFsaScanItem* pScanItem,
  1689. OUT OLECHAR** pValue,
  1690. IN ULONG bufferSize
  1691. )
  1692. /*++
  1693. Implements:
  1694. IHsmCriteria::Value().
  1695. --*/
  1696. {
  1697. HRESULT hr = S_OK;
  1698. FILETIME time;
  1699. try {
  1700. WsbAssert(0 != pScanItem, E_POINTER);
  1701. WsbAssert(0 != pValue, E_POINTER);
  1702. WsbAffirmHr(pScanItem->GetModifyTime(&time));
  1703. // If this is a relative time (i.e. and age), then we need
  1704. // to know the present time before we can do the comparrison.
  1705. if (m_isRelative) {
  1706. FILETIME present;
  1707. WsbAffirmHr(CoFileTimeNow(&present));
  1708. time = WsbFtSubFt(present, time);
  1709. }
  1710. hr = WsbFTtoWCS(m_isRelative, time, pValue, bufferSize);
  1711. } WsbCatch(hr);
  1712. return(hr);
  1713. }
  1714. HRESULT
  1715. CHsmCritOwner::FinalConstruct(
  1716. void
  1717. )
  1718. /*++
  1719. Implements:
  1720. CComObjectRoot::FinalConstruct().
  1721. --*/
  1722. {
  1723. HRESULT hr = S_OK;
  1724. try {
  1725. WsbAffirmHr(CHsmRelativeCriteria::FinalConstruct());
  1726. m_nameId = IDS_HSMCRITOWNER_ID;
  1727. } WsbCatch(hr);
  1728. return(hr);
  1729. }
  1730. HRESULT
  1731. CHsmCritOwner::GetClassID(
  1732. OUT CLSID* pClsid
  1733. )
  1734. /*++
  1735. Implements:
  1736. IPersist::GetClassID().
  1737. --*/
  1738. {
  1739. HRESULT hr = S_OK;
  1740. WsbTraceIn(OLESTR("CHsmCritOwner::GetClassID"), OLESTR(""));
  1741. try {
  1742. WsbAssert(0 != pClsid, E_POINTER);
  1743. *pClsid = CLSID_CHsmCritOwner;
  1744. } WsbCatch(hr);
  1745. WsbTraceOut(OLESTR("CHsmCritOwner::GetClassID"), OLESTR("hr = <%ls>, CLSID = <%ls>"), WsbHrAsString(hr), WsbGuidAsString(*pClsid));
  1746. return(hr);
  1747. }
  1748. HRESULT
  1749. CHsmCritOwner::ShouldDo(
  1750. IN IFsaScanItem* pScanItem,
  1751. IN USHORT /*scale*/
  1752. )
  1753. /*++
  1754. Implements:
  1755. IHsmCriteria::ShouldDo().
  1756. --*/
  1757. {
  1758. HRESULT hr = S_OK;
  1759. OLECHAR* owner = 0;
  1760. int stringCompare1;
  1761. int stringCompare2;
  1762. WsbTraceIn(OLESTR("CHsmCritOwner::ShouldDo"), OLESTR(""));
  1763. try {
  1764. // We at least need one argument to be able to do a comparisson.
  1765. WsbAssert(0 != m_arg1, E_INVALIDARG);
  1766. // Get the Group's name.
  1767. WsbAffirmHr(pScanItem->GetOwner(&owner, 0));
  1768. hr = S_FALSE;
  1769. stringCompare1 = wcscmp(m_arg1, owner);
  1770. switch (m_comparator) {
  1771. default:
  1772. case HSM_CRITERIACOMPARATOR_NOTSET:
  1773. hr = E_INVALIDARG;
  1774. break;
  1775. case HSM_CRITERIACOMPARATOR_LT:
  1776. if (stringCompare1 < 0) {
  1777. hr = S_OK;
  1778. }
  1779. break;
  1780. case HSM_CRITERIACOMPARATOR_LTE:
  1781. if (stringCompare1 <= 0) {
  1782. hr = S_OK;
  1783. }
  1784. break;
  1785. case HSM_CRITERIACOMPARATOR_EQL:
  1786. if (stringCompare1 == 0) {
  1787. hr = S_OK;
  1788. }
  1789. break;
  1790. case HSM_CRITERIACOMPARATOR_NEQL:
  1791. if (stringCompare1 != 0) {
  1792. hr = S_OK;
  1793. }
  1794. break;
  1795. case HSM_CRITERIACOMPARATOR_GTE:
  1796. if (stringCompare1 >= 0) {
  1797. hr = S_OK;
  1798. }
  1799. break;
  1800. case HSM_CRITERIACOMPARATOR_GT:
  1801. if (stringCompare1 > 0) {
  1802. hr = S_OK;
  1803. }
  1804. break;
  1805. case HSM_CRITERIACOMPARATOR_BETWEEN:
  1806. WsbAssert( 0 != m_arg2, E_INVALIDARG);
  1807. stringCompare2 = wcscmp(m_arg2, owner);
  1808. if ((stringCompare1 >= 0) && (stringCompare2 <= 0)) {
  1809. hr = S_OK;
  1810. }
  1811. break;
  1812. case HSM_CRITERIACOMPARATOR_OUTSIDE:
  1813. WsbAssert( 0 != m_arg2, E_INVALIDARG);
  1814. stringCompare2 = wcscmp(m_arg2, owner);
  1815. if ((stringCompare1 < 0) || (stringCompare2 > 0)) {
  1816. hr = S_OK;
  1817. }
  1818. break;
  1819. case HSM_CRITERIACOMPARATOR_MEMBEROF:
  1820. hr = pScanItem->IsOwnerMemberOf(m_arg1);
  1821. break;
  1822. }
  1823. WsbFree(owner);
  1824. if (SUCCEEDED(hr) && m_isNegated) {
  1825. if (S_OK == hr) {
  1826. hr = S_FALSE;
  1827. } else {
  1828. hr = S_OK;
  1829. }
  1830. }
  1831. } WsbCatch(hr);
  1832. WsbTraceOut(OLESTR("CHsmCritOwner::ShouldDo"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  1833. return(hr);
  1834. }
  1835. HRESULT
  1836. CHsmCritOwner::Value(
  1837. IN IFsaScanItem* pScanItem,
  1838. OUT OLECHAR** pValue,
  1839. IN ULONG bufferSize
  1840. )
  1841. /*++
  1842. Implements:
  1843. IHsmCriteria::Value().
  1844. --*/
  1845. {
  1846. HRESULT hr = S_OK;
  1847. try {
  1848. WsbAssert(0 != pScanItem, E_POINTER);
  1849. WsbAssert(0 != pValue, E_POINTER);
  1850. WsbAffirmHr(pScanItem->GetOwner(pValue, bufferSize));
  1851. } WsbCatch(hr);
  1852. return(hr);
  1853. }
  1854. HRESULT
  1855. CHsmCritPhysicalSize::FinalConstruct(
  1856. void
  1857. )
  1858. /*++
  1859. Implements:
  1860. CComObjectRoot::FinalConstruct().
  1861. --*/
  1862. {
  1863. HRESULT hr = S_OK;
  1864. try {
  1865. WsbAffirmHr(CHsmRelativeCriteria::FinalConstruct());
  1866. m_nameId = IDS_HSMCRITPHYSICALSIZE_ID;
  1867. } WsbCatch(hr);
  1868. return(hr);
  1869. }
  1870. HRESULT
  1871. CHsmCritPhysicalSize::GetClassID(
  1872. OUT CLSID* pClsid
  1873. )
  1874. /*++
  1875. Implements:
  1876. IPersist::GetClassID().
  1877. --*/
  1878. {
  1879. HRESULT hr = S_OK;
  1880. WsbTraceIn(OLESTR("CHsmCritPhysicalSize::GetClassID"), OLESTR(""));
  1881. try {
  1882. WsbAssert(0 != pClsid, E_POINTER);
  1883. *pClsid = CLSID_CHsmCritPhysicalSize;
  1884. } WsbCatch(hr);
  1885. WsbTraceOut(OLESTR("CHsmCritPhysicalSize::GetClassID"), OLESTR("hr = <%ls>, CLSID = <%ls>"), WsbHrAsString(hr), WsbGuidAsString(*pClsid));
  1886. return(hr);
  1887. }
  1888. HRESULT
  1889. CHsmCritPhysicalSize::SetArg1(
  1890. IN OLECHAR* arg
  1891. )
  1892. /*++
  1893. Implements:
  1894. IHsmCriteria::SetArg2().
  1895. --*/
  1896. {
  1897. HRESULT hr = S_OK;
  1898. try {
  1899. WsbAffirmHr(WsbWCStoLL(arg, &m_value1));
  1900. WsbAffirmHr(CHsmRelativeCriteria::SetArg1(arg));
  1901. } WsbCatch(hr);
  1902. return(hr);
  1903. }
  1904. HRESULT
  1905. CHsmCritPhysicalSize::SetArg2(
  1906. IN OLECHAR* arg
  1907. )
  1908. /*++
  1909. Implements:
  1910. IHsmCriteria::SetArg2().
  1911. --*/
  1912. {
  1913. HRESULT hr = S_OK;
  1914. try {
  1915. WsbAffirmHr(WsbWCStoLL(arg, &m_value2));
  1916. WsbAffirmHr(CHsmRelativeCriteria::SetArg2(arg));
  1917. } WsbCatch(hr);
  1918. return(hr);
  1919. }
  1920. HRESULT
  1921. CHsmCritPhysicalSize::ShouldDo(
  1922. IN IFsaScanItem* pScanItem,
  1923. IN USHORT /*scale*/
  1924. )
  1925. /*++
  1926. Implements:
  1927. IHsmCriteria::ShouldDo().
  1928. --*/
  1929. {
  1930. HRESULT hr = S_OK;
  1931. LONGLONG size;
  1932. WsbTraceIn(OLESTR("CHsmCritPhysicalSize::ShouldDo"), OLESTR(""));
  1933. try {
  1934. // We at least need one argument to be able to do a comparisson.
  1935. WsbAssert(0 != m_arg1, E_INVALIDARG);
  1936. // Get the size.
  1937. WsbAffirmHr(pScanItem->GetPhysicalSize(&size));
  1938. // See how it compares.
  1939. hr = S_FALSE;
  1940. switch (m_comparator) {
  1941. default:
  1942. case HSM_CRITERIACOMPARATOR_NOTSET:
  1943. hr = E_INVALIDARG;
  1944. break;
  1945. case HSM_CRITERIACOMPARATOR_LT:
  1946. if (size < m_value1) {
  1947. hr = S_OK;
  1948. }
  1949. break;
  1950. case HSM_CRITERIACOMPARATOR_LTE:
  1951. if (size <= m_value1) {
  1952. hr = S_OK;
  1953. }
  1954. break;
  1955. case HSM_CRITERIACOMPARATOR_EQL:
  1956. if (size == m_value1) {
  1957. hr = S_OK;
  1958. }
  1959. break;
  1960. case HSM_CRITERIACOMPARATOR_NEQL:
  1961. if (size != m_value1) {
  1962. hr = S_OK;
  1963. }
  1964. break;
  1965. case HSM_CRITERIACOMPARATOR_GTE:
  1966. if (size >= m_value1) {
  1967. hr = S_OK;
  1968. }
  1969. break;
  1970. case HSM_CRITERIACOMPARATOR_GT:
  1971. if (size > m_value1) {
  1972. hr = S_OK;
  1973. }
  1974. break;
  1975. case HSM_CRITERIACOMPARATOR_BETWEEN:
  1976. WsbAssert(0 != m_arg2, E_INVALIDARG);
  1977. if ((m_value1 <= size) && (size <= m_value2)) {
  1978. hr = S_OK;
  1979. }
  1980. break;
  1981. case HSM_CRITERIACOMPARATOR_OUTSIDE:
  1982. WsbAssert(0 != m_arg2, E_INVALIDARG);
  1983. if ((size < m_value1) || (m_value2 > size)) {
  1984. hr = S_OK;
  1985. }
  1986. break;
  1987. }
  1988. if (SUCCEEDED(hr) && m_isNegated) {
  1989. if (S_OK == hr) {
  1990. hr = S_FALSE;
  1991. } else {
  1992. hr = S_OK;
  1993. }
  1994. }
  1995. } WsbCatch(hr);
  1996. WsbTraceOut(OLESTR("CHsmCritPhysicalSize::ShouldDo"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  1997. return(hr);
  1998. }
  1999. HRESULT
  2000. CHsmCritPhysicalSize::Value(
  2001. IN IFsaScanItem* pScanItem,
  2002. OUT OLECHAR** pValue,
  2003. IN ULONG bufferSize
  2004. )
  2005. /*++
  2006. Implements:
  2007. IHsmCriteria::Value().
  2008. --*/
  2009. {
  2010. HRESULT hr = S_OK;
  2011. LONGLONG size;
  2012. try {
  2013. WsbAssert(0 != pScanItem, E_POINTER);
  2014. WsbAssert(0 != pValue, E_POINTER);
  2015. WsbAffirmHr(pScanItem->GetPhysicalSize(&size));
  2016. WsbAffirmHr(WsbLLtoWCS(size, pValue, bufferSize));
  2017. } WsbCatch(hr);
  2018. return(hr);
  2019. }