[pywin32-checkins] /hgroot/pywin32/pywin32: Add IConverterSession and supporting me...
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: <pyw...@li...> - 2013-11-24 23:23:40
|
changeset c031fedef936 in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=c031fedef936 summary: Add IConverterSession and supporting methods, via patch #132 diffstat: CHANGES.txt | 4 + com/win32comext/mapi/src/PyIExchangeManageStore.i | 10 +--- com/win32comext/mapi/src/mapi.i | 49 ++++++++++++++++++++++- setup.py | 2 + 4 files changed, 56 insertions(+), 9 deletions(-) diffs (145 lines): diff -r cbcbd126551c -r c031fedef936 CHANGES.txt --- a/CHANGES.txt Thu Jun 13 19:16:16 2013 +1000 +++ b/CHANGES.txt Mon Nov 25 10:23:29 2013 +1100 @@ -6,6 +6,10 @@ Since build 218: ---------------- + * win32com.mapi + Addded outlook interface IConverterSession with methods MIMEToMAPI, MAPIToMIMEStm, and SetAdrBook + Added method OpenStreamOnFile (Nick Czeczulin) + * Conversions from a Python object to a variant now does a better job at deciding what variant type to use, taking into account the size and sign of the value (Stefan Schukat via patch #127) diff -r cbcbd126551c -r c031fedef936 com/win32comext/mapi/src/PyIExchangeManageStore.i --- a/com/win32comext/mapi/src/PyIExchangeManageStore.i Thu Jun 13 19:16:16 2013 +1000 +++ b/com/win32comext/mapi/src/PyIExchangeManageStore.i Mon Nov 25 10:23:29 2013 +1100 @@ -76,14 +76,10 @@ Py_END_ALLOW_THREADS if (FAILED(hRes)) - { - OleSetOleError(hRes); - goto error; - } + result = OleSetOleError(hRes); + else + result = Py_BuildValue("s#", sbEID.lpb, sbEID.cb); - result = Py_BuildValue("s#", sbEID.lpb, sbEID.cb); - -error: MAPIFreeBuffer((LPENTRYID)sbEID.lpb); return result; diff -r cbcbd126551c -r c031fedef936 com/win32comext/mapi/src/mapi.i --- a/com/win32comext/mapi/src/mapi.i Thu Jun 13 19:16:16 2013 +1000 +++ b/com/win32comext/mapi/src/mapi.i Mon Nov 25 10:23:29 2013 +1100 @@ -44,6 +44,8 @@ #include "PyIProfSect.h" #include "PyIMsgServiceAdmin.h" #include "PyIMAPIAdviseSink.h" +#include "IConverterSession.h" +#include "PyIConverterSession.h" #include "MAPISPI.H" #include "MAPISPI.H" @@ -176,6 +178,12 @@ if ( PyCom_RegisterGatewayObject(IID_IMAPIAdviseSink, GET_PYGATEWAY_CTOR(PyGMAPIAdviseSink), "IMAPIAdviseSink") != 0) return MODINIT_ERROR_RETURN; ADD_IID(IID_IMAPIAdviseSink); + if ( PyCom_RegisterClientType(&PyIConverterSession::type, &IID_IConverterSession) != 0 ) return MODINIT_ERROR_RETURN; + { + ADD_IID(IID_IConverterSession); + ADD_IID(CLSID_IConverterSession); + } + ADD_IID(PS_PUBLIC_STRINGS); ADD_IID(PS_MAPI); ADD_IID(PS_ROUTING_EMAIL_ADDRESSES); @@ -183,7 +191,6 @@ ADD_IID(PS_ROUTING_DISPLAY_NAME); ADD_IID(PS_ROUTING_ENTRYID); ADD_IID(PS_ROUTING_SEARCH_KEY); - %} #define NO_ATTACHMENT NO_ATTACHMENT // The attachment has just been created. @@ -235,7 +242,7 @@ #define RTF_SYNC_RTF_CHANGED RTF_SYNC_RTF_CHANGED // The RTF version of the message has changed. #define MAPI_CREATE MAPI_CREATE // The object will be created if necessary. -#define MAPI_E_CALL_FAILED +#define MAPI_E_CALL_FAILED MAPI_E_CALL_FAILED #define MAPI_E_NOT_ENOUGH_MEMORY MAPI_E_NOT_ENOUGH_MEMORY #define MAPI_E_INVALID_PARAMETER MAPI_E_INVALID_PARAMETER #define MAPI_E_INTERFACE_NOT_SUPPORTED MAPI_E_INTERFACE_NOT_SUPPORTED @@ -449,6 +456,18 @@ #define FLUSH_NO_UI FLUSH_NO_UI #define FLUSH_ASYNC_OK FLUSH_ASYNC_OK +// IConverterSession Constants - http://msdn2.microsoft.com/en-us/library/bb905201.aspx +#define CCSF_SMTP CCSF_SMTP // the converter is being passed an SMTP message +#define CCSF_NOHEADERS CCSF_NOHEADERS // the converter should ignore the headers on the outside message +#define CCSF_USE_TNEF CCSF_USE_TNEF // the converter should embed TNEF in the MIME message +#define CCSF_INCLUDE_BCC CCSF_INCLUDE_BCC // the converter should include Bcc recipients +#define CCSF_8BITHEADERS CCSF_8BITHEADERS // the converter should allow 8 bit headers +#define CCSF_USE_RTF CCSF_USE_RTF // the converter should do HTML->RTF conversion +#define CCSF_PLAIN_TEXT_ONLY CCSF_PLAIN_TEXT_ONLY // the converter should just send plain text +#define CCSF_NO_MSGID CCSF_NO_MSGID // don't include Message-Id field in outgoing messages +#define CCSF_EMBEDDED_MESSAGE CCSF_EMBEDDED_MESSAGE // sent/unsent information is persisted in X-Unsent +#define CCSF_PRESERVE_SOURCE CCSF_PRESERVE_SOURCE // don't modify the source message + // @object MAPIINIT_0|A MAPIINIT_0 is represented as a tuple of: // @tupleitem 0|int|version|This must be MAPI_INIT_VERSION. // @tupleitem 1|int|flags|MAPI initlization flags. @@ -775,3 +794,29 @@ } %} %native(RTFStreamToHTML) MyRTFStreamToHTML; + + +%{ +PyObject *PyOpenStreamOnFile(PyObject *self, PyObject *args) +{ + HRESULT hRes; + unsigned long flags = 0; + IStream *pStream; + char *filepath; + + if (!PyArg_ParseTuple(args, "s|l:OpenStreamOnFile", &filepath, &flags)) + return NULL; + + PY_INTERFACE_PRECALL; + hRes = OpenStreamOnFile(MAPIAllocateBuffer, MAPIFreeBuffer, flags, filepath, NULL, &pStream); + PY_INTERFACE_POSTCALL; + + if (FAILED(hRes)) + return OleSetOleError(hRes); + + return PyCom_PyObjectFromIUnknown(pStream, IID_IStream, FALSE); +} +%} +%native(OpenStreamOnFile) PyOpenStreamOnFile; + + diff -r cbcbd126551c -r c031fedef936 setup.py --- a/setup.py Thu Jun 13 19:16:16 2013 +1000 +++ b/setup.py Mon Nov 25 10:23:29 2013 +1100 @@ -1937,6 +1937,7 @@ %(mapi)s/PyIMsgStore.i %(mapi)s/PyIMsgStore.cpp %(mapi)s/PyIProfAdmin.i %(mapi)s/PyIProfAdmin.cpp %(mapi)s/PyIProfSect.i %(mapi)s/PyIProfSect.cpp + %(mapi)s/PyIConverterSession.i %(mapi)s/PyIConverterSession.cpp %(mapi)s/PyIMAPIAdviseSink.cpp %(mapi)s/mapiutil.cpp %(mapi)s/mapiguids.cpp @@ -2308,6 +2309,7 @@ 'PyIMsgStore': 'IMAPIProp', 'PyIProfAdmin': '', 'PyIProfSect': 'IMAPIProp', + 'PyIConverterSession': '', # exchange and exchdapi 'exchange': None, 'exchdapi': None, |