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.

568 lines
34 KiB

  1. // --------------------------------------------------------------------------------
  2. // ContainX.h
  3. // Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  4. // --------------------------------------------------------------------------------
  5. #ifndef __CONTAINX_H
  6. #define __CONTAINX_H
  7. // ---------------------------------------------------------------------------------------
  8. // IID_CMimePropertyTable - {E31B34B2-8DA0-11d0-826A-00C04FD85AB4}
  9. // ---------------------------------------------------------------------------------------
  10. DEFINE_GUID(IID_CMimePropertyContainer, 0xe31b34b2, 0x8da0, 0x11d0, 0x82, 0x6a, 0x0, 0xc0, 0x4f, 0xd8, 0x5a, 0xb4);
  11. // ---------------------------------------------------------------------------------------
  12. // Depends
  13. // ---------------------------------------------------------------------------------------
  14. #include "variantx.h"
  15. #include "addressx.h"
  16. // ---------------------------------------------------------------------------------------
  17. // Forward Decls
  18. // ---------------------------------------------------------------------------------------
  19. class CInternetStream;
  20. class CStreamLockBytes;
  21. typedef struct tagWRAPTEXTINFO *LPWRAPTEXTINFO;
  22. typedef struct tagRESOLVEURLINFO *LPRESOLVEURLINFO;
  23. typedef struct tagPROPERTY *LPPROPERTY;
  24. CODEPAGEID MimeOleGetWindowsCPEx(LPINETCSETINFO pCharset);
  25. // --------------------------------------------------------------------------------
  26. // Hash Table Stats
  27. // --------------------------------------------------------------------------------
  28. #ifdef DEBUG
  29. extern DWORD g_cSetPidLookups;
  30. extern DWORD g_cHashLookups;
  31. extern DWORD g_cHashInserts;
  32. extern DWORD g_cHashCollides;
  33. #endif
  34. // --------------------------------------------------------------------------------
  35. // HHEADERROW MACROS
  36. // --------------------------------------------------------------------------------
  37. #define HROWINDEX(_hrow) (ULONG)HIWORD(_hrow)
  38. #define HROWTICK(_hrow) (WORD)LOWORD(_hrow)
  39. #define HROWMAKE(_index) (HHEADERROW)(MAKELPARAM(m_wTag, _index))
  40. #define PRowFromHRow(_hrow) (m_rHdrTable.prgpRow[HROWINDEX(_hrow)])
  41. // --------------------------------------------------------------------------------
  42. // HADDRESS MACROS
  43. // --------------------------------------------------------------------------------
  44. #define HADDRESSINDEX(_hadr) (ULONG)HIWORD(_hadr)
  45. #define HADDRESSTICK(_hadr) (WORD)LOWORD(_hadr)
  46. #define HADDRESSMAKE(_index) (HADDRESS)(MAKELPARAM(m_wTag, _index))
  47. #define HADDRESSGET(_hadr) (m_rAdrTable.prgpAdr[HADDRESSINDEX(_hadr)])
  48. // --------------------------------------------------------------------------------
  49. // ADDRESSGROUP
  50. // --------------------------------------------------------------------------------
  51. typedef struct tagADDRESSGROUP {
  52. DWORD cAdrs; // Number of addresses lin list
  53. LPMIMEADDRESS pHead; // Head Address props
  54. LPMIMEADDRESS pTail; // Tail Address props
  55. LPPROPERTY pNext; // Next Address Group
  56. LPPROPERTY pPrev; // Previous Address Group
  57. BOOL fDirty; // Dirty ?
  58. } ADDRESSGROUP, *LPADDRESSGROUP;
  59. // --------------------------------------------------------------------------------
  60. // ADDRESSTABLE
  61. // --------------------------------------------------------------------------------
  62. typedef struct tagADDRESSTABLE {
  63. LPPROPERTY pHead; // Head Address Group
  64. LPPROPERTY pTail; // Tail Address Group
  65. ULONG cEmpty; // Number of empty cells in prgAddr
  66. ULONG cAdrs; // Count of addresses
  67. ULONG cAlloc; // Number of items allocated in prgAddr
  68. LPMIMEADDRESS *prgpAdr; // Array of addresses
  69. } ADDRESSTABLE, *LPADDRESSTABLE;
  70. // ---------------------------------------------------------------------------------------
  71. // Container States
  72. // ---------------------------------------------------------------------------------------
  73. #define COSTATE_DIRTY FLAG01 // The container is dirty
  74. #define COSTATE_CSETTAGGED FLAG02 // The object is tagged with a charset
  75. #define COSTATE_1522CSETTAG FLAG03 // I am using an rfc1522 charset as the default
  76. #define COSTATE_HANDSONSTORAGE FLAG04 // I am holding a stream that I don't own
  77. #define COSTATE_RFC822NEWS FLAG05 // I am a message/rfc822 news message
  78. // --------------------------------------------------------------------------------
  79. // Property States
  80. // --------------------------------------------------------------------------------
  81. #define PRSTATE_ALLOCATED FLAG02 // m_pbBlob has been allocated, free it
  82. #define PRSTATE_HASDATA FLAG03 // The value has had data set into it
  83. #define PRSTATE_DIRTY FLAG06 // Charset change, data change
  84. #define PRSTATE_PARENT FLAG07 // This prop is the parent of a multi-value prop
  85. #define PRSTATE_RFC1522 FLAG08 // The data is encoded in rfc1522
  86. #define PRSTATE_EXIST_BEFORE_LOAD FLAG09 // The property existed before ::Load started
  87. #define PRSTATE_USERSETROWNUM FLAG10 // The user set the row number of this property
  88. #define PRSTATE_NEEDPARSE FLAG11 // The property contains address data, but has not been parsed into a groups
  89. #define PRSTATE_SAVENOENCODE FLAG12 // Don't encode or change the property data on save
  90. // --------------------------------------------------------------------------------
  91. // Number of Buckets in the Mime Property Container Hash Table
  92. // --------------------------------------------------------------------------------
  93. #define CBUCKETS 25
  94. // --------------------------------------------------------------------------------
  95. // PROPERTY
  96. // --------------------------------------------------------------------------------
  97. typedef struct tagPROPERTY {
  98. MIMEVARIANT rValue; // Property Value
  99. LPINETCSETINFO pCharset; // Character Set Information
  100. ENCODINGTYPE ietValue; // State of this variable (IET_DECODED or IET_ENCODED)
  101. LPBYTE pbBlob; // Data Blob
  102. ULONG cbBlob; // Amount of valid date in m_pbBlob
  103. ULONG cbAlloc; // Sizeof m_pbBlob
  104. BYTE rgbScratch[170]; // Buffer to use if data fits
  105. HHEADERROW hRow; // Handle to the header row
  106. LPPROPSYMBOL pSymbol; // Property Symbol
  107. DWORD dwState; // PDS_xxx
  108. LPPROPERTY pNextHash; // Next Hash Value
  109. LPPROPERTY pNextValue; // Next Property
  110. LPPROPERTY pTailValue; // Tail data item (only for PRSTATE_PARENT) properties
  111. DWORD dwRowNumber; // Header Name to find
  112. ULONG cboffStart; // Index into pStream where Header Starts (From: xxxx)
  113. ULONG cboffColon; // Index into pStream of the Header Colon
  114. ULONG cboffEnd; // Index into pStream where the Header Ends
  115. LPADDRESSGROUP pGroup; // Head address if MPF_ADDRESS group
  116. } PROPERTY;
  117. // ---------------------------------------------------------------------------------------
  118. // PSZDEFPRPOSTRINGA - Derefs rStringA.pszVal or uses _pszDefault if not a valid string
  119. // ---------------------------------------------------------------------------------------
  120. #define PSZDEFPROPSTRINGA(_pProperty, _pszDefault) \
  121. (((_pProperty) && ISSTRINGA(&(_pProperty)->rValue)) ? (_pProperty)->rValue.rStringA.pszVal : _pszDefault)
  122. // --------------------------------------------------------------------------------
  123. // HEADERTABLE
  124. // --------------------------------------------------------------------------------
  125. typedef struct tagHEADERTABLE {
  126. ULONG cRows; // Number of lines in the header
  127. ULONG cEmpty; // Number of empty (deleted) entries
  128. ULONG cAlloc; // Number of items allocated in prgLine
  129. LPPROPERTY *prgpRow; // Array of header rows
  130. } HEADERTABLE, *LPHEADERTABLE;
  131. // --------------------------------------------------------------------------------
  132. // ROWINDEX
  133. // --------------------------------------------------------------------------------
  134. typedef struct tagROWINDEX {
  135. HHEADERROW hRow; // Handle to the header row
  136. DWORD dwWeight; // Position Weigth used to determine save order
  137. BOOL fSaved; // Saved Yet?
  138. } ROWINDEX, *LPROWINDEX;
  139. // --------------------------------------------------------------------------------
  140. // ENCODINGTABLE
  141. // --------------------------------------------------------------------------------
  142. typedef struct tagENCODINGTABLE {
  143. LPCSTR pszEncoding; // Encoding Name (i.e. base64)
  144. ENCODINGTYPE ietEncoding; // Encoding type
  145. } ENCODINGTABLE;
  146. // --------------------------------------------------------------------------------
  147. // RESOLVEURLINFO
  148. // --------------------------------------------------------------------------------
  149. typedef struct tagRESOLVEURLINFO {
  150. LPCSTR pszInheritBase; // An Inherited base from multipart/realted
  151. LPCSTR pszBase; // URL Base
  152. LPCSTR pszURL; // Absolute or Relative URL
  153. BOOL fIsCID; // Is pszURL a CID:<something>
  154. } RESOLVEURLINFO, *LPRESOLVEURLINFO;
  155. // --------------------------------------------------------------------------------
  156. // FINDPROPERTY Information
  157. // --------------------------------------------------------------------------------
  158. typedef struct tagFINDPROPERTY {
  159. LPCSTR pszPrefix; // Name Prefix to Find
  160. ULONG cchPrefix; // Length of prefix
  161. LPCSTR pszName; // Name of property to find par:xxx:
  162. ULONG cchName; // Length of pszName
  163. DWORD wHashIndex; // Current search bucket
  164. LPPROPERTY pProperty; // Current property being searched
  165. } FINDPROPERTY, *LPFINDPROPERTY;
  166. // --------------------------------------------------------------------------------
  167. // HEADOPTIONS
  168. // --------------------------------------------------------------------------------
  169. typedef struct tagHEADOPTIONS {
  170. LPINETCSETINFO pDefaultCharset; // Current character set for this message
  171. ULONG cbMaxLine; // Max Line length
  172. BOOL fAllow8bit; // Use rfc1522 encoding
  173. MIMESAVETYPE savetype; // Save as SAVE_RFC1521 or SAVE_RFC822
  174. BOOL fNoDefCntType; // Don't default content-type to text/plain on save
  175. RELOADTYPE ReloadType; // How the the root header be treated on a reload
  176. } HEADOPTIONS, *LPHEADOPTIONS;
  177. // --------------------------------------------------------------------------------
  178. // Global Default Header Options
  179. // --------------------------------------------------------------------------------
  180. extern const HEADOPTIONS g_rDefHeadOptions;
  181. extern const ENCODINGTABLE g_rgEncoding[];
  182. // --------------------------------------------------------------------------------
  183. // TRIGGERTYPE
  184. // --------------------------------------------------------------------------------
  185. typedef DWORD TRIGGERTYPE; // Trigger Type
  186. #define IST_DELETEPROP FLAG01 // Property is being deleted
  187. #define IST_POSTSETPROP FLAG02 // Before _HrSetPropertyValue
  188. #define IST_POSTGETPROP FLAG03 // Before _HrGetPropertyValue
  189. #define IST_GETDEFAULT FLAG04 // Property was not found, get the default
  190. #define IST_VARIANT_TO_STRINGA FLAG05 // MVT_VARIANT -> MVT_STRINGA
  191. #define IST_VARIANT_TO_STRINGW FLAG06 // MVT_VARIANT -> MVT_STRINGW
  192. #define IST_VARIANT_TO_VARIANT FLAG07 // MVT_VARIANT -> MVT_VARIANT
  193. #define IST_STRINGA_TO_VARIANT FLAG08 // MVT_STRINGA -> MVT_VARIANT
  194. #define IST_STRINGW_TO_VARIANT FLAG09 // MVT_STRINGW -> MVT_VARIANT
  195. #define IST_VARIANTCONVERT (IST_VARIANT_TO_STRINGA | IST_VARIANT_TO_STRINGW | IST_VARIANT_TO_VARIANT | IST_VARIANT_TO_VARIANT | IST_STRINGA_TO_VARIANT | IST_STRINGW_TO_VARIANT)
  196. // --------------------------------------------------------------------------------
  197. // TRIGGERCALL
  198. // --------------------------------------------------------------------------------
  199. typedef struct tagTRIGGERCALL {
  200. LPPROPSYMBOL pSymbol; // Property Symbol that generated the dispatch
  201. TRIGGERTYPE tyTrigger; // Reason or type of dispatch
  202. } TRIGGERCALL, *LPTRIGGERCALL;
  203. // --------------------------------------------------------------------------------
  204. // TRIGGERCALLSTACK
  205. // --------------------------------------------------------------------------------
  206. #define CTSTACKSIZE 5
  207. typedef struct tagTRIGGERCALLSTACK {
  208. WORD cCalls; // Number of dispatch calls on the stack
  209. TRIGGERCALL rgStack[CTSTACKSIZE]; // Dispatch Call Stack
  210. } TRIGGERCALLSTACK, *LPTRIGGERCALLSTACK;
  211. // --------------------------------------------------------------------------------
  212. // DECLARE_TRIGGER Macro
  213. // --------------------------------------------------------------------------------
  214. #define DECLARE_TRIGGER(_pfnTrigger) \
  215. static HRESULT _pfnTrigger(LPCONTAINER, TRIGGERTYPE, DWORD, LPMIMEVARIANT, LPMIMEVARIANT)
  216. // --------------------------------------------------------------------------------
  217. // ISTRIGGERED - Does the symbol have an associated trigger
  218. // --------------------------------------------------------------------------------
  219. #define ISTRIGGERED(_pSymbol, _tyTrigger) \
  220. (NULL != (_pSymbol)->pTrigger && ISFLAGSET((_pSymbol)->pTrigger->dwTypes, _tyTrigger) && NULL != (_pSymbol)->pTrigger->pfnTrigger)
  221. // --------------------------------------------------------------------------------
  222. // PFNSYMBOLTRIGGER
  223. // --------------------------------------------------------------------------------
  224. typedef HRESULT (APIENTRY *PFNSYMBOLTRIGGER)(LPCONTAINER, TRIGGERTYPE, DWORD, LPMIMEVARIANT, LPMIMEVARIANT);
  225. // --------------------------------------------------------------------------------
  226. // CALLTRIGGER - Executes a Trigger Based on a Symbol
  227. // --------------------------------------------------------------------------------
  228. #define CALLTRIGGER(_pSymbol, _pContainer, _tyTrigger, _dwFlags, _pSource, _pDest) \
  229. (*(_pSymbol)->pTrigger->pfnTrigger)(_pContainer, _tyTrigger, _dwFlags, _pSource, _pDest)
  230. // --------------------------------------------------------------------------------
  231. // CMimePropertyContainer
  232. // --------------------------------------------------------------------------------
  233. class CMimePropertyContainer : public IMimePropertySet,
  234. public IMimeHeaderTable,
  235. public IMimeAddressTableW
  236. {
  237. public:
  238. // ----------------------------------------------------------------------------
  239. // CMimePropertyContainer
  240. // ----------------------------------------------------------------------------
  241. CMimePropertyContainer(void);
  242. ~CMimePropertyContainer(void);
  243. // ---------------------------------------------------------------------------
  244. // IUnknown members
  245. // ---------------------------------------------------------------------------
  246. STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
  247. STDMETHODIMP_(ULONG) AddRef(void);
  248. STDMETHODIMP_(ULONG) Release(void);
  249. // ---------------------------------------------------------------------------
  250. // IPersistStreamInit members
  251. // ---------------------------------------------------------------------------
  252. STDMETHODIMP GetClassID(CLSID *pClassID);
  253. STDMETHODIMP GetSizeMax(ULARGE_INTEGER* pcbSize);
  254. STDMETHODIMP InitNew(void);
  255. STDMETHODIMP IsDirty(void);
  256. STDMETHODIMP Load(LPSTREAM pStream);
  257. STDMETHODIMP Save(LPSTREAM pStream, BOOL fClearDirty);
  258. // ---------------------------------------------------------------------------
  259. // IMimePropertySet members
  260. // ---------------------------------------------------------------------------
  261. STDMETHODIMP AppendProp(LPCSTR pszName, DWORD dwFlags, LPPROPVARIANT pValue);
  262. STDMETHODIMP DeleteProp(LPCSTR pszName);
  263. STDMETHODIMP CopyProps(ULONG cNames, LPCSTR *prgszName, IMimePropertySet *pPropertySet);
  264. STDMETHODIMP MoveProps(ULONG cNames, LPCSTR *prgszName, IMimePropertySet *pPropertySet);
  265. STDMETHODIMP DeleteExcept(ULONG cNames, LPCSTR *prgszName);
  266. STDMETHODIMP QueryProp(LPCSTR pszName, LPCSTR pszCriteria, boolean fSubString, boolean fCaseSensitive);
  267. STDMETHODIMP GetCharset(LPHCHARSET phCharset);
  268. STDMETHODIMP SetCharset(HCHARSET hCharset, CSETAPPLYTYPE applytype);
  269. STDMETHODIMP GetParameters(LPCSTR pszName, ULONG *pcParams, LPMIMEPARAMINFO *pprgParam);
  270. STDMETHODIMP Clone(IMimePropertySet **ppPropertySet);
  271. STDMETHODIMP SetOption(const TYPEDID oid, LPCPROPVARIANT pValue);
  272. STDMETHODIMP GetOption(const TYPEDID oid, LPPROPVARIANT pValue);
  273. STDMETHODIMP BindToObject(REFIID riid, void **ppvObject);
  274. STDMETHODIMP GetPropInfo(LPCSTR pszName, LPMIMEPROPINFO pInfo);
  275. STDMETHODIMP SetPropInfo(LPCSTR pszName, LPCMIMEPROPINFO pInfo);
  276. STDMETHODIMP EnumProps(DWORD dwFlags, IMimeEnumProperties **ppEnum);
  277. STDMETHODIMP IsContentType(LPCSTR pszCntType, LPCSTR pszSubType);
  278. HRESULT IsContentTypeW(LPCWSTR pszPriType, LPCWSTR pszSubType);
  279. // ---------------------------------------------------------------------------
  280. // Overloaded IMimePropertySet members
  281. // ---------------------------------------------------------------------------
  282. HRESULT AppendProp(LPPROPSYMBOL pSymbol, DWORD dwFlags, LPMIMEVARIANT pValue);
  283. HRESULT DeleteProp(LPPROPSYMBOL pSymbol);
  284. HRESULT QueryProp(LPPROPSYMBOL pSymbol, LPCSTR pszCriteria, boolean fSubString, boolean fCaseSensitive);
  285. HRESULT Clone(LPCONTAINER *ppContainer);
  286. // ---------------------------------------------------------------------------
  287. // Overloaded GetProp
  288. // ---------------------------------------------------------------------------
  289. STDMETHODIMP GetProp(LPCSTR pszName, DWORD dwFlags, LPPROPVARIANT pValue); /* IMimePropertySet */
  290. HRESULT GetProp(LPCSTR pszName, LPSTR *ppszData);
  291. HRESULT GetProp(LPPROPSYMBOL pSymbol, LPSTR *ppszData);
  292. HRESULT GetProp(LPPROPSYMBOL pSymbol, DWORD dwFlags, LPMIMEVARIANT pValue);
  293. HRESULT GetPropW(LPPROPSYMBOL pSymbol, LPWSTR *ppwszData);
  294. // ---------------------------------------------------------------------------
  295. // Overloaded SetProp
  296. // ---------------------------------------------------------------------------
  297. HRESULT SetProp(LPCSTR pszName, LPCSTR pszData);
  298. HRESULT SetProp(LPPROPSYMBOL pSymbol, LPCSTR pszData);
  299. HRESULT SetProp(LPCSTR pszName, DWORD dwFlags, LPCSTR pszData);
  300. HRESULT SetProp(LPCSTR pszName, DWORD dwFlags, LPCMIMEVARIANT pValue);
  301. HRESULT SetProp(LPPROPSYMBOL pSymbol, DWORD dwFlags, LPCMIMEVARIANT pValue);
  302. STDMETHODIMP SetProp(LPCSTR pszName, DWORD dwFlags, LPCPROPVARIANT pValue); /* IMimePropertySet */
  303. // ---------------------------------------------------------------------------
  304. // IMimeHeaderTable members
  305. // ---------------------------------------------------------------------------
  306. STDMETHODIMP FindFirstRow(LPFINDHEADER pFindHeader, LPHHEADERROW phRow);
  307. STDMETHODIMP FindNextRow(LPFINDHEADER pFindHeader, LPHHEADERROW phRow);
  308. STDMETHODIMP CountRows(LPCSTR pszHeader, ULONG *pcRows);
  309. STDMETHODIMP AppendRow(LPCSTR pszHeader, DWORD dwFlags, LPCSTR pszData, ULONG cchData, LPHHEADERROW phRow);
  310. STDMETHODIMP DeleteRow(HHEADERROW hRow);
  311. STDMETHODIMP GetRowData(HHEADERROW hRow, DWORD dwFlags, LPSTR *ppszData, ULONG *pcchData);
  312. STDMETHODIMP SetRowData(HHEADERROW hRow, DWORD dwFlags, LPCSTR pszData, ULONG cchData);
  313. STDMETHODIMP GetRowInfo(HHEADERROW hRow, LPHEADERROWINFO pInfo);
  314. STDMETHODIMP SetRowNumber(HHEADERROW hRow, DWORD dwRowNumber);
  315. STDMETHODIMP EnumRows(LPCSTR pszHeader, DWORD dwFlags, IMimeEnumHeaderRows **ppEnum);
  316. STDMETHODIMP Clone(IMimeHeaderTable **ppTable);
  317. // ----------------------------------------------------------------------------
  318. // IMimeAddressTable
  319. // ----------------------------------------------------------------------------
  320. STDMETHODIMP Append(DWORD dwAdrType, ENCODINGTYPE ietFriendly, LPCSTR pszFriendly, LPCSTR pszEmail, LPHADDRESS phAddress);
  321. STDMETHODIMP Insert(LPADDRESSPROPS pProps, LPHADDRESS phAddress);
  322. STDMETHODIMP SetProps(HADDRESS hAddress, LPADDRESSPROPS pProps);
  323. STDMETHODIMP GetProps(HADDRESS hAddress, LPADDRESSPROPS pProps);
  324. STDMETHODIMP GetSender(LPADDRESSPROPS pProps);
  325. STDMETHODIMP CountTypes(DWORD dwAdrTypes, ULONG *pcTypes);
  326. STDMETHODIMP GetTypes(DWORD dwAdrTypes, DWORD dwProps, LPADDRESSLIST pList);
  327. STDMETHODIMP EnumTypes(DWORD dwAdrTypes, DWORD dwProps, IMimeEnumAddressTypes **ppEnum);
  328. STDMETHODIMP Delete(HADDRESS hAddress);
  329. STDMETHODIMP DeleteTypes(DWORD dwAdrTypes);
  330. STDMETHODIMP GetFormat(DWORD dwAdrType, ADDRESSFORMAT format, LPSTR *ppszFormat);
  331. STDMETHODIMP AppendRfc822(DWORD dwAdrType, ENCODINGTYPE ietEncoding, LPCSTR pszRfc822Adr);
  332. STDMETHODIMP ParseRfc822(DWORD dwAdrType, ENCODINGTYPE ietEncoding, LPCSTR pszRfc822Adr, LPADDRESSLIST pList);
  333. STDMETHODIMP Clone(IMimeAddressTable **ppTable);
  334. // ----------------------------------------------------------------------------
  335. // IMimeAddressTableW
  336. // ----------------------------------------------------------------------------
  337. STDMETHODIMP AppendW(DWORD dwAdrType, ENCODINGTYPE ietFriendly, LPCWSTR pwszFriendly, LPCWSTR pwszEmail, LPHADDRESS phAddress);
  338. STDMETHODIMP GetFormatW(DWORD dwAdrType, ADDRESSFORMAT format, LPWSTR *ppwszFormat);
  339. STDMETHODIMP AppendRfc822W(DWORD dwAdrType, ENCODINGTYPE ietEncoding, LPCWSTR pwszRfc822Adr);
  340. STDMETHODIMP ParseRfc822W(DWORD dwAdrType, LPCWSTR pwszRfc822Adr, LPADDRESSLIST pList);
  341. // ---------------------------------------------------------------------------
  342. // Generic Stuff
  343. // ---------------------------------------------------------------------------
  344. HRESULT IsState(DWORD dwState);
  345. void ClearState(DWORD dwState);
  346. void SetState(DWORD dwState);
  347. DWORD DwGetState(LPDWORD pdwState);
  348. DWORD DwGetMessageFlags(BOOL fHideTnef);
  349. HRESULT Load(CInternetStream *pInternet);
  350. HRESULT HrInsertCopy(LPPROPERTY pSource, BOOL fFromMovePropos);
  351. HRESULT HrResolveURL(LPRESOLVEURLINFO pInfo);
  352. HRESULT IsPropSet(LPCSTR pszName);
  353. ENCODINGTYPE GetEncodingType(void);
  354. // ---------------------------------------------------------------------------
  355. // Inline Public Stuff
  356. // ---------------------------------------------------------------------------
  357. ULONG CountProps(void) {
  358. EnterCriticalSection(&m_cs);
  359. ULONG c = m_cProps;
  360. LeaveCriticalSection(&m_cs);
  361. return c;
  362. }
  363. CODEPAGEID GetWindowsCP(void) {
  364. EnterCriticalSection(&m_cs);
  365. CODEPAGEID cp = MimeOleGetWindowsCPEx(m_rOptions.pDefaultCharset);
  366. LeaveCriticalSection(&m_cs);
  367. return cp;
  368. }
  369. // ---------------------------------------------------------------------------
  370. // Variant Conversion Stuff
  371. // ---------------------------------------------------------------------------
  372. HRESULT HrConvertVariant(LPPROPSYMBOL pSymbol, LPINETCSETINFO pCharset, ENCODINGTYPE ietSource, DWORD dwFlags, DWORD dwState, LPMIMEVARIANT pSource, LPMIMEVARIANT pDest, BOOL *pfRfc1522=NULL);
  373. HRESULT HrConvertVariant(LPPROPERTY pProperty, DWORD dwFlags, LPMIMEVARIANT pDest);
  374. HRESULT HrConvertVariant(LPPROPERTY pProperty, DWORD dwFlags, DWORD dwState, LPMIMEVARIANT pSource, LPMIMEVARIANT pDest, BOOL *pfRfc1522=NULL);
  375. private:
  376. // ----------------------------------------------------------------------------
  377. // Property Methods
  378. // ----------------------------------------------------------------------------
  379. void _FreeHashTableElements(void);
  380. void _FreePropertyChain(LPPROPERTY pProperty);
  381. void _UnlinkProperty(LPPROPERTY pProperty, LPPROPERTY *ppNextHash=NULL);
  382. void _ReloadInitNew(void);
  383. void _SetStateOnAllProps(DWORD dwState);
  384. BOOL _FExcept(LPPROPSYMBOL pSymbol, ULONG cNames, LPCSTR *prgszName);
  385. HRESULT _HrFindProperty(LPPROPSYMBOL pSymbol, LPPROPERTY *ppProperty);
  386. HRESULT _HrCreateProperty(LPPROPSYMBOL pSymbol, LPPROPERTY *ppProperty);
  387. HRESULT _HrOpenProperty(LPPROPSYMBOL pSymbol, LPPROPERTY *ppProperty);
  388. HRESULT _HrAppendProperty(LPPROPSYMBOL pSymbol, LPPROPERTY *ppProperty);
  389. HRESULT _HrSetPropertyValue(LPPROPERTY pProperty, DWORD dwFlags, LPCMIMEVARIANT pValue, BOOL fFromMovePropos);
  390. HRESULT _HrStoreVariantValue(LPPROPERTY pProperty, DWORD dwFlags, LPCMIMEVARIANT pValue);
  391. HRESULT _HrFindFirstProperty(LPFINDPROPERTY pFind, LPPROPERTY *ppProperty);
  392. HRESULT _HrFindNextProperty(LPFINDPROPERTY pFind, LPPROPERTY *ppProperty);
  393. HRESULT _HrGetPropertyValue(LPPROPERTY pProperty, DWORD dwFlags, LPMIMEVARIANT pValue);
  394. HRESULT _HrGetMultiValueProperty(LPPROPERTY pProperty, DWORD dwFlags, LPMIMEVARIANT pValue);
  395. HRESULT _HrClonePropertiesTo(LPCONTAINER pContainer);
  396. HRESULT _HrGenerateFileName(LPCWSTR pszSuggest, DWORD dwFlags, LPMIMEVARIANT pValue);
  397. HRESULT _HrCopyParameters(LPPROPERTY pProperty, LPCONTAINER pDest);
  398. HRESULT _HrCopyProperty(LPPROPERTY pProperty, LPCONTAINER pDest, BOOL fFromMovePropos);
  399. HRESULT _GetFormatBase(DWORD dwAdrType, ADDRESSFORMAT format, LPPROPVARIANT pVariant);
  400. CODEPAGEID _GetAddressCodePageId(LPINETCSETINFO pDefaultCset, ENCODINGTYPE ietEncoding);
  401. // ----------------------------------------------------------------------------
  402. // Dispatch Members
  403. // ----------------------------------------------------------------------------
  404. HRESULT _HrCallSymbolTrigger(LPPROPSYMBOL pSymbol, TRIGGERTYPE tyTrigger, DWORD dwFlags, LPMIMEVARIANT pValue);
  405. HRESULT _HrIsTriggerCaller(DWORD dwPropId, TRIGGERTYPE tyTrigger);
  406. // ----------------------------------------------------------------------------
  407. // Parameter Based Members
  408. // ----------------------------------------------------------------------------
  409. void _DeleteLinkedParameters(LPPROPERTY pProperty);
  410. HRESULT _HrParseParameters(LPPROPERTY pProperty, DWORD dwFlags, LPCMIMEVARIANT pValue);
  411. HRESULT _HrBuildParameterString(LPPROPERTY pProperty, DWORD dwFlags, LPMIMEVARIANT pValue);
  412. // ----------------------------------------------------------------------------
  413. // Internet Address Members
  414. // ----------------------------------------------------------------------------
  415. HRESULT _HrAppendAddressTable(LPPROPERTY pProperty);
  416. HRESULT _HrBuildAddressString(LPPROPERTY pProperty, DWORD dwFlags, LPMIMEVARIANT pValue);
  417. HRESULT _HrParseInternetAddress(LPPROPERTY pProperty);
  418. HRESULT _HrSaveAddressGroup(LPPROPERTY pProperty, IStream *pStream, ULONG *pcAddrsWrote, ADDRESSFORMAT format, VARTYPE vtFormat);
  419. HRESULT _HrSaveAddressA(LPPROPERTY pProperty, LPMIMEADDRESS pAddress, IStream *pStream, ULONG *pcAddrsWrote, ADDRESSFORMAT format);
  420. HRESULT _HrSaveAddressW(LPPROPERTY pProperty, LPMIMEADDRESS pAddress, IStream *pStream, ULONG *pcAddrsWrote, ADDRESSFORMAT format);
  421. HRESULT _HrAppendAddressGroup(LPADDRESSGROUP pGroup, LPMIMEADDRESS *ppAddress);
  422. HRESULT _HrQueryAddressGroup(LPPROPERTY pProperty, LPCSTR pszCriteria, boolean fSubString, boolean fCaseSensitive);
  423. HRESULT _HrQueryAddress(LPPROPERTY pProperty, LPMIMEADDRESS pAddress, LPCSTR pszCriteria, boolean fSubString, boolean fCaseSensitive);
  424. HRESULT _HrSetAddressProps(LPADDRESSPROPS pProps, LPMIMEADDRESS pAddress);
  425. HRESULT _HrGetAddressProps(LPADDRESSPROPS pProps, LPMIMEADDRESS pAddress);
  426. void _FreeAddressChain(LPADDRESSGROUP pGroup);
  427. void _UnlinkAddressGroup(LPPROPERTY pProperty);
  428. void _UnlinkAddress(LPMIMEADDRESS pAddress);
  429. void _FreeAddress(LPMIMEADDRESS pAddress);
  430. void _LinkAddress(LPMIMEADDRESS pAddress, LPADDRESSGROUP pGroup);
  431. // ----------------------------------------------------------------------------
  432. // IMimeHeaderTable Private Helpers
  433. // ----------------------------------------------------------------------------
  434. HRESULT _HrGetHeaderTableSaveIndex(ULONG *pcRows, LPROWINDEX *pprgIndex);
  435. void _SortHeaderTableSaveIndex(LONG left, LONG right, LPROWINDEX prgIndex);
  436. BOOL _FIsValidHRow(HHEADERROW hRow);
  437. BOOL _FIsValidHAddress(HADDRESS hAddress);
  438. void _UnlinkHeaderRow(HHEADERROW hRow);
  439. HRESULT _HrAppendHeaderTable(LPPROPERTY pProperty);
  440. HRESULT _HrParseInlineHeaderName(LPCSTR pszData, LPSTR pszScratch, ULONG cchScratch, LPSTR *ppszHeader, ULONG *pcboffColon);
  441. HRESULT _HrGetInlineSymbol(LPCSTR pszData, LPPROPSYMBOL *ppSymbol, ULONG *pcboffColon);
  442. public:
  443. // ----------------------------------------------------------------------------
  444. // Property Symbol Triggers
  445. // ----------------------------------------------------------------------------
  446. DECLARE_TRIGGER(TRIGGER_ATT_FILENAME);
  447. DECLARE_TRIGGER(TRIGGER_ATT_GENFNAME);
  448. DECLARE_TRIGGER(TRIGGER_ATT_NORMSUBJ);
  449. DECLARE_TRIGGER(TRIGGER_HDR_SUBJECT);
  450. DECLARE_TRIGGER(TRIGGER_HDR_CNTTYPE);
  451. DECLARE_TRIGGER(TRIGGER_ATT_PRITYPE);
  452. DECLARE_TRIGGER(TRIGGER_ATT_SUBTYPE);
  453. DECLARE_TRIGGER(TRIGGER_HDR_CNTXFER);
  454. DECLARE_TRIGGER(TRIGGER_PAR_NAME);
  455. DECLARE_TRIGGER(TRIGGER_PAR_FILENAME);
  456. DECLARE_TRIGGER(TRIGGER_ATT_SENTTIME);
  457. DECLARE_TRIGGER(TRIGGER_ATT_RECVTIME);
  458. DECLARE_TRIGGER(TRIGGER_ATT_PRIORITY);
  459. private:
  460. // ----------------------------------------------------------------------------
  461. // Private Data
  462. // ----------------------------------------------------------------------------
  463. LONG m_cRef; // Container Reference Count
  464. DWORD m_dwState; // State of the container
  465. ULONG m_cProps; // Current number of properties
  466. LPPROPERTY m_prgIndex[PID_LAST]; // Array of pointers into local hash table for known items
  467. LPPROPERTY m_prgHashTable[CBUCKETS]; // Hash table for properties
  468. TRIGGERCALLSTACK m_rTrigger; // Current Property Id Owning the Dispatch
  469. WORD m_wTag; // Handle Tag
  470. HEADERTABLE m_rHdrTable; // The header table
  471. ADDRESSTABLE m_rAdrTable; // The Address Table
  472. ULONG m_cbSize; // Size of this header
  473. ULONG m_cbStart; // Start Position of m_pStmLock
  474. CStreamLockBytes *m_pStmLock; // Protective Wrapper for the stream object
  475. HEADOPTIONS m_rOptions; // Header Options
  476. CRITICAL_SECTION m_cs; // Thread Safety
  477. };
  478. // --------------------------------------------------------------------------------
  479. // SYMBOLTRIGGER
  480. // --------------------------------------------------------------------------------
  481. typedef struct tagSYMBOLTRIGGER {
  482. DWORD dwTypes;
  483. PFNSYMBOLTRIGGER pfnTrigger;
  484. } SYMBOLTRIGGER, *LPSYMBOLTRIGGER;
  485. // --------------------------------------------------------------------------------
  486. // Macro To Define a Trigger Function
  487. // --------------------------------------------------------------------------------
  488. #ifdef DEFINE_TRIGGERS
  489. #define DEFINE_TRIGGER(_pfnTrigger, _dwTypes) \
  490. SYMBOLTRIGGER r##_pfnTrigger = \
  491. { \
  492. /* SYMBOLTRIGGER::dwTypes */ _dwTypes, \
  493. /* SYMBOLTRIGGER::pfnTrigger */ (PFNSYMBOLTRIGGER)CMimePropertyContainer::_pfnTrigger \
  494. }; \
  495. const LPSYMBOLTRIGGER LP##_pfnTrigger = &r##_pfnTrigger;
  496. #else
  497. #define DEFINE_TRIGGER(_pfnTrigger, _dwTypes) \
  498. extern const LPSYMBOLTRIGGER LP##_pfnTrigger;
  499. #endif
  500. // --------------------------------------------------------------------------------
  501. // Trigger Definitions
  502. // --------------------------------------------------------------------------------
  503. DEFINE_TRIGGER(TRIGGER_ATT_FILENAME, IST_POSTSETPROP | IST_DELETEPROP | IST_POSTGETPROP | IST_GETDEFAULT);
  504. DEFINE_TRIGGER(TRIGGER_ATT_GENFNAME, IST_POSTGETPROP | IST_GETDEFAULT);
  505. DEFINE_TRIGGER(TRIGGER_ATT_NORMSUBJ, IST_GETDEFAULT);
  506. DEFINE_TRIGGER(TRIGGER_HDR_SUBJECT, IST_DELETEPROP);
  507. DEFINE_TRIGGER(TRIGGER_HDR_CNTTYPE, IST_DELETEPROP | IST_POSTSETPROP | IST_GETDEFAULT);
  508. DEFINE_TRIGGER(TRIGGER_ATT_PRITYPE, IST_POSTSETPROP | IST_GETDEFAULT);
  509. DEFINE_TRIGGER(TRIGGER_ATT_SUBTYPE, IST_POSTSETPROP | IST_GETDEFAULT);
  510. DEFINE_TRIGGER(TRIGGER_HDR_CNTXFER, IST_GETDEFAULT);
  511. DEFINE_TRIGGER(TRIGGER_PAR_NAME, IST_POSTSETPROP);
  512. DEFINE_TRIGGER(TRIGGER_PAR_FILENAME, IST_DELETEPROP | IST_POSTSETPROP);
  513. DEFINE_TRIGGER(TRIGGER_ATT_SENTTIME, IST_DELETEPROP | IST_POSTSETPROP | IST_GETDEFAULT);
  514. DEFINE_TRIGGER(TRIGGER_ATT_RECVTIME, IST_DELETEPROP | IST_GETDEFAULT);
  515. DEFINE_TRIGGER(TRIGGER_ATT_PRIORITY, IST_POSTSETPROP | IST_DELETEPROP | IST_GETDEFAULT | IST_VARIANTCONVERT);
  516. #endif // __CONTAINX_H