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.

1131 lines
30 KiB

  1. //+------------------------------------------------------------
  2. //
  3. // Copyright (C) 1998, Microsoft Corporation
  4. //
  5. // File: catparams.cpp
  6. //
  7. // Contents: Categorizer server event parameter classes
  8. //
  9. // Classes:
  10. //
  11. // Functions:
  12. //
  13. // History:
  14. // jstamerj 1998/06/23 13:13:58: Created.
  15. //
  16. //-------------------------------------------------------------
  17. #include <stdio.h>
  18. #include <windows.h>
  19. #include <mailmsg.h>
  20. #include <dbgtrace.h>
  21. #include <cpool.h>
  22. #include <filehc.h>
  23. #define _ATL_NO_DEBUG_CRT
  24. #define _ATL_STATIC_REGISTRY 1
  25. #define _ASSERTE _ASSERT
  26. #define _WINDLL
  27. #include "atlbase.h"
  28. extern CComModule _Module;
  29. #include "atlcom.h"
  30. #undef _WINDLL
  31. #include <seo.h>
  32. #include <seolib.h>
  33. #include <smtpdisp_i.c>
  34. #include <mailmsgi.h>
  35. #include <smtpevent.h>
  36. #include <seomgr.h>
  37. #define MAX_RULE_LENGTH 4096
  38. //
  39. // Message object
  40. //
  41. #define MAILMSG_PROGID L"Exchange.MailMsg"
  42. #define INITGUID
  43. #include "initguid.h"
  44. #include "smtpguid.h"
  45. #include "wildmat.h"
  46. #include "smtpdisp.h"
  47. #include "seodisp.h"
  48. #include "evntwrap.h"
  49. //
  50. // CMailTransportCatRegisterParams:
  51. //
  52. //+------------------------------------------------------------
  53. //
  54. // Function: CStoreDispatcher::CMailTransportCatRegisterParams::CallObject
  55. //
  56. // Synopsis: Call the sink
  57. //
  58. // Arguments:
  59. // CBinding
  60. // punkObject
  61. //
  62. // Returns:
  63. // S_OK: Success
  64. // error from QI or sink function
  65. //
  66. // History:
  67. // jstamerj 980610 19:04:59: Created.
  68. //
  69. //-------------------------------------------------------------
  70. HRESULT CStoreDispatcher::CMailTransportCatRegisterParams::CallObject(
  71. CBinding& bBinding,
  72. IUnknown *punkObject)
  73. {
  74. HRESULT hrRes = S_OK;
  75. IMailTransportCategorize *pSink;
  76. TraceFunctEnterEx((LPARAM)this, "CStoreDispatcher::CMailTransportCatRegisterParams::CallObject");
  77. _ASSERT(m_dwEventType == SMTP_MAILTRANSPORT_CATEGORIZE_REGISTER_EVENT);
  78. hrRes = punkObject->QueryInterface(
  79. IID_IMailTransportCategorize,
  80. (PVOID *)&pSink);
  81. if(FAILED(hrRes)) {
  82. ErrorTrace((LPARAM)this, "QI failed on sink, hr %08lx", hrRes);
  83. TraceFunctLeaveEx((LPARAM)this);
  84. return(hrRes);
  85. }
  86. DebugTrace((LPARAM)this, "Calling submission event on this sink");
  87. hrRes = pSink->Register(
  88. m_pContext->pICatParams);
  89. DebugTrace((LPARAM)this, "Sink returned hr %08lx", hrRes);
  90. //
  91. // This sink is not allowed to be async...
  92. //
  93. _ASSERT(hrRes != MAILTRANSPORT_S_PENDING);
  94. if(FAILED(hrRes) && (hrRes != E_NOTIMPL) && SUCCEEDED(m_pContext->hrSinkStatus)) {
  95. //
  96. // Set the first failure value
  97. //
  98. m_pContext->hrSinkStatus = hrRes;
  99. }
  100. pSink->Release();
  101. TraceFunctLeaveEx((LPARAM)this);
  102. return(hrRes);
  103. }
  104. //+------------------------------------------------------------
  105. //
  106. // Function: CStoreDispatcher::CMailTransportCatRegisterParams::CallDefault
  107. //
  108. // Synopsis: The dispatcher will call this routine when it the default
  109. // sink processing priority is reached
  110. //
  111. // Arguments: NONE
  112. //
  113. // Returns:
  114. // S_OK: Success, continueing calling sinks
  115. // S_FALSE: Stop calling sinks
  116. //
  117. // History:
  118. // jstamerj 980611 14:15:43: Created.
  119. //
  120. //-------------------------------------------------------------
  121. HRESULT CStoreDispatcher::CMailTransportCatRegisterParams::CallDefault()
  122. {
  123. HRESULT hr;
  124. TraceFunctEnterEx((LPARAM)this, "CStoreDispatcher::CMailTransportCatRegisterParams::CallDefault");
  125. _ASSERT(m_dwEventType == SMTP_MAILTRANSPORT_CATEGORIZE_REGISTER_EVENT);
  126. hr = (*m_pContext->pfnDefault) (S_OK, m_pContext);
  127. if(FAILED(hr) && (hr != E_NOTIMPL) && SUCCEEDED(m_pContext->hrSinkStatus)) {
  128. //
  129. // Set the first failure value
  130. //
  131. m_pContext->hrSinkStatus = hr;
  132. }
  133. TraceFunctLeaveEx((LPARAM)this);
  134. return hr;
  135. }
  136. //
  137. // CMailTransportCatBeginParams:
  138. //
  139. //+------------------------------------------------------------
  140. //
  141. // Function: CStoreDispatcher::CMailTransportCatBeginParams::CallObject
  142. //
  143. // Synopsis: Call the sink
  144. //
  145. // Arguments:
  146. // CBinding
  147. // punkObject
  148. //
  149. // Returns:
  150. // S_OK: Success
  151. // error from QI or sink function
  152. //
  153. // History:
  154. // jstamerj 980610 19:04:59: Created.
  155. //
  156. //-------------------------------------------------------------
  157. HRESULT CStoreDispatcher::CMailTransportCatBeginParams::CallObject(
  158. CBinding& bBinding,
  159. IUnknown *punkObject)
  160. {
  161. HRESULT hrRes = S_OK;
  162. IMailTransportCategorize *pSink;
  163. TraceFunctEnterEx((LPARAM)this, "CStoreDispatcher::CMailTransportCatBeginParams::CallObject");
  164. _ASSERT(m_dwEventType == SMTP_MAILTRANSPORT_CATEGORIZE_BEGIN_EVENT);
  165. hrRes = punkObject->QueryInterface(
  166. IID_IMailTransportCategorize,
  167. (PVOID *)&pSink);
  168. if(FAILED(hrRes)) {
  169. ErrorTrace((LPARAM)this, "QI failed on sink, hr %08lx", hrRes);
  170. TraceFunctLeaveEx((LPARAM)this);
  171. return(hrRes);
  172. }
  173. DebugTrace((LPARAM)this, "Calling submission event on this sink");
  174. hrRes = pSink->BeginMessageCategorization(
  175. m_pContext->pICatMailMsgs);
  176. DebugTrace((LPARAM)this, "Sink returned hr %08lx", hrRes);
  177. //
  178. // This sink is not allowed to be async...
  179. //
  180. _ASSERT(hrRes != MAILTRANSPORT_S_PENDING);
  181. pSink->Release();
  182. TraceFunctLeaveEx((LPARAM)this);
  183. return(hrRes);
  184. }
  185. //+------------------------------------------------------------
  186. //
  187. // Function: CStoreDispatcher::CMailTransportCatBeginParams::CallDefault
  188. //
  189. // Synopsis: The dispatcher will call this routine when it the default
  190. // sink processing priority is reached
  191. //
  192. // Arguments: NONE
  193. //
  194. // Returns:
  195. // S_OK: Success, continueing calling sinks
  196. // S_FALSE: Stop calling sinks
  197. //
  198. // History:
  199. // jstamerj 980611 14:15:43: Created.
  200. //
  201. //-------------------------------------------------------------
  202. HRESULT CStoreDispatcher::CMailTransportCatBeginParams::CallDefault()
  203. {
  204. TraceFunctEnterEx((LPARAM)this, "CStoreDispatcher::CMailTransportCatBeginParams::CallDefault");
  205. _ASSERT(m_dwEventType == SMTP_MAILTRANSPORT_CATEGORIZE_BEGIN_EVENT);
  206. TraceFunctLeaveEx((LPARAM)this);
  207. return S_OK;
  208. }
  209. //
  210. // CMailTransportCatEndParams:
  211. //
  212. //+------------------------------------------------------------
  213. //
  214. // Function: CStoreDispatcher::CMailTransportCatEndParams::CallObject
  215. //
  216. // Synopsis: Call the sink
  217. //
  218. // Arguments:
  219. // CBinding
  220. // punkObject
  221. //
  222. // Returns:
  223. // S_OK: Success
  224. // error from QI or sink function
  225. //
  226. // History:
  227. // jstamerj 980610 19:04:59: Created.
  228. //
  229. //-------------------------------------------------------------
  230. HRESULT CStoreDispatcher::CMailTransportCatEndParams::CallObject(
  231. CBinding& bBinding,
  232. IUnknown *punkObject)
  233. {
  234. HRESULT hrRes = S_OK;
  235. IMailTransportCategorize *pSink;
  236. TraceFunctEnterEx((LPARAM)this, "CStoreDispatcher::CMailTransportCatEndParams::CallObject");
  237. _ASSERT(m_dwEventType == SMTP_MAILTRANSPORT_CATEGORIZE_END_EVENT);
  238. hrRes = punkObject->QueryInterface(
  239. IID_IMailTransportCategorize,
  240. (PVOID *)&pSink);
  241. if(FAILED(hrRes)) {
  242. ErrorTrace((LPARAM)this, "QI failed on sink, hr %08lx", hrRes);
  243. TraceFunctLeaveEx((LPARAM)this);
  244. return(hrRes);
  245. }
  246. DebugTrace((LPARAM)this, "Calling submission event on this sink");
  247. hrRes = pSink->EndMessageCategorization(
  248. m_pContext->pICatMailMsgs,
  249. m_pContext->hrStatus);
  250. DebugTrace((LPARAM)this, "Sink returned hr %08lx", hrRes);
  251. //
  252. // This sink is not allowed to be async...
  253. //
  254. _ASSERT(hrRes != MAILTRANSPORT_S_PENDING);
  255. pSink->Release();
  256. TraceFunctLeaveEx((LPARAM)this);
  257. return(hrRes);
  258. }
  259. //+------------------------------------------------------------
  260. //
  261. // Function: CStoreDispatcher::CMailTransportCatEndParams::CallDefault
  262. //
  263. // Synopsis: The dispatcher will call this routine when it the default
  264. // sink processing priority is reached
  265. //
  266. // Arguments: NONE
  267. //
  268. // Returns:
  269. // S_OK: Success, continueing calling sinks
  270. // S_FALSE: Stop calling sinks
  271. //
  272. // History:
  273. // jstamerj 980611 14:15:43: Created.
  274. //
  275. //-------------------------------------------------------------
  276. HRESULT CStoreDispatcher::CMailTransportCatEndParams::CallDefault()
  277. {
  278. TraceFunctEnterEx((LPARAM)this, "CStoreDispatcher::CMailTransportCatEndParams::CallDefault");
  279. _ASSERT(m_dwEventType == SMTP_MAILTRANSPORT_CATEGORIZE_END_EVENT);
  280. TraceFunctLeaveEx((LPARAM)this);
  281. return S_OK;
  282. }
  283. //
  284. // CMailTransportCatBuildQueryParams:
  285. //
  286. //+------------------------------------------------------------
  287. //
  288. // Function: CStoreDispatcher::CMailTransportCatBuildQueryParams::CallObject
  289. //
  290. // Synopsis: Call the sink
  291. //
  292. // Arguments:
  293. // CBinding
  294. // punkObject
  295. //
  296. // Returns:
  297. // S_OK: Success
  298. // error from QI or sink function
  299. //
  300. // History:
  301. // jstamerj 980610 19:04:59: Created.
  302. //
  303. //-------------------------------------------------------------
  304. HRESULT CStoreDispatcher::CMailTransportCatBuildQueryParams::CallObject(
  305. CBinding& bBinding,
  306. IUnknown *punkObject)
  307. {
  308. HRESULT hrRes = S_OK;
  309. IMailTransportCategorize *pSink;
  310. TraceFunctEnterEx((LPARAM)this, "CStoreDispatcher::CMailTransportCatBuildQueryParams::CallObject");
  311. _ASSERT(m_dwEventType == SMTP_MAILTRANSPORT_CATEGORIZE_BUILDQUERY_EVENT);
  312. hrRes = punkObject->QueryInterface(
  313. IID_IMailTransportCategorize,
  314. (PVOID *)&pSink);
  315. if(FAILED(hrRes)) {
  316. ErrorTrace((LPARAM)this, "QI failed on sink, hr %08lx", hrRes);
  317. TraceFunctLeaveEx((LPARAM)this);
  318. return(hrRes);
  319. }
  320. DebugTrace((LPARAM)this, "Calling submission event on this sink");
  321. hrRes = pSink->BuildQuery(
  322. m_pContext->pICatParams,
  323. m_pContext->pICatItem);
  324. DebugTrace((LPARAM)this, "Sink returned hr %08lx", hrRes);
  325. //
  326. // This sink is not allowed to be async...
  327. //
  328. _ASSERT(hrRes != MAILTRANSPORT_S_PENDING);
  329. pSink->Release();
  330. TraceFunctLeaveEx((LPARAM)this);
  331. return(hrRes);
  332. }
  333. //+------------------------------------------------------------
  334. //
  335. // Function: CStoreDispatcher::CMailTransportCatBuildQueryParams::CallDefault
  336. //
  337. // Synopsis: The dispatcher will call this routine when it the default
  338. // sink processing priority is reached
  339. //
  340. // Arguments: NONE
  341. //
  342. // Returns:
  343. // S_OK: Success, continueing calling sinks
  344. // S_FALSE: Stop calling sinks
  345. //
  346. // History:
  347. // jstamerj 980611 14:15:43: Created.
  348. //
  349. //-------------------------------------------------------------
  350. HRESULT CStoreDispatcher::CMailTransportCatBuildQueryParams::CallDefault()
  351. {
  352. TraceFunctEnterEx((LPARAM)this, "CStoreDispatcher::CMailTransportCatBuildQueryParams::CallDefault");
  353. HRESULT hr;
  354. _ASSERT(m_dwEventType == SMTP_MAILTRANSPORT_CATEGORIZE_BUILDQUERY_EVENT);
  355. hr = (m_pContext->pfnDefault)(S_OK, m_pContext);
  356. TraceFunctLeaveEx((LPARAM)this);
  357. return hr;
  358. }
  359. //
  360. // CMailTransportCatBuildQueriesParams:
  361. //
  362. //+------------------------------------------------------------
  363. //
  364. // Function: CStoreDispatcher::CMailTransportCatBuildQueriesParams::CallObject
  365. //
  366. // Synopsis: Call the sink
  367. //
  368. // Arguments:
  369. // CBinding
  370. // punkObject
  371. //
  372. // Returns:
  373. // S_OK: Success
  374. // error from QI or sink function
  375. //
  376. // History:
  377. // jstamerj 980610 19:04:59: Created.
  378. //
  379. //-------------------------------------------------------------
  380. HRESULT CStoreDispatcher::CMailTransportCatBuildQueriesParams::CallObject(
  381. CBinding& bBinding,
  382. IUnknown *punkObject)
  383. {
  384. HRESULT hrRes = S_OK;
  385. IMailTransportCategorize *pSink;
  386. TraceFunctEnterEx((LPARAM)this, "CStoreDispatcher::CMailTransportCatBuildQueriesParams::CallObject");
  387. _ASSERT(m_dwEventType == SMTP_MAILTRANSPORT_CATEGORIZE_BUILDQUERIES_EVENT);
  388. hrRes = punkObject->QueryInterface(
  389. IID_IMailTransportCategorize,
  390. (PVOID *)&pSink);
  391. if(FAILED(hrRes)) {
  392. ErrorTrace((LPARAM)this, "QI failed on sink, hr %08lx", hrRes);
  393. TraceFunctLeaveEx((LPARAM)this);
  394. return(hrRes);
  395. }
  396. DebugTrace((LPARAM)this, "Calling submission event on this sink");
  397. hrRes = pSink->BuildQueries(
  398. m_pContext->pICatParams,
  399. m_pContext->dwcAddresses,
  400. m_pContext->rgpICatItems,
  401. m_pContext->pICatQueries);
  402. DebugTrace((LPARAM)this, "Sink returned hr %08lx", hrRes);
  403. //
  404. // This sink is not allowed to be async...
  405. //
  406. _ASSERT(hrRes != MAILTRANSPORT_S_PENDING);
  407. pSink->Release();
  408. TraceFunctLeaveEx((LPARAM)this);
  409. return(hrRes);
  410. }
  411. //+------------------------------------------------------------
  412. //
  413. // Function: CStoreDispatcher::CMailTransportCatBuildQueriesParams::CallDefault
  414. //
  415. // Synopsis: The dispatcher will call this routine when it the default
  416. // sink processing priority is reached
  417. //
  418. // Arguments: NONE
  419. //
  420. // Returns:
  421. // S_OK: Success, continueing calling sinks
  422. // S_FALSE: Stop calling sinks
  423. //
  424. // History:
  425. // jstamerj 980611 14:15:43: Created.
  426. //
  427. //-------------------------------------------------------------
  428. HRESULT CStoreDispatcher::CMailTransportCatBuildQueriesParams::CallDefault()
  429. {
  430. HRESULT hr;
  431. TraceFunctEnterEx((LPARAM)this, "CStoreDispatcher::CMailTransportCatBuildQueriesParams::CallDefault");
  432. _ASSERT(m_dwEventType == SMTP_MAILTRANSPORT_CATEGORIZE_BUILDQUERIES_EVENT);
  433. hr = (*m_pContext->pfnDefault) (S_OK, m_pContext);
  434. TraceFunctLeaveEx((LPARAM)this);
  435. return hr;
  436. }
  437. //
  438. // CMailTransportCatSendQueryParams:
  439. //
  440. //+------------------------------------------------------------
  441. //
  442. // Function: CStoreDispatcher::CMailTransportCatSendQueryParams::CallObject
  443. //
  444. // Synopsis: Call the sink
  445. //
  446. // Arguments:
  447. // CBinding
  448. // punkObject
  449. //
  450. // Returns:
  451. // S_OK: Success
  452. // error from QI or sink function
  453. //
  454. // History:
  455. // jstamerj 980610 19:04:59: Created.
  456. //
  457. //-------------------------------------------------------------
  458. HRESULT CStoreDispatcher::CMailTransportCatSendQueryParams::CallObject(
  459. CBinding& bBinding,
  460. IUnknown *punkObject)
  461. {
  462. HRESULT hrRes = S_OK;
  463. IMailTransportCategorize *pSink;
  464. TraceFunctEnterEx((LPARAM)this, "CStoreDispatcher::CMailTransportCatSendQueryParams::CallObject");
  465. _ASSERT(m_dwEventType == SMTP_MAILTRANSPORT_CATEGORIZE_SENDQUERY_EVENT);
  466. hrRes = punkObject->QueryInterface(
  467. IID_IMailTransportCategorize,
  468. (PVOID *)&pSink);
  469. if(FAILED(hrRes)) {
  470. ErrorTrace((LPARAM)this, "QI failed on sink, hr %08lx", hrRes);
  471. TraceFunctLeaveEx((LPARAM)this);
  472. return(hrRes);
  473. }
  474. //
  475. // Remember the sink so we can release this sink later if it
  476. // returns pending
  477. //
  478. _ASSERT(m_pIUnknownSink == NULL);
  479. m_pIUnknownSink = (IUnknown*)pSink;
  480. m_pIUnknownSink->AddRef();
  481. DebugTrace((LPARAM)this, "Calling submission event on this sink");
  482. hrRes = pSink->SendQuery(
  483. m_Context.pICatParams,
  484. m_Context.pICatQueries,
  485. m_Context.pICatAsyncContext,
  486. (LPVOID)&m_Context);
  487. DebugTrace((LPARAM)this, "Sink returned hr %08lx", hrRes);
  488. pSink->Release();
  489. //
  490. // SendQuery return values:
  491. // MAILTRANSPORT_S_PEDING: Will call (or already called)
  492. // ICategorizerAsyncContext.CompleteQuery with the result of
  493. // this lookup
  494. // S_OK: Will not call CompleteQuery, please continue
  495. // S_FALSE: Will not call CompleteQuery, please stop calling sinks
  496. // Everything else: Will not call CompleteQuery.
  497. //
  498. if(hrRes != MAILTRANSPORT_S_PENDING) {
  499. //
  500. // We completed synchronously, so release the sink
  501. //
  502. m_pIUnknownSink->Release();
  503. m_pIUnknownSink = NULL;
  504. }
  505. TraceFunctLeaveEx((LPARAM)this);
  506. return(hrRes);
  507. }
  508. //+------------------------------------------------------------
  509. //
  510. // Function: CStoreDispatcher::CMailTransportCatSendQueryParams::CallDefault
  511. //
  512. // Synopsis: The dispatcher will call this routine when it the default
  513. // sink processing priority is reached
  514. //
  515. // Arguments: NONE
  516. //
  517. // Returns:
  518. // S_OK: Success, continueing calling sinks
  519. // S_FALSE: Stop calling sinks
  520. //
  521. // History:
  522. // jstamerj 980611 14:15:43: Created.
  523. //
  524. //-------------------------------------------------------------
  525. HRESULT CStoreDispatcher::CMailTransportCatSendQueryParams::CallDefault()
  526. {
  527. HRESULT hr;
  528. TraceFunctEnterEx((LPARAM)this, "CStoreDispatcher::CMailTransportCatSendQueryParams::CallDefault");
  529. _ASSERT(m_dwEventType == SMTP_MAILTRANSPORT_CATEGORIZE_SENDQUERY_EVENT);
  530. hr = (*m_Context.pfnDefault) (S_OK, &m_Context);
  531. TraceFunctLeaveEx((LPARAM)this);
  532. return hr;
  533. }
  534. //+------------------------------------------------------------
  535. //
  536. // Function: CStoreDispatcher::CMailTransportCatSendQueryParams::CallCompletion
  537. //
  538. // Synopsis: The dispatcher will call this routine after all sinks
  539. // have been called
  540. //
  541. // Arguments:
  542. // hrStatus: Status server event sinks have returned
  543. //
  544. // Returns:
  545. // S_OK: Success
  546. //
  547. // History:
  548. // jstamerj 980611 14:17:51: Created.
  549. //
  550. //-------------------------------------------------------------
  551. HRESULT CStoreDispatcher::CMailTransportCatSendQueryParams::CallCompletion(
  552. HRESULT hrStatus)
  553. {
  554. HRESULT hr;
  555. TraceFunctEnterEx((LPARAM)this, "CStoreDispatcher::CMailTransportCatSendQueryParams::CallCompletion");
  556. _ASSERT(m_dwEventType == SMTP_MAILTRANSPORT_CATEGORIZE_SENDQUERY_EVENT);
  557. hr = (*m_Context.pfnCompletion) (hrStatus, &m_Context);
  558. CStoreBaseParams::CallCompletion(hrStatus);
  559. TraceFunctLeaveEx((LPARAM)this);
  560. return hr;
  561. }
  562. //
  563. // CMailTransportCatSortQueryResultParams:
  564. //
  565. //+------------------------------------------------------------
  566. //
  567. // Function: CStoreDispatcher::CMailTransportCatSortQueryResultParams::CallObject
  568. //
  569. // Synopsis: Call the sink
  570. //
  571. // Arguments:
  572. // CBinding
  573. // punkObject
  574. //
  575. // Returns:
  576. // S_OK: Success
  577. // error from QI or sink function
  578. //
  579. // History:
  580. // jstamerj 980610 19:04:59: Created.
  581. //
  582. //-------------------------------------------------------------
  583. HRESULT CStoreDispatcher::CMailTransportCatSortQueryResultParams::CallObject(
  584. CBinding& bBinding,
  585. IUnknown *punkObject)
  586. {
  587. HRESULT hrRes = S_OK;
  588. IMailTransportCategorize *pSink;
  589. TraceFunctEnterEx((LPARAM)this, "CStoreDispatcher::CMailTransportCatSortQueryResultParams::CallObject");
  590. _ASSERT(m_dwEventType == SMTP_MAILTRANSPORT_CATEGORIZE_SORTQUERYRESULT_EVENT);
  591. hrRes = punkObject->QueryInterface(
  592. IID_IMailTransportCategorize,
  593. (PVOID *)&pSink);
  594. if(FAILED(hrRes)) {
  595. ErrorTrace((LPARAM)this, "QI failed on sink, hr %08lx", hrRes);
  596. TraceFunctLeaveEx((LPARAM)this);
  597. return(hrRes);
  598. }
  599. DebugTrace((LPARAM)this, "Calling submission event on this sink");
  600. hrRes = pSink->SortQueryResult(
  601. m_pContext->pICatParams,
  602. m_pContext->hrResolutionStatus,
  603. m_pContext->dwcAddresses,
  604. m_pContext->rgpICatItems,
  605. m_pContext->dwcResults,
  606. m_pContext->rgpICatItemAttributes);
  607. DebugTrace((LPARAM)this, "Sink returned hr %08lx", hrRes);
  608. //
  609. // This sink is not allowed to be async...
  610. //
  611. _ASSERT(hrRes != MAILTRANSPORT_S_PENDING);
  612. pSink->Release();
  613. TraceFunctLeaveEx((LPARAM)this);
  614. return(hrRes);
  615. }
  616. //+------------------------------------------------------------
  617. //
  618. // Function: CStoreDispatcher::CMailTransportCatSortQueryResultParams::CallDefault
  619. //
  620. // Synopsis: The dispatcher will call this routine when it the default
  621. // sink processing priority is reached
  622. //
  623. // Arguments: NONE
  624. //
  625. // Returns:
  626. // S_OK: Success, continueing calling sinks
  627. // S_FALSE: Stop calling sinks
  628. //
  629. // History:
  630. // jstamerj 980611 14:15:43: Created.
  631. //
  632. //-------------------------------------------------------------
  633. HRESULT CStoreDispatcher::CMailTransportCatSortQueryResultParams::CallDefault()
  634. {
  635. HRESULT hr;
  636. TraceFunctEnterEx((LPARAM)this, "CStoreDispatcher::CMailTransportCatSortQueryResultParams::CallDefault");
  637. _ASSERT(m_dwEventType == SMTP_MAILTRANSPORT_CATEGORIZE_SORTQUERYRESULT_EVENT);
  638. hr = (*m_pContext->pfnDefault) (S_OK, m_pContext);
  639. TraceFunctLeaveEx((LPARAM)this);
  640. return hr;
  641. }
  642. //
  643. // CMailTransportCatProcessItemParams:
  644. //
  645. //+------------------------------------------------------------
  646. //
  647. // Function: CStoreDispatcher::CMailTransportCatProcessItemParams::CallObject
  648. //
  649. // Synopsis: Call the sink
  650. //
  651. // Arguments:
  652. // CBinding
  653. // punkObject
  654. //
  655. // Returns:
  656. // S_OK: Success
  657. // error from QI or sink function
  658. //
  659. // History:
  660. // jstamerj 980610 19:04:59: Created.
  661. //
  662. //-------------------------------------------------------------
  663. HRESULT CStoreDispatcher::CMailTransportCatProcessItemParams::CallObject(
  664. CBinding& bBinding,
  665. IUnknown *punkObject)
  666. {
  667. HRESULT hrRes = S_OK;
  668. IMailTransportCategorize *pSink;
  669. TraceFunctEnterEx((LPARAM)this, "CStoreDispatcher::CMailTransportCatProcessItemParams::CallObject");
  670. _ASSERT(m_dwEventType == SMTP_MAILTRANSPORT_CATEGORIZE_PROCESSITEM_EVENT);
  671. hrRes = punkObject->QueryInterface(
  672. IID_IMailTransportCategorize,
  673. (PVOID *)&pSink);
  674. if(FAILED(hrRes)) {
  675. ErrorTrace((LPARAM)this, "QI failed on sink, hr %08lx", hrRes);
  676. TraceFunctLeaveEx((LPARAM)this);
  677. return(hrRes);
  678. }
  679. DebugTrace((LPARAM)this, "Calling submission event on this sink");
  680. hrRes = pSink->ProcessItem(
  681. m_pContext->pICatParams,
  682. m_pContext->pICatItem);
  683. DebugTrace((LPARAM)this, "Sink returned hr %08lx", hrRes);
  684. //
  685. // This sink is not allowed to be async...
  686. //
  687. _ASSERT(hrRes != MAILTRANSPORT_S_PENDING);
  688. pSink->Release();
  689. TraceFunctLeaveEx((LPARAM)this);
  690. return(hrRes);
  691. }
  692. //+------------------------------------------------------------
  693. //
  694. // Function: CStoreDispatcher::CMailTransportCatProcessItemParams::CallDefault
  695. //
  696. // Synopsis: The dispatcher will call this routine when it the default
  697. // sink processing priority is reached
  698. //
  699. // Arguments: NONE
  700. //
  701. // Returns:
  702. // S_OK: Success, continueing calling sinks
  703. // S_FALSE: Stop calling sinks
  704. //
  705. // History:
  706. // jstamerj 980611 14:15:43: Created.
  707. //
  708. //-------------------------------------------------------------
  709. HRESULT CStoreDispatcher::CMailTransportCatProcessItemParams::CallDefault()
  710. {
  711. HRESULT hr;
  712. TraceFunctEnterEx((LPARAM)this, "CStoreDispatcher::CMailTransportCatProcessItemParams::CallDefault");
  713. _ASSERT(m_dwEventType == SMTP_MAILTRANSPORT_CATEGORIZE_PROCESSITEM_EVENT);
  714. hr = (*m_pContext->pfnDefault) (S_OK, m_pContext);
  715. TraceFunctLeaveEx((LPARAM)this);
  716. return hr;
  717. }
  718. //
  719. // CMailTransportCatExpandItemParams:
  720. //
  721. //+------------------------------------------------------------
  722. //
  723. // Function: CStoreDispatcher::CMailTransportCatExpandItemParams::CallObject
  724. //
  725. // Synopsis: Call the sink
  726. //
  727. // Arguments:
  728. // CBinding
  729. // punkObject
  730. //
  731. // Returns:
  732. // S_OK: Success
  733. // error from QI or sink function
  734. //
  735. // History:
  736. // jstamerj 980610 19:04:59: Created.
  737. //
  738. //-------------------------------------------------------------
  739. HRESULT CStoreDispatcher::CMailTransportCatExpandItemParams::CallObject(
  740. CBinding& bBinding,
  741. IUnknown *punkObject)
  742. {
  743. HRESULT hrRes = S_OK;
  744. IMailTransportCategorize *pSink;
  745. BOOL fAlreadyAsync;
  746. TraceFunctEnterEx((LPARAM)this, "CStoreDispatcher::CMailTransportCatExpandItemParams::CallObject");
  747. _ASSERT(m_dwEventType == SMTP_MAILTRANSPORT_CATEGORIZE_EXPANDITEM_EVENT);
  748. hrRes = punkObject->QueryInterface(
  749. IID_IMailTransportCategorize,
  750. (PVOID *)&pSink);
  751. if(FAILED(hrRes)) {
  752. ErrorTrace((LPARAM)this, "QI failed on sink, hr %08lx", hrRes);
  753. TraceFunctLeaveEx((LPARAM)this);
  754. return(hrRes);
  755. }
  756. //
  757. // Remember the sink so we can release this sink later if it
  758. // returns pending
  759. //
  760. _ASSERT(m_pIUnknownSink == NULL);
  761. m_pIUnknownSink = (IUnknown*)pSink;
  762. m_pIUnknownSink->AddRef();
  763. //
  764. // Since it is possible for this to return pending before we
  765. // analyze the return value, assume it will return pending
  766. // beforehand
  767. //
  768. fAlreadyAsync = m_fAsyncCompletion;
  769. m_fAsyncCompletion = TRUE;
  770. DebugTrace((LPARAM)this, "Calling expanditem event on this sink");
  771. hrRes = pSink->ExpandItem(
  772. m_Context.pICatParams,
  773. m_Context.pICatItem,
  774. m_pINotify,
  775. (PVOID)this);
  776. DebugTrace((LPARAM)this, "Sink returned hr %08lx", hrRes);
  777. //
  778. // If it actuall returned sync, restore m_fAsyncCompletion to its
  779. // old value
  780. //
  781. if(hrRes != MAILTRANSPORT_S_PENDING) {
  782. m_fAsyncCompletion = fAlreadyAsync;
  783. //
  784. // We completed synchronously, so release the sink
  785. //
  786. m_pIUnknownSink->Release();
  787. m_pIUnknownSink = NULL;
  788. }
  789. pSink->Release();
  790. TraceFunctLeaveEx((LPARAM)this);
  791. return(hrRes);
  792. }
  793. //+------------------------------------------------------------
  794. //
  795. // Function: CStoreDispatcher::CMailTransportCatExpandItemParams::CallDefault
  796. //
  797. // Synopsis: The dispatcher will call this routine when it the default
  798. // sink processing priority is reached
  799. //
  800. // Arguments: NONE
  801. //
  802. // Returns:
  803. // S_OK: Success, continueing calling sinks
  804. // S_FALSE: Stop calling sinks
  805. //
  806. // History:
  807. // jstamerj 980611 14:15:43: Created.
  808. //
  809. //-------------------------------------------------------------
  810. HRESULT CStoreDispatcher::CMailTransportCatExpandItemParams::CallDefault()
  811. {
  812. HRESULT hr;
  813. BOOL fAlreadyAsync;
  814. TraceFunctEnterEx((LPARAM)this, "CStoreDispatcher::CMailTransportCatExpandItemParams::CallDefault");
  815. _ASSERT(m_dwEventType == SMTP_MAILTRANSPORT_CATEGORIZE_EXPANDITEM_EVENT);
  816. //
  817. // Since it is possible for this to return pending before we
  818. // analyze the return value, assume it will return pending
  819. // beforehand
  820. //
  821. fAlreadyAsync = m_fAsyncCompletion;
  822. m_fAsyncCompletion = TRUE;
  823. hr = (*m_Context.pfnDefault) (S_OK, &m_Context);
  824. //
  825. // If it actuall returned sync, restore m_fAsyncCompletion to its
  826. // old value
  827. //
  828. if(hr != MAILTRANSPORT_S_PENDING)
  829. m_fAsyncCompletion = fAlreadyAsync;
  830. TraceFunctLeaveEx((LPARAM)this);
  831. return hr;
  832. }
  833. //+------------------------------------------------------------
  834. //
  835. // Function: CStoreDispatcher::CMailTransportCatExpandItemParams::CallCompletion
  836. //
  837. // Synopsis: The dispatcher will call this routine after all sinks
  838. // have been called
  839. //
  840. // Arguments:
  841. // hrStatus: Status server event sinks have returned
  842. //
  843. // Returns:
  844. // S_OK: Success
  845. // Or return value from supplied completion routine
  846. //
  847. // History:
  848. // jstamerj 980611 14:17:51: Created.
  849. //
  850. //-------------------------------------------------------------
  851. HRESULT CStoreDispatcher::CMailTransportCatExpandItemParams::CallCompletion(
  852. HRESULT hrStatus)
  853. {
  854. HRESULT hr = S_OK;
  855. TraceFunctEnterEx((LPARAM)this, "CStoreDispatcher::CMailTransportCatExpandItemParams::CallCompletion");
  856. _ASSERT(m_dwEventType == SMTP_MAILTRANSPORT_CATEGORIZE_EXPANDITEM_EVENT);
  857. //
  858. // The way ExpandItem works is the following:
  859. // If any sinks return MAILTRANSPORT_S_PENDING (including the default),
  860. // then TriggerServerEvent returns MAILTRANSPORT_S_PENDING, and
  861. // the supplied completion routine will be called.
  862. // Otherwise, TriggerServerEvent returns S_OK and no completion
  863. // routine is called
  864. //
  865. if(m_fAsyncCompletion)
  866. hr = (*m_Context.pfnCompletion) (hrStatus, &m_Context);
  867. CStoreBaseParams::CallCompletion(hrStatus);
  868. TraceFunctLeaveEx((LPARAM)this);
  869. return hr;
  870. }
  871. //
  872. // CMailTransportCatCompleteItemParams:
  873. //
  874. //+------------------------------------------------------------
  875. //
  876. // Function: CStoreDispatcher::CMailTransportCatCompleteItemParams::CallObject
  877. //
  878. // Synopsis: Call the sink
  879. //
  880. // Arguments:
  881. // CBinding
  882. // punkObject
  883. //
  884. // Returns:
  885. // S_OK: Success
  886. // error from QI or sink function
  887. //
  888. // History:
  889. // jstamerj 980610 19:04:59: Created.
  890. //
  891. //-------------------------------------------------------------
  892. HRESULT CStoreDispatcher::CMailTransportCatCompleteItemParams::CallObject(
  893. CBinding& bBinding,
  894. IUnknown *punkObject)
  895. {
  896. HRESULT hrRes = S_OK;
  897. IMailTransportCategorize *pSink;
  898. TraceFunctEnterEx((LPARAM)this, "CStoreDispatcher::CMailTransportCatCompleteItemParams::CallObject");
  899. _ASSERT(m_dwEventType == SMTP_MAILTRANSPORT_CATEGORIZE_COMPLETEITEM_EVENT);
  900. hrRes = punkObject->QueryInterface(
  901. IID_IMailTransportCategorize,
  902. (PVOID *)&pSink);
  903. if(FAILED(hrRes)) {
  904. ErrorTrace((LPARAM)this, "QI failed on sink, hr %08lx", hrRes);
  905. TraceFunctLeaveEx((LPARAM)this);
  906. return(hrRes);
  907. }
  908. DebugTrace((LPARAM)this, "Calling submission event on this sink");
  909. hrRes = pSink->CompleteItem(
  910. m_pContext->pICatParams,
  911. m_pContext->pICatItem);
  912. DebugTrace((LPARAM)this, "Sink returned hr %08lx", hrRes);
  913. //
  914. // This sink is not allowed to be async...
  915. //
  916. _ASSERT(hrRes != MAILTRANSPORT_S_PENDING);
  917. pSink->Release();
  918. TraceFunctLeaveEx((LPARAM)this);
  919. return(hrRes);
  920. }
  921. //+------------------------------------------------------------
  922. //
  923. // Function: CStoreDispatcher::CMailTransportCatCompleteItemParams::CallDefault
  924. //
  925. // Synopsis: The dispatcher will call this routine when it the default
  926. // sink processing priority is reached
  927. //
  928. // Arguments: NONE
  929. //
  930. // Returns:
  931. // S_OK: Success, continueing calling sinks
  932. // S_FALSE: Stop calling sinks
  933. //
  934. // History:
  935. // jstamerj 980611 14:15:43: Created.
  936. //
  937. //-------------------------------------------------------------
  938. HRESULT CStoreDispatcher::CMailTransportCatCompleteItemParams::CallDefault()
  939. {
  940. HRESULT hr;
  941. TraceFunctEnterEx((LPARAM)this, "CStoreDispatcher::CMailTransportCatCompleteItemParams::CallDefault");
  942. _ASSERT(m_dwEventType == SMTP_MAILTRANSPORT_CATEGORIZE_COMPLETEITEM_EVENT);
  943. hr = (*m_pContext->pfnDefault) (S_OK, m_pContext);
  944. TraceFunctLeaveEx((LPARAM)this);
  945. return hr;
  946. }