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.

199 lines
5.5 KiB

  1. //
  2. // idstore.h -- This file contains class and function definitions for
  3. //
  4. // CEmailIDStore -- A pure virtual class that is used by the common
  5. // router code to store and retrieve email ID information. By making
  6. // this a pure virtual class, we facilitate multiple implementations
  7. // of this class.
  8. //
  9. // GetEmailIDStore -- Each implementation must provide this routine to
  10. // return a pointer to an uninitialized instance of a CEmailIDStore.
  11. //
  12. // ReleaseEmailIDStore -- Each implementation must provide this routine
  13. // to free up resources used by the instance of CEmailIDStore being
  14. // released.
  15. //
  16. // Created:
  17. // Dec 17, 1996 -- Milan Shah (milans)
  18. //
  19. // Changes:
  20. //
  21. #ifndef __IDSTORE_H__
  22. #define __IDSTORE_H__
  23. #include <windows.h>
  24. #include <transmem.h>
  25. #include "catdefs.h"
  26. #include "cattype.h"
  27. #include "smtpevent.h"
  28. //
  29. // A FNLIST_COMPLETION routine is called when all email ids in a list being
  30. // resolve asynchronously have been resolved.
  31. //
  32. typedef VOID (*LPFNLIST_COMPLETION)(VOID *pContext);
  33. typedef VOID (*LPSEARCHCOMPLETIONCOMPLETION)(
  34. LPVOID lpContext);
  35. typedef VOID (*PFN_DLEXPANSIONCOMPLETION)(
  36. HRESULT hrStatus,
  37. PVOID pContext);
  38. class CInsertionRequest;
  39. template <class T> class CEmailIDStore {
  40. public:
  41. //
  42. // Initialize the store.
  43. // If this fails, SMTPSVC will not start
  44. //
  45. virtual HRESULT Initialize(
  46. ICategorizerParametersEx *pICatParams,
  47. ISMTPServer *pISMTPServer) = 0;
  48. //
  49. // Create a new context for looking up a list of entries
  50. // asynchronously
  51. //
  52. virtual HRESULT InitializeResolveListContext(
  53. VOID *pUserContext,
  54. LPRESOLVE_LIST_CONTEXT pResolveListContext) = 0;
  55. //
  56. // Free the context allocated witht InitializeResolveListContext
  57. //
  58. virtual VOID FreeResolveListContext(
  59. LPRESOLVE_LIST_CONTEXT pResolveListContext) = 0;
  60. virtual HRESULT InsertInsertionRequest(
  61. LPRESOLVE_LIST_CONTEXT pResolveListContext,
  62. CInsertionRequest *pCRequest) = 0;
  63. //
  64. // Fetch an entry asynchronously. This function returns as soon as
  65. // the Lookup request has been queued.
  66. // Lookup the address contained in the CCatAddr object.
  67. // Upon completion, SetProperty routines will be called in the
  68. // CCatAddr object for returned properties followed by a call
  69. // to CCatAddr::HrCompletion
  70. //
  71. virtual HRESULT LookupEntryAsync(
  72. T *pCCatAddr,
  73. LPRESOLVE_LIST_CONTEXT pResolveListContext) = 0;
  74. //
  75. // Multi-Thread-UNSAFE cancel of pending resolves in the resolve list
  76. // context that have not yet been dispatched
  77. //
  78. virtual HRESULT CancelResolveList(
  79. LPRESOLVE_LIST_CONTEXT pResolveListContext,
  80. HRESULT hr) = 0;
  81. //
  82. // Cancel all outstanding lookup requests
  83. //
  84. virtual VOID CancelAllLookups() = 0;
  85. //
  86. // Paged DL's require repeated lookups with a "special" attribute
  87. // list (ie. "members;range=1000-*"). Because of this special
  88. // behavior, we have an interface function for it.
  89. //
  90. virtual HRESULT HrExpandPagedDlMembers(
  91. CCatAddr *pCCatAddr,
  92. LPRESOLVE_LIST_CONTEXT pListContext,
  93. CAT_ADDRESS_TYPE CAType,
  94. PFN_DLEXPANSIONCOMPLETION pfnCompletion,
  95. PVOID pContext) = 0;
  96. //
  97. // Similar to paged DLs, dynamic DLs require a special lookup
  98. // where every result found is a DL member. Rather than pass a
  99. // query string dirctly to ldapstor we have a special interface
  100. // function for Dynamic DLs
  101. //
  102. virtual HRESULT HrExpandDynamicDlMembers(
  103. CCatAddr *pCCatAddr,
  104. LPRESOLVE_LIST_CONTEXT pListContext,
  105. PFN_DLEXPANSIONCOMPLETION pfnCompletion,
  106. PVOID pContext) = 0;
  107. //
  108. // Users of this object should call GetInsertionContext before
  109. // calling LookupEntryAsync. ReleaseInsertionContext should be
  110. // called once for every GetInsertionContext.
  111. //
  112. virtual VOID GetInsertionContext(
  113. LPRESOLVE_LIST_CONTEXT pListContext) = 0;
  114. virtual VOID ReleaseInsertionContext(
  115. LPRESOLVE_LIST_CONTEXT pListContext) = 0;
  116. };
  117. //
  118. // Function to instantiate a new CEmailIDStore object.
  119. //
  120. template <class T> HRESULT GetEmailIDStore(
  121. CEmailIDStore<T> **ppStore);
  122. //
  123. // Function to release an instance of CEmailIDStore object.
  124. //
  125. template <class T> VOID ReleaseEmailIDStore(
  126. CEmailIDStore<T> *pStore);
  127. class CInsertionRequest
  128. {
  129. public:
  130. CInsertionRequest()
  131. {
  132. m_dwRefCount = 1;
  133. }
  134. virtual ~CInsertionRequest()
  135. {
  136. _ASSERT(m_dwRefCount == 0);
  137. }
  138. virtual DWORD AddRef()
  139. {
  140. return InterlockedIncrement((PLONG)&m_dwRefCount);
  141. }
  142. virtual DWORD Release()
  143. {
  144. DWORD dwRet;
  145. dwRet = InterlockedDecrement((PLONG)&m_dwRefCount);
  146. if(dwRet == 0)
  147. FinalRelease();
  148. return dwRet;
  149. }
  150. virtual HRESULT HrInsertSearches(
  151. DWORD dwcSearches) = 0;
  152. virtual DWORD GetMinimumRequiredSearches()
  153. {
  154. return 1;
  155. }
  156. virtual VOID NotifyDeQueue(
  157. HRESULT hr) = 0;
  158. virtual BOOL IsBatchable()
  159. {
  160. return TRUE;
  161. }
  162. LIST_ENTRY m_listentry_insertionrequest;
  163. protected:
  164. virtual VOID FinalRelease()
  165. {
  166. delete this;
  167. }
  168. LONG m_dwRefCount;
  169. };
  170. #endif // __IDSTORE_H__