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.

1039 lines
30 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 2000.
  5. //
  6. // File: WrapStor.cxx
  7. //
  8. // Contents: Persistent property store (external to docfile)
  9. //
  10. // Classes: CPropertyStoreWrapper
  11. //
  12. // History: 17-Mar-97 KrishnaN Created
  13. //
  14. //----------------------------------------------------------------------------
  15. #include <pch.cxx>
  16. #pragma hdrstop
  17. #include "wrapstor.hxx"
  18. //+---------------------------------------------------------------------------
  19. //
  20. // Member: CPropertyStoreWrapper::CPropertyStoreWrapper, public
  21. //
  22. // Arguments: [pAdviseStatus] - lets the object advise caller of status.
  23. //
  24. // Returns: Nothing
  25. //
  26. // History: 17-Mar-97 KrishnaN Created.
  27. // 01-Nov-98 KLam Added cbDiskSpaceToLeave to constructor
  28. // Pass cbDiskSpaceToLeave to CPropStoreManager
  29. //
  30. //----------------------------------------------------------------------------
  31. CPropertyStoreWrapper::CPropertyStoreWrapper ( ICiCAdviseStatus *pAdviseStatus,
  32. ULONG ulMaxPropStoreMappedCachePrimary,
  33. ULONG ulMaxPropStoreMappedCacheSecondary,
  34. ULONG cbDiskSpaceToLeave ) :
  35. _lRefCount ( 1 ),
  36. _pStorage(0),
  37. {
  38. pAdviseStatus->AddRef(); // Hold on to it and release it at destruct time
  39. _xAdviseStatus.Set(pAdviseStatus);
  40. _pPropStoreMgr = new CPropStoreManager ( cbDiskSpaceToLeave );
  41. _pPropStoreMgr->SetMappedCacheSize(ulMaxPropStoreMappedCachePrimary, PRIMARY_STORE);
  42. _pPropStoreMgr->SetMappedCacheSize(ulMaxPropStoreMappedCacheSecondary, SECONDARY_STORE);
  43. }
  44. //+---------------------------------------------------------------------------
  45. //
  46. // Member: CPropertyStoreWrapper::~CPropertyStoreWrapper, private
  47. //
  48. // Arguments: None
  49. //
  50. // Returns: Nothing
  51. //
  52. // History: 17-Mar-97 KrishnaN Created.
  53. //
  54. //----------------------------------------------------------------------------
  55. CPropertyStoreWrapper::~CPropertyStoreWrapper ()
  56. {
  57. delete _pPropStoreMgr;
  58. delete _pStorage;
  59. }
  60. //+---------------------------------------------------------------------------
  61. //
  62. // Member: CPropertyStoreWrapper::IsDirty, public
  63. //
  64. // Arguments: [pid] -- Propid to check.
  65. //
  66. // Returns: TRUE if [pid] can exist in property store (e.g. has been
  67. // registered).
  68. //
  69. // History: 17-Mar-97 KrishnaN Created.
  70. //
  71. //----------------------------------------------------------------------------
  72. inline SCODE CPropertyStoreWrapper::IsDirty(BOOL &fIsDirty) const
  73. {
  74. fIsDirty = _pPropStoreMgr->IsDirty();
  75. return S_OK;
  76. }
  77. //+---------------------------------------------------------------------------
  78. //
  79. // Member: CPropertyStoreWrapper::CanStore, public
  80. //
  81. // Arguments: [pid] -- Propid to check.
  82. //
  83. // Returns: TRUE if [pid] can exist in property store (e.g. has been
  84. // registered).
  85. //
  86. // History: 17-Mar-97 KrishnaN Created.
  87. //
  88. //----------------------------------------------------------------------------
  89. inline SCODE CPropertyStoreWrapper::CanStore( PROPID pid, BOOL &fCanStore )
  90. {
  91. fCanStore = _pPropStoreMgr->CanStore( pid );
  92. return S_OK;
  93. }
  94. //+---------------------------------------------------------------------------
  95. //
  96. // Member: CPropertyStoreWrapper::Size, public
  97. //
  98. // Arguments: [pid] -- Propid whose size is queried.
  99. // [pusSize] -- Returns size, or 0 if it isn't in store.
  100. //
  101. // Returns: S_OK to indicate call succeeded.
  102. //
  103. // History: 17-Mar-97 KrishnaN Created.
  104. //
  105. //----------------------------------------------------------------------------
  106. inline SCODE CPropertyStoreWrapper::Size( PROPID pid, unsigned * pusSize )
  107. {
  108. *pusSize = _pPropStoreMgr->Size( pid );
  109. return S_OK;
  110. }
  111. //+---------------------------------------------------------------------------
  112. //
  113. // Member: CPropertyStoreWrapper::Type, public
  114. //
  115. // Arguments: [pid] -- Propid to check.
  116. // [pulType] -- Type of property, or VT_EMPTY if it isn't in store
  117. //
  118. // Returns: S_OK to indicate call succeeded.
  119. //
  120. // History: 17-Mar-97 KrishnaN Created.
  121. //
  122. //----------------------------------------------------------------------------
  123. inline SCODE CPropertyStoreWrapper::Type( PROPID pid, PULONG pulType )
  124. {
  125. *pulType = _pPropStoreMgr->Type( pid );
  126. return S_OK;
  127. }
  128. //+---------------------------------------------------------------------------
  129. //
  130. // Member: CPropertyStoreWrapper::WritePropertyInNewRecord, public
  131. //
  132. // Synopsis: Like WriteProperty, but also allocates record.
  133. //
  134. // Arguments: [pid] -- Propid to write.
  135. // [var] -- Property value
  136. // [pwid] - Workid of new record
  137. //
  138. // Returns: Success or Failure SCODE.
  139. //
  140. // History: 17-Mar-97 KrishnaN Created.
  141. //
  142. //----------------------------------------------------------------------------
  143. inline SCODE CPropertyStoreWrapper::WritePropertyInNewRecord( PROPID pid,
  144. CStorageVariant const & var,
  145. WORKID *pwid)
  146. {
  147. SCODE sc = S_OK;
  148. TRY
  149. {
  150. *pwid = _pPropStoreMgr->WritePropertyInNewRecord( pid, var );
  151. }
  152. CATCH ( CException, e )
  153. {
  154. sc = e.GetErrorCode();
  155. ciDebugOut((DEB_ERROR, "CPropertyStoreWrapper::WritePropertyInNewRecord caught exception 0x%X\n", sc));
  156. }
  157. END_CATCH
  158. return sc;
  159. }
  160. //+---------------------------------------------------------------------------
  161. //
  162. // Member: CPropertyStoreWrapper::CountRecordsInUse, public
  163. //
  164. // Returns: Count of 'top level' records (correspond to user wids)
  165. //
  166. // History: 17-Mar-97 KrishnaN Created.
  167. //
  168. //----------------------------------------------------------------------------
  169. inline SCODE CPropertyStoreWrapper::CountRecordsInUse(ULONG &ulRecInUse) const
  170. {
  171. ulRecInUse = _pPropStoreMgr->CountRecordsInUse();
  172. return S_OK;
  173. }
  174. //+---------------------------------------------------------------------------
  175. //
  176. // Member: CPropertyStoreWrapper::MaxWorkId, public
  177. //
  178. // Returns: Maximum workid which has been allocated.
  179. //
  180. // History: 17-Mar-97 KrishnaN Created.
  181. //
  182. //----------------------------------------------------------------------------
  183. inline SCODE CPropertyStoreWrapper::MaxWorkId(WORKID &wid)
  184. {
  185. wid = _pPropStoreMgr->MaxWorkId();
  186. return S_OK;
  187. }
  188. //+---------------------------------------------------------------------------
  189. //
  190. // Member: CPropertyStoreWrapper::FastInit, public
  191. //
  192. // Arguments: [pwszDirectory] -- Location of the property store
  193. //
  194. // Returns: Success or Failure SCODE.
  195. //
  196. // History: 17-Mar-97 KrishnaN Created.
  197. //
  198. //----------------------------------------------------------------------------
  199. SCODE CPropertyStoreWrapper::FastInit( WCHAR const * pwszDirectory )
  200. {
  201. SCODE sc = S_OK;
  202. TRY
  203. {
  204. Win4Assert (0 == _pStorage);
  205. XPtr<CiStorage> xStorage(new CiStorage( pwszDirectory, _xAdviseStatus.GetReference(),
  206. FSCI_VERSION_STAMP));
  207. _pPropStoreMgr->FastInit( xStorage.GetPointer() );
  208. _pStorage = xStorage.Acquire();
  209. }
  210. CATCH( CException, e )
  211. {
  212. sc = e.GetErrorCode();
  213. ciDebugOut((DEB_ERROR, "CPropertyStoreWrapper::FastInit caught exception 0x%X\n", sc));
  214. }
  215. END_CATCH
  216. return sc;
  217. }
  218. //+---------------------------------------------------------------------------
  219. //
  220. // Member: CPropertyStoreWrapper::LongInit, public
  221. //
  222. // Arguments: [fWasDirty] -- Is set to TRUE/FALSE to indiciate file corrpution
  223. // [cInconsistencies] -- Set to number of corruptions detected
  224. //
  225. // Returns: Succcess of Failure SCODE.
  226. //
  227. // History: 17-Mar-97 KrishnaN Created.
  228. //
  229. //----------------------------------------------------------------------------
  230. SCODE CPropertyStoreWrapper::LongInit( BOOL & fWasDirty,
  231. ULONG & cInconsistencies,
  232. T_UpdateDoc pfnUpdateCallback,
  233. void const *pUserData)
  234. {
  235. SCODE sc = S_OK;
  236. TRY
  237. {
  238. _pPropStoreMgr->LongInit( fWasDirty, cInconsistencies, pfnUpdateCallback, pUserData );
  239. }
  240. CATCH( CException, e )
  241. {
  242. sc = e.GetErrorCode();
  243. ciDebugOut((DEB_ERROR, "CPropertyStoreWrapper::LongInit caught exception 0x%X\n", sc));
  244. }
  245. END_CATCH
  246. return sc;
  247. }
  248. //+---------------------------------------------------------------------------
  249. //
  250. // Member: CPropertyStoreWrapper::Empty, public
  251. //
  252. // Returns: Success or Failure SCODE.
  253. //
  254. // History: 17-Mar-97 KrishnaN Created.
  255. //
  256. //----------------------------------------------------------------------------
  257. SCODE CPropertyStoreWrapper::Empty()
  258. {
  259. SCODE sc = S_OK;
  260. TRY
  261. {
  262. _pPropStoreMgr->Empty();
  263. }
  264. CATCH( CException, e )
  265. {
  266. sc = e.GetErrorCode();
  267. ciDebugOut((DEB_ERROR, "CPropertyStoreWrapper::Empty caught exception 0x%X\n", sc));
  268. }
  269. END_CATCH
  270. return sc;
  271. }
  272. //+---------------------------------------------------------------------------
  273. //
  274. // Member: CPropertyStoreWrapper::BeginTransaction, public
  275. //
  276. // Arguments: [pulReturn] -- Returns the transaction code.
  277. //
  278. // Returns: Success or Failure SCODE.
  279. //
  280. // History: 17-Mar-97 KrishnaN Created.
  281. //
  282. //----------------------------------------------------------------------------
  283. SCODE CPropertyStoreWrapper::BeginTransaction( PULONG_PTR pulReturn)
  284. {
  285. SCODE sc = S_OK;
  286. TRY
  287. {
  288. *pulReturn = _pPropStoreMgr->BeginTransaction();
  289. }
  290. CATCH( CException, e )
  291. {
  292. sc = e.GetErrorCode();
  293. ciDebugOut((DEB_ERROR, "CPropertyStoreWrapper::BeginTransaction caught exception 0x%X\n", sc));
  294. }
  295. END_CATCH
  296. return sc;
  297. }
  298. //+---------------------------------------------------------------------------
  299. //
  300. // Member: CPropertyStoreWrapper::Setup, public
  301. //
  302. // Arguments: [pid] -- Propid
  303. // [vt] -- Datatype of property. VT_VARIANT if unknown.
  304. // [cbMaxLen] -- Soft-maximum length for variable length
  305. // properties. This much space is pre-allocated
  306. // in original record.
  307. // [ulToken] -- Token of transaction
  308. //
  309. // Returns: Success or failure code.
  310. //
  311. // History: 17-Mar-97 KrishnaN Created.
  312. //
  313. //----------------------------------------------------------------------------
  314. SCODE CPropertyStoreWrapper::Setup( PROPID pid, ULONG vt, DWORD cbMaxLen,
  315. ULONG_PTR ulToken, BOOL fCanBeModified,
  316. ULONG dwStoreLevel )
  317. {
  318. SCODE sc = S_OK;
  319. TRY
  320. {
  321. _pPropStoreMgr->Setup ( pid, vt, cbMaxLen, ulToken );
  322. }
  323. CATCH( CException, e )
  324. {
  325. sc = e.GetErrorCode();
  326. ciDebugOut((DEB_ERROR, "CPropertyStoreWrapper::Setup caught exception 0x%X\n", sc));
  327. }
  328. END_CATCH
  329. return sc;
  330. }
  331. //+---------------------------------------------------------------------------
  332. //
  333. // Member: CPropertyStoreWrapper::EndTransaction, public
  334. //
  335. // Arguments: [ulToken] -- Token of transaction
  336. // [fCommit] -- TRUE --> Commit transaction
  337. // [pidFixedPrimary] -- Every workid with this pid will move to the
  338. // same workid in the new property cache.
  339. // [pidFixedSecondary] -- Every workid with this pid will move to the
  340. // same workid in the new property cache.
  341. //
  342. // Returns: Success or failure code.
  343. //
  344. // History: 17-Mar-97 KrishnaN Created.
  345. //
  346. //----------------------------------------------------------------------------
  347. SCODE CPropertyStoreWrapper::EndTransaction(ULONG_PTR ulToken, BOOL fCommit,
  348. PROPID pidFixedPrimary,
  349. PROPID pidFixedSecondary )
  350. {
  351. SCODE sc = S_OK;
  352. TRY
  353. {
  354. _pPropStoreMgr->EndTransaction ( ulToken, fCommit,
  355. pidFixedPrimary, pidFixedSecondary );
  356. }
  357. CATCH( CException, e )
  358. {
  359. sc = e.GetErrorCode();
  360. ciDebugOut((DEB_ERROR, "CPropertyStoreWrapper::EndTransaction caught exception 0x%X\n", sc));
  361. }
  362. END_CATCH
  363. return sc;
  364. }
  365. //+---------------------------------------------------------------------------
  366. //
  367. // Member: CPropertyStoreWrapper::WriteProperty, public
  368. //
  369. // Arguments: [wid] -- Workid
  370. // [pid] -- Propid
  371. // [var] -- Value
  372. //
  373. // Returns: Success or failure.
  374. //
  375. // History: 17-Mar-97 KrishnaN Created.
  376. //
  377. //----------------------------------------------------------------------------
  378. SCODE CPropertyStoreWrapper::WriteProperty(WORKID wid, PROPID pid,
  379. CStorageVariant const & var,
  380. BOOL &fExists)
  381. {
  382. SCODE sc = _pPropStoreMgr->WriteProperty ( wid, pid, var );
  383. fExists = (S_OK == sc);
  384. return sc;
  385. }
  386. //+---------------------------------------------------------------------------
  387. //
  388. // Member: CPropertyStoreWrapper::ReadProperty, public
  389. //
  390. // Arguments: [wid] -- Workid
  391. // [pid] -- Propid
  392. // [pbData] -- Place to return the value
  393. // [pcb] -- On input, the maximum number of bytes to
  394. // write at pbData. On output, the number of
  395. // bytes written if the call was successful,
  396. // else the number of bytes required.
  397. //
  398. // Returns: Success or failure.
  399. //
  400. // History: 17-Mar-97 KrishnaN Created.
  401. //
  402. //----------------------------------------------------------------------------
  403. SCODE CPropertyStoreWrapper::ReadProperty( WORKID wid, PROPID pid,
  404. PROPVARIANT * pbData, unsigned * pcb,
  405. BOOL &fExists)
  406. {
  407. SCODE sc = S_OK;
  408. TRY
  409. {
  410. fExists = _pPropStoreMgr->ReadProperty ( wid, pid, pbData, pcb );
  411. }
  412. CATCH( CException, e )
  413. {
  414. sc = e.GetErrorCode();
  415. ciDebugOut((DEB_ERROR, "CPropertyStoreWrapper::ReadProperty caught exception 0x%X\n", sc));
  416. fExists = FALSE;
  417. }
  418. END_CATCH
  419. return sc;
  420. }
  421. //+---------------------------------------------------------------------------
  422. //
  423. // Member: CPropertyStoreWrapper::ReadProperty, public
  424. //
  425. // Arguments: [wid] -- Workid
  426. // [pid] -- Propid
  427. // [var] -- Property to read into
  428. // [pbExtra] -- Place to store additional pointer(s).
  429. // [pcbExtra] -- On input, the maximum number of bytes to
  430. // write at pbExtra. On output, the number of
  431. // bytes written if the call was successful,
  432. // else the number of bytes required.
  433. // [fExists] -- Indicates if the property exists or not.
  434. //
  435. // Returns: Success code
  436. //
  437. // History: 17-Mar-97 KrishnaN Created.
  438. //
  439. //----------------------------------------------------------------------------
  440. SCODE CPropertyStoreWrapper::ReadProperty( WORKID wid, PROPID pid,
  441. PROPVARIANT & var, BYTE * pbExtra,
  442. unsigned * pcbExtra, BOOL &fExists )
  443. {
  444. SCODE sc = S_OK;
  445. TRY
  446. {
  447. fExists = _pPropStoreMgr->ReadProperty ( wid, pid, var, pbExtra, pcbExtra );
  448. }
  449. CATCH( CException, e )
  450. {
  451. sc = e.GetErrorCode();
  452. ciDebugOut((DEB_ERROR, "CPropertyStoreWrapper::ReadProperty caught exception 0x%X\n", sc));
  453. fExists = FALSE;
  454. }
  455. END_CATCH
  456. return sc;
  457. }
  458. //+---------------------------------------------------------------------------
  459. //
  460. // Member: CPropertyStoreWrapper::ReadProperty, public
  461. //
  462. // Arguments: [wid] -- Workid
  463. // [pid] -- Propid
  464. // [var] -- Variant written here
  465. // [pbExtra] -- Place to store additional pointer(s).
  466. // [pcbExtra] -- On input, the maximum number of bytes to
  467. // write at pbExtra. On output, the number of
  468. // bytes written if the call was successful,
  469. // else the number of bytes required.
  470. //
  471. // Returns:
  472. //
  473. // History: 17-Mar-97 KrishnaN Created.
  474. //
  475. //----------------------------------------------------------------------------
  476. SCODE CPropertyStoreWrapper::ReadProperty( HPropRecord hPropRecord, PROPID pid,
  477. PROPVARIANT & var, BYTE * pbExtra,
  478. unsigned * pcbExtra, BOOL &fExists )
  479. {
  480. SCODE sc = S_OK;
  481. TRY
  482. {
  483. fExists = _pPropStoreMgr->ReadProperty ( *((CCompositePropRecord *)hPropRecord),
  484. pid, var, pbExtra, pcbExtra );
  485. }
  486. CATCH( CException, e )
  487. {
  488. sc = e.GetErrorCode();
  489. ciDebugOut((DEB_ERROR, "CPropertyStoreWrapper::ReadProperty caught exception 0x%X\n", sc));
  490. fExists = FALSE;
  491. }
  492. END_CATCH
  493. return sc;
  494. }
  495. //+---------------------------------------------------------------------------
  496. //
  497. // Member: CPropertyStoreWrapper::ReadProperty, public
  498. //
  499. // Arguments: [PropRec] -- Pre-opened property record
  500. // [pid] -- Propid
  501. // [pbData] -- Place to return the value
  502. // [pcb] -- On input, the maximum number of bytes to
  503. // write at pbData. On output, the number of
  504. // bytes written if the call was successful,
  505. // else the number of bytes required.
  506. // Returns: Success or failure.
  507. //
  508. // History: 17-Mar-97 KrishnaN Created.
  509. //
  510. //----------------------------------------------------------------------------
  511. SCODE CPropertyStoreWrapper::ReadProperty( HPropRecord hPropRecord, PROPID pid,
  512. PROPVARIANT * pbData, unsigned * pcb,
  513. BOOL &fExists)
  514. {
  515. SCODE sc = S_OK;
  516. TRY
  517. {
  518. fExists = _pPropStoreMgr->ReadProperty ( *((CCompositePropRecord *)hPropRecord), pid, pbData, pcb );
  519. }
  520. CATCH( CException, e )
  521. {
  522. sc = e.GetErrorCode();
  523. ciDebugOut((DEB_ERROR, "CPropertyStoreWrapper::ReadProperty caught exception 0x%X\n", sc));
  524. fExists = FALSE;
  525. }
  526. END_CATCH
  527. return sc;
  528. }
  529. //+---------------------------------------------------------------------------
  530. //
  531. // Member: CPropertyStoreWrapper::ReadProperty, public
  532. //
  533. // Arguments: [wid] -- Workid
  534. // [pid] -- Propid
  535. // [var] -- Place to return the value
  536. //
  537. // Returns: Success or failure.
  538. //
  539. // History: 17-Mar-97 KrishnaN Created.
  540. //
  541. //----------------------------------------------------------------------------
  542. SCODE CPropertyStoreWrapper::ReadProperty( WORKID wid, PROPID pid, PROPVARIANT & var,
  543. BOOL &fExists)
  544. {
  545. SCODE sc = S_OK;
  546. TRY
  547. {
  548. fExists = _pPropStoreMgr->ReadProperty ( wid, pid, var );
  549. }
  550. CATCH( CException, e )
  551. {
  552. sc = e.GetErrorCode();
  553. ciDebugOut((DEB_ERROR, "CPropertyStoreWrapper::ReadPropertyInNewRecord caught exception 0x%X\n", sc));
  554. fExists = FALSE;
  555. }
  556. END_CATCH
  557. return sc;
  558. }
  559. //+---------------------------------------------------------------------------
  560. //
  561. // Member: CPropertyStoreWrapper::OpenRecord, public
  562. //
  563. // Arguments: [wid] -- record to open
  564. // [pb] -- Storage for record
  565. //
  566. // Returns: Property record
  567. //
  568. // History: 17-Mar-97 KrishnaN Created.
  569. //
  570. //----------------------------------------------------------------------------
  571. SCODE CPropertyStoreWrapper::OpenRecord( WORKID wid, BYTE * pb, HPropRecord &hRec)
  572. {
  573. SCODE sc = S_OK;
  574. TRY
  575. {
  576. hRec = (HPropRecord) _pPropStoreMgr->OpenRecord ( wid, pb );
  577. }
  578. CATCH( CException, e )
  579. {
  580. sc = e.GetErrorCode();
  581. ciDebugOut((DEB_ERROR, "CPropertyStoreWrapper::OpenRecord caught exception 0x%X\n", sc));
  582. hRec = 0;
  583. }
  584. END_CATCH
  585. return sc;
  586. }
  587. //+---------------------------------------------------------------------------
  588. //
  589. // Member: CPropertyStoreWrapper::CloseRecord, public
  590. //
  591. // Arguments: [hRec] -- Property record handle
  592. //
  593. // Returns:
  594. //
  595. // History: 17-Mar-97 KrishnaN Created.
  596. //
  597. //----------------------------------------------------------------------------
  598. SCODE CPropertyStoreWrapper::CloseRecord( HPropRecord hRec )
  599. {
  600. SCODE sc = S_OK;
  601. TRY
  602. {
  603. _pPropStoreMgr->CloseRecord ( (CCompositePropRecord *)hRec );
  604. }
  605. CATCH( CException, e )
  606. {
  607. sc = e.GetErrorCode();
  608. ciDebugOut((DEB_ERROR, "CPropertyStoreWrapper::CloseRecord caught exception 0x%X\n", sc));
  609. }
  610. END_CATCH
  611. return sc;
  612. }
  613. //+---------------------------------------------------------------------------
  614. //
  615. // Member: CPropertyStoreWrapper::DeleteRecord, public
  616. //
  617. // Arguments: [wid] -- Workid
  618. //
  619. // Returns:
  620. //
  621. // History: 17-Mar-97 KrishnaN Created.
  622. //
  623. //----------------------------------------------------------------------------
  624. SCODE CPropertyStoreWrapper::DeleteRecord( WORKID wid )
  625. {
  626. SCODE sc = S_OK;
  627. TRY
  628. {
  629. _pPropStoreMgr->DeleteRecord ( wid );
  630. }
  631. CATCH( CException, e )
  632. {
  633. sc = e.GetErrorCode();
  634. ciDebugOut((DEB_ERROR, "CPropertyStoreWrapper::DeleteRecord caught exception 0x%X\n", sc));
  635. }
  636. END_CATCH
  637. return sc;
  638. }
  639. //+---------------------------------------------------------------------------
  640. //
  641. // Member: CPropertyStoreWrapper::Shutdown, public
  642. //
  643. // Returns: Success or failure SCODE.
  644. //
  645. // History: 17-Mar-97 KrishnaN Created.
  646. //
  647. //----------------------------------------------------------------------------
  648. SCODE CPropertyStoreWrapper::Shutdown()
  649. {
  650. SCODE sc = S_OK;
  651. TRY
  652. {
  653. _pPropStoreMgr->Shutdown ( );
  654. }
  655. CATCH( CException, e )
  656. {
  657. sc = e.GetErrorCode();
  658. ciDebugOut((DEB_ERROR, "CPropertyStoreWrapper::Shutdown caught exception 0x%X\n", sc));
  659. }
  660. END_CATCH
  661. return sc;
  662. }
  663. //+---------------------------------------------------------------------------
  664. //
  665. // Member: CPropertyStoreWrapper::Flush, public
  666. //
  667. // Returns: Success or failure SCODE.
  668. //
  669. // History: 17-Mar-97 KrishnaN Created.
  670. //
  671. //----------------------------------------------------------------------------
  672. SCODE CPropertyStoreWrapper::Flush()
  673. {
  674. SCODE sc = S_OK;
  675. TRY
  676. {
  677. _pPropStoreMgr->Flush ( );
  678. }
  679. CATCH( CException, e )
  680. {
  681. sc = e.GetErrorCode();
  682. ciDebugOut((DEB_ERROR, "CPropertyStoreWrapper::Flush caught exception 0x%X\n", sc));
  683. }
  684. END_CATCH
  685. return sc;
  686. }
  687. //+---------------------------------------------------------------------------
  688. //
  689. // Member: CPropertyStoreWrapper::Save, public
  690. //
  691. // Arguments: [pwszDirectory] - Dir to save to.
  692. // [pProgressNotify]- Progress indication
  693. // [dstStorage] - Destination storage to use
  694. // [pEnumWorkids] - List of workids to copy. If null, all the
  695. // workids are copied.
  696. // [pfAbort] - Caller initiated abort flag
  697. // [ppFileList] - List of propstore files copied.
  698. //
  699. // Returns: Success or failure SCODE.
  700. //
  701. // History: 17-Mar-97 KrishnaN Created.
  702. //
  703. //----------------------------------------------------------------------------
  704. SCODE CPropertyStoreWrapper::Save( WCHAR const * pwszDirectory,
  705. IProgressNotify * pProgressNotify,
  706. ICiEnumWorkids * pEnumWorkids,
  707. BOOL * pfAbort,
  708. IEnumString ** ppFileList )
  709. {
  710. SCODE sc = S_OK;
  711. TRY
  712. {
  713. Win4Assert( pfAbort );
  714. XPtr<CiStorage> xStorage(new CiStorage( pwszDirectory, _xAdviseStatus.GetReference(),
  715. FSCI_VERSION_STAMP));
  716. _pPropStoreMgr->MakeBackupCopy ( pProgressNotify,
  717. *pfAbort,
  718. xStorage.GetReference(),
  719. pEnumWorkids,
  720. ppFileList);
  721. }
  722. CATCH( CException, e )
  723. {
  724. sc = e.GetErrorCode();
  725. ciDebugOut((DEB_ERROR, "CPropertyStoreWrapper::Save caught exception 0x%X\n", sc));
  726. }
  727. END_CATCH
  728. return sc;
  729. }
  730. //+---------------------------------------------------------------------------
  731. //
  732. // Member: CPropertyStoreWrapper::Load, public
  733. //
  734. // Synopsis: Copies/moves the list of files to the destination directory.
  735. //
  736. // Arguments: [pwszDestDir] -- Dir to move/copy files to
  737. // [pFileList] -- List of files to move/copy
  738. // [pProgressNotify] -- Progress notification
  739. // [fCallerOwnsFiles]-- Move if False, Copy if True
  740. // [pfAbort] -- Use to cause abort
  741. //
  742. // Returns: Success or failure SCODE.
  743. //
  744. // History: 17-Mar-97 KrishnaN Created.
  745. //
  746. //----------------------------------------------------------------------------
  747. SCODE CPropertyStoreWrapper::Load( WCHAR const * pwszDestDir,
  748. IEnumString * pFileList,
  749. IProgressNotify * pProgressNotify,
  750. BOOL fCallerOwnsFiles,
  751. BOOL * pfAbort )
  752. {
  753. SCODE sc = S_OK;
  754. TRY
  755. {
  756. _pPropStoreMgr->Load( pwszDestDir,
  757. _xAdviseStatus.GetPointer(),
  758. pFileList,
  759. pProgressNotify,
  760. fCallerOwnsFiles,
  761. pfAbort );
  762. }
  763. CATCH( CException, e )
  764. {
  765. sc = e.GetErrorCode();
  766. ciDebugOut((DEB_ERROR, "CPropertyStoreWrapper::Load caught exception 0x%X\n", sc));
  767. }
  768. END_CATCH
  769. return sc;
  770. }
  771. //+---------------------------------------------------------------------------
  772. //
  773. // Member: CPropertyStoreWrapper::SetParameter, public
  774. //
  775. // Returns:
  776. //
  777. // History: 23-Sep-97 KrishnaN Created.
  778. //
  779. //----------------------------------------------------------------------------
  780. HRESULT CPropertyStoreWrapper::SetParameter(VARIANT var, DWORD eParamType)
  781. {
  782. switch (eParamType)
  783. {
  784. case PSPARAM_PRIMARY_MAPPEDCACHESIZE:
  785. _pPropStoreMgr->SetMappedCacheSize(var.ulVal, PRIMARY_STORE);
  786. return S_OK;
  787. case PSPARAM_PRIMARY_BACKUPSIZE:
  788. _pPropStoreMgr->SetBackupSize(var.ulVal, PRIMARY_STORE);
  789. return S_OK;
  790. case PSPARAM_SECONDARY_MAPPEDCACHESIZE:
  791. _pPropStoreMgr->SetMappedCacheSize(var.ulVal, SECONDARY_STORE);
  792. return S_OK;
  793. case PSPARAM_SECONDARY_BACKUPSIZE:
  794. _pPropStoreMgr->SetBackupSize(var.ulVal, SECONDARY_STORE);
  795. return S_OK;
  796. default:
  797. Win4Assert(!"How did we get here?");
  798. return E_INVALIDARG;
  799. }
  800. }
  801. //+---------------------------------------------------------------------------
  802. //
  803. // Member: CPropertyStoreWrapper::GetParameter, public
  804. //
  805. // Returns:
  806. //
  807. // History: 23-Sep-97 KrishnaN Created.
  808. //
  809. //----------------------------------------------------------------------------
  810. HRESULT CPropertyStoreWrapper::GetParameter(VARIANT &var, DWORD eParamType)
  811. {
  812. switch (eParamType)
  813. {
  814. case PSPARAM_PRIMARY_MAPPEDCACHESIZE:
  815. var.ulVal = _pPropStoreMgr->GetMappedCacheSize(PRIMARY_STORE);
  816. return S_OK;
  817. case PSPARAM_PRIMARY_BACKUPSIZE:
  818. var.ulVal = _pPropStoreMgr->GetBackupSize(PRIMARY_STORE);
  819. return S_OK;
  820. case PSPARAM_SECONDARY_MAPPEDCACHESIZE:
  821. var.ulVal = _pPropStoreMgr->GetMappedCacheSize(SECONDARY_STORE);
  822. return S_OK;
  823. case PSPARAM_SECONDARY_BACKUPSIZE:
  824. var.ulVal = _pPropStoreMgr->GetBackupSize(SECONDARY_STORE);
  825. return S_OK;
  826. default:
  827. Win4Assert(!"How did we get here?");
  828. return E_INVALIDARG;
  829. }
  830. }
  831. //+---------------------------------------------------------------------------
  832. //
  833. // Member: CPropertyStoreWrapper::AddRef, public
  834. //
  835. // Returns:
  836. //
  837. // History: 17-Mar-97 KrishnaN Created.
  838. //
  839. //----------------------------------------------------------------------------
  840. ULONG CPropertyStoreWrapper::AddRef()
  841. {
  842. return InterlockedIncrement(&_lRefCount);
  843. }
  844. //+---------------------------------------------------------------------------
  845. //
  846. // Member: CPropertyStoreWrapper::Release, public
  847. //
  848. // Returns:
  849. //
  850. // History: 17-Mar-97 KrishnaN Created.
  851. //
  852. //----------------------------------------------------------------------------
  853. ULONG CPropertyStoreWrapper::Release()
  854. {
  855. LONG lRef;
  856. lRef = InterlockedDecrement(&_lRefCount);
  857. if ( lRef <= 0 )
  858. delete this;
  859. return lRef;
  860. }
  861. SCODE CPropertyStoreWrapper::GetTotalSizeInKB(ULONG * pSize)
  862. {
  863. if (0 == pSize)
  864. return E_INVALIDARG;
  865. *pSize = _pPropStoreMgr->GetTotalSizeInKB();
  866. return S_OK;
  867. }
  868. //+---------------------------------------------------------------------------
  869. //
  870. // Member: CreateWrapStor, public
  871. //
  872. // Arguments: [pAdviseStatus] -- so the caller can be kept posted
  873. // [ppPropertyStore] -- to take back the created prop store
  874. //
  875. // Returns: PPropertyStore object
  876. //
  877. // History: 17-Mar-97 KrishnaN Created.
  878. //
  879. //----------------------------------------------------------------------------
  880. SCODE CreatePropertyStore( ICiCAdviseStatus *pAdviseStatus,
  881. ULONG ulMaxPropStoreMappedCachePrimary,
  882. ULONG ulMaxPropStoreMappedCacheSecondary,
  883. PPropertyStore **ppPropertyStore )
  884. {
  885. if (0 == pAdviseStatus || 0 == ppPropertyStore)
  886. return E_INVALIDARG;
  887. *ppPropertyStore = 0;
  888. SCODE sc = S_OK;
  889. TRY
  890. {
  891. *ppPropertyStore = new CPropertyStoreWrapper (pAdviseStatus,
  892. ulMaxPropStoreMappedCachePrimary,
  893. ulMaxPropStoreMappedCacheSecondary);
  894. }
  895. CATCH( CException, e)
  896. {
  897. sc = e.GetErrorCode();
  898. ciDebugOut((DEB_ERROR, "CreatePropertyStore caught exception 0x%X\n", sc));
  899. }
  900. END_CATCH
  901. return sc;
  902. }