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