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.

409 lines
12 KiB

  1. //+------------------------------------------------------------
  2. //
  3. // Copyright (C) 1998, Microsoft Corporation
  4. //
  5. // File: ccataddr.h
  6. //
  7. // Contents: Definition of the CCatAddr class
  8. //
  9. // Classes: CCatAddr
  10. //
  11. // Functions:
  12. //
  13. // History:
  14. // jstamerj 980324 19:08:13: Created.
  15. //
  16. //-------------------------------------------------------------
  17. #ifndef __CCATADDR_H__
  18. #define __CCATADDR_H__
  19. #include <transmem.h>
  20. #include <smtpinet.h>
  21. #include "smtpevent.h"
  22. #include "idstore.h"
  23. #include "mailmsg.h"
  24. #include "mailmsgprops.h"
  25. #include "cattype.h"
  26. #include "spinlock.h"
  27. #include "ccat.h"
  28. #include "icatitem.h"
  29. #include "icatlistresolve.h"
  30. typedef VOID (*PFN_EXPANDITEMCOMPLETION)(PVOID pContext);
  31. // CCatAddr: abstract base class
  32. // The basic idea is this object which will contain the address,
  33. // address type, properties on this address, and the completion
  34. // routine to call when all properties have been looked up. It is
  35. // the object that will be created by CAddressBook and passed to the
  36. // store for resolution.
  37. //
  38. class CCatAddr :
  39. public CICategorizerItemIMP
  40. {
  41. public:
  42. typedef enum _ADDROBJTYPE {
  43. OBJT_UNKNOWN,
  44. OBJT_USER,
  45. OBJT_DL
  46. } ADDROBJTYPE, *PADDROBJTYPE;
  47. //
  48. // Flags describing the locality of the orig address
  49. //
  50. #define LOCF_UNKNOWN 0x0000 // We haven't checked the locality yet
  51. #define LOCF_LOCALMAILBOX 0x0001 // The orig address is a local mailbox domain
  52. #define LOCF_LOCALDROP 0x0002 // The orig address is a local drop domain
  53. #define LOCF_REMOTE 0x0004 // The orig address is not local
  54. #define LOCF_ALIAS 0x0008 // The orig address is a local alias domain
  55. #define LOCF_UNKNOWNTYPE 0x0010 // Unknown due to the address type
  56. //
  57. // Flags that indicate the address should generally be treated as local
  58. //
  59. #define LOCFS_LOCAL (LOCF_LOCALMAILBOX | LOCF_LOCALDROP | \
  60. LOCF_UNKNOWNTYPE)
  61. CCatAddr(CICategorizerListResolveIMP *pCICatListResolveIMP);
  62. virtual ~CCatAddr();
  63. // Send our query to the store
  64. virtual HRESULT HrDispatchQuery();
  65. // Lookup routine called by the EmailIDStore
  66. virtual VOID LookupCompletion();
  67. // ProcessItem routines
  68. virtual HRESULT HrProcessItem();
  69. virtual HRESULT HrProcessItem_Default();
  70. // ExpandItem routines
  71. virtual HRESULT HrExpandItem();
  72. virtual HRESULT HrExpandItem_Default(
  73. PFN_EXPANDITEMCOMPLETION pfnCompletion,
  74. PVOID pContext) = 0;
  75. // CompleteItem routines
  76. virtual HRESULT HrCompleteItem();
  77. virtual HRESULT HrCompleteItem_Default() = 0;
  78. //
  79. // Storage and retreival procedures
  80. //
  81. virtual HRESULT HrGetOrigAddress(LPTSTR psz, DWORD dwcc, CAT_ADDRESS_TYPE *pType);
  82. virtual HRESULT GetSpecificOrigAddress(CAT_ADDRESS_TYPE CAType, LPTSTR psz, DWORD dwcc) = 0;
  83. virtual HRESULT HrGetLookupAddress(LPTSTR psz, DWORD dwcc, CAT_ADDRESS_TYPE *pType);
  84. virtual HRESULT HrAddAddresses(DWORD dwNumAddresses, CAT_ADDRESS_TYPE *rgCAType, LPTSTR *rgpsz) = 0;
  85. //
  86. // Property setting routines to be called before completion routine
  87. //
  88. virtual HRESULT AddForward(CAT_ADDRESS_TYPE CAType, LPTSTR szForwardingAddress) = 0;
  89. virtual HRESULT AddDLMember(CAT_ADDRESS_TYPE CAType, LPTSTR pszAddress) = 0;
  90. virtual HRESULT AddDynamicDLMember(
  91. ICategorizerItemAttributes *pICatItemAttr) = 0;
  92. //
  93. // We will not know that a particular CCatAddr is the first in a
  94. // loop until after ProcessItem/ExpandItem/CompleteItem have all
  95. // finished -- so this function may be called after everything
  96. // has happened to this CCatAddr
  97. //
  98. virtual HRESULT HandleLoopHead()
  99. {
  100. return E_NOTIMPL;
  101. }
  102. //
  103. // The default implementation of AddNewAddress will call this if
  104. // HrValidateAddress fails
  105. //
  106. virtual HRESULT HrHandleInvalidAddress()
  107. {
  108. return S_OK;
  109. }
  110. //
  111. // For store assisted DL expansion (paged or dynamic), it will
  112. // call this function to indicate a particular attribute should be
  113. // expanded in an ICatItemAttributes
  114. //
  115. virtual HRESULT HrExpandAttribute(
  116. ICategorizerItemAttributes *pICatItemAttr,
  117. CAT_ADDRESS_TYPE CAType,
  118. LPSTR pszAttributeName,
  119. PDWORD pdwNumberMembers)
  120. {
  121. return E_NOTIMPL;
  122. }
  123. //
  124. // Check and see if this object needs to be resolved or not (based
  125. // on DsUseCat flags)
  126. // Returns S_OK if the address should be resolved
  127. // Returns S_FALSE if the address should NOT be resolved
  128. //
  129. virtual HRESULT HrNeedsResolveing() = 0;
  130. //
  131. // Resolve this object if necessary (based on DsUseCat flags)
  132. //
  133. virtual HRESULT HrResolveIfNecessary();
  134. //
  135. // Build a query for this object
  136. //
  137. virtual HRESULT HrTriggerBuildQuery();
  138. protected:
  139. HRESULT HrValidateAddress(CAT_ADDRESS_TYPE CAType, LPTSTR pszAddress);
  140. HRESULT HrGetAddressLocFlags(LPTSTR szAddress,
  141. CAT_ADDRESS_TYPE CAType,
  142. DWORD *pdwlocflags,
  143. DWORD *pdwDomainOffset);
  144. DWORD DwGetOrigAddressLocFlags();
  145. HRESULT HrIsOrigAddressLocal(BOOL *pfLocal);
  146. HRESULT HrIsOrigAddressLocalMailbox(BOOL *pfLocal);
  147. HRESULT HrGetSMTPDomainLocFlags(LPTSTR pszDomain,
  148. DWORD *pdwlocflags);
  149. HRESULT HrGetSMTPDomainFlags(LPTSTR pszDomain, PDWORD pdwFlags);
  150. HRESULT HrSwitchToAliasedDomain(CAT_ADDRESS_TYPE CAType,
  151. LPTSTR szSMTPAddress,
  152. DWORD dwcch);
  153. LPTSTR GetNewAddress(CAT_ADDRESS_TYPE CAType);
  154. HRESULT CheckAncestorsForDuplicate(
  155. CAT_ADDRESS_TYPE CAType,
  156. LPTSTR pszAddress,
  157. BOOL fCheckSelf,
  158. CCatAddr **ppCCatAddrDup);
  159. HRESULT CheckAncestorsForDuplicate(
  160. DWORD dwNumAddresses,
  161. CAT_ADDRESS_TYPE *rgCAType,
  162. LPTSTR *rgpsz,
  163. BOOL fCheckSelf,
  164. CCatAddr **ppCCatAddrDup);
  165. HRESULT CheckForDuplicateCCatAddr(
  166. DWORD dwNumAddresses,
  167. CAT_ADDRESS_TYPE *rgCAType,
  168. LPTSTR *rgpsz);
  169. HRESULT HrAddNewAddressesFromICatItemAttr();
  170. static HRESULT HrBuildQueryDefault(
  171. HRESULT HrStatus,
  172. PVOID pContext);
  173. HRESULT HrComposeLdapFilter();
  174. HRESULT HrComposeLdapFilterForType(
  175. DWORD dwSearchAttribute,
  176. DWORD dwSearchFilter,
  177. LPTSTR pszAddress);
  178. HRESULT HrComposeLdapFilterFromPair(
  179. LPTSTR pszSearchAttribute,
  180. LPTSTR pszAttributeValue);
  181. HRESULT HrFormatAttributeValue(
  182. LPTSTR pszAddress,
  183. DWORD dwSearchFilter,
  184. LPTSTR pszAttributeValue);
  185. static HRESULT HrConvertDNtoRDN(
  186. LPTSTR pszDN,
  187. LPTSTR pszRDNAttribute,
  188. LPTSTR pszRDN);
  189. HRESULT HrEscapeFilterString(
  190. LPSTR pszSrc,
  191. DWORD dwcchDest,
  192. LPSTR pszDest);
  193. //
  194. // Get the parent CCatAddr (if any)
  195. //
  196. HRESULT GetParentAddr(
  197. CCatAddr **ppParent)
  198. {
  199. HRESULT hr;
  200. ICategorizerItem *pItem;
  201. //
  202. // Get the parent ICatItem
  203. //
  204. hr = GetICategorizerItem(
  205. ICATEGORIZERITEM_PARENT,
  206. &pItem);
  207. if(FAILED(hr))
  208. return hr;
  209. //
  210. // Get CCatAddr from ICatItem
  211. //
  212. hr = pItem->GetPVoid(
  213. m_pCICatListResolve->GetCCategorizer()->GetICatItemCCatAddrPropId(),
  214. (PVOID *) ppParent);
  215. //
  216. // Addref this CCatAddr for our caller and release the ICatItem parent
  217. // interface
  218. //
  219. if(SUCCEEDED(hr)) {
  220. (*ppParent)->AddRef();
  221. }
  222. pItem->Release();
  223. return hr;
  224. }
  225. HRESULT SetMailMsgCatStatus(
  226. IMailMsgProperties *pIMailMsgProps,
  227. HRESULT hrStatus)
  228. {
  229. return m_pCICatListResolve->SetMailMsgCatStatus(
  230. pIMailMsgProps,
  231. hrStatus);
  232. }
  233. HRESULT SetListResolveStatus(
  234. HRESULT hrStatus)
  235. {
  236. return m_pCICatListResolve->SetListResolveStatus(
  237. hrStatus);
  238. }
  239. HRESULT GetListResolveStatus()
  240. {
  241. return m_pCICatListResolve->GetListResolveStatus();
  242. }
  243. //
  244. // Inline methods to retrieve ICategorizerItem Props
  245. //
  246. HRESULT GetItemStatus()
  247. {
  248. HRESULT hr;
  249. _VERIFY(SUCCEEDED(GetHRESULT(
  250. ICATEGORIZERITEM_HRSTATUS,
  251. &hr)));
  252. return hr;
  253. }
  254. HRESULT SetRecipientStatus(HRESULT hr)
  255. {
  256. return PutHRESULT(
  257. ICATEGORIZERITEM_HRSTATUS,
  258. hr);
  259. }
  260. HRESULT SetRecipientNDRCode(HRESULT hr)
  261. {
  262. return PutHRESULT(
  263. ICATEGORIZERITEM_HRNDRREASON,
  264. hr);
  265. }
  266. CCategorizer *GetCCategorizer()
  267. {
  268. return m_pCICatListResolve->GetCCategorizer();
  269. }
  270. ICategorizerParameters *GetICatParams()
  271. {
  272. return GetCCategorizer()->GetICatParams();
  273. }
  274. ISMTPServer *GetISMTPServer()
  275. {
  276. return m_pCICatListResolve->GetISMTPServer();
  277. }
  278. ISMTPServerEx *GetISMTPServerEx()
  279. {
  280. return m_pCICatListResolve->GetISMTPServerEx();
  281. }
  282. LPRESOLVE_LIST_CONTEXT GetResolveListContext()
  283. {
  284. return m_pCICatListResolve->GetResolveListContext();
  285. }
  286. DWORD GetCatFlags()
  287. {
  288. return GetCCategorizer()->GetCatFlags();
  289. }
  290. VOID SetSenderResolved(BOOL fResolved)
  291. {
  292. m_pCICatListResolve->SetSenderResolved(fResolved);
  293. }
  294. VOID SetResolvingSender(BOOL fResolving)
  295. {
  296. m_pCICatListResolve->SetResolvingSender(fResolving);
  297. }
  298. BOOL IsSenderResolveFinished()
  299. {
  300. return m_pCICatListResolve->IsSenderResolveFinished();
  301. }
  302. PCATPERFBLOCK GetPerfBlock()
  303. {
  304. return m_pCICatListResolve->GetPerfBlock();
  305. }
  306. VOID IncPendingLookups()
  307. {
  308. m_pCICatListResolve->IncPendingLookups();
  309. }
  310. VOID DecrPendingLookups()
  311. {
  312. m_pCICatListResolve->DecrPendingLookups();
  313. }
  314. VOID GetStoreInsertionContext()
  315. {
  316. m_pCICatListResolve->GetStoreInsertionContext();
  317. }
  318. VOID ReleaseStoreInsertionContext()
  319. {
  320. m_pCICatListResolve->ReleaseStoreInsertionContext();
  321. }
  322. HRESULT HrInsertInsertionRequest(
  323. CInsertionRequest *pCInsertionRequest)
  324. {
  325. return m_pCICatListResolve->HrInsertInsertionRequest(
  326. pCInsertionRequest);
  327. }
  328. // Member data
  329. CICategorizerListResolveIMP *m_pCICatListResolve;
  330. DWORD m_dwlocFlags;
  331. DWORD m_dwDomainOffset;
  332. LIST_ENTRY m_listentry;
  333. //
  334. // Any of these flags set indicates that the domain is local and
  335. // addresses in this domain should be found in the DS
  336. // (these are flags returned form IAdvQueueDomainType)
  337. //
  338. #define DOMAIN_LOCAL_FLAGS (DOMAIN_INFO_LOCAL_MAILBOX)
  339. friend HRESULT MailTransport_Default_ProcessItem(
  340. HRESULT hrStatus,
  341. PVOID pContext);
  342. friend HRESULT MailTransport_Default_ExpandItem(
  343. HRESULT hrStatus,
  344. PVOID pContext);
  345. friend VOID MailTransport_DefaultCompletion_ExpandItem(
  346. PVOID pContext);
  347. friend HRESULT MailTransport_Completion_ExpandItem(
  348. HRESULT hrStatus,
  349. PVOID pContext);
  350. friend HRESULT MailTransport_Default_CompleteItem(
  351. HRESULT hrStatus,
  352. PVOID pContext);
  353. friend class CSinkInsertionRequest;
  354. };
  355. #endif // __CCATADDDR_H__