Source code of Windows XP (NT5)
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.

198 lines
7.4 KiB

  1. /*
  2. * I M E S S A G E . H
  3. *
  4. * External definitions for MAPI's IMessage-on-IStorage facility
  5. *
  6. * Copyright 1986-1999 Microsoft Corporation. All Rights Reserved.
  7. */
  8. #ifndef _IMESSAGE_H_
  9. #define _IMESSAGE_H_
  10. #if _MSC_VER > 1000
  11. #pragma once
  12. #endif
  13. #ifdef __cplusplus
  14. extern "C"
  15. {
  16. #endif
  17. typedef struct _MSGSESS FAR * LPMSGSESS;
  18. /* Typedef of optional callback routine to be called on last release of
  19. * top-level messages opened with OpenIMsgOnIStg
  20. */
  21. typedef void (STDAPICALLTYPE MSGCALLRELEASE)(
  22. ULONG ulCallerData,
  23. LPMESSAGE lpMessage );
  24. /* DLL Entry Points (found in mapiu.dll) */
  25. /* OpenIMsgSession
  26. * CloseIMsgSession
  27. *
  28. * These entry points allow the caller to "wrap" the creation of messages
  29. * inside a session, so that when the session is closed, all messages
  30. * created within that session are closed as well. Use of IMSG sessions
  31. * is optional. If OpenIMsgOnIStg is called with a NULL for the lpmsgsess
  32. * parameter, the message is created independent of any session, and has
  33. * no way to be shutdown. If the caller forgets to release the message, or
  34. * to release open tables within the message, the memory will be leaked until
  35. * the external application terminates.
  36. */
  37. STDAPI_(SCODE) OpenIMsgSession(
  38. LPMALLOC lpMalloc, /* -> Co malloc object */
  39. ULONG ulFlags, /* reserved. Must be zero. */
  40. LPMSGSESS FAR *lppMsgSess ); /* <- message session object */
  41. STDAPI_(void) CloseIMsgSession(
  42. LPMSGSESS lpMsgSess ); /* -> message session object */
  43. /* OpenIMsgOnIStg - Main entry point
  44. *
  45. * NOTE 1: The IStg must be opened with STGM_TRANSACTED if STGM_READWRITE
  46. * is specified. Since messages don't support a write only mode, IMessage
  47. * doesn't allow a storage object opened in write only mode. If the storage
  48. * is opened STGM_READ, then STGM_TRANSACTED is NOT required.
  49. *
  50. * NOTE 2: The lpMapiSup parameter is optional. If supplied then IMessage
  51. * will support the MAPI_DIALOG and ATTACH_DIALOG flags (by calling
  52. * support method: DoMCDialog) on CopyTo and DeleteAttach methods.
  53. * If lpMapiSup is not supplied (i.e. passed 0) then dialog flags will be
  54. * ignored. If supplied then ModifyRecipients will attempt to convert
  55. * short term entryids to long term entryids (by calling support method
  56. * OpenAddressBook and calls on the returned object). If not supplied
  57. * then short term entryid's will be stored without conversion.
  58. *
  59. * NOTE 3: The lpfMsgCallRelease parameter is optional. If supplied then
  60. * IMessage will call the routine when the last release on (the toplevel only)
  61. * message is called. It is intended to allow the callee to free the IStorage
  62. * that contains the message. IMessage will not use the IStorage object after
  63. * making this call.
  64. *
  65. * NOTE 4: Behavior of multiple opens of sub-objects (Attachments, Streams,
  66. * Storages, Messages, etc.) within a message is deliberately undefined in
  67. * MAPI. This implementation allows them, but will do it by AddRef'ing the
  68. * existing open and returning it to the caller of OpenAttachment or
  69. * OpenProperty. This means that whatever access mode the first open on a
  70. * specific Attachment or Property had is what all others will get regardless
  71. * of what the subsequent opens asked for.
  72. *
  73. * NOTE 5: There is currently one flag defined for use with the ulFlags
  74. * parameter. The IMSG_NO_ISTG_COMMIT flag controls whether the commit
  75. * method of IStorage is called when the client calls SaveChanges on the
  76. * IMessage object. Some clients of IMessage may wish to commit the IStorage
  77. * themselves after writing additional data to the storage (beyond what
  78. * IMessage itself writes). To aid in this, the IMessage implementation
  79. * guarantees to name all sub-storages starting with "__". Therefore,
  80. * if the client keeps its names out of that namespace, there will be no
  81. * accidental collisions.
  82. *
  83. * WARNING:
  84. *
  85. * This implementation of IMessage will support OpenProperty w/MAPI_CREATE
  86. * where the source interface is IID_IStorage if the property id is
  87. * 'PR_ATTACH_DATA'. Once this has been done, the caller has an IStorage
  88. * interface on this property. This is ok and should allow for
  89. * easier implementation of OLE 2.0 Server functionality. However, if you
  90. * pass in the new IStorage ptr (to the attachment data) through the
  91. * OpenIMsgOnIStg entry point and then proceed to release things in the
  92. * wrong order we will make no attempt to behave in a predictable fashion.
  93. * Keep in mind that the correct method for placing a message into an
  94. * attachment is to call OpenProperty where the source interface is
  95. * IID_IMessage. The IStorage interface is supported to allow an easy way
  96. * to stick a WWord doc. into an attachment w/o converting to/from IStream.
  97. *
  98. */
  99. STDAPI_(SCODE) OpenIMsgOnIStg(
  100. LPMSGSESS lpMsgSess, /* -> message session obj (optional) */
  101. LPALLOCATEBUFFER lpAllocateBuffer, /* -> AllocateBuffer memory routine */
  102. LPALLOCATEMORE lpAllocateMore, /* -> AllocateMore memory routine */
  103. LPFREEBUFFER lpFreeBuffer, /* -> FreeBuffer memory routine */
  104. LPMALLOC lpMalloc, /* -> Co malloc object */
  105. LPVOID lpMapiSup, /* -> MAPI Support Obj (optional) */
  106. LPSTORAGE lpStg, /* -> open IStorage containing msg */
  107. MSGCALLRELEASE FAR *lpfMsgCallRelease, /* -> release callback rtn (opt) */
  108. ULONG ulCallerData, /* caller data returned in callback */
  109. ULONG ulFlags, /* -> flags (controls istg commit) */
  110. LPMESSAGE FAR *lppMsg ); /* <- open message object */
  111. #define IMSG_NO_ISTG_COMMIT ((ULONG) 0x00000001)
  112. /* NOTE: Property Attributes are specific to this IMessage on IStorage */
  113. /* implementation and are not a part of standard MAPI 1.0 property methods */
  114. /* Property Attributes */
  115. #define PROPATTR_MANDATORY ((ULONG) 0x00000001)
  116. #define PROPATTR_READABLE ((ULONG) 0x00000002)
  117. #define PROPATTR_WRITEABLE ((ULONG) 0x00000004)
  118. #define PROPATTR_NOT_PRESENT ((ULONG) 0x00000008)
  119. /* Attribute Array */
  120. typedef struct _SPropAttrArray
  121. {
  122. ULONG cValues;
  123. ULONG aPropAttr[MAPI_DIM];
  124. } SPropAttrArray, FAR * LPSPropAttrArray;
  125. #define CbNewSPropAttrArray(_cattr) \
  126. (offsetof(SPropAttrArray,aPropAttr) + (_cattr)*sizeof(ULONG))
  127. #define CbSPropAttrArray(_lparray) \
  128. (offsetof(SPropAttrArray,aPropAttr) + \
  129. (UINT)((_lparray)->cValues)*sizeof(ULONG))
  130. #define SizedSPropAttrArray(_cattr, _name) \
  131. struct _SPropAttrArray_ ## _name \
  132. { \
  133. ULONG cValues; \
  134. ULONG aPropAttr[_cattr]; \
  135. } _name
  136. /* GetAttribIMsgOnIStg - To get attributes on properties
  137. *
  138. * This call is provided because there is no method of IMAPIPropSet to allow
  139. * getting attributes.
  140. */
  141. STDAPI GetAttribIMsgOnIStg(
  142. LPVOID lpObject,
  143. LPSPropTagArray lpPropTagArray,
  144. LPSPropAttrArray FAR *lppPropAttrArray );
  145. /* SetAttribIMsgOnIStg - To set attributes on properties
  146. *
  147. * This call is provided because there is no method of IMAPIPropSet to allow
  148. * setting of attributes.
  149. */
  150. STDAPI SetAttribIMsgOnIStg(
  151. LPVOID lpObject,
  152. LPSPropTagArray lpPropTags,
  153. LPSPropAttrArray lpPropAttrs,
  154. LPSPropProblemArray FAR *lppPropProblems );
  155. /* MapStorageSCode - To map an IStorage hResult to a MAPI sCode value
  156. *
  157. * This call is provided for the internal use of PDK components that base
  158. * their message implementations on IMessage. Since these components must
  159. * open the storage themselves, there is a common need to map OLE 2.0
  160. * Storage error returns to MAPI sCodes.
  161. *
  162. * WARNING: There is no guarantee that this entry point will exist in
  163. * shipped versions of mapiu.dll.
  164. */
  165. STDAPI_(SCODE) MapStorageSCode( SCODE StgSCode );
  166. #ifdef __cplusplus
  167. }
  168. #endif
  169. #endif /* _IMESSAGE_H_ */