Skip to content

Commit

Permalink
Re-vendor MapiStubLibrary
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Sep 12, 2024
1 parent a83b36c commit 8666c6c
Show file tree
Hide file tree
Showing 43 changed files with 29,445 additions and 15,270 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ jobs:
- uses: psf/black@stable
with:
options: "--fast --check --diff --verbose"
- run: | # Too many files to fit in a single command, exclude vendored Scintilla and mapi_headers
- run: | # Too many files to fit in a single command, also exclude vendored Scintilla and MAPIStubLibrary
clang-format --Werror --dry-run $(git ls-files '*.cpp')
clang-format --Werror --dry-run $(git ls-files '*.h' ':!:Pythonwin/Scintilla/' ':!:com/win32comext/mapi/src/mapi_headers/')
clang-format --Werror --dry-run $(git ls-files '*.h' ':!:Pythonwin/Scintilla/' ':!:com/win32comext/mapi/src/MAPIStubLibrary/')
shell: powershell
mypy:
Expand Down
3 changes: 1 addition & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ repos:
# https://github.com/pre-commit/mirrors-clang-format/blob/main/.pre-commit-hooks.yaml#L6
types: [c++]


# Vendored
exclude: ^(com/win32comext/mapi/src/mapi_headers/|Pythonwin/Scintilla/).*$
exclude: ^(com/win32comext/mapi/src/MAPIStubLibrary/|Pythonwin/Scintilla/).*$

ci:
autoupdate_schedule: quarterly
10 changes: 10 additions & 0 deletions com/win32comext/mapi/src/MAPIStubLibrary/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# MAPIStubLibrary

The MAPI Stub Library is a drop in replacement for mapi32.lib which supports building both 32 and 64 bit MAPI applications. This library eliminates the need to explicitly link to MAPI.

**See the [documentation](https://msdn.microsoft.com/en-us/library/office/cc963763.aspx) for information on building the MAPI Stub Library and integrating it into your project.**
**See the [FAQ](https://mapistublibrary.codeplex.com/wikipage?title=FAQ) for questions about this library, such as when and why to use it.**

---

These MAPI headers were downloaded from <https://github.com/microsoft/MAPIStubLibrary/commit/5183a5f18c388a1b964662fa48bb0f08592fc4b8> and enable us to build the MAPI extension.
1,191 changes: 1,191 additions & 0 deletions com/win32comext/mapi/src/MAPIStubLibrary/include/EMSABTAG.H

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ DEFINE_GUID(IID_IExchangeManageStore, 0x559d10b0,0xa772,0x11cd,0x9b,0xc8,0x00,0x
DEFINE_GUID(IID_IExchangeManageStore2,0xb6dca470, 0xff3, 0x11d0, 0xa4, 0x9, 0x0, 0xc0, 0x4f, 0xd7, 0xbd, 0x87);
DEFINE_GUID(IID_IExchangeManageStore3,0x166d9bc2, 0xdb75, 0x44a9, 0x8a, 0x93, 0x9f, 0x3f, 0xfc, 0x99, 0x4d, 0x76) ;
DEFINE_GUID(IID_IExchangeManageStore4,0x2590ff87, 0xc431, 0x4f9c, 0xb1, 0xa8, 0xcd, 0x69, 0xd7, 0x60, 0xcd, 0x10); // {2590FF87-C431-4f9c-B1A8-CD69D760CD10}
DEFINE_GUID(IID_IExchangeManageStoreEx, 0x7fe3c629, 0x4d9a, 0x4510, 0xa4, 0x79, 0x56, 0x96, 0x2b, 0x24, 0x6d, 0xc6);
DEFINE_GUID(IID_IExchangeModifyTable, 0x2d734cb0,0x53fd,0x101b,0xb1,0x9d,0x08,0x00,0x2b,0x30,0x56,0xe3);
DEFINE_GUID(IID_IExchangeRuleAction, 0x74bba840,0xc93a,0x11ce,0x95,0x81,0x00,0xaa,0x00,0x57,0x42,0xf7);

DEFINE_GUID(IID_IExchangeFastTransfer, 0xff7db070,0xa88a,0x11cd,0x9b,0xc8,0x00,0xaa,0x00,0x2f,0xc4,0x5a);

DEFINE_GUID(IID_IExchangeExportChanges, 0xa3ea9cc0,0xd1b2,0x11cd,0x80,0xfc,0x00,0xaa,0x00,0x4b,0xba,0x0b);
DEFINE_GUID(IID_IExchangeExportChanges2, 0x387cebe0,0xf53f,0x11cf,0xa4,0x8f,0x00,0xc0,0x4f, 0xd6, 0x55, 0x95);
DEFINE_GUID(IID_IExchangeExportChanges3, 0x702e7f86,0x50a6,0x11d1,0xab,0xd6,0x00,0xa0,0xc9, 0x05, 0x66, 0x0a);
DEFINE_GUID(IID_IExchangeExportChanges, 0xa3ea9cc0,0xd1b2,0x11cd,0x80,0xfc,0x00,0xaa,0x00,0x4b,0xba,0x0b);
DEFINE_GUID(IID_IExchangeExportChanges2, 0x387cebe0,0xf53f,0x11cf,0xa4,0x8f,0x00,0xc0,0x4f,0xd6,0x55,0x95);
DEFINE_GUID(IID_IExchangeExportChanges3, 0x702e7f86,0x50a6,0x11d1,0xab,0xd6,0x00,0xa0,0xc9,0x05,0x66,0x0a);
DEFINE_GUID(IID_IExchangeImportHierarchyChanges, 0x85a66cf0,0xd0e0,0x11cd,0x80,0xfc,0x00,0xaa,0x00,0x4b,0xba,0x0b);
DEFINE_GUID(IID_IExchangeImportContentsChanges, 0xf75abfa0,0xd0e0,0x11cd,0x80,0xfc,0x00,0xaa,0x00,0x4b,0xba,0x0b);
DEFINE_GUID(IID_IExchangeImportContentsChanges2, 0x7dfdd720,0xf53f,0x11cf,0xa4,0x8f,0x00,0xc0,0x4f,0xd6,0x55,0x95);
Expand Down
2,717 changes: 2,717 additions & 0 deletions com/win32comext/mapi/src/MAPIStubLibrary/include/EdkMdb.h

Large diffs are not rendered by default.

74 changes: 74 additions & 0 deletions com/win32comext/mapi/src/MAPIStubLibrary/include/ExchForm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#ifndef EXCHFORM_H
#define EXCHFORM_H


/*
* E X C H F O R M . H
*
* Declarations of interfaces and constants for forms that work with
* the Microsoft Exchange client.
*
* Copyright 1986-1999 Microsoft Corporation. All Rights Reserved.
*/


/*
* V e r b s
*/


// Interpersonal messaging verbs
#define EXCHIVERB_OPEN 0
#define EXCHIVERB_RESERVED_COMPOSE 100
#define EXCHIVERB_RESERVED_OPEN 101
#define EXCHIVERB_REPLYTOSENDER 102
#define EXCHIVERB_REPLYTOALL 103
#define EXCHIVERB_FORWARD 104
#define EXCHIVERB_PRINT 105
#define EXCHIVERB_SAVEAS 106
#define EXCHIVERB_RESERVED_DELIVERY 107
#define EXCHIVERB_REPLYTOFOLDER 108


/*
* G U I D s
*/


#define DEFINE_EXCHFORMGUID(name, b) \
DEFINE_GUID(name, 0x00020D00 | (b), 0, 0, 0xC0,0,0,0,0,0,0,0x46)

#ifndef NOEXCHFORMGUIDS
DEFINE_EXCHFORMGUID(PS_EXCHFORM, 0x0C);
#endif // NOEXCHFORMGUIDS


/*
* E x t e n d e d P r o p e r t i e s
*/


// Operation map property
#define psOpMap PS_EXCHFORM
#define ulKindOpMap MNID_ID
#define lidOpMap 1
#define ptOpMap PT_STRING8

// Operation map indices
#define ichOpMapReservedCompose 0
#define ichOpMapOpen 1
#define ichOpMapReplyToSender 2
#define ichOpMapReplyToAll 3
#define ichOpMapForward 4
#define ichOpMapPrint 5
#define ichOpMapSaveAs 6
#define ichOpMapReservedDelivery 7
#define ichOpMapReplyToFolder 8

// Operation map values
#define chOpMapByClient '0'
#define chOpMapByForm '1'
#define chOpMapDisable '2'


#endif // EXCHFORM_H
66 changes: 66 additions & 0 deletions com/win32comext/mapi/src/MAPIStubLibrary/include/IMSCapabilities.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#ifndef IMSCAPABILITIESGUID_H
#ifdef INITGUID
#include <mapiguid.h>
#define IMSCAPABILITIESGUID_H
#endif /* INITGUID */

// {00020393-0000-0000-C000-000000000046}
#if !defined(INITGUID) || defined(USES_IID_IMSCapabilities)
DEFINE_OLEGUID(IID_IMSCapabilities, 0x00020393, 0, 0);
#endif

#endif /* IMSCAPABILITIESGUID_H */

#ifndef IMSCAPABILITIES_H
#define IMSCAPABILITIES_H

#ifdef __cplusplus
extern "C"
{
#endif

#ifndef BEGIN_INTERFACE
#define BEGIN_INTERFACE
#endif

// IMSCapabilities - advertises capabilities of the given store provider

/* Selector values for GetCapabilities() */
enum class MSCAP_SELECTOR
{
MSCAP_SEL_RESERVED1 = 0,
MSCAP_SEL_RESERVED2 = 1,
MSCAP_SEL_FOLDER = 2,
MSCAP_SEL_RESERVED3 = 3,
MSCAP_SEL_RESTRICTION = 4,
};

/* Return values for GetCapabilities */
/* Values based on selector used to query */

// MSCAP_SEL_FOLDER
// Support for folder homepages in non-default stores
#define MSCAP_SECURE_FOLDER_HOMEPAGES ((ULONG) 0x00000001)

// MSCAP_SEL_RESTRICTION
// Support for RES_ANNOTATION restrictions
#define MSCAP_RES_ANNOTATION ((ULONG) 0x00000001)

#define MAPI_IMSCAPABILITIES_METHODS(IPURE) \
MAPIMETHOD_(ULONG, GetCapabilities) (THIS_ MSCAP_SELECTOR mscapSelector);

#undef INTERFACE
#define INTERFACE IMSCapabilities
DECLARE_MAPI_INTERFACE_(IMSCapabilities, IUnknown)
{
MAPI_IUNKNOWN_METHODS(PURE)
MAPI_IMSCAPABILITIES_METHODS(PURE)
};

DECLARE_MAPI_INTERFACE_PTR(IMSCapabilities, LPMSCAPABILITIES);

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* IMSCAPABILITIES_H */
198 changes: 198 additions & 0 deletions com/win32comext/mapi/src/MAPIStubLibrary/include/IMessage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
/*
* I M E S S A G E . H
*
* External definitions for MAPI's IMessage-on-IStorage facility
*
* Copyright 1986-1999 Microsoft Corporation. All Rights Reserved.
*/

#ifndef _IMESSAGE_H_
#define _IMESSAGE_H_

#if _MSC_VER > 1000
#pragma once
#endif

#ifdef __cplusplus
extern "C"
{
#endif

typedef struct _MSGSESS FAR * LPMSGSESS;

/* Typedef of optional callback routine to be called on last release of
* top-level messages opened with OpenIMsgOnIStg
*/
typedef void (STDAPICALLTYPE MSGCALLRELEASE)(
ULONG ulCallerData,
LPMESSAGE lpMessage );

/* DLL Entry Points (found in mapiu.dll) */

/* OpenIMsgSession
* CloseIMsgSession
*
* These entry points allow the caller to "wrap" the creation of messages
* inside a session, so that when the session is closed, all messages
* created within that session are closed as well. Use of IMSG sessions
* is optional. If OpenIMsgOnIStg is called with a NULL for the lpmsgsess
* parameter, the message is created independent of any session, and has
* no way to be shutdown. If the caller forgets to release the message, or
* to release open tables within the message, the memory will be leaked until
* the external application terminates.
*/

STDAPI_(SCODE) OpenIMsgSession(
LPMALLOC lpMalloc, /* -> Co malloc object */
ULONG ulFlags, /* reserved. Must be zero. */
LPMSGSESS FAR *lppMsgSess ); /* <- message session object */

STDAPI_(void) CloseIMsgSession(
LPMSGSESS lpMsgSess ); /* -> message session object */

/* OpenIMsgOnIStg - Main entry point
*
* NOTE 1: The IStg must be opened with STGM_TRANSACTED if STGM_READWRITE
* is specified. Since messages don't support a write only mode, IMessage
* doesn't allow a storage object opened in write only mode. If the storage
* is opened STGM_READ, then STGM_TRANSACTED is NOT required.
*
* NOTE 2: The lpMapiSup parameter is optional. If supplied then IMessage
* will support the MAPI_DIALOG and ATTACH_DIALOG flags (by calling
* support method: DoMCDialog) on CopyTo and DeleteAttach methods.
* If lpMapiSup is not supplied (i.e. passed 0) then dialog flags will be
* ignored. If supplied then ModifyRecipients will attempt to convert
* short term entryids to long term entryids (by calling support method
* OpenAddressBook and calls on the returned object). If not supplied
* then short term entryid's will be stored without conversion.
*
* NOTE 3: The lpfMsgCallRelease parameter is optional. If supplied then
* IMessage will call the routine when the last release on (the toplevel only)
* message is called. It is intended to allow the callee to free the IStorage
* that contains the message. IMessage will not use the IStorage object after
* making this call.
*
* NOTE 4: Behavior of multiple opens of sub-objects (Attachments, Streams,
* Storages, Messages, etc.) within a message is deliberately undefined in
* MAPI. This implementation allows them, but will do it by AddRef'ing the
* existing open and returning it to the caller of OpenAttachment or
* OpenProperty. This means that whatever access mode the first open on a
* specific Attachment or Property had is what all others will get regardless
* of what the subsequent opens asked for.
*
* NOTE 5: There is currently one flag defined for use with the ulFlags
* parameter. The IMSG_NO_ISTG_COMMIT flag controls whether the commit
* method of IStorage is called when the client calls SaveChanges on the
* IMessage object. Some clients of IMessage may wish to commit the IStorage
* themselves after writing additional data to the storage (beyond what
* IMessage itself writes). To aid in this, the IMessage implementation
* guarantees to name all sub-storages starting with "__". Therefore,
* if the client keeps its names out of that namespace, there will be no
* accidental collisions.
*
* WARNING:
*
* This implementation of IMessage will support OpenProperty w/MAPI_CREATE
* where the source interface is IID_IStorage if the property id is
* 'PR_ATTACH_DATA'. Once this has been done, the caller has an IStorage
* interface on this property. This is ok and should allow for
* easier implementation of OLE 2.0 Server functionality. However, if you
* pass in the new IStorage ptr (to the attachment data) through the
* OpenIMsgOnIStg entry point and then proceed to release things in the
* wrong order we will make no attempt to behave in a predictable fashion.
* Keep in mind that the correct method for placing a message into an
* attachment is to call OpenProperty where the source interface is
* IID_IMessage. The IStorage interface is supported to allow an easy way
* to stick a WWord doc. into an attachment w/o converting to/from IStream.
*
*/
STDAPI_(SCODE) OpenIMsgOnIStg(
LPMSGSESS lpMsgSess, /* -> message session obj (optional) */
LPALLOCATEBUFFER lpAllocateBuffer, /* -> AllocateBuffer memory routine */
LPALLOCATEMORE lpAllocateMore, /* -> AllocateMore memory routine */
LPFREEBUFFER lpFreeBuffer, /* -> FreeBuffer memory routine */
LPMALLOC lpMalloc, /* -> Co malloc object */
LPVOID lpMapiSup, /* -> MAPI Support Obj (optional) */
LPSTORAGE lpStg, /* -> open IStorage containing msg */
MSGCALLRELEASE FAR *lpfMsgCallRelease, /* -> release callback rtn (opt) */
ULONG ulCallerData, /* caller data returned in callback */
ULONG ulFlags, /* -> flags (controls istg commit) */
LPMESSAGE FAR *lppMsg ); /* <- open message object */

#define IMSG_NO_ISTG_COMMIT ((ULONG) 0x00000001)


/* NOTE: Property Attributes are specific to this IMessage on IStorage */
/* implementation and are not a part of standard MAPI 1.0 property methods */

/* Property Attributes */

#define PROPATTR_MANDATORY ((ULONG) 0x00000001)
#define PROPATTR_READABLE ((ULONG) 0x00000002)
#define PROPATTR_WRITEABLE ((ULONG) 0x00000004)

#define PROPATTR_NOT_PRESENT ((ULONG) 0x00000008)

/* Attribute Array */

typedef struct _SPropAttrArray
{
ULONG cValues;
ULONG aPropAttr[MAPI_DIM];
} SPropAttrArray, FAR * LPSPropAttrArray;

#define CbNewSPropAttrArray(_cattr) \
(offsetof(SPropAttrArray,aPropAttr) + (_cattr)*sizeof(ULONG))
#define CbSPropAttrArray(_lparray) \
(offsetof(SPropAttrArray,aPropAttr) + \
(UINT)((_lparray)->cValues)*sizeof(ULONG))

#define SizedSPropAttrArray(_cattr, _name) \
struct _SPropAttrArray_ ## _name \
{ \
ULONG cValues; \
ULONG aPropAttr[_cattr]; \
} _name



/* GetAttribIMsgOnIStg - To get attributes on properties
*
* This call is provided because there is no method of IMAPIPropSet to allow
* getting attributes.
*/
STDAPI GetAttribIMsgOnIStg(
LPVOID lpObject,
LPSPropTagArray lpPropTagArray,
LPSPropAttrArray FAR *lppPropAttrArray );

/* SetAttribIMsgOnIStg - To set attributes on properties
*
* This call is provided because there is no method of IMAPIPropSet to allow
* setting of attributes.
*/
STDAPI SetAttribIMsgOnIStg(
LPVOID lpObject,
LPSPropTagArray lpPropTags,
LPSPropAttrArray lpPropAttrs,
LPSPropProblemArray FAR *lppPropProblems );

/* MapStorageSCode - To map an IStorage hResult to a MAPI sCode value
*
* This call is provided for the internal use of PDK components that base
* their message implementations on IMessage. Since these components must
* open the storage themselves, there is a common need to map OLE 2.0
* Storage error returns to MAPI sCodes.
*
* WARNING: There is no guarantee that this entry point will exist in
* shipped versions of mapiu.dll.
*/
STDAPI_(SCODE) MapStorageSCode( SCODE StgSCode );


#ifdef __cplusplus
}
#endif

#endif /* _IMESSAGE_H_ */

Loading

0 comments on commit 8666c6c

Please sign in to comment.