home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / tnef.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  14KB  |  372 lines

  1. /*
  2.  *  T N E F . H
  3.  *
  4.  *
  5.  *  This file contains structure and function definitions for the
  6.  *  MAPI implementation of the Transport Neutral Encapsilation Format
  7.  *  used by MAPI providers for the neutral serialization of a MAPI
  8.  *  message.  This implementation sits on top of the IStream object as
  9.  *  documented in the OLE 2 Specs.
  10.  *
  11.  *  Copyright 1986-1996 Microsoft Corporation. All Rights Reserved.
  12.  */
  13.  
  14. #ifndef TNEF_H
  15. #define TNEF_H
  16.  
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20.  
  21.  
  22. #ifndef BEGIN_INTERFACE
  23. #define BEGIN_INTERFACE
  24. #endif
  25.  
  26. /* ------------------------------------ */
  27. /* TNEF Problem and TNEF Problem Arrays */
  28. /* ------------------------------------ */
  29.  
  30. typedef struct _STnefProblem
  31. {
  32.     ULONG   ulComponent;
  33.     ULONG   ulAttribute;
  34.     ULONG   ulPropTag;
  35.     SCODE   scode;
  36. } STnefProblem;
  37.  
  38. typedef struct _STnefProblemArray
  39. {
  40.     ULONG           cProblem;
  41.     STnefProblem    aProblem[MAPI_DIM];
  42. } STnefProblemArray, FAR * LPSTnefProblemArray;
  43.  
  44. #define CbNewSTnefProblemArray(_cprob) \
  45.     (offsetof(STnefProblemArray,aProblem) + (_cprob)*sizeof(STnefProblem))
  46. #define CbSTnefProblemArray(_lparray) \
  47.     (offsetof(STnefProblemArray,aProblem) + \
  48.     (UINT) ((_lparray)->cProblem*sizeof(STnefProblem)))
  49.  
  50. /* Pointers to TNEF Interface ---------------------------------------- */
  51.  
  52. DECLARE_MAPI_INTERFACE_PTR(ITnef, LPITNEF);
  53.  
  54. /*  OpenTNEFStream */
  55.  
  56. #define TNEF_DECODE                 ((ULONG) 0)
  57. #define TNEF_ENCODE                 ((ULONG) 2)
  58.  
  59. #define TNEF_PURE                   ((ULONG) 0x00010000)
  60. #define TNEF_COMPATIBILITY          ((ULONG) 0x00020000)
  61. #define TNEF_BEST_DATA              ((ULONG) 0x00040000)
  62. #define TNEF_COMPONENT_ENCODING     ((ULONG) 0x80000000)
  63.  
  64. /*  AddProps, ExtractProps */
  65.  
  66. #define TNEF_PROP_INCLUDE           ((ULONG) 0x00000001)
  67. #define TNEF_PROP_EXCLUDE           ((ULONG) 0x00000002)
  68. #define TNEF_PROP_CONTAINED         ((ULONG) 0x00000004)
  69. #define TNEF_PROP_MESSAGE_ONLY      ((ULONG) 0x00000008)
  70. #define TNEF_PROP_ATTACHMENTS_ONLY  ((ULONG) 0x00000010)
  71. #define TNEF_PROP_CONTAINED_TNEF    ((ULONG) 0x00000040)
  72.  
  73. /*  FinishComponent */
  74.  
  75. #define TNEF_COMPONENT_MESSAGE      ((ULONG) 0x00001000)
  76. #define TNEF_COMPONENT_ATTACHMENT   ((ULONG) 0x00002000)
  77.  
  78. #define MAPI_ITNEF_METHODS(IPURE)                                       \
  79.     MAPIMETHOD(AddProps)                                                \
  80.         (THIS_  ULONG                       ulFlags,                    \
  81.                 ULONG                       ulElemID,                   \
  82.                 LPVOID                      lpvData,                    \
  83.                 LPSPropTagArray             lpPropList) IPURE;          \
  84.     MAPIMETHOD(ExtractProps)                                            \
  85.         (THIS_  ULONG                       ulFlags,                    \
  86.                 LPSPropTagArray             lpPropList,                 \
  87.                 LPSTnefProblemArray FAR *   lpProblems) IPURE;          \
  88.     MAPIMETHOD(Finish)                                                  \
  89.         (THIS_  ULONG                       ulFlags,                    \
  90.                 WORD FAR *                  lpKey,                      \
  91.                 LPSTnefProblemArray FAR *   lpProblems) IPURE;          \
  92.     MAPIMETHOD(OpenTaggedBody)                                          \
  93.         (THIS_  LPMESSAGE                   lpMessage,                  \
  94.                 ULONG                       ulFlags,                    \
  95.                 LPSTREAM FAR *              lppStream) IPURE;           \
  96.     MAPIMETHOD(SetProps)                                                \
  97.         (THIS_  ULONG                       ulFlags,                    \
  98.                 ULONG                       ulElemID,                   \
  99.                 ULONG                       cValues,                    \
  100.                 LPSPropValue                lpProps) IPURE;             \
  101.     MAPIMETHOD(EncodeRecips)                                            \
  102.         (THIS_  ULONG                       ulFlags,                    \
  103.                 LPMAPITABLE                 lpRecipientTable) IPURE;    \
  104.     MAPIMETHOD(FinishComponent)                                         \
  105.         (THIS_  ULONG                       ulFlags,                    \
  106.                 ULONG                       ulComponentID,              \
  107.                 LPSPropTagArray             lpCustomPropList,           \
  108.                 LPSPropValue                lpCustomProps,              \
  109.                 LPSPropTagArray             lpPropList,                 \
  110.                 LPSTnefProblemArray FAR *   lpProblems) IPURE;          \
  111.  
  112. #undef       INTERFACE
  113. #define      INTERFACE  ITnef
  114. DECLARE_MAPI_INTERFACE_(ITnef, IUnknown)
  115. {
  116.     BEGIN_INTERFACE
  117.     MAPI_IUNKNOWN_METHODS(PURE)
  118.     MAPI_ITNEF_METHODS(PURE)
  119. };
  120.  
  121. STDMETHODIMP OpenTnefStream(
  122.     LPVOID              lpvSupport,
  123.     LPSTREAM            lpStream,
  124.     LPTSTR              lpszStreamName,
  125.     ULONG               ulFlags,
  126.     LPMESSAGE           lpMessage,
  127.     WORD                wKeyVal,
  128.     LPITNEF FAR *       lppTNEF);
  129.  
  130. typedef HRESULT (STDMETHODCALLTYPE FAR * LPOPENTNEFSTREAM) (
  131.     LPVOID              lpvSupport,
  132.     LPSTREAM            lpStream,
  133.     LPTSTR              lpszStreamName,
  134.     ULONG               ulFlags,
  135.     LPMESSAGE           lpMessage,
  136.     WORD                wKeyVal,
  137.     LPITNEF FAR *       lppTNEF);
  138.  
  139. STDMETHODIMP OpenTnefStreamEx(
  140.     LPVOID              lpvSupport,
  141.     LPSTREAM            lpStream,
  142.     LPTSTR              lpszStreamName,
  143.     ULONG               ulFlags,
  144.     LPMESSAGE           lpMessage,
  145.     WORD                wKeyVal,
  146.     LPADRBOOK           lpAdressBook,
  147.     LPITNEF FAR *       lppTNEF);
  148.  
  149. typedef HRESULT (STDMETHODCALLTYPE FAR * LPOPENTNEFSTREAMEX) (
  150.     LPVOID              lpvSupport,
  151.     LPSTREAM            lpStream,
  152.     LPTSTR              lpszStreamName,
  153.     ULONG               ulFlags,
  154.     LPMESSAGE           lpMessage,
  155.     WORD                wKeyVal,
  156.     LPADRBOOK           lpAdressBook,
  157.     LPITNEF FAR *       lppTNEF);
  158.  
  159. STDMETHODIMP GetTnefStreamCodepage (
  160.     LPSTREAM            lpStream,
  161.     ULONG FAR *         lpulCodepage,
  162.     ULONG FAR *         lpulSubCodepage);
  163.  
  164. typedef HRESULT (STDMETHODCALLTYPE FAR * LPGETTNEFSTREAMCODEPAGE) (
  165.     LPSTREAM            lpStream,
  166.     ULONG FAR *         lpulCodepage,
  167.     ULONG FAR *         lpulSubCodepage);
  168.  
  169. #define OPENTNEFSTREAM "OpenTnefStream"
  170. #define OPENTNEFSTREAMEX "OpenTnefStreamEx"
  171. #define GETTNEFSTREAMCODEPAGE "GetTnefStreamCodePage"
  172.  
  173. /* -------------------------- */
  174. /* TNEF Signature and Version */
  175. /* -------------------------- */
  176.  
  177. #define MAKE_TNEF_VERSION(_mj,_mn)  (((ULONG)(0x0000FFFF & _mj) << 16) | (ULONG)(0x0000FFFF & _mn))
  178. #define TNEF_SIGNATURE  ((ULONG) 0x223E9F78)
  179. #define TNEF_VERSION    ((ULONG) MAKE_TNEF_VERSION(1,0))
  180.  
  181.  
  182. /* ------------------------------------------- */
  183. /* TNEF Down-level Attachment Types/Structures */
  184. /* ------------------------------------------- */
  185.  
  186. typedef WORD ATYP;
  187. enum { atypNull, atypFile, atypOle, atypPicture, atypMax };
  188.  
  189. #define MAC_BINARY  ((DWORD) 0x00000001)
  190.  
  191. #pragma pack (1)
  192. typedef struct _renddata
  193. {
  194.     ATYP    atyp;
  195.     ULONG   ulPosition;
  196.     WORD    dxWidth;
  197.     WORD    dyHeight;
  198.     DWORD   dwFlags;
  199.  
  200. } RENDDATA, *PRENDDATA;
  201. #pragma pack ()
  202.  
  203.  
  204. /* ----------------------------------- */
  205. /* TNEF Down-level Date/Time Structure */
  206. /* ----------------------------------- */
  207.  
  208. #pragma pack (1)
  209. typedef struct _dtr
  210. {
  211.     WORD    wYear;
  212.     WORD    wMonth;
  213.     WORD    wDay;
  214.     WORD    wHour;
  215.     WORD    wMinute;
  216.     WORD    wSecond;
  217.     WORD    wDayOfWeek;
  218.  
  219. } DTR;
  220. #pragma pack ()
  221.  
  222.  
  223. /* ----------------------------- */
  224. /* TNEF Down-level Message Flags */
  225. /* ----------------------------- */
  226.  
  227. #define fmsNull         ((BYTE) 0x00)
  228. #define fmsModified     ((BYTE) 0x01)
  229. #define fmsLocal        ((BYTE) 0x02)
  230. #define fmsSubmitted    ((BYTE) 0x04)
  231. #define fmsRead         ((BYTE) 0x20)
  232. #define fmsHasAttach    ((BYTE) 0x80)
  233.  
  234.  
  235. /* ----------------------------------------- */
  236. /* TNEF Down-level Triple Address Structures */
  237. /* ----------------------------------------- */
  238.  
  239. #define trpidNull                   ((WORD) 0x0000)
  240. #define trpidUnresolved             ((WORD) 0x0001)
  241. #define trpidResolvedNSID           ((WORD) 0x0002)
  242. #define trpidResolvedAddress        ((WORD) 0x0003)
  243. #define trpidOneOff                 ((WORD) 0x0004)
  244. #define trpidGroupNSID              ((WORD) 0x0005)
  245. #define trpidOffline                ((WORD) 0x0006)
  246. #define trpidIgnore                 ((WORD) 0x0007)
  247. #define trpidClassEntry             ((WORD) 0x0008)
  248. #define trpidResolvedGroupAddress   ((WORD) 0x0009)
  249. typedef struct _trp
  250. {
  251.     WORD    trpid;
  252.     WORD    cbgrtrp;
  253.     WORD    cch;
  254.     WORD    cbRgb;
  255.  
  256. } TRP, *PTRP, *PGRTRP, FAR * LPTRP;
  257. #define CbOfTrp(_p)     (sizeof(TRP) + (_p)->cch + (_p)->cbRgb)
  258. #define LpszOfTrp(_p)   ((LPSTR)(((LPTRP) (_p)) + 1))
  259. #define LpbOfTrp(_p)    (((LPBYTE)(((LPTRP)(_p)) + 1)) + (_p)->cch)
  260. #define LptrpNext(_p)   ((LPTRP)((LPBYTE)(_p) + CbOfTrp(_p)))
  261.  
  262. typedef DWORD XTYPE;
  263. #define xtypeUnknown    ((XTYPE) 0)
  264. #define xtypeInternet   ((XTYPE) 6)
  265.  
  266. #define cbDisplayName   41
  267. #define cbEmailName     11
  268. #define cbSeverName     12
  269. typedef struct _ADDR_ALIAS
  270. {
  271.     char    rgchName[cbDisplayName];
  272.     char    rgchEName[cbEmailName];
  273.     char    rgchSrvr[cbSeverName];
  274.     ULONG   dibDetail;
  275.     WORD    type;
  276.  
  277. } ADDRALIAS, FAR * LPADDRALIAS;
  278. #define cbALIAS sizeof(ALIAS)
  279.  
  280. #define cbTYPE              16
  281. #define cbMaxIdData         200
  282. typedef struct _NSID
  283. {
  284.     DWORD   dwSize;
  285.     unsigned char   uchType[cbTYPE];
  286.     XTYPE   xtype;
  287.     LONG    lTime;
  288.  
  289.     union
  290.     {
  291.         ADDRALIAS   alias;
  292.         char        rgchInterNet[1];
  293.  
  294.     } address;
  295.  
  296. } NSID, * LPNSID;
  297. #define cbNSID sizeof(NSID)
  298.  
  299.  
  300. /* -------------------------- */
  301. /* TNEF Down-level Priorities */
  302. /* -------------------------- */
  303.  
  304. #define prioLow     3
  305. #define prioNorm    2
  306. #define prioHigh    1
  307.  
  308.  
  309. /* ------------------------------------- */
  310. /* TNEF Down-level Attributes/Properties */
  311. /* ------------------------------------- */
  312.  
  313. #define atpTriples      ((WORD) 0x0000)
  314. #define atpString       ((WORD) 0x0001)
  315. #define atpText         ((WORD) 0x0002)
  316. #define atpDate         ((WORD) 0x0003)
  317. #define atpShort        ((WORD) 0x0004)
  318. #define atpLong         ((WORD) 0x0005)
  319. #define atpByte         ((WORD) 0x0006)
  320. #define atpWord         ((WORD) 0x0007)
  321. #define atpDword        ((WORD) 0x0008)
  322. #define atpMax          ((WORD) 0x0009)
  323.  
  324. #define LVL_MESSAGE     ((BYTE) 0x01)
  325. #define LVL_ATTACHMENT  ((BYTE) 0x02)
  326.  
  327. #define ATT_ID(_att)                ((WORD) ((_att) & 0x0000FFFF))
  328. #define ATT_TYPE(_att)              ((WORD) (((_att) >> 16) & 0x0000FFFF))
  329. #define ATT(_atp, _id)              ((((DWORD) (_atp)) << 16) | ((WORD) (_id)))
  330.  
  331. #define attNull                     ATT( 0,             0x0000)
  332. #define attFrom                     ATT( atpTriples,    0x8000) /* PR_ORIGINATOR_RETURN_ADDRESS */
  333. #define attSubject                  ATT( atpString,     0x8004) /* PR_SUBJECT */
  334. #define attDateSent                 ATT( atpDate,       0x8005) /* PR_CLIENT_SUBMIT_TIME */
  335. #define attDateRecd                 ATT( atpDate,       0x8006) /* PR_MESSAGE_DELIVERY_TIME */
  336. #define attMessageStatus            ATT( atpByte,       0x8007) /* PR_MESSAGE_FLAGS */
  337. #define attMessageClass             ATT( atpWord,       0x8008) /* PR_MESSAGE_CLASS */
  338. #define attMessageID                ATT( atpString,     0x8009) /* PR_MESSAGE_ID */
  339. #define attParentID                 ATT( atpString,     0x800A) /* PR_PARENT_ID */
  340. #define attConversationID           ATT( atpString,     0x800B) /* PR_CONVERSATION_ID */
  341. #define attBody                     ATT( atpText,       0x800C) /* PR_BODY */
  342. #define attPriority                 ATT( atpShort,      0x800D) /* PR_IMPORTANCE */
  343. #define attAttachData               ATT( atpByte,       0x800F) /* PR_ATTACH_DATA_xxx */
  344. #define attAttachTitle              ATT( atpString,     0x8010) /* PR_ATTACH_FILENAME */
  345. #define attAttachMetaFile           ATT( atpByte,       0x8011) /* PR_ATTACH_RENDERING */
  346. #define attAttachCreateDate         ATT( atpDate,       0x8012) /* PR_CREATION_TIME */
  347. #define attAttachModifyDate         ATT( atpDate,       0x8013) /* PR_LAST_MODIFICATION_TIME */
  348. #define attDateModified             ATT( atpDate,       0x8020) /* PR_LAST_MODIFICATION_TIME */
  349. #define attAttachTransportFilename  ATT( atpByte,       0x9001) /* PR_ATTACH_TRANSPORT_NAME */
  350. #define attAttachRenddata           ATT( atpByte,       0x9002)
  351. #define attMAPIProps                ATT( atpByte,       0x9003)
  352. #define attRecipTable               ATT( atpByte,       0x9004) /* PR_MESSAGE_RECIPIENTS */
  353. #define attAttachment               ATT( atpByte,       0x9005)
  354. #define attTnefVersion              ATT( atpDword,      0x9006)
  355. #define attOemCodepage              ATT( atpByte,       0x9007)
  356. #define attOriginalMessageClass     ATT( atpWord,       0x0006) /* PR_ORIG_MESSAGE_CLASS */
  357.  
  358. #define attOwner                    ATT( atpByte,       0x0000) /* PR_RCVD_REPRESENTING_xxx  or
  359.                                                                    PR_SENT_REPRESENTING_xxx */
  360. #define attSentFor                  ATT( atpByte,       0x0001) /* PR_SENT_REPRESENTING_xxx */
  361. #define attDelegate                 ATT( atpByte,       0x0002) /* PR_RCVD_REPRESENTING_xxx */
  362. #define attDateStart                ATT( atpDate,       0x0006) /* PR_DATE_START */
  363. #define attDateEnd                  ATT( atpDate,       0x0007) /* PR_DATE_END */
  364. #define attAidOwner                 ATT( atpLong,       0x0008) /* PR_OWNER_APPT_ID */
  365. #define attRequestRes               ATT( atpShort,      0x0009) /* PR_RESPONSE_REQUESTED */
  366.  
  367. #ifdef __cplusplus
  368. }
  369. #endif
  370.  
  371. #endif  /*  defined TNEF_H */
  372.