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.

665 lines
39 KiB

  1. // --------------------------------------------------------------------------------
  2. // BookTree.h
  3. // Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  4. // Steven J. Bailey
  5. // --------------------------------------------------------------------------------
  6. #ifndef __BOOKTREE_H
  7. #define __BOOKTREE_H
  8. // --------------------------------------------------------------------------------
  9. // Depends On
  10. // --------------------------------------------------------------------------------
  11. #include "mimeole.h"
  12. #include "privunk.h"
  13. #include "variantx.h"
  14. // --------------------------------------------------------------------------------
  15. // Forward Decls
  16. // --------------------------------------------------------------------------------
  17. class CBindStream;
  18. class CMessageBody;
  19. class CMessageWebPage;
  20. typedef struct tagTEMPFILEINFO *LPTEMPFILEINFO;
  21. typedef CMessageBody *LPMESSAGEBODY;
  22. class CStreamLockBytes;
  23. class CInternetStream;
  24. class CMimePropertySet;
  25. class CMessageTree;
  26. class CBodyLockBytes;
  27. class CActiveUrl;
  28. typedef class CMimePropertyContainer *LPCONTAINER;
  29. typedef struct tagRESOLVEURLINFO *LPRESOLVEURLINFO;
  30. typedef class CActiveUrlRequest *LPURLREQUEST;
  31. #define AthFileTimeToDateTimeW(pft, wszDateTime, cch, dwFlags) \
  32. CchFileTimeToDateTimeW(pft, wszDateTime, cch, dwFlags, \
  33. GetDateFormatWrapW, GetTimeFormatWrapW, GetLocaleInfoWrapW)
  34. // --------------------------------------------------------------------------------
  35. // For the Product Version
  36. // --------------------------------------------------------------------------------
  37. #include <ntverp.h>
  38. // --------------------------------------------------------------------------------
  39. // GUIDs
  40. // --------------------------------------------------------------------------------
  41. // {FD853CD8-7F86-11d0-8252-00C04FD85AB4}
  42. DEFINE_GUID(IID_CMessageTree, 0xfd853cd8, 0x7f86, 0x11d0, 0x82, 0x52, 0x0, 0xc0, 0x4f, 0xd8, 0x5a, 0xb4);
  43. // --------------------------------------------------------------------------------
  44. // Defines
  45. // --------------------------------------------------------------------------------
  46. #define VER_BODYTREEV2 0x00000001 // Version of the persisted body tree format
  47. #define CCHMAX_BOUNDARY 71
  48. #define STR_MIMEOLE_VERSION "Produced By Microsoft MimeOLE V" VER_PRODUCTVERSION_STR
  49. #define TREE_MIMEVERSION 1
  50. #define CFORMATS_IDATAOBJECT 5 // Max number of formats in IDataObject impl
  51. // --------------------------------------------------------------------------------
  52. // Cache Node Signing
  53. // --------------------------------------------------------------------------------
  54. #define DwSignNode(_info, _index) (DWORD)MAKELONG(_info.wSignature, _index)
  55. #define FVerifySignedNode(_info, _snode) (BOOL)(LOWORD(_snode) == _info.wSignature && HIWORD(_snode) < _info.cNodes)
  56. #define PNodeFromSignedNode(_snode) (m_rTree.prgpNode[HIWORD(_snode)])
  57. // --------------------------------------------------------------------------------
  58. // HBODY Macros
  59. // --------------------------------------------------------------------------------
  60. #define HBODYMAKE(_index) (HBODY)MAKELPARAM(m_wTag, _index)
  61. #define HBODYINDEX(_hbody) (ULONG)HIWORD(_hbody)
  62. #define HBODYTAG(_hbody) (WORD)LOWORD(_hbody)
  63. // --------------------------------------------------------------------------------
  64. // TEXTTYPEINFO
  65. // --------------------------------------------------------------------------------
  66. typedef struct tagTEXTTYPEINFO {
  67. DWORD dwTxtType; // Text Type Flag
  68. LPCSTR pszSubType; // Text Subtype (plain)
  69. DWORD dwWeight; // Text Alternative Weight
  70. } TEXTTYPEINFO, *LPTEXTTYPEINFO;
  71. // --------------------------------------------------------------------------------
  72. // CACHEINFOV2
  73. // --------------------------------------------------------------------------------
  74. typedef struct tagCACHEINFOV2 {
  75. WORD wVersion; // Version of the BIDXTABLE
  76. WORD wSignature; // Used to sign the nodes
  77. DWORD dwReserved; // Reserved
  78. DWORD cbMessage; // Size of the message this index was created for
  79. DWORD iRoot; // Zero-Based index of root node
  80. DWORD cNodes; // Number of nodes in the tree
  81. DWORD rgReserved[6]; // Reserve 6 DWORDS for future use
  82. } CACHEINFOV2, *LPCACHEINFOV2;
  83. // --------------------------------------------------------------------------------
  84. // CACHENODEV2
  85. // --------------------------------------------------------------------------------
  86. typedef struct tagCACHENODEV2 {
  87. DWORD dwType; // Flags for this node
  88. DWORD cChildren; // Number of children
  89. DWORD iParent; // Index of parent of this node
  90. DWORD iPrev; // Index of next sibling to this node
  91. DWORD iNext; // Index of next sibling to this node
  92. DWORD iChildHead; // Index of first child
  93. DWORD iChildTail; // Tail Child
  94. DWORD cbBodyStart; // Byte offset to body start
  95. DWORD cbBodyEnd; // Byte offset to body end
  96. DWORD cbHeaderStart; // Byte offset to start of header
  97. DWORD dwReserved; // Not Used
  98. DWORD dwBoundary; // Boundary Type for this body
  99. DWORD cbBoundaryStart; // Byte offset to starting boundary
  100. DWORD rgReserved[10]; // Reserve 6 DWORDS for future use
  101. } CACHENODEV2, *LPCACHENODEV2;
  102. // --------------------------------------------------------------------------------
  103. // BINDNODESTATE
  104. // --------------------------------------------------------------------------------
  105. typedef enum tagBINDNODESTATE {
  106. BINDSTATE_COMPLETE=0, // The bind is complete
  107. BINDSTATE_PARSING_HEADER, // Parsing a header
  108. BINDSTATE_FINDING_MIMEFIRST, // Finding mime start boundary
  109. BINDSTATE_FINDING_MIMENEXT, // Reading body to end mime boundary
  110. BINDSTATE_FINDING_UUBEGIN, // begin uuencode
  111. BINDSTATE_FINDING_UUEND, // End uuencode
  112. BINDSTATE_PARSING_RFC1154, // Parsing an RFC1154 message
  113. BINDSTATE_LAST // Don't Use
  114. } BINDNODESTATE;
  115. // --------------------------------------------------------------------------------
  116. // BOUNDARYTYPE
  117. // --------------------------------------------------------------------------------
  118. typedef enum tagBOUNDARYTYPE {
  119. BOUNDARY_NONE = 0, // No Boundary
  120. BOUNDARY_ROOT = 1, // This is the root boundary (0)
  121. BOUNDARY_MIMEEND = 3, // Terminating mime boundary
  122. BOUNDARY_MIMENEXT = 4, // Mime Boundary non-terminating
  123. BOUNDARY_UUBEGIN = 5, // UUENCODE begining boundary
  124. BOUNDARY_UUEND = 6, // UUENCODE ending boundary
  125. BOUNDARY_LAST = 7 // Don't use
  126. } BOUNDARYTYPE;
  127. // --------------------------------------------------------------------------------
  128. // PFNBINDPARSER
  129. // --------------------------------------------------------------------------------
  130. typedef HRESULT (CMessageTree::*PFNBINDPARSER)(THIS_);
  131. // --------------------------------------------------------------------------------
  132. // Node Flags
  133. // --------------------------------------------------------------------------------
  134. #define NODETYPE_INCOMPLETE FLAG01 // The body's boundries do not match
  135. #define NODETYPE_FAKEMULTIPART FLAG02 // The body is a fake multipart
  136. #define NODETYPE_RFC1154_ROOT FLAG03 // The body is the root of an RFC1154
  137. #define NODETYPE_RFC1154_BINHEX FLAG04 // The body is BINHEX from RFC1154
  138. // --------------------------------------------------------------------------------
  139. // Node State
  140. // --------------------------------------------------------------------------------
  141. #define NODESTATE_MESSAGE FLAG01 // We are parsing a message/rfc822 body
  142. #define NODESTATE_VERIFYTNEF FLAG02 // Verify tnef signature after HrBindToTree
  143. #define NODESTATE_BOUNDNOFREE FLAG03 // Don't free BINDPARSEINFO::rBoundary (it is a copy)
  144. #define NODESTATE_BOUNDTOTREE FLAG04 // IMimeBody::HrBindToTree(pNode) has been called
  145. #define NODESTATE_ONWEBPAGE FLAG05 // CMessageWebPage has renedered the start body from this multipart/related body
  146. #define NODESTATE_INSLIDESHOW FLAG06 // CMessageWebPage will render this body in a slide show
  147. #define WEBPAGE_NODESTATE_BITS (NODESTATE_ONWEBPAGE | NODESTATE_INSLIDESHOW)
  148. #define NODESTATE_AUTOATTACH FLAG07 // Marked as an attachment in _HandleCanInlineTextOption
  149. // --------------------------------------------------------------------------------
  150. // TREENODEINFO
  151. // --------------------------------------------------------------------------------
  152. typedef struct tagTREENODEINFO *LPTREENODEINFO;
  153. typedef struct tagTREENODEINFO {
  154. HBODY hBody; // Index of this body in BODYTABLE::prgpBody
  155. DWORD dwType; // NODETYPE_xxx Flags
  156. DWORD dwState; // NODESTATE_xxx Flags
  157. HRESULT hrBind; // Bind Result
  158. ULONG cChildren; // Number of chilren if cnttype == CNT_MULTIPART
  159. DWORD iCacheNode; // Used for saving
  160. BINDNODESTATE bindstate; // Current parsing state
  161. PROPSTRINGA rBoundary; // Boundary
  162. BOUNDARYTYPE boundary; // Boundary Type for this body
  163. DWORD cbBoundaryStart; // Byte offset to starting boundary
  164. DWORD cbHeaderStart; // Byte offset to start of header
  165. DWORD cbBodyStart; // Byte offset to body start
  166. DWORD cbBodyEnd; // Byte offset to body end
  167. LPURLREQUEST pResolved; // Head Binding Requests
  168. LPTREENODEINFO pBindParent; // BindStackPrevious Node
  169. LPTREENODEINFO pParent; // Parent body
  170. LPTREENODEINFO pNext; // Next Sibling
  171. LPTREENODEINFO pPrev; // Previous Sibling
  172. LPTREENODEINFO pChildHead; // Handle to first child (if multipart)
  173. LPTREENODEINFO pChildTail; // Handle to first child (if multipart)
  174. LPCONTAINER pContainer; // The parsed header
  175. CBodyLockBytes *pLockBytes; // The binded tree data
  176. LPMESSAGEBODY pBody; // The body object for this tree node
  177. } TREENODEINFO;
  178. // --------------------------------------------------------------------------------
  179. // TREENODETABLE
  180. // --------------------------------------------------------------------------------
  181. typedef struct tagTREENODETABLE {
  182. ULONG cNodes; // Number of valid elements in prgpBody
  183. ULONG cEmpty; // Number of empty cells in prgpBody
  184. ULONG cAlloc; // Number of elements allocated in prgpBody
  185. LPTREENODEINFO *prgpNode; // Array of pointers to bindinfo structs
  186. } TREENODETABLE, *LPTREENODETABLE;
  187. // --------------------------------------------------------------------------------
  188. // Tree State
  189. // --------------------------------------------------------------------------------
  190. #define TREESTATE_DIRTY FLAG01 // The tree is dirty
  191. //#define TREESTATE_BOUND FLAG02 // Load & LoadOffsetTable has bound success
  192. #define TREESTATE_LOADED FLAG03 // LoadOffsetTable has success
  193. #define TREESTATE_HANDSONSTORAGE FLAG04 // I have AddRef'ed somebodies storage
  194. #define TREESTATE_SAVENEWS FLAG05 // We are saving a news message
  195. #define TREESTATE_REUSESIGNBOUND FLAG06 // Saving multipart/signed reuse boundary
  196. #define TREESTATE_BINDDONE FLAG07 // The bind operation is complete
  197. #define TREESTATE_BINDUSEFILE FLAG08 // Hands off storage OnStopBinding
  198. #define TREESTATE_LOADEDBYMONIKER FLAG09 // IPersistMoniker::Load was called to load this
  199. #define TREESTATE_RESYNCHRONIZE FLAG10
  200. // --------------------------------------------------------------------------------
  201. // More Save Body Flags
  202. // --------------------------------------------------------------------------------
  203. #define SAVEBODY_UPDATENODES FLAG32 // Update the node offsets to point to the new stream
  204. #define SAVEBODY_SMIMECTE FLAG31 // Change CTE rules for S/MIME bodies
  205. #define SAVEBODY_REUSECTE FLAG30 // Force CTE to be re-used
  206. // --------------------------------------------------------------------------------
  207. // Tree Options
  208. // if you add anything to this struct, you *must* update g_rDefTreeOptions
  209. // in imsgtree.cpp
  210. // --------------------------------------------------------------------------------
  211. typedef struct tagTREEOPTIONS {
  212. BYTE fCleanupTree; // Cleanup Tree On Save ?
  213. BYTE fHideTnef; // HIDE TNEF attachments?
  214. BYTE fAllow8bitHeader; // Allow 8bit in header
  215. BYTE fGenMessageId; // Should I generate the message id ?
  216. BYTE fWrapBodyText; // Wrap Body Text
  217. ULONG cchMaxHeaderLine; // Max header line length
  218. ULONG cchMaxBodyLine; // Max body line length
  219. MIMESAVETYPE savetype; // Commit type
  220. LPINETCSETINFO pCharset; // Current Character Set
  221. CSETAPPLYTYPE csetapply; // Method in which to use m_hCharset
  222. ENCODINGTYPE ietTextXmit; // Text transfer encoding
  223. ENCODINGTYPE ietPlainXmit; // Transmit Text Format
  224. ENCODINGTYPE ietHtmlXmit; // Transmit Text Format
  225. ULONG ulSecIgnoreMask; // Mask of ignorable errors
  226. RELOADTYPE ReloadType; // How the the root header be treated on a reload
  227. BOOL fCanInlineText; // Can the client inline multiple text bodies
  228. BOOL fShowMacBin; // Can the client handle macbinary??
  229. BOOL fKeepBoundary; // OID_SAVEBODY_KEEPBOUNDARY
  230. BOOL fBindUseFile; // If TRUE, I duplicate the stream on load
  231. BOOL fHandsOffOnSave; // Don't Hold onto pStream after IMimeMessage::Save
  232. BOOL fExternalBody; // Handle message/external-body
  233. BOOL fDecodeRfc1154; // Decode using RFC1154 (aka Encoding: header)
  234. // if you add anything to this struct, you *must* update g_rDefTreeOptions
  235. // in imsgtree.cpp
  236. } TREEOPTIONS, *LPTREEOPTIONS;
  237. // --------------------------------------------------------------------------------
  238. // BOOKTREERESET - Used with _ResetObject
  239. // --------------------------------------------------------------------------------
  240. typedef enum tagBOOKTREERESET {
  241. BOOKTREE_RESET_DECONSTRUCT,
  242. BOOKTREE_RESET_LOADINITNEW,
  243. BOOKTREE_RESET_INITNEW
  244. } BOOKTREERESET;
  245. // --------------------------------------------------------------------------------
  246. // BOOKTREE1154 - Used for RFC1154 Handling
  247. // --------------------------------------------------------------------------------
  248. typedef enum tagBT1154ENCODING { // Body encoding type
  249. BT1154ENC_MINIMUM=0,
  250. BT1154ENC_TEXT=0, // text body
  251. BT1154ENC_UUENCODE=1, // uuencoded body
  252. BT1154ENC_BINHEX=2, // binhex body
  253. BT1154ENC_MAXIMUM=2
  254. } BT1154ENCODING;
  255. typedef struct tagBT1154BODY { // Info about one body
  256. BT1154ENCODING encEncoding; // Body encoding type
  257. ULONG cLines; // Number of lines in the body
  258. } BT1154BODY;
  259. typedef struct tagBOOKTREE1154 { // Info about the state of RFC1154 handling
  260. ULONG cBodies; // Count of the number of bodies
  261. ULONG cCurrentBody; // The index of the current body (zero-based)
  262. ULONG cCurrentLine; // The current line number in the current body
  263. HRESULT hrLoadResult; // The result of the load.
  264. BT1154BODY aBody[1]; // The bodies
  265. } BOOKTREE1154, *LPBOOKTREE1154;
  266. // --------------------------------------------------------------------------------
  267. // CMessageTree Definition
  268. // --------------------------------------------------------------------------------
  269. class CMessageTree : public CPrivateUnknown,
  270. public IMimeMessageW,
  271. public IDataObject,
  272. public IPersistFile,
  273. public IPersistMoniker,
  274. public IServiceProvider,
  275. #ifdef SMIME_V3
  276. public IMimeSecurity2,
  277. #endif // SMIME_V3
  278. public IBindStatusCallback
  279. {
  280. public:
  281. // ----------------------------------------------------------------------------
  282. // Construction
  283. // ----------------------------------------------------------------------------
  284. CMessageTree(IUnknown *pUnkOuter=NULL);
  285. virtual ~CMessageTree(void);
  286. // ---------------------------------------------------------------------------
  287. // IUnknown members
  288. // ---------------------------------------------------------------------------
  289. virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj) {
  290. return CPrivateUnknown::QueryInterface(riid, ppvObj); };
  291. virtual STDMETHODIMP_(ULONG) AddRef(void) {
  292. return CPrivateUnknown::AddRef();};
  293. virtual STDMETHODIMP_(ULONG) Release(void) {
  294. return CPrivateUnknown::Release(); };
  295. // ---------------------------------------------------------------------------
  296. // IDataObject members
  297. // ---------------------------------------------------------------------------
  298. STDMETHODIMP EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC **ppEnum);
  299. STDMETHODIMP GetCanonicalFormatEtc(FORMATETC *pFormatIn, FORMATETC *pFormatOut);
  300. STDMETHODIMP GetData(FORMATETC *pFormat, STGMEDIUM *pMedium);
  301. STDMETHODIMP GetDataHere(FORMATETC *pFormat, STGMEDIUM *pMedium);
  302. STDMETHODIMP QueryGetData(FORMATETC *pFormat);
  303. STDMETHODIMP SetData(FORMATETC *pFormat, STGMEDIUM *pMedium, BOOL fRelease) {
  304. return TrapError(E_NOTIMPL); }
  305. STDMETHODIMP DAdvise(FORMATETC *pFormat, DWORD, IAdviseSink *pAdvise, DWORD *pdwConn) {
  306. return TrapError(OLE_E_ADVISENOTSUPPORTED); }
  307. STDMETHODIMP DUnadvise(DWORD dwConn) {
  308. return TrapError(OLE_E_ADVISENOTSUPPORTED); }
  309. STDMETHODIMP EnumDAdvise(IEnumSTATDATA **ppEnum) {
  310. return TrapError(OLE_E_ADVISENOTSUPPORTED); }
  311. // ---------------------------------------------------------------------------
  312. // IPersist Members
  313. // ---------------------------------------------------------------------------
  314. STDMETHODIMP GetClassID(CLSID *pClassID);
  315. // ---------------------------------------------------------------------------
  316. // IPersistMoniker Members
  317. // ---------------------------------------------------------------------------
  318. STDMETHODIMP Load(BOOL fFullyAvailable, IMoniker *pMoniker, IBindCtx *pBindCtx, DWORD grfMode);
  319. STDMETHODIMP GetCurMoniker(IMoniker **ppMoniker);
  320. STDMETHODIMP Save(IMoniker *pMoniker, IBindCtx *pBindCtx, BOOL fRemember) {
  321. return TrapError(E_NOTIMPL); }
  322. STDMETHODIMP SaveCompleted(IMoniker *pMoniker, IBindCtx *pBindCtx) {
  323. return TrapError(E_NOTIMPL); }
  324. // ---------------------------------------------------------------------------
  325. // IPersistStreamInit Members
  326. // ---------------------------------------------------------------------------
  327. STDMETHODIMP GetSizeMax(ULARGE_INTEGER* pcbSize);
  328. STDMETHODIMP Load(LPSTREAM pStream);
  329. STDMETHODIMP Save(LPSTREAM pStream, BOOL fClearDirty);
  330. STDMETHODIMP InitNew(void);
  331. STDMETHODIMP IsDirty(void);
  332. // ---------------------------------------------------------------------------
  333. // IPersistFile Members
  334. // ---------------------------------------------------------------------------
  335. STDMETHODIMP GetCurFile(LPOLESTR *ppszFileName);
  336. STDMETHODIMP Load(LPCOLESTR pszFileName, DWORD dwMode);
  337. STDMETHODIMP Save(LPCOLESTR pszFileName, BOOL fRemember);
  338. STDMETHODIMP SaveCompleted(LPCOLESTR pszFileName);
  339. // ----------------------------------------------------------------------------
  340. // IServiceProvider methods
  341. // ----------------------------------------------------------------------------
  342. STDMETHODIMP QueryService(REFGUID rsid, REFIID riid, void **ppvObj); /* IServiceProvider */
  343. // ---------------------------------------------------------------------------
  344. // IBindStatusCallback
  345. // ---------------------------------------------------------------------------
  346. STDMETHODIMP OnStartBinding(DWORD dwReserved, IBinding *pBinding);
  347. STDMETHODIMP GetPriority(LONG *plPriority);
  348. STDMETHODIMP OnLowResource(DWORD reserved);
  349. STDMETHODIMP OnProgress(ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR pszStatusText);
  350. STDMETHODIMP OnStopBinding(HRESULT hrResult, LPCWSTR pszError);
  351. STDMETHODIMP GetBindInfo(DWORD *grfBINDF, BINDINFO *pBindInfo);
  352. STDMETHODIMP OnDataAvailable(DWORD grfBSCF, DWORD dwSize, FORMATETC *pFormat, STGMEDIUM *pMedium);
  353. STDMETHODIMP OnObjectAvailable(REFIID riid, IUnknown *pUnknown) { return TrapError(E_NOTIMPL); }
  354. // ---------------------------------------------------------------------------
  355. // IMimeMessageTree members
  356. // ---------------------------------------------------------------------------
  357. STDMETHODIMP LoadOffsetTable(IStream *pStream);
  358. STDMETHODIMP SaveOffsetTable(IStream *pStream, DWORD dwFlags);
  359. STDMETHODIMP GetMessageSize(ULONG *pcbSize, DWORD dwFlags);
  360. STDMETHODIMP Commit(DWORD dwFlags);
  361. STDMETHODIMP HandsOffStorage(void);
  362. STDMETHODIMP IsBodyType(HBODY hBody, IMSGBODYTYPE bodytype);
  363. STDMETHODIMP SaveBody(HBODY hBody, DWORD dwFlags, IStream *pStream);
  364. STDMETHODIMP BindToObject(const HBODY hBody, REFIID riid, void **ppvObject);
  365. STDMETHODIMP InsertBody(BODYLOCATION location, HBODY hPivot, LPHBODY phBody);
  366. STDMETHODIMP GetBody(BODYLOCATION location, HBODY hPivot, LPHBODY phBody);
  367. STDMETHODIMP DeleteBody(HBODY hBody, DWORD dwFlags);
  368. STDMETHODIMP MoveBody(HBODY hBody, BODYLOCATION location);
  369. STDMETHODIMP CountBodies(HBODY hParent, boolean fRecurse, ULONG *pcBodies);
  370. STDMETHODIMP FindFirst(LPFINDBODY pFindBody, LPHBODY phBody);
  371. STDMETHODIMP FindNext(LPFINDBODY pFindBody, LPHBODY phBody);
  372. STDMETHODIMP GetMessageSource(IStream **ppStream, DWORD dwFlags);
  373. STDMETHODIMP GetCharset(LPHCHARSET phCharset);
  374. STDMETHODIMP SetCharset(HCHARSET hCharset, CSETAPPLYTYPE applytype);
  375. STDMETHODIMP ToMultipart(HBODY hBody, LPCSTR pszSubType, LPHBODY phMultipart);
  376. STDMETHODIMP GetBodyOffsets(HBODY hBody, LPBODYOFFSETS pOffsets);
  377. STDMETHODIMP IsContentType(HBODY hBody, LPCSTR pszCntType, LPCSTR pszSubType);
  378. STDMETHODIMP QueryBodyProp(HBODY hBody, LPCSTR pszName, LPCSTR pszCriteria, boolean fSubString, boolean fCaseSensitive);
  379. STDMETHODIMP GetBodyProp(HBODY hBody, LPCSTR pszName, DWORD dwFlags, LPPROPVARIANT pValue);
  380. STDMETHODIMP SetBodyProp(HBODY hBody, LPCSTR pszName, DWORD dwFlags, LPCPROPVARIANT pValue);
  381. STDMETHODIMP DeleteBodyProp(HBODY hBody, LPCSTR pszName);
  382. STDMETHODIMP GetFlags(DWORD *pdwFlags);
  383. STDMETHODIMP SetOption(const TYPEDID oid, LPCPROPVARIANT pValue);
  384. STDMETHODIMP GetOption(const TYPEDID oid, LPPROPVARIANT pValue);
  385. STDMETHODIMP ResolveURL(HBODY hRelated, LPCSTR pszBase, LPCSTR pszURL, DWORD dwFlags, LPHBODY phBody);
  386. // ---------------------------------------------------------------------------
  387. // IMimeMessage members
  388. // ---------------------------------------------------------------------------
  389. STDMETHODIMP GetRootMoniker(LPMONIKER *ppmk); /* will die soon */
  390. STDMETHODIMP CreateWebPage(IStream *pStmRoot, LPWEBPAGEOPTIONS pOptions, IMimeMessageCallback *pCallback, IMoniker **ppMoniker);
  391. STDMETHODIMP GetProp(LPCSTR pszName, DWORD dwFlags, LPPROPVARIANT pValue);
  392. STDMETHODIMP SetProp(LPCSTR pszName, DWORD dwFlags, LPCPROPVARIANT pValue);
  393. STDMETHODIMP DeleteProp(LPCSTR pszName);
  394. STDMETHODIMP QueryProp(LPCSTR pszName, LPCSTR pszCriteria, boolean fSubString, boolean fCaseSensitive);
  395. STDMETHODIMP GetTextBody(DWORD dwTxtType, ENCODINGTYPE ietEncoding, IStream **ppStream, LPHBODY phBody);
  396. STDMETHODIMP SetTextBody(DWORD dwTxtType, ENCODINGTYPE ietEncoding, HBODY hAlternative, IStream *pStream, LPHBODY phBody);
  397. STDMETHODIMP AttachObject(REFIID riid, void *pvObject, LPHBODY phBody);
  398. STDMETHODIMP AttachFile(LPCSTR pszFilePath, IStream *pstmFile, LPHBODY phBody);
  399. STDMETHODIMP GetAttachments(ULONG *pcAttach, LPHBODY *pprghAttach);
  400. STDMETHODIMP AttachURL(LPCSTR pszBase, LPCSTR pszURL, DWORD dwFlags, IStream *pstmURL, LPSTR *ppszCID, LPHBODY phBody);
  401. STDMETHODIMP SplitMessage(ULONG cbMaxPart, IMimeMessageParts **ppParts);
  402. STDMETHODIMP GetAddressTable(IMimeAddressTable **ppTable);
  403. STDMETHODIMP GetSender(LPADDRESSPROPS pAddress);
  404. STDMETHODIMP GetAddressTypes(DWORD dwAdrTypes, DWORD dwProps, LPADDRESSLIST pList);
  405. STDMETHODIMP GetAddressFormat(DWORD dwAdrType, ADDRESSFORMAT format, LPSTR *ppszFormat);
  406. STDMETHODIMP EnumAddressTypes(DWORD dwAdrTypes, DWORD dwProps, IMimeEnumAddressTypes **ppEnum);
  407. // ---------------------------------------------------------------------------
  408. // IMimeMessageW members
  409. // ---------------------------------------------------------------------------
  410. STDMETHODIMP AttachFileW(LPCWSTR pszFilePath, IStream *pstmFile, LPHBODY phBody);
  411. STDMETHODIMP GetAddressFormatW(DWORD dwAdrType, ADDRESSFORMAT format, LPWSTR *ppszFormat);
  412. STDMETHODIMP GetPropW(LPCWSTR pwszName, DWORD dwFlags, LPPROPVARIANT pValue);
  413. STDMETHODIMP SetPropW(LPCWSTR pwszName, DWORD dwFlags, LPCPROPVARIANT pValue);
  414. STDMETHODIMP DeletePropW(LPCWSTR pwszName);
  415. STDMETHODIMP QueryPropW(LPCWSTR pwszName, LPCWSTR pwszCriteria, boolean fSubString, boolean fCaseSensitive);
  416. STDMETHODIMP AttachURLW(LPCWSTR pwszBase, LPCWSTR pwszURL, DWORD dwFlags, IStream *pstmURL, LPWSTR *ppwszCID, LPHBODY phBody);
  417. STDMETHODIMP ResolveURLW(HBODY hRelated, LPCWSTR pwszBase, LPCWSTR pwszURL, DWORD dwFlags, LPHBODY phBody);
  418. #ifdef SMIME_V3
  419. // ---------------------------------------------------------------------------
  420. // IMimeSecurity2 members
  421. // ---------------------------------------------------------------------------
  422. STDMETHODIMP Encode(HWND hwnd, DWORD dwFlags);
  423. STDMETHODIMP Decode(HWND hwnd, DWORD dwFlags, IMimeSecurityCallback * pfn);
  424. STDMETHODIMP GetRecipientCount(DWORD dwFlags, DWORD *pdwRecipCount);
  425. STDMETHODIMP AddRecipient(DWORD dwFlags, DWORD cRecipData, PCMS_RECIPIENT_INFO recipData);
  426. STDMETHODIMP GetRecipient(DWORD dwFlags, DWORD iRecipient, DWORD cRecipients, PCMS_RECIPIENT_INFO pRecipData);
  427. STDMETHODIMP DeleteRecipient(DWORD dwFlgas, DWORD iRecipient, DWORD cRecipients);
  428. STDMETHODIMP GetAttribute(DWORD dwFlags, DWORD iSigner, DWORD iAttributeSet,
  429. DWORD iInstance, LPCSTR pszObjId,
  430. CRYPT_ATTRIBUTE ** ppattr);
  431. STDMETHODIMP SetAttribute(DWORD dwFlags, DWORD iSigner, DWORD iAttributeSet,
  432. const CRYPT_ATTRIBUTE * pattr);
  433. STDMETHODIMP DeleteAttribute(DWORD dwFlags, DWORD iSigner, DWORD iAttributeSet,
  434. DWORD iInstance, LPCSTR pszObjid);
  435. STDMETHODIMP CreateReceipt(DWORD dwFlags, DWORD cbFromNames, const BYTE * pbFromNames, DWORD cSignerCertificates, PCCERT_CONTEXT * rgSignerCertificates, IMimeMessage ** ppMimeMessageRecipient);
  436. STDMETHODIMP GetReceiptSendersList(DWORD dwFlags, DWORD * pcSendersList, CERT_NAME_BLOB ** rgSendersList);
  437. STDMETHODIMP VerifyReceipt(DWORD dwFlags, IMimeMessage * pMimeMesageReceipt);
  438. STDMETHODIMP CapabilitiesSupported(DWORD * pdwFeatures);
  439. #endif // SMIME_V3
  440. // ---------------------------------------------------------------------------
  441. // CMessageTree members
  442. // ---------------------------------------------------------------------------
  443. HRESULT IsState(DWORD dwState);
  444. DWORD DwGetFlags(void);
  445. void ClearDirty(void);
  446. virtual HRESULT PrivateQueryInterface(REFIID riid, LPVOID * ppvObj);
  447. void SetState(DWORD dwState) {
  448. EnterCriticalSection(&m_cs);
  449. FLAGSET(m_dwState, dwState);
  450. LeaveCriticalSection(&m_cs);
  451. }
  452. // ---------------------------------------------------------------------------
  453. // Active Url Caching Methods
  454. // ---------------------------------------------------------------------------
  455. HRESULT HrActiveUrlRequest(LPURLREQUEST pRequest);
  456. HRESULT CompareRootUrl(LPCSTR pszUrl);
  457. HRESULT SetActiveUrl(CActiveUrl *pActiveUrl);
  458. // ---------------------------------------------------------------------------
  459. // CMessageTree members
  460. // ---------------------------------------------------------------------------
  461. #ifdef DEBUG
  462. void DebugDumpTree(LPSTR pszfunc, BOOL fWrite);
  463. void DebugDumpTree(LPTREENODEINFO pParent, ULONG ulLevel, BOOL fVerbose);
  464. void DebugAssertNotLinked(LPTREENODEINFO pBody);
  465. void DebugWriteXClient();
  466. #endif
  467. private:
  468. // ----------------------------------------------------------------------------
  469. // Save Methods
  470. // ----------------------------------------------------------------------------
  471. HRESULT _HrApplySaveSecurity(void);
  472. HRESULT _HrWriteMessage(IStream *pStream, BOOL fClearDirty, BOOL fHandsOffOnSave,
  473. BOOL fSMimeCTE);
  474. HRESULT _HrCleanupMessageTree(LPTREENODEINFO pParent);
  475. HRESULT _HrSetMessageId(LPTREENODEINFO pNode);
  476. HRESULT _HrWriteUUFileName(IStream *pStream, LPTREENODEINFO pNode);
  477. HRESULT _HrWriteHeader(BOOL fClearDirty, IStream *pStream, LPTREENODEINFO pNode);
  478. HRESULT _HrWriteBoundary(LPSTREAM pStream, LPSTR pszBoundary, BOUNDARYTYPE boundary, LPDWORD pcboffStart, LPDWORD pcboffEnd);
  479. HRESULT _HrBodyInheritOptions(LPTREENODEINFO pNode);
  480. HRESULT _HrSaveBody(BOOL fClearDirty, DWORD dwFlags, IStream *pStream, LPTREENODEINFO pNode, ULONG ulLevel);
  481. HRESULT _HrSaveMultiPart(BOOL fClearDirty, DWORD dwFlags, LPSTREAM pStream, LPTREENODEINFO pNode, ULONG ulLevel);
  482. HRESULT _HrSaveSinglePart(BOOL fClearDirty, DWORD dwFlags, LPSTREAM pStream, LPTREENODEINFO pNode, ULONG ulLevel);
  483. HRESULT _HrComputeBoundary(LPTREENODEINFO pNode, ULONG ulLevel, LPSTR pszBoundary, LONG cchMax);
  484. void _GenerateBoundary(LPSTR pszBoundary, DWORD cchSize, ULONG ulLevel);
  485. void _HandleCanInlineTextOption(void);
  486. HRESULT _GetContentTransferEncoding(LPTREENODEINFO pNode, BOOL fText, BOOL fPlain, BOOL fMessage, BOOL fAttachment, DWORD dwFlags, ENCODINGTYPE *pietEncoding);
  487. // ----------------------------------------------------------------------------
  488. // BindToOffsetTable Methods
  489. // ----------------------------------------------------------------------------
  490. HRESULT _HrBindOffsetTable(IStream *pStream, CStreamLockBytes **ppStmLock);
  491. HRESULT _HrFastParseBody(CInternetStream *pInternet, LPTREENODEINFO pNode);
  492. HRESULT _HrValidateOffsets(LPTREENODEINFO pNode);
  493. HRESULT _HrValidateStartBoundary(CInternetStream *pInternet, LPTREENODEINFO pNode, LPSTR *ppszFileName);
  494. HRESULT _HrComputeDefaultContent(LPTREENODEINFO pNode, LPCSTR pszFileName);
  495. // ----------------------------------------------------------------------------
  496. // Allocators / De-Allocator Methods
  497. // ----------------------------------------------------------------------------
  498. HRESULT _HrCreateTreeNode(LPTREENODEINFO *ppNode);
  499. HRESULT _HrAllocateTreeNode(ULONG ulIndex);
  500. void _PostCreateTreeNode(HRESULT hrResult, LPTREENODEINFO pNode);
  501. void _FreeNodeTableElements(void);
  502. void _UnlinkTreeNode(LPTREENODEINFO pNode);
  503. void _FreeTreeNodeInfo(LPTREENODEINFO pNode, BOOL fFull=TRUE);
  504. // ----------------------------------------------------------------------------
  505. // International Methods
  506. // ----------------------------------------------------------------------------
  507. HRESULT _HrSetCharsetTree(LPTREENODEINFO pNode, HCHARSET hCharset, CSETAPPLYTYPE applytype);
  508. HRESULT _HrGetCharsetTree(LPTREENODEINFO pNode, LPHCHARSET phCharset);
  509. // ----------------------------------------------------------------------------
  510. // Boundary Methods
  511. // ----------------------------------------------------------------------------
  512. BOOL _FIsUuencodeBegin(LPPROPSTRINGA pLine, LPSTR *ppszFileName);
  513. BOUNDARYTYPE _GetMimeBoundaryType(LPPROPSTRINGA pLine, LPPROPSTRINGA pBoundary);
  514. // ----------------------------------------------------------------------------
  515. // Interface Recursion and Helper Methods
  516. // ----------------------------------------------------------------------------
  517. void _DeleteChildren(LPTREENODEINFO pParent);
  518. void _CountChildrenInt(LPTREENODEINFO pParent, BOOL fRecurse, ULONG *pcChildren);
  519. void _InitNewWithoutRoot(void);
  520. void _ApplyOptionToAllBodies(const TYPEDID oid, LPCPROPVARIANT pValue);
  521. void _FuzzyPartialRecognition(BOOL fIsMime);
  522. void _ResetObject(BOOKTREERESET ResetType);
  523. void _RecursiveGetFlags(LPTREENODEINFO pNode, LPDWORD pdwFlags, BOOL fInRelated);
  524. BOOL _FIsValidHandle(HBODY hBody);
  525. HRESULT _HrLoadInitNew(void);
  526. HRESULT _HrDeletePromoteChildren(LPTREENODEINFO pNode);
  527. HRESULT _HrNodeFromHandle(HBODY hBody, LPTREENODEINFO *ppNode);
  528. HRESULT _HrRecurseResolveURL(LPTREENODEINFO pRelated, LPRESOLVEURLINFO pInfo, LPHBODY phBody);
  529. HRESULT _HrEnumeratAttachments(HBODY hBody, ULONG *pcBodies, LPHBODY prghBody);
  530. HRESULT _HrDataObjectGetHeaderA(LPSTREAM pStream);
  531. HRESULT _HrDataObjectGetHeaderW(LPSTREAM pStream);
  532. HRESULT _HrDataObjectWriteHeaderA(LPSTREAM pStream, UINT idsHeader, LPSTR pszData);
  533. HRESULT _HrDataObjectWriteHeaderW(LPSTREAM pStream, UINT idsHeader, LPWSTR pwszData);
  534. HRESULT _HrDataObjectGetSource(CLIPFORMAT cfFormat, LPSTREAM pstmData);
  535. HRESULT _HrGetTextTypeInfo(DWORD dwTxtType, LPTEXTTYPEINFO *ppTextInfo);
  536. HRESULT _FindDisplayableTextBody(LPCSTR pszSubType, LPTREENODEINFO pNode, LPHBODY phBody);
  537. LPTREENODEINFO _PNodeFromHBody(HBODY hBody);
  538. // ----------------------------------------------------------------------------
  539. // Private Members
  540. // ----------------------------------------------------------------------------
  541. void _LinkUrlRequest(LPURLREQUEST pRequest, LPURLREQUEST *ppHead);
  542. void _ReleaseUrlRequestList(LPURLREQUEST *ppHead);
  543. void _UnlinkUrlRequest(LPURLREQUEST pRequest, LPURLREQUEST *ppHead);
  544. void _RelinkUrlRequest(LPURLREQUEST pRequest, LPURLREQUEST *ppSource, LPURLREQUEST *ppDest);
  545. HRESULT _HrBindNodeComplete(LPTREENODEINFO pNode, HRESULT hrResult);
  546. HRESULT _HrOnFoundMultipartEnd(void);
  547. HRESULT _HrOnFoundNodeEnd(DWORD cbBoundaryStart, HRESULT hrBind=S_OK);
  548. HRESULT _HrProcessPendingUrlRequests(void);
  549. HRESULT _HrResolveUrlRequest(LPURLREQUEST pRequest, BOOL *pfResolved);
  550. HRESULT _HrMultipartMimeNext(DWORD cboffBoundary);
  551. HRESULT _HrInitializeStorage(IStream *pStream);
  552. HRESULT _HrBindTreeNode(LPTREENODEINFO pNode);
  553. HRESULT _HrSychronizeWebPage(LPTREENODEINFO pNode);
  554. void _DecodeRfc1154();
  555. // ----------------------------------------------------------------------------
  556. // Bind State Handlers
  557. // ----------------------------------------------------------------------------
  558. HRESULT _HrBindParsingHeader(void);
  559. HRESULT _HrBindFindingMimeFirst(void);
  560. HRESULT _HrBindFindingMimeNext(void);
  561. HRESULT _HrBindFindingUuencodeBegin(void);
  562. HRESULT _HrBindFindingUuencodeEnd(void);
  563. HRESULT _HrBindRfc1154(void);
  564. // ----------------------------------------------------------------------------
  565. // Static Array of Function Pointers
  566. // ----------------------------------------------------------------------------
  567. static const PFNBINDPARSER m_rgBindStates[BINDSTATE_LAST];
  568. // ----------------------------------------------------------------------------
  569. // CMessageWebPage is a good friend
  570. // ----------------------------------------------------------------------------
  571. friend CMessageWebPage;
  572. private:
  573. // ----------------------------------------------------------------------------
  574. // Private Data
  575. // ----------------------------------------------------------------------------
  576. TREEOPTIONS m_rOptions; // Save options
  577. LPWSTR m_pwszFilePath; // File Used in IPersistFile
  578. WORD m_wTag; // HBODY Tag
  579. DWORD m_cbMessage; // Sizeof message
  580. DWORD m_dwState; // State of the tree TS_xxx
  581. LPTREENODEINFO m_pRootNode; // Root Body Object
  582. CStreamLockBytes *m_pStmLock; // Protective Wrapper for m_pStream
  583. IMoniker *m_pMoniker; // Current moniker
  584. IBinding *m_pBinding; // Used in async binding operation
  585. CInternetStream *m_pInternet; // Text Stream that wraps m_pStmLock
  586. CBindStream *m_pStmBind; // Used for tempfile binding
  587. IStream *m_pRootStm; // Root document stream
  588. HRESULT m_hrBind; // Current Bind Result
  589. LPTREENODEINFO m_pBindNode; // Current Node being parsed
  590. LPURLREQUEST m_pPending; // Head Un-resolved bind request
  591. LPURLREQUEST m_pComplete; // Head Un-resolved bind request
  592. TREENODETABLE m_rTree; // Body Table
  593. PROPSTRINGA m_rRootUrl; // Moniker Base Url
  594. CActiveUrl *m_pActiveUrl; // Active Url
  595. CMessageWebPage *m_pWebPage; // CreateWebPage Results
  596. WEBPAGEOPTIONS m_rWebPageOpt; // Web Page Options
  597. IMimeMessageCallback *m_pCallback; // WebPage Callback
  598. BOOL m_fApplySaveSecurity;// Used to prevent re-entrancy into _HrWriteMessage
  599. CRITICAL_SECTION m_cs; // Thread Safety
  600. LPBC m_pBC; // bindcontext for moniker
  601. BOOKTREE1154 *m_pBT1154; // State of RFC1154 handling
  602. };
  603. // --------------------------------------------------------------------------------
  604. // Types
  605. // --------------------------------------------------------------------------------
  606. typedef CMessageTree *LPMESSAGETREE;
  607. #endif // __BOOKTREE_H