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.

1951 lines
50 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: stgwrap.cxx
  7. //
  8. // Contents: IStorage/IStream wrappers for async docfile
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 19-Dec-95 SusiA Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #include "astghead.cxx"
  18. #pragma hdrstop
  19. #include "stgwrap.hxx"
  20. #include "asyncerr.hxx"
  21. #define UNTERMINATED 0
  22. #define TERMINATED_NORMAL 1
  23. #define TERMINATED_ABNORMAL 2
  24. //+---------------------------------------------------------------------------
  25. //
  26. // Member: CAsyncStorage::Notify, public
  27. //
  28. // Synopsis:
  29. //
  30. // Returns: Appropriate status code
  31. //
  32. // History: 14-Jan-96 SusiA Created
  33. //
  34. //----------------------------------------------------------------------------
  35. SCODE CAsyncStorage::Notify(void)
  36. {
  37. SCODE sc = S_OK;
  38. ULONG ulWaterMark;
  39. ULONG ulFailurePoint;
  40. HANDLE hNotifyEvent;
  41. CSinkList *pslTemp;
  42. _pflb->GetFailureInfo(&ulWaterMark,
  43. &ulFailurePoint);
  44. pslTemp =_cpoint.GetHead();
  45. while ((pslTemp == NULL) ||
  46. (sc = pslTemp->GetProgressNotify()->OnProgress(ulWaterMark, ulFailurePoint, FALSE)) ==S_OK)
  47. {
  48. DWORD dwFlags;
  49. // wait for an event to signal
  50. hNotifyEvent = _pflb->GetNotificationEvent();
  51. WaitForSingleObject(hNotifyEvent, INFINITE);
  52. _pflb->GetTerminationStatus(&dwFlags);
  53. // client terminated call?
  54. if (dwFlags == TERMINATED_ABNORMAL)
  55. return STG_E_TERMINATED;
  56. // download is complete
  57. else if (dwFlags == TERMINATED_NORMAL)
  58. break;
  59. else
  60. { _pflb->GetFailureInfo(&ulWaterMark,
  61. &ulFailurePoint);
  62. // all the data is available now
  63. if (ulWaterMark >= ulFailurePoint)
  64. break;
  65. }
  66. }
  67. if (sc == S_FALSE)
  68. return S_OK;
  69. else return sc;
  70. }
  71. //+---------------------------------------------------------------------------
  72. //
  73. // Member: CAsyncStream::Notify, public
  74. //
  75. // Synopsis:
  76. //
  77. // Returns: Appropriate status code
  78. //
  79. // History: 14-Jan-96 SusiA Created
  80. //
  81. //----------------------------------------------------------------------------
  82. SCODE CAsyncStream::Notify(void)
  83. {
  84. SCODE sc = S_OK;
  85. ULONG ulWaterMark;
  86. ULONG ulFailurePoint;
  87. CSinkList *pslTemp;
  88. HANDLE hNotifyEvent;
  89. _pflb->GetFailureInfo(&ulWaterMark,
  90. &ulFailurePoint);
  91. pslTemp =_cpoint.GetHead();
  92. while ((pslTemp == NULL) ||
  93. (sc = pslTemp->GetProgressNotify()->OnProgress(ulWaterMark, ulFailurePoint, FALSE)) ==S_OK)
  94. {
  95. DWORD dwFlags;
  96. // wait for an event to signal
  97. hNotifyEvent = _pflb->GetNotificationEvent();
  98. WaitForSingleObject(hNotifyEvent, INFINITE);
  99. _pflb->GetTerminationStatus(&dwFlags);
  100. // client terminated call?
  101. if (dwFlags == TERMINATED_ABNORMAL)
  102. return STG_E_TERMINATED;
  103. // download is complete
  104. else if (dwFlags == TERMINATED_NORMAL)
  105. break;
  106. else
  107. { _pflb->GetFailureInfo(&ulWaterMark,
  108. &ulFailurePoint);
  109. // all the data is available now
  110. if (ulWaterMark >= ulFailurePoint)
  111. break;
  112. }
  113. }
  114. if (sc == S_FALSE)
  115. return S_OK;
  116. else return sc;
  117. }
  118. //+---------------------------------------------------------------------------
  119. //
  120. // Member: CAsyncEnum::Notify, public
  121. //
  122. // Synopsis:
  123. //
  124. // Returns: Appropriate status code
  125. //
  126. // History: 14-Jan-96 SusiA Created
  127. //
  128. //----------------------------------------------------------------------------
  129. SCODE CAsyncEnum::Notify(void)
  130. {
  131. SCODE sc = S_OK;
  132. ULONG ulWaterMark;
  133. ULONG ulFailurePoint;
  134. CSinkList *pslTemp;
  135. HANDLE hNotifyEvent;
  136. _pflb->GetFailureInfo(&ulWaterMark,
  137. &ulFailurePoint);
  138. pslTemp =_cpoint.GetHead();
  139. while ((pslTemp == NULL) ||
  140. (sc = pslTemp->GetProgressNotify()->OnProgress(ulWaterMark, ulFailurePoint, FALSE)) ==S_OK)
  141. {
  142. DWORD dwFlags;
  143. // wait for an event to signal
  144. hNotifyEvent = _pflb->GetNotificationEvent();
  145. WaitForSingleObject(hNotifyEvent, INFINITE);
  146. _pflb->GetTerminationStatus(&dwFlags);
  147. // client terminated call?
  148. if (dwFlags == TERMINATED_ABNORMAL)
  149. return STG_E_TERMINATED;
  150. // download is complete
  151. else if (dwFlags == TERMINATED_NORMAL)
  152. break;
  153. else
  154. { _pflb->GetFailureInfo(&ulWaterMark,
  155. &ulFailurePoint);
  156. // all the data is available now
  157. if (ulWaterMark >= ulFailurePoint)
  158. break;
  159. }
  160. }
  161. if (sc == S_FALSE)
  162. return S_OK;
  163. else return sc;
  164. }
  165. //+---------------------------------------------------------------------------
  166. //
  167. // Member: CAsyncStorage::QueryInterface, public
  168. //
  169. // Synopsis:
  170. //
  171. // Returns: Appropriate status code
  172. //
  173. // History: 01-Jan-96 SusiA Created
  174. //
  175. //----------------------------------------------------------------------------
  176. STDMETHODIMP CAsyncStorage::QueryInterface(REFIID iid, void **ppvObj)
  177. {
  178. SCODE sc = S_OK;
  179. *ppvObj = NULL;
  180. astgDebugOut((DEB_ITRACE, "In CAsyncStorage::QueryInterface:%p()\n", this));
  181. if (IsEqualIID(iid, IID_IUnknown))
  182. {
  183. *ppvObj = (IStorage *)this;
  184. }
  185. else if (IsEqualIID(iid, IID_IStorage))
  186. {
  187. *ppvObj = (IStorage *)this;
  188. }
  189. else if (IsEqualIID(iid, IID_IConnectionPointContainer))
  190. {
  191. *ppvObj = (IConnectionPointContainer *)this;
  192. }
  193. else
  194. {
  195. sc = E_NOINTERFACE;
  196. }
  197. if (SUCCEEDED(sc))
  198. {
  199. AddRef();
  200. }
  201. astgDebugOut((DEB_ITRACE, "Out CAsyncStorage::QueryInterface:%p()\n", this));
  202. return sc;
  203. }
  204. //+---------------------------------------------------------------------------
  205. //
  206. // Member: CAsyncStorage::AddRef, public
  207. //
  208. // Synopsis:
  209. //
  210. // Returns: Appropriate status code
  211. //
  212. // History: 01-Jan-96 SusiA Created
  213. //
  214. //----------------------------------------------------------------------------
  215. STDMETHODIMP_(ULONG) CAsyncStorage::AddRef(void)
  216. {
  217. ULONG ulRet;
  218. astgDebugOut((DEB_ITRACE, "In CAsyncStorage::AddRef:%p()\n", this));
  219. InterlockedIncrement(&_cReferences);
  220. ulRet = _cReferences;
  221. _pRealStg->AddRef();
  222. astgDebugOut((DEB_ITRACE, "Out CAsyncStorage::AddRef\n"));
  223. return ulRet;
  224. }
  225. //+---------------------------------------------------------------------------
  226. //
  227. // Member: CAsyncStorage::Release, public
  228. //
  229. // Synopsis:
  230. //
  231. // Returns: Appropriate status code
  232. //
  233. // History: 01-Jan-96 SusiA Created
  234. //
  235. //----------------------------------------------------------------------------
  236. STDMETHODIMP_(ULONG) CAsyncStorage::Release(void)
  237. {
  238. LONG lRet;
  239. astgDebugOut((DEB_ITRACE, "In CAsyncStorage::Release:%p()\n", this));
  240. lRet = InterlockedDecrement(&_cReferences);
  241. _pRealStg->Release();
  242. if (lRet == 0)
  243. {
  244. delete this;
  245. }
  246. else if (lRet < 0)
  247. lRet = 0;
  248. astgDebugOut((DEB_ITRACE, "Out CAsyncStorage::Release\n"));
  249. return (ULONG)lRet;
  250. }
  251. //+---------------------------------------------------------------------------
  252. //
  253. // Member: CAsyncStorage::CreateStream, public
  254. //
  255. // Synopsis:
  256. //
  257. // Returns: Appropriate status code
  258. //
  259. // History: 01-Jan-96 SusiA Created
  260. //
  261. //----------------------------------------------------------------------------
  262. STDMETHODIMP CAsyncStorage::CreateStream(OLECHAR const *pwcsName,
  263. DWORD grfMode,
  264. DWORD reserved1,
  265. DWORD reserved2,
  266. IStream **ppstm)
  267. {
  268. SCODE sc = S_OK,
  269. sc2 = S_OK;
  270. CAsyncStream *pwstm;
  271. astgDebugOut((DEB_ITRACE, "In CAsyncStorage::CreateStream:%p()\n", this));
  272. do
  273. {
  274. sc = _pRealStg->CreateStream(pwcsName,
  275. grfMode,
  276. reserved1,
  277. reserved2,
  278. ppstm);
  279. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  280. return ResultFromScode(sc2);
  281. } while (sc == STG_E_PENDING );
  282. if (SUCCEEDED(sc))
  283. {
  284. CAsyncStream *pwstm = new CAsyncStream(*ppstm, _pflb);
  285. *ppstm = (IStream *)pwstm;
  286. }
  287. astgDebugOut((DEB_ITRACE, "Out CAsyncStorage::CreateStream:%p()\n", this));
  288. return ResultFromScode(sc);
  289. }
  290. //+---------------------------------------------------------------------------
  291. //
  292. // Member: CAsyncStorage::OpenStream, public
  293. //
  294. // Synopsis:
  295. //
  296. // Returns: Appropriate status code
  297. //
  298. // History: 01-Jan-96 SusiA Created
  299. //
  300. //----------------------------------------------------------------------------
  301. STDMETHODIMP CAsyncStorage::OpenStream(OLECHAR const *pwcsName,
  302. void *reserved1,
  303. DWORD grfMode,
  304. DWORD reserved2,
  305. IStream **ppstm)
  306. {
  307. CAsyncStream *pwstm;
  308. SCODE sc = S_OK;
  309. SCODE sc2 = S_OK;
  310. astgDebugOut((DEB_ITRACE, "In CAsyncStorage::OpenStream:%p()\n", this));
  311. do
  312. {
  313. sc = _pRealStg->OpenStream(pwcsName,
  314. reserved1,
  315. grfMode,
  316. reserved2,
  317. ppstm);
  318. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  319. return ResultFromScode(sc2);
  320. } while (sc == STG_E_PENDING );
  321. if (SUCCEEDED(sc))
  322. {
  323. CAsyncStream *pwstm = new CAsyncStream(*ppstm, _pflb);
  324. *ppstm = (IStream *)pwstm;
  325. }
  326. astgDebugOut((DEB_ITRACE, "Out CAsyncStorage::OpenStream:%p()\n", this));
  327. return ResultFromScode(sc);
  328. }
  329. //+---------------------------------------------------------------------------
  330. //
  331. // Member: CAsyncStorage::CreateStorage, public
  332. //
  333. // Synopsis:
  334. //
  335. // Returns: Appropriate status code
  336. //
  337. // History: 01-Jan-96 SusiA Created
  338. //
  339. //----------------------------------------------------------------------------
  340. STDMETHODIMP CAsyncStorage::CreateStorage(OLECHAR const *pwcsName,
  341. DWORD grfMode,
  342. DWORD reserved1,
  343. LPSTGSECURITY reserved2,
  344. IStorage **ppstg)
  345. {
  346. SCODE sc = S_OK;
  347. SCODE sc2 = S_OK;
  348. astgDebugOut((DEB_ITRACE, "In CAsyncStorage::CreateStorage:%p()\n", this));
  349. do
  350. { sc = _pRealStg->CreateStorage( pwcsName,
  351. grfMode,
  352. reserved1,
  353. reserved2,
  354. ppstg);
  355. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  356. return ResultFromScode(sc2);
  357. } while (sc == STG_E_PENDING );
  358. if (SUCCEEDED(sc))
  359. {
  360. CAsyncStorage *pwstg = new CAsyncStorage(*ppstg, _pflb);
  361. *ppstg = (IStorage *) pwstg;
  362. }
  363. astgDebugOut((DEB_ITRACE, "Out CAsyncStorage::CreateStorage:%p()\n", this));
  364. return ResultFromScode(sc);
  365. }
  366. //+---------------------------------------------------------------------------
  367. //
  368. // Member: CAsyncStorage::OpenStorage, public
  369. //
  370. // Synopsis:
  371. //
  372. // Returns: Appropriate status code
  373. //
  374. // History: 01-Jan-96 SusiA Created
  375. //
  376. //----------------------------------------------------------------------------
  377. STDMETHODIMP CAsyncStorage::OpenStorage(OLECHAR const *pwcsName,
  378. IStorage *pstgPriority,
  379. DWORD grfMode,
  380. SNB snbExclude,
  381. DWORD reserved,
  382. IStorage **ppstg)
  383. {
  384. SCODE sc = S_OK;
  385. SCODE sc2 = S_OK;
  386. astgDebugOut((DEB_ITRACE, "In CAsyncStorage::OpenStorage:%p()\n", this));
  387. do
  388. { sc = _pRealStg->OpenStorage( pwcsName,
  389. pstgPriority,
  390. grfMode,
  391. snbExclude,
  392. reserved,
  393. ppstg);
  394. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  395. return ResultFromScode(sc2);
  396. } while (sc == STG_E_PENDING );
  397. if (SUCCEEDED(sc))
  398. {
  399. CAsyncStorage *pwstg = new CAsyncStorage(*ppstg, _pflb);
  400. *ppstg = (IStorage *) pwstg;
  401. }
  402. astgDebugOut((DEB_ITRACE, "Out CAsyncStorage::OpenStorage:%p()\n", this));
  403. return ResultFromScode(sc);
  404. }
  405. //+---------------------------------------------------------------------------
  406. //
  407. // Member: CAsyncStorage::CopyTo, public
  408. //
  409. // Synopsis:
  410. //
  411. // Returns: Appropriate status code
  412. //
  413. // History: 01-Jan-96 SusiA Created
  414. //
  415. //----------------------------------------------------------------------------
  416. STDMETHODIMP CAsyncStorage::CopyTo(DWORD ciidExclude,
  417. IID const *rgiidExclude,
  418. SNB snbExclude,
  419. IStorage *pstgDest)
  420. {
  421. SCODE sc = S_OK;
  422. SCODE sc2 = S_OK;
  423. astgDebugOut((DEB_ITRACE, "In CAsyncStorage::CopyTo%p()\n", this));
  424. do
  425. {
  426. sc = _pRealStg->CopyTo( ciidExclude,
  427. rgiidExclude,
  428. snbExclude,
  429. pstgDest);
  430. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  431. return ResultFromScode(sc2);
  432. } while (sc == STG_E_PENDING );
  433. astgDebugOut((DEB_ITRACE, "Out CAsyncStorage::CopyTo\n"));
  434. return ResultFromScode(sc);
  435. }
  436. //+---------------------------------------------------------------------------
  437. //
  438. // Member: CAsyncStorage::MoveElementTo, public
  439. //
  440. // Synopsis:
  441. //
  442. // Returns: Appropriate status code
  443. //
  444. // History: 01-Jan-96 SusiA Created
  445. //
  446. //----------------------------------------------------------------------------
  447. STDMETHODIMP CAsyncStorage::MoveElementTo(OLECHAR const *lpszName,
  448. IStorage *pstgDest,
  449. OLECHAR const *lpszNewName,
  450. DWORD grfFlags)
  451. {
  452. SCODE sc = S_OK;
  453. SCODE sc2 = S_OK;
  454. astgDebugOut((DEB_ITRACE, "In CAsyncStorage::MoveElementTo%p()\n", this));
  455. do
  456. {
  457. sc = _pRealStg->MoveElementTo(lpszName,
  458. pstgDest,
  459. lpszNewName,
  460. grfFlags) ;
  461. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  462. return ResultFromScode(sc2);
  463. }
  464. while (sc == STG_E_PENDING );
  465. astgDebugOut((DEB_ITRACE, "Out CAsyncStorage::MoveElementTo\n"));
  466. return ResultFromScode(sc);
  467. }
  468. //+---------------------------------------------------------------------------
  469. //
  470. // Member: CAsyncStorage::Commit, public
  471. //
  472. // Synopsis:
  473. //
  474. // Returns: Appropriate status code
  475. //
  476. // History: 01-Jan-96 SusiA Created
  477. //
  478. //----------------------------------------------------------------------------
  479. STDMETHODIMP CAsyncStorage::Commit(DWORD grfCommitFlags)
  480. {
  481. SCODE sc = S_OK;
  482. SCODE sc2 = S_OK;
  483. astgDebugOut((DEB_ITRACE, "In CAsyncStorage::Commit%p()\n", this));
  484. do
  485. {
  486. sc = _pRealStg->Commit(grfCommitFlags);
  487. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  488. return ResultFromScode(sc2);
  489. } while (sc == STG_E_PENDING );
  490. astgDebugOut((DEB_ITRACE, "Out CAsyncStorage::Commit\n"));
  491. return ResultFromScode(sc);
  492. }
  493. //+---------------------------------------------------------------------------
  494. //
  495. // Member: CAsyncStorage::Revert, public
  496. //
  497. // Synopsis:
  498. //
  499. // Returns: Appropriate status code
  500. //
  501. // History: 01-Jan-96 SusiA Created
  502. //
  503. //----------------------------------------------------------------------------
  504. STDMETHODIMP CAsyncStorage::Revert(void)
  505. {
  506. SCODE sc = S_OK;
  507. SCODE sc2 = S_OK;
  508. astgDebugOut((DEB_ITRACE, "In CAsyncStorage::Revert%p()\n", this));
  509. do
  510. {
  511. sc = _pRealStg->Revert();
  512. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  513. return ResultFromScode(sc2);
  514. } while (sc == STG_E_PENDING );
  515. astgDebugOut((DEB_ITRACE, "Out CAsyncStorage::Revert\n"));
  516. return ResultFromScode(sc);
  517. }
  518. //+---------------------------------------------------------------------------
  519. //
  520. // Member: CAsyncStorage::EnumElements, public
  521. //
  522. // Synopsis:
  523. //
  524. // Returns: Appropriate status code
  525. //
  526. // History: 01-Jan-96 SusiA Created
  527. //
  528. //----------------------------------------------------------------------------
  529. STDMETHODIMP CAsyncStorage::EnumElements(DWORD reserved1,
  530. void *reserved2,
  531. DWORD reserved3,
  532. IEnumSTATSTG **ppenm)
  533. {
  534. SCODE sc = S_OK;
  535. SCODE sc2 = S_OK;
  536. astgDebugOut((DEB_ITRACE, "In CAsyncStorage::EnumElements%p()\n", this));
  537. do
  538. {
  539. sc = _pRealStg->EnumElements(reserved1,
  540. reserved2,
  541. reserved3,
  542. ppenm);
  543. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  544. return ResultFromScode(sc2);
  545. } while (sc == STG_E_PENDING );
  546. if (SUCCEEDED(sc))
  547. {
  548. CAsyncEnum *pwenum = new CAsyncEnum(*ppenm, _pflb);
  549. *ppenm = (IEnumSTATSTG *)pwenum;
  550. }
  551. astgDebugOut((DEB_ITRACE, "Out CAsyncStorage::EnumElements\n"));
  552. return ResultFromScode(sc);
  553. }
  554. //+---------------------------------------------------------------------------
  555. //
  556. // Member: CAsyncStorage::DestroyElement, public
  557. //
  558. // Synopsis:
  559. //
  560. // Returns: Appropriate status code
  561. //
  562. // History: 01-Jan-96 SusiA Created
  563. //
  564. //----------------------------------------------------------------------------
  565. STDMETHODIMP CAsyncStorage::DestroyElement(OLECHAR const *pwcsName)
  566. {
  567. SCODE sc = S_OK;
  568. SCODE sc2 = S_OK;
  569. ULONG ulWaterMark;
  570. ULONG ulFailurePoint;
  571. HANDLE hNotifyEvent;
  572. CSinkList *pslTemp;
  573. astgDebugOut((DEB_ITRACE, "In CAsyncStorage::DestroyElement%p()\n", this));
  574. pslTemp =_cpoint.GetHead();
  575. while (1)
  576. {
  577. DWORD dwFlags;
  578. _pflb->GetTerminationStatus(&dwFlags);
  579. // client terminated call?
  580. if (dwFlags == TERMINATED_ABNORMAL)
  581. return STG_E_TERMINATED;
  582. // download is complete
  583. else if (dwFlags == TERMINATED_NORMAL)
  584. break;
  585. // wait for an event to signal
  586. hNotifyEvent = _pflb->GetNotificationEvent();
  587. WaitForSingleObject(hNotifyEvent, INFINITE);
  588. if (pslTemp != NULL)
  589. {
  590. _pflb->GetFailureInfo(&ulWaterMark,
  591. &ulFailurePoint);
  592. pslTemp->GetProgressNotify()->OnProgress(ulWaterMark, (ULONG) -1 , FALSE);
  593. }
  594. }
  595. sc = _pRealStg->DestroyElement(pwcsName);
  596. astgDebugOut((DEB_ITRACE, "Out CAsyncStorage::DestroyElement\n"));
  597. return ResultFromScode(sc);
  598. }
  599. //+---------------------------------------------------------------------------
  600. //
  601. // Member: CAsyncStorage::RenameElement, public
  602. //
  603. // Synopsis:
  604. //
  605. // Returns: Appropriate status code
  606. //
  607. // History: 01-Jan-96 SusiA Created
  608. //
  609. //----------------------------------------------------------------------------
  610. STDMETHODIMP CAsyncStorage::RenameElement(OLECHAR const *pwcsOldName,
  611. OLECHAR const *pwcsNewName)
  612. {
  613. SCODE sc = S_OK;
  614. SCODE sc2 = S_OK;
  615. astgDebugOut((DEB_ITRACE, "In CAsyncStorage::RenameElement%p()\n", this));
  616. do
  617. {
  618. sc = _pRealStg->RenameElement(pwcsOldName,
  619. pwcsNewName);
  620. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  621. return ResultFromScode(sc2);
  622. } while (sc == STG_E_PENDING );
  623. astgDebugOut((DEB_ITRACE, "Out CAsyncStorage::RenameElement\n"));
  624. return ResultFromScode(sc);
  625. }
  626. //+---------------------------------------------------------------------------
  627. //
  628. // Member: CAsyncStorage::SetElementTimes, public
  629. //
  630. // Synopsis:
  631. //
  632. // Returns: Appropriate status code
  633. //
  634. // History: 01-Jan-96 SusiA Created
  635. //
  636. //----------------------------------------------------------------------------
  637. STDMETHODIMP CAsyncStorage::SetElementTimes(const OLECHAR *lpszName,
  638. FILETIME const *pctime,
  639. FILETIME const *patime,
  640. FILETIME const *pmtime)
  641. {
  642. SCODE sc = S_OK;
  643. SCODE sc2 = S_OK;
  644. astgDebugOut((DEB_ITRACE, "In CAsyncStorage::SetElementTimes%p()\n", this));
  645. do
  646. {
  647. sc = _pRealStg->SetElementTimes(lpszName,
  648. pctime,
  649. patime,
  650. pmtime);
  651. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  652. return ResultFromScode(sc2);
  653. } while (sc == STG_E_PENDING );
  654. astgDebugOut((DEB_ITRACE, "Out CAsyncStorage::SetElementTimes\n"));
  655. return ResultFromScode(sc);
  656. }
  657. //+---------------------------------------------------------------------------
  658. //
  659. // Member: CAsyncStorage::SetClass, public
  660. //
  661. // Synopsis:
  662. //
  663. // Returns: Appropriate status code
  664. //
  665. // History: 01-Jan-96 SusiA Created
  666. //
  667. //----------------------------------------------------------------------------
  668. STDMETHODIMP CAsyncStorage::SetClass(REFCLSID clsid)
  669. {
  670. SCODE sc = S_OK;
  671. SCODE sc2 = S_OK;
  672. astgDebugOut((DEB_ITRACE, "In CAsyncStorage::SetClass%p()\n", this));
  673. do
  674. {
  675. sc = _pRealStg->SetClass(clsid);
  676. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  677. return ResultFromScode(sc2);
  678. } while (sc == STG_E_PENDING );
  679. astgDebugOut((DEB_ITRACE, "Out CAsyncStorage::SetClass\n"));
  680. return ResultFromScode(sc);
  681. }
  682. //+---------------------------------------------------------------------------
  683. //
  684. // Member: CAsyncStorage::SetStateBits, public
  685. //
  686. // Synopsis:
  687. //
  688. // Returns: Appropriate status code
  689. //
  690. // History: 01-Jan-96 SusiA Created
  691. //
  692. //----------------------------------------------------------------------------
  693. STDMETHODIMP CAsyncStorage::SetStateBits(DWORD grfStateBits, DWORD grfMask)
  694. {
  695. SCODE sc = S_OK;
  696. SCODE sc2 = S_OK;
  697. astgDebugOut((DEB_ITRACE, "In CAsyncStorage::SetStateBits%p()\n", this));
  698. do
  699. { sc = _pRealStg->SetStateBits(grfStateBits, grfMask);
  700. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  701. return ResultFromScode(sc2);
  702. } while (sc == STG_E_PENDING );
  703. astgDebugOut((DEB_ITRACE, "Out CAsyncStorage::SetStateBits\n"));
  704. return ResultFromScode(sc);
  705. }
  706. //+---------------------------------------------------------------------------
  707. //
  708. // Member: CAsyncStorage::Stat, public
  709. //
  710. // Synopsis:
  711. //
  712. // Returns: Appropriate status code
  713. //
  714. // History: 01-Jan-96 SusiA Created
  715. //
  716. //----------------------------------------------------------------------------
  717. STDMETHODIMP CAsyncStorage::Stat(STATSTG *pstatstg, DWORD grfStatFlag)
  718. {
  719. SCODE sc = S_OK;
  720. SCODE sc2 = S_OK;
  721. astgDebugOut((DEB_ITRACE, "In CAsyncStorage::Stat%p()\n", this));
  722. do
  723. { sc = _pRealStg->Stat( pstatstg, grfStatFlag);
  724. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  725. return ResultFromScode(sc2);
  726. } while (sc == STG_E_PENDING );
  727. astgDebugOut((DEB_ITRACE, "Out CAsyncStorage::Stat\n"));
  728. return ResultFromScode(sc);
  729. }
  730. //+---------------------------------------------------------------------------
  731. //
  732. // Member: CAsyncStorage::EnumConnectionPoints, public
  733. //
  734. // Synopsis: Return enumerator on connection points
  735. //
  736. // Arguments: [ppEnum] -- Return pointer of enumerator
  737. //
  738. // Returns: Appropriate status code
  739. //
  740. // History: 28-Dec-95 SusiA Created
  741. //
  742. //----------------------------------------------------------------------------
  743. STDMETHODIMP CAsyncStorage::EnumConnectionPoints(
  744. IEnumConnectionPoints **ppEnum)
  745. {
  746. astgDebugOut((DEB_ITRACE,
  747. "In CAsyncStorage::EnumConnectionPoints:%p()\n",
  748. this));
  749. astgDebugOut((DEB_ITRACE,
  750. "Out CAsyncStorage::EnumConnectionPoints\n"));
  751. return E_NOTIMPL;
  752. }
  753. //+---------------------------------------------------------------------------
  754. //
  755. // Member: CAsyncStorage::FindConnectionPoint, public
  756. //
  757. // Synopsis: Return a connection point given an IID
  758. //
  759. // Arguments: [iid] -- IID to return connection point for
  760. // [ppCP] -- Return location for pointer
  761. //
  762. // Returns: Appropriate status code
  763. //
  764. // History: 28-Dec-95 SusiA Created
  765. //
  766. //----------------------------------------------------------------------------
  767. STDMETHODIMP CAsyncStorage::FindConnectionPoint(
  768. REFIID iid,
  769. IConnectionPoint **ppCP)
  770. {
  771. astgDebugOut((DEB_ITRACE,
  772. "In CAsyncStorage::FindConnectionPoint:%p()\n",
  773. this));
  774. CConnectionPoint *pcp;
  775. if (IsEqualIID(iid, IID_IProgressNotify))
  776. {
  777. pcp = &_cpoint;
  778. }
  779. else
  780. {
  781. *ppCP = NULL;
  782. return E_NOINTERFACE;
  783. }
  784. pcp->AddRef();
  785. *ppCP = pcp;
  786. astgDebugOut((DEB_ITRACE,
  787. "Out CAsyncStorage::FindConnectionPoint\n"));
  788. return S_OK;
  789. }
  790. //+---------------------------------------------------------------------------
  791. //
  792. // Member: CAsyncRootStorage::QueryInterface, public
  793. //
  794. // Synopsis:
  795. //
  796. // Returns: Appropriate status code
  797. //
  798. // History: 01-Jan-96 SusiA Created
  799. //
  800. //----------------------------------------------------------------------------
  801. STDMETHODIMP CAsyncRootStorage::QueryInterface(REFIID iid, void **ppvObj)
  802. {
  803. SCODE sc = S_OK;
  804. *ppvObj = NULL;
  805. astgDebugOut((DEB_ITRACE, "In CAsyncRootStorage::QueryInterface:%p()\n", this));
  806. if (IsEqualIID(iid, IID_IUnknown))
  807. {
  808. *ppvObj = (IStorage *)this;
  809. }
  810. else if (IsEqualIID(iid, IID_IStorage))
  811. {
  812. *ppvObj = (IStorage *)this;
  813. }
  814. else if (IsEqualIID(iid, IID_IRootStorage))
  815. {
  816. *ppvObj = (IRootStorage *)this;
  817. }
  818. else if (IsEqualIID(iid, IID_IConnectionPointContainer))
  819. {
  820. *ppvObj = (IConnectionPointContainer *)this;
  821. }
  822. else
  823. {
  824. sc = E_NOINTERFACE;
  825. }
  826. if (SUCCEEDED(sc))
  827. {
  828. AddRef();
  829. }
  830. astgDebugOut((DEB_ITRACE, "Out CAsyncRootStorage::QueryInterface:%p()\n", this));
  831. return sc;
  832. }
  833. //+---------------------------------------------------------------------------
  834. //
  835. // Member: CAsyncRootStorage::AddRef, public
  836. //
  837. // Synopsis:
  838. //
  839. // Returns: Appropriate status code
  840. //
  841. // History: 01-Jan-96 SusiA Created
  842. //
  843. //----------------------------------------------------------------------------
  844. STDMETHODIMP_(ULONG) CAsyncRootStorage::AddRef(void)
  845. {
  846. ULONG ulRet;
  847. astgDebugOut((DEB_ITRACE, "In CAsyncRootStorage::AddRef:%p()\n", this));
  848. InterlockedIncrement(&_cReferences);
  849. ulRet = _cReferences;
  850. _pRealStg->AddRef();
  851. astgDebugOut((DEB_ITRACE, "Out CAsyncRootStorage::AddRef\n"));
  852. return ulRet;
  853. }
  854. //+---------------------------------------------------------------------------
  855. //
  856. // Member: CAsyncRootStorage::Release, public
  857. //
  858. // Synopsis:
  859. //
  860. // Returns: Appropriate status code
  861. //
  862. // History: 01-Jan-96 SusiA Created
  863. //
  864. //----------------------------------------------------------------------------
  865. STDMETHODIMP_(ULONG) CAsyncRootStorage::Release(void)
  866. {
  867. LONG lRet;
  868. astgDebugOut((DEB_ITRACE, "In CAsyncRootStorage::Release:%p()\n", this));
  869. lRet = InterlockedDecrement(&_cReferences);
  870. _pRealStg->Release();
  871. if (lRet == 0)
  872. {
  873. delete this;
  874. }
  875. else if (lRet < 0)
  876. lRet = 0;
  877. astgDebugOut((DEB_ITRACE, "Out CAsyncRootStorage::Release\n"));
  878. return (ULONG)lRet;
  879. }
  880. //+---------------------------------------------------------------------------
  881. //
  882. // Member: CAsyncRootStorage::SwitchToFile, public
  883. //
  884. // Synopsis:
  885. //
  886. // Returns: Appropriate status code
  887. //
  888. // History: 01-Jan-96 SusiA Created
  889. //
  890. //----------------------------------------------------------------------------
  891. STDMETHODIMP CAsyncRootStorage::SwitchToFile(OLECHAR *ptcsFile)
  892. {
  893. SCODE sc = S_OK;
  894. SCODE sc2 = S_OK;
  895. IRootStorage *prstg;
  896. astgDebugOut((DEB_ITRACE, "In CAsyncStorage::%p()\n", this));
  897. if (!SUCCEEDED( _pRealStg->QueryInterface(IID_IRootStorage, (void **) &prstg)))
  898. return E_NOINTERFACE;
  899. do
  900. {
  901. sc = prstg->SwitchToFile(ptcsFile);
  902. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  903. return ResultFromScode(sc2);
  904. } while (sc == STG_E_PENDING );
  905. astgDebugOut((DEB_ITRACE, "Out CAsyncStorage::\n"));
  906. return ResultFromScode(sc);
  907. }
  908. //+---------------------------------------------------------------------------
  909. //
  910. // Member: CAsyncStream::QueryInterface, public
  911. //
  912. // Synopsis:
  913. //
  914. // Returns: Appropriate status code
  915. //
  916. // History: 01-Jan-96 SusiA Created
  917. //
  918. //----------------------------------------------------------------------------
  919. STDMETHODIMP CAsyncStream::QueryInterface(REFIID iid, void **ppvObj)
  920. {
  921. SCODE sc = S_OK;
  922. *ppvObj = NULL;
  923. astgDebugOut((DEB_ITRACE, "In CAsyncStream::QueryInterface:%p()\n", this));
  924. if (IsEqualIID(iid, IID_IUnknown))
  925. {
  926. *ppvObj = (IStream *)this;
  927. }
  928. else if (IsEqualIID(iid, IID_IStream))
  929. {
  930. *ppvObj = (IStream *)this;
  931. }
  932. else if (IsEqualIID(iid, IID_IConnectionPointContainer))
  933. {
  934. *ppvObj = (IConnectionPointContainer *)this;
  935. }
  936. else
  937. {
  938. sc = E_NOINTERFACE;
  939. }
  940. if (SUCCEEDED(sc))
  941. {
  942. AddRef();
  943. _pRealStm->AddRef();
  944. }
  945. astgDebugOut((DEB_ITRACE, "Out CAsyncStream::QueryInterface:%p()\n", this));
  946. return sc;
  947. }
  948. //+---------------------------------------------------------------------------
  949. //
  950. // Member: CAsyncStream::AddRef, public
  951. //
  952. // Synopsis:
  953. //
  954. // Returns: Appropriate status code
  955. //
  956. // History: 01-Jan-96 SusiA Created
  957. //
  958. //----------------------------------------------------------------------------
  959. STDMETHODIMP_(ULONG) CAsyncStream::AddRef(void)
  960. {
  961. ULONG ulRet;
  962. astgDebugOut((DEB_ITRACE, "In CAsyncStream::AddRef:%p()\n", this));
  963. InterlockedIncrement(&_cReferences);
  964. ulRet = _cReferences;
  965. _pRealStm->AddRef();
  966. astgDebugOut((DEB_ITRACE, "Out CAsyncStream::AddRef\n"));
  967. return ulRet;
  968. }
  969. //+---------------------------------------------------------------------------
  970. //
  971. // Member: CAsyncStream::Release, public
  972. //
  973. // Synopsis:
  974. //
  975. // Returns: Appropriate status code
  976. //
  977. // History: 01-Jan-96 SusiA Created
  978. //
  979. //----------------------------------------------------------------------------
  980. STDMETHODIMP_(ULONG) CAsyncStream::Release(void)
  981. {
  982. LONG lRet;
  983. astgDebugOut((DEB_ITRACE, "In CAsyncStream::Release:%p()\n", this));
  984. lRet = InterlockedDecrement(&_cReferences);
  985. _pRealStm->Release();
  986. if (lRet == 0)
  987. {
  988. delete this;
  989. }
  990. else if (lRet < 0)
  991. lRet = 0;
  992. astgDebugOut((DEB_ITRACE, "Out CAsyncStream::Release\n"));
  993. return (ULONG)lRet;
  994. }
  995. //+---------------------------------------------------------------------------
  996. //
  997. // Member: CAsyncStream::Read, public
  998. //
  999. // Synopsis:
  1000. //
  1001. // Returns: Appropriate status code
  1002. //
  1003. // History: 01-Jan-96 SusiA Created
  1004. //
  1005. //----------------------------------------------------------------------------
  1006. STDMETHODIMP CAsyncStream::Read(VOID HUGEP *pv,
  1007. ULONG cb,
  1008. ULONG *pcbRead)
  1009. {
  1010. SCODE sc = S_OK;
  1011. SCODE sc2 = S_OK;
  1012. astgDebugOut((DEB_ITRACE, "In CAsyncStream::Read:%p()\n", this));
  1013. do
  1014. {
  1015. sc = _pRealStm->Read(pv,cb,pcbRead);
  1016. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  1017. return ResultFromScode(sc2);
  1018. } while (sc == STG_E_PENDING );
  1019. astgDebugOut((DEB_ITRACE, "Out CAsyncStream::Read\n"));
  1020. return ResultFromScode(sc);
  1021. }
  1022. //+---------------------------------------------------------------------------
  1023. //
  1024. // Member: CAsyncStream::Write, public
  1025. //
  1026. // Synopsis:
  1027. //
  1028. // Returns: Appropriate status code
  1029. //
  1030. // History: 01-Jan-96 SusiA Created
  1031. //
  1032. //----------------------------------------------------------------------------
  1033. STDMETHODIMP CAsyncStream::Write(VOID const HUGEP *pv,
  1034. ULONG cb,
  1035. ULONG *pcbWritten)
  1036. {
  1037. SCODE sc = S_OK;
  1038. SCODE sc2 = S_OK;
  1039. astgDebugOut((DEB_ITRACE, "In CAsyncStream::Write:%p()\n", this));
  1040. do
  1041. { sc = _pRealStm->Write(pv,cb,pcbWritten);
  1042. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  1043. return ResultFromScode(sc2);
  1044. } while (sc == STG_E_PENDING );
  1045. astgDebugOut((DEB_ITRACE, "Out CAsyncStream::Write\n"));
  1046. return ResultFromScode(sc);
  1047. }
  1048. //+---------------------------------------------------------------------------
  1049. //
  1050. // Member: CAsyncStream::Seek, public
  1051. //
  1052. // Synopsis:
  1053. //
  1054. // Returns: Appropriate status code
  1055. //
  1056. // History: 01-Jan-96 SusiA Created
  1057. //
  1058. //----------------------------------------------------------------------------
  1059. STDMETHODIMP CAsyncStream::Seek(LARGE_INTEGER dlibMove,
  1060. DWORD dwOrigin,
  1061. ULARGE_INTEGER *plibNewPosition)
  1062. {
  1063. SCODE sc = S_OK;
  1064. SCODE sc2 = S_OK;
  1065. astgDebugOut((DEB_ITRACE, "In CAsyncStream::Seek:%p()\n", this));
  1066. do
  1067. {
  1068. sc = _pRealStm->Seek(dlibMove, dwOrigin,plibNewPosition);
  1069. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  1070. return ResultFromScode(sc2);
  1071. } while (sc == STG_E_PENDING );
  1072. astgDebugOut((DEB_ITRACE, "Out CAsyncStream::Seek\n"));
  1073. return ResultFromScode(sc);
  1074. }
  1075. //+---------------------------------------------------------------------------
  1076. //
  1077. // Member: CAsyncStream::CopyTo, public
  1078. //
  1079. // Synopsis:
  1080. //
  1081. // Returns: Appropriate status code
  1082. //
  1083. // History: 01-Jan-96 SusiA Created
  1084. //
  1085. //----------------------------------------------------------------------------
  1086. STDMETHODIMP CAsyncStream::CopyTo(IStream *pstm,
  1087. ULARGE_INTEGER cb,
  1088. ULARGE_INTEGER *pcbRead,
  1089. ULARGE_INTEGER *pcbWritten)
  1090. {
  1091. SCODE sc = S_OK;
  1092. SCODE sc2 = S_OK;
  1093. astgDebugOut((DEB_ITRACE, "In CAsyncStream::CopyTo:%p()\n", this));
  1094. do
  1095. { sc = _pRealStm->CopyTo(pstm, cb,pcbRead, pcbWritten);
  1096. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  1097. return ResultFromScode(sc2);
  1098. } while (sc == STG_E_PENDING );
  1099. astgDebugOut((DEB_ITRACE, "Out CAsyncStream::CopyTo\n"));
  1100. return ResultFromScode(sc);
  1101. }
  1102. //+---------------------------------------------------------------------------
  1103. //
  1104. // Member: CAsyncStream::SetSize, public
  1105. //
  1106. // Synopsis:
  1107. //
  1108. // Returns: Appropriate status code
  1109. //
  1110. // History: 01-Jan-96 SusiA Created
  1111. //
  1112. //----------------------------------------------------------------------------
  1113. STDMETHODIMP CAsyncStream::SetSize(ULARGE_INTEGER cb)
  1114. {
  1115. SCODE sc = S_OK;
  1116. SCODE sc2 = S_OK;
  1117. astgDebugOut((DEB_ITRACE, "In CAsyncStream::SetSize%p()\n", this));
  1118. do
  1119. { sc = _pRealStm->SetSize(cb);
  1120. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  1121. return ResultFromScode(sc2);
  1122. } while (sc == STG_E_PENDING );
  1123. astgDebugOut((DEB_ITRACE, "Out CAsyncStream::SetSize\n"));
  1124. return ResultFromScode(sc);
  1125. }
  1126. //+---------------------------------------------------------------------------
  1127. //
  1128. // Member: CAsyncStream::Commit, public
  1129. //
  1130. // Synopsis:
  1131. //
  1132. // Returns: Appropriate status code
  1133. //
  1134. // History: 01-Jan-96 SusiA Created
  1135. //
  1136. //----------------------------------------------------------------------------
  1137. STDMETHODIMP CAsyncStream::Commit(DWORD grfCommitFlags)
  1138. {
  1139. SCODE sc = S_OK;
  1140. SCODE sc2 = S_OK;
  1141. astgDebugOut((DEB_ITRACE, "In CAsyncStream::Commit%p()\n", this));
  1142. do
  1143. {
  1144. sc = _pRealStm->Commit(grfCommitFlags);
  1145. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  1146. return ResultFromScode(sc2);
  1147. } while (sc == STG_E_PENDING );
  1148. astgDebugOut((DEB_ITRACE, "Out CAsyncStream::Commit\n"));
  1149. return ResultFromScode(sc);
  1150. }
  1151. //+---------------------------------------------------------------------------
  1152. //
  1153. // Member: CAsyncStream::Revert, public
  1154. //
  1155. // Synopsis:
  1156. //
  1157. // Returns: Appropriate status code
  1158. //
  1159. // History: 01-Jan-96 SusiA Created
  1160. //
  1161. //----------------------------------------------------------------------------
  1162. STDMETHODIMP CAsyncStream::Revert(void)
  1163. {
  1164. SCODE sc = S_OK;
  1165. SCODE sc2 = S_OK;
  1166. astgDebugOut((DEB_ITRACE, "In CAsyncStream::Revert%p()\n", this));
  1167. do
  1168. {
  1169. sc = _pRealStm->Revert();
  1170. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  1171. return ResultFromScode(sc2);
  1172. } while (sc == STG_E_PENDING );
  1173. astgDebugOut((DEB_ITRACE, "Out CAsyncStream::Revert\n"));
  1174. return ResultFromScode(sc);
  1175. }
  1176. //+---------------------------------------------------------------------------
  1177. //
  1178. // Member: CAsyncStream::LockRegion, public
  1179. //
  1180. // Synopsis:
  1181. //
  1182. // Returns: Appropriate status code
  1183. //
  1184. // History: 01-Jan-96 SusiA Created
  1185. //
  1186. //----------------------------------------------------------------------------
  1187. STDMETHODIMP CAsyncStream::LockRegion(ULARGE_INTEGER libOffset,
  1188. ULARGE_INTEGER cb,
  1189. DWORD dwLockType)
  1190. {
  1191. SCODE sc = S_OK;
  1192. SCODE sc2 = S_OK;
  1193. astgDebugOut((DEB_ITRACE, "In CAsyncStream::LockRegion%p()\n", this));
  1194. do
  1195. { sc = _pRealStm->LockRegion(libOffset,
  1196. cb,
  1197. dwLockType);
  1198. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  1199. return ResultFromScode(sc2);
  1200. } while (sc == STG_E_PENDING );
  1201. astgDebugOut((DEB_ITRACE, "Out CAsyncStream::LockRegion\n"));
  1202. return ResultFromScode(sc);
  1203. }
  1204. //+---------------------------------------------------------------------------
  1205. //
  1206. // Member: CAsyncStream::UnlockRegion, public
  1207. //
  1208. // Synopsis:
  1209. //
  1210. // Returns: Appropriate status code
  1211. //
  1212. // History: 01-Jan-96 SusiA Created
  1213. //
  1214. //----------------------------------------------------------------------------
  1215. STDMETHODIMP CAsyncStream::UnlockRegion(ULARGE_INTEGER libOffset,
  1216. ULARGE_INTEGER cb,
  1217. DWORD dwLockType)
  1218. {
  1219. SCODE sc = S_OK;
  1220. SCODE sc2 = S_OK;
  1221. astgDebugOut((DEB_ITRACE, "In CAsyncStream::UnlockRegion%p()\n", this));
  1222. do
  1223. {
  1224. sc = _pRealStm->UnlockRegion(libOffset,
  1225. cb,
  1226. dwLockType);
  1227. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  1228. return ResultFromScode(sc2);
  1229. } while (sc == STG_E_PENDING );
  1230. astgDebugOut((DEB_ITRACE, "Out CAsyncStream::UnlockRegion\n"));
  1231. return ResultFromScode(sc);
  1232. }
  1233. //+---------------------------------------------------------------------------
  1234. //
  1235. // Member: CAsyncStream::Stat, public
  1236. //
  1237. // Synopsis:
  1238. //
  1239. // Returns: Appropriate status code
  1240. //
  1241. // History: 01-Jan-96 SusiA Created
  1242. //
  1243. //----------------------------------------------------------------------------
  1244. STDMETHODIMP CAsyncStream::Stat(STATSTG *pstatstg, DWORD grfStatFlag)
  1245. {
  1246. SCODE sc = S_OK;
  1247. SCODE sc2 = S_OK;
  1248. astgDebugOut((DEB_ITRACE, "In CAsyncStream::Stat%p()\n", this));
  1249. do
  1250. { sc = _pRealStm->Stat(pstatstg, grfStatFlag);
  1251. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  1252. return ResultFromScode(sc2);
  1253. } while (sc == STG_E_PENDING );
  1254. astgDebugOut((DEB_ITRACE, "Out CAsyncStream::Stat\n"));
  1255. return ResultFromScode(sc);
  1256. }
  1257. //+---------------------------------------------------------------------------
  1258. //
  1259. // Member: CAsyncStream::Clone, public
  1260. //
  1261. // Synopsis:
  1262. //
  1263. // Returns: Appropriate status code
  1264. //
  1265. // History: 01-Jan-96 SusiA Created
  1266. //
  1267. //----------------------------------------------------------------------------
  1268. STDMETHODIMP CAsyncStream::Clone(IStream **ppstm)
  1269. {
  1270. SCODE sc = S_OK;
  1271. SCODE sc2 = S_OK;
  1272. astgDebugOut((DEB_ITRACE, "In CAsyncStream::Clone:%p()\n", this));
  1273. do
  1274. {
  1275. sc = _pRealStm->Clone(ppstm);
  1276. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  1277. return ResultFromScode(sc2);
  1278. } while (sc == STG_E_PENDING );
  1279. if (SUCCEEDED(sc))
  1280. {
  1281. CAsyncStream *pwstm = new CAsyncStream(*ppstm, _pflb);
  1282. *ppstm = (IStream *) pwstm;
  1283. }
  1284. astgDebugOut((DEB_ITRACE, "Out CAsyncStream::Clone\n"));
  1285. return ResultFromScode(sc);
  1286. }
  1287. //+---------------------------------------------------------------------------
  1288. //
  1289. // Member: CAsyncStream::EnumConnectionPoints, public
  1290. //
  1291. // Synopsis: Return enumerator on connection points
  1292. //
  1293. // Arguments: [ppEnum] -- Return pointer of enumerator
  1294. //
  1295. // Returns: Appropriate status code
  1296. //
  1297. // History: 28-Dec-95 SusiA Created
  1298. //
  1299. //----------------------------------------------------------------------------
  1300. STDMETHODIMP CAsyncStream::EnumConnectionPoints(
  1301. IEnumConnectionPoints **ppEnum)
  1302. {
  1303. astgDebugOut((DEB_ITRACE,
  1304. "In CAsyncStream::EnumConnectionPoints:%p()\n",
  1305. this));
  1306. astgDebugOut((DEB_ITRACE,
  1307. "Out CAsyncStream::EnumConnectionPoints\n"));
  1308. return E_NOTIMPL;
  1309. }
  1310. //+---------------------------------------------------------------------------
  1311. //
  1312. // Member: CAsyncStream::FindConnectionPoint, public
  1313. //
  1314. // Synopsis: Return a connection point given an IID
  1315. //
  1316. // Arguments: [iid] -- IID to return connection point for
  1317. // [ppCP] -- Return location for pointer
  1318. //
  1319. // Returns: Appropriate status code
  1320. //
  1321. // History: 28-Dec-95 SusiA Created
  1322. //
  1323. //----------------------------------------------------------------------------
  1324. STDMETHODIMP CAsyncStream::FindConnectionPoint(
  1325. REFIID iid,
  1326. IConnectionPoint **ppCP)
  1327. {
  1328. astgDebugOut((DEB_ITRACE,
  1329. "In CAsyncStream::FindConnectionPoint:%p()\n",
  1330. this));
  1331. CConnectionPoint *pcp;
  1332. if (IsEqualIID(iid, IID_IProgressNotify))
  1333. {
  1334. pcp = &_cpoint;
  1335. }
  1336. else
  1337. {
  1338. *ppCP = NULL;
  1339. return E_NOINTERFACE;
  1340. }
  1341. pcp->AddRef();
  1342. *ppCP = pcp;
  1343. astgDebugOut((DEB_ITRACE,
  1344. "Out CAsyncStream::FindConnectionPoint\n"));
  1345. return S_OK;
  1346. }
  1347. //+---------------------------------------------------------------------------
  1348. //
  1349. // Member: CAsyncEnum::QueryInterface, public
  1350. //
  1351. // Synopsis:
  1352. //
  1353. // Returns: Appropriate status code
  1354. //
  1355. // History: 01-Jan-96 SusiA Created
  1356. //
  1357. //----------------------------------------------------------------------------
  1358. STDMETHODIMP CAsyncEnum::QueryInterface(REFIID iid, void **ppvObj)
  1359. {
  1360. SCODE sc = S_OK;
  1361. *ppvObj = NULL;
  1362. astgDebugOut((DEB_ITRACE, "In CAsyncEnum::QueryInterface:%p()\n", this));
  1363. if (IsEqualIID(iid, IID_IUnknown))
  1364. {
  1365. *ppvObj = (IEnumSTATSTG *)this;
  1366. }
  1367. else if (IsEqualIID(iid, IID_IEnumSTATSTG))
  1368. {
  1369. *ppvObj = (IEnumSTATSTG *)this;
  1370. }
  1371. else if (IsEqualIID(iid, IID_IConnectionPointContainer))
  1372. {
  1373. *ppvObj = (IConnectionPointContainer *)this;
  1374. }
  1375. else
  1376. {
  1377. sc = E_NOINTERFACE;
  1378. }
  1379. if (SUCCEEDED(sc))
  1380. {
  1381. AddRef();
  1382. _pRealEnum->AddRef();
  1383. }
  1384. astgDebugOut((DEB_ITRACE, "Out CAsyncEnum::QueryInterface:%p()\n", this));
  1385. return sc;
  1386. }
  1387. //+---------------------------------------------------------------------------
  1388. //
  1389. // Member: CAsyncEnum::AddRef, public
  1390. //
  1391. // Synopsis:
  1392. //
  1393. // Returns: Appropriate status code
  1394. //
  1395. // History: 01-Jan-96 SusiA Created
  1396. //
  1397. //----------------------------------------------------------------------------
  1398. STDMETHODIMP_(ULONG) CAsyncEnum::AddRef(void)
  1399. {
  1400. ULONG ulRet;
  1401. astgDebugOut((DEB_ITRACE, "In CAsyncEnum::AddRef:%p()\n", this));
  1402. InterlockedIncrement(&_cReferences);
  1403. ulRet = _cReferences;
  1404. _pRealEnum->AddRef();
  1405. astgDebugOut((DEB_ITRACE, "Out CAsyncEnum::AddRef\n"));
  1406. return ulRet;
  1407. }
  1408. //+---------------------------------------------------------------------------
  1409. //
  1410. // Member: CAsyncEnum::Release, public
  1411. //
  1412. // Synopsis:
  1413. //
  1414. // Returns: Appropriate status code
  1415. //
  1416. // History: 01-Jan-96 SusiA Created
  1417. //
  1418. //----------------------------------------------------------------------------
  1419. STDMETHODIMP_(ULONG) CAsyncEnum::Release(void)
  1420. {
  1421. LONG lRet;
  1422. astgDebugOut((DEB_ITRACE, "In CAsyncEnum::Release:%p()\n", this));
  1423. lRet = InterlockedDecrement(&_cReferences);
  1424. _pRealEnum->Release();
  1425. if (lRet == 0)
  1426. {
  1427. delete this;
  1428. }
  1429. else if (lRet < 0)
  1430. lRet = 0;
  1431. astgDebugOut((DEB_ITRACE, "Out CAsyncEnum::Release\n"));
  1432. return (ULONG)lRet;
  1433. }
  1434. //+---------------------------------------------------------------------------
  1435. //
  1436. // Member: CAsyncEnum::EnumConnectionPoints, public
  1437. //
  1438. // Synopsis: Return enumerator on connection points
  1439. //
  1440. // Arguments: [ppEnum] -- Return pointer of enumerator
  1441. //
  1442. // Returns: Appropriate status code
  1443. //
  1444. // History: 28-Dec-95 SusiA Created
  1445. //
  1446. //----------------------------------------------------------------------------
  1447. STDMETHODIMP CAsyncEnum::EnumConnectionPoints(
  1448. IEnumConnectionPoints **ppEnum)
  1449. {
  1450. astgDebugOut((DEB_ITRACE,
  1451. "In CAsyncEnum::EnumConnectionPoints:%p()\n",
  1452. this));
  1453. astgDebugOut((DEB_ITRACE,
  1454. "Out CAsyncEnum::EnumConnectionPoints\n"));
  1455. return E_NOTIMPL;
  1456. }
  1457. //+---------------------------------------------------------------------------
  1458. //
  1459. // Member: CAsyncEnum::FindConnectionPoint, public
  1460. //
  1461. // Synopsis: Return a connection point given an IID
  1462. //
  1463. // Arguments: [iid] -- IID to return connection point for
  1464. // [ppCP] -- Return location for pointer
  1465. //
  1466. // Returns: Appropriate status code
  1467. //
  1468. // History: 28-Dec-95 SusiA Created
  1469. //
  1470. //----------------------------------------------------------------------------
  1471. STDMETHODIMP CAsyncEnum::FindConnectionPoint(
  1472. REFIID iid,
  1473. IConnectionPoint **ppCP)
  1474. {
  1475. astgDebugOut((DEB_ITRACE,
  1476. "In CAsyncEnum::FindConnectionPoint:%p()\n",
  1477. this));
  1478. CConnectionPoint *pcp;
  1479. if (IsEqualIID(iid, IID_IProgressNotify))
  1480. {
  1481. pcp = &_cpoint;
  1482. }
  1483. else
  1484. {
  1485. *ppCP = NULL;
  1486. return E_NOINTERFACE;
  1487. }
  1488. pcp->AddRef();
  1489. *ppCP = pcp;
  1490. astgDebugOut((DEB_ITRACE,
  1491. "Out CAsyncEnum::FindConnectionPoint\n"));
  1492. return S_OK;
  1493. }
  1494. //+---------------------------------------------------------------------------
  1495. //
  1496. // Member: CAsyncEnum::Next, public
  1497. //
  1498. // Synopsis:
  1499. //
  1500. // Returns: Appropriate status code
  1501. //
  1502. // History: 01-Jan-96 SusiA Created
  1503. //
  1504. //----------------------------------------------------------------------------
  1505. STDMETHODIMP CAsyncEnum::Next(ULONG celt, STATSTG FAR *rgelt, ULONG *pceltFetched)
  1506. {
  1507. SCODE sc = S_OK;
  1508. SCODE sc2 = S_OK;
  1509. astgDebugOut((DEB_ITRACE, "In CAsyncEnum::Next:%p()\n", this));
  1510. do
  1511. { sc = _pRealEnum->Next(celt, rgelt, pceltFetched);
  1512. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  1513. return ResultFromScode(sc2);
  1514. } while (sc == STG_E_PENDING );
  1515. astgDebugOut((DEB_ITRACE, "Out CAsyncEnum::Next\n"));
  1516. return ResultFromScode(sc);
  1517. }
  1518. //+---------------------------------------------------------------------------
  1519. //
  1520. // Member: CAsyncEnum::Skip, public
  1521. //
  1522. // Synopsis:
  1523. //
  1524. // Returns: Appropriate status code
  1525. //
  1526. // History: 01-Jan-96 SusiA Created
  1527. //
  1528. //----------------------------------------------------------------------------
  1529. STDMETHODIMP CAsyncEnum::Skip(ULONG celt)
  1530. {
  1531. SCODE sc = S_OK;
  1532. SCODE sc2 = S_OK;
  1533. astgDebugOut((DEB_ITRACE, "In CAsyncEnum::Skip:%p()\n", this));
  1534. sc = _pRealEnum->Skip(celt);
  1535. do
  1536. {
  1537. sc = _pRealEnum->Reset();
  1538. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  1539. return ResultFromScode(sc2);
  1540. } while (sc == STG_E_PENDING );
  1541. astgDebugOut((DEB_ITRACE, "Out CAsyncEnum::Skip\n"));
  1542. return ResultFromScode(sc);
  1543. }
  1544. //+---------------------------------------------------------------------------
  1545. //
  1546. // Member: CAsyncEnum::Reset, public
  1547. //
  1548. // Synopsis:
  1549. //
  1550. // Returns: Appropriate status code
  1551. //
  1552. // History: 01-Jan-96 SusiA Created
  1553. //
  1554. //----------------------------------------------------------------------------
  1555. STDMETHODIMP CAsyncEnum::Reset(void)
  1556. {
  1557. SCODE sc = S_OK;
  1558. SCODE sc2 = S_OK;
  1559. astgDebugOut((DEB_ITRACE, "In CAsyncEnum::Reset:%p()\n", this));
  1560. do
  1561. {
  1562. sc = _pRealEnum->Reset();
  1563. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  1564. return ResultFromScode(sc2);
  1565. } while (sc == STG_E_PENDING );
  1566. astgDebugOut((DEB_ITRACE, "Out CAsyncEnum::Reset\n"));
  1567. return ResultFromScode(sc);
  1568. }
  1569. //+---------------------------------------------------------------------------
  1570. //
  1571. // Member: CAsyncEnum::Clone, public
  1572. //
  1573. // Synopsis:
  1574. //
  1575. // Returns: Appropriate status code
  1576. //
  1577. // History: 01-Jan-96 SusiA Created
  1578. //
  1579. //----------------------------------------------------------------------------
  1580. STDMETHODIMP CAsyncEnum::Clone(IEnumSTATSTG **ppenm)
  1581. {
  1582. SCODE sc = S_OK;
  1583. SCODE sc2 = S_OK;
  1584. astgDebugOut((DEB_ITRACE, "In CAsyncEnum::Clone:%p()\n", this));
  1585. do
  1586. {
  1587. sc = _pRealEnum->Clone(ppenm);
  1588. if (( STG_E_PENDING==sc) && ((sc2 = Notify())!= S_OK))
  1589. return ResultFromScode(sc2);
  1590. } while (sc == STG_E_PENDING );
  1591. if (SUCCEEDED(sc))
  1592. {
  1593. CAsyncEnum *pwenum = new CAsyncEnum(*ppenm, _pflb);
  1594. *ppenm = (IEnumSTATSTG *) pwenum;
  1595. }
  1596. astgDebugOut((DEB_ITRACE, "Out CAsyncEnum::Clone\n"));
  1597. return ResultFromScode(sc);
  1598. }