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.

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