2007-11-02 12:49:29 +01:00
|
|
|
/*
|
|
|
|
* MIME OLE Interfaces
|
|
|
|
*
|
|
|
|
* Copyright 2006 Robert Shearman for CodeWeavers
|
2007-11-26 13:01:12 +01:00
|
|
|
* Copyright 2007 Huw Davies for CodeWeavers
|
2007-11-02 12:49:29 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
2007-12-07 01:02:08 +01:00
|
|
|
#define NONAMELESSUNION
|
2007-11-02 12:49:29 +01:00
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2007-11-02 12:51:23 +01:00
|
|
|
#include "winuser.h"
|
2007-11-02 12:49:29 +01:00
|
|
|
#include "objbase.h"
|
2007-11-02 12:52:27 +01:00
|
|
|
#include "ole2.h"
|
2007-11-02 12:51:23 +01:00
|
|
|
#include "mimeole.h"
|
2016-07-01 09:57:42 +02:00
|
|
|
#include "propvarutil.h"
|
2007-11-02 12:49:29 +01:00
|
|
|
|
2007-11-26 13:01:52 +01:00
|
|
|
#include "wine/list.h"
|
2007-11-02 12:49:29 +01:00
|
|
|
#include "wine/debug.h"
|
2017-02-01 11:22:27 +01:00
|
|
|
#include "wine/unicode.h"
|
2007-11-02 12:49:29 +01:00
|
|
|
|
|
|
|
#include "inetcomm_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(inetcomm);
|
|
|
|
|
2007-11-26 13:01:52 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
LPCSTR name;
|
|
|
|
DWORD id;
|
|
|
|
DWORD flags; /* MIMEPROPFLAGS */
|
|
|
|
VARTYPE default_vt;
|
|
|
|
} property_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
property_t prop;
|
|
|
|
} property_list_entry_t;
|
|
|
|
|
|
|
|
static const property_t default_props[] =
|
|
|
|
{
|
2016-06-01 08:06:30 +02:00
|
|
|
{"X-Newsgroup", PID_HDR_NEWSGROUP, 0, VT_LPSTR},
|
|
|
|
{"Newsgroups", PID_HDR_NEWSGROUPS, 0, VT_LPSTR},
|
|
|
|
{"References", PID_HDR_REFS, 0, VT_LPSTR},
|
|
|
|
{"Subject", PID_HDR_SUBJECT, 0, VT_LPSTR},
|
|
|
|
{"From", PID_HDR_FROM, MPF_ADDRESS, VT_LPSTR},
|
|
|
|
{"Message-ID", PID_HDR_MESSAGEID, 0, VT_LPSTR},
|
|
|
|
{"Return-Path", PID_HDR_RETURNPATH, MPF_ADDRESS, VT_LPSTR},
|
|
|
|
{"Rr", PID_HDR_RR, 0, VT_LPSTR},
|
|
|
|
{"Return-Receipt-To", PID_HDR_RETRCPTO, MPF_ADDRESS, VT_LPSTR},
|
|
|
|
{"Apparently-To", PID_HDR_APPARTO, MPF_ADDRESS, VT_LPSTR},
|
|
|
|
{"Date", PID_HDR_DATE, 0, VT_LPSTR},
|
|
|
|
{"Received", PID_HDR_RECEIVED, 0, VT_LPSTR},
|
|
|
|
{"Reply-To", PID_HDR_REPLYTO, MPF_ADDRESS, VT_LPSTR},
|
|
|
|
{"X-Mailer", PID_HDR_XMAILER, 0, VT_LPSTR},
|
|
|
|
{"Bcc", PID_HDR_BCC, MPF_ADDRESS, VT_LPSTR},
|
|
|
|
{"MIME-Version", PID_HDR_MIMEVER, MPF_MIME, VT_LPSTR},
|
|
|
|
{"Content-Type", PID_HDR_CNTTYPE, MPF_MIME | MPF_HASPARAMS, VT_LPSTR},
|
|
|
|
{"Content-Transfer-Encoding", PID_HDR_CNTXFER, MPF_MIME, VT_LPSTR},
|
|
|
|
{"Content-ID", PID_HDR_CNTID, MPF_MIME, VT_LPSTR},
|
|
|
|
{"Content-Description", PID_HDR_CNTDESC, MPF_MIME, VT_LPSTR},
|
|
|
|
{"Content-Disposition", PID_HDR_CNTDISP, MPF_MIME | MPF_HASPARAMS, VT_LPSTR},
|
|
|
|
{"Content-Base", PID_HDR_CNTBASE, MPF_MIME, VT_LPSTR},
|
|
|
|
{"Content-Location", PID_HDR_CNTLOC, MPF_MIME, VT_LPSTR},
|
|
|
|
{"To", PID_HDR_TO, MPF_ADDRESS, VT_LPSTR},
|
|
|
|
{"Path", PID_HDR_PATH, 0, VT_LPSTR},
|
|
|
|
{"Followup-To", PID_HDR_FOLLOWUPTO, 0, VT_LPSTR},
|
|
|
|
{"Expires", PID_HDR_EXPIRES, 0, VT_LPSTR},
|
|
|
|
{"Cc", PID_HDR_CC, MPF_ADDRESS, VT_LPSTR},
|
|
|
|
{"Control", PID_HDR_CONTROL, 0, VT_LPSTR},
|
|
|
|
{"Distribution", PID_HDR_DISTRIB, 0, VT_LPSTR},
|
|
|
|
{"Keywords", PID_HDR_KEYWORDS, 0, VT_LPSTR},
|
|
|
|
{"Summary", PID_HDR_SUMMARY, 0, VT_LPSTR},
|
|
|
|
{"Approved", PID_HDR_APPROVED, 0, VT_LPSTR},
|
|
|
|
{"Lines", PID_HDR_LINES, 0, VT_LPSTR},
|
|
|
|
{"Xref", PID_HDR_XREF, 0, VT_LPSTR},
|
|
|
|
{"Organization", PID_HDR_ORG, 0, VT_LPSTR},
|
|
|
|
{"X-Newsreader", PID_HDR_XNEWSRDR, 0, VT_LPSTR},
|
|
|
|
{"X-Priority", PID_HDR_XPRI, 0, VT_LPSTR},
|
|
|
|
{"X-MSMail-Priority", PID_HDR_XMSPRI, 0, VT_LPSTR},
|
|
|
|
{"par:content-disposition:filename", PID_PAR_FILENAME, 0, VT_LPSTR},
|
|
|
|
{"par:content-type:boundary", PID_PAR_BOUNDARY, 0, VT_LPSTR},
|
|
|
|
{"par:content-type:charset", PID_PAR_CHARSET, 0, VT_LPSTR},
|
|
|
|
{"par:content-type:name", PID_PAR_NAME, 0, VT_LPSTR},
|
|
|
|
{"att:filename", PID_ATT_FILENAME, 0, VT_LPSTR},
|
|
|
|
{"att:pri-content-type", PID_ATT_PRITYPE, 0, VT_LPSTR},
|
|
|
|
{"att:sub-content-type", PID_ATT_SUBTYPE, 0, VT_LPSTR},
|
|
|
|
{"att:illegal-lines", PID_ATT_ILLEGAL, 0, VT_LPSTR},
|
|
|
|
{"att:rendered", PID_ATT_RENDERED, 0, VT_LPSTR},
|
|
|
|
{"att:sent-time", PID_ATT_SENTTIME, 0, VT_LPSTR},
|
|
|
|
{"att:priority", PID_ATT_PRIORITY, 0, VT_LPSTR},
|
|
|
|
{"Comment", PID_HDR_COMMENT, 0, VT_LPSTR},
|
|
|
|
{"Encoding", PID_HDR_ENCODING, 0, VT_LPSTR},
|
|
|
|
{"Encrypted", PID_HDR_ENCRYPTED, 0, VT_LPSTR},
|
|
|
|
{"X-Offsets", PID_HDR_OFFSETS, 0, VT_LPSTR},
|
|
|
|
{"X-Unsent", PID_HDR_XUNSENT, 0, VT_LPSTR},
|
|
|
|
{"X-ArticleId", PID_HDR_ARTICLEID, 0, VT_LPSTR},
|
|
|
|
{"Sender", PID_HDR_SENDER, MPF_ADDRESS, VT_LPSTR},
|
|
|
|
{"att:athena-server", PID_ATT_SERVER, 0, VT_LPSTR},
|
|
|
|
{"att:athena-account-id", PID_ATT_ACCOUNT, 0, VT_LPSTR},
|
|
|
|
{"att:athena-pop3-uidl", PID_ATT_UIDL, 0, VT_LPSTR},
|
|
|
|
{"att:athena-store-msgid", PID_ATT_STOREMSGID, 0, VT_LPSTR},
|
|
|
|
{"att:athena-user-name", PID_ATT_USERNAME, 0, VT_LPSTR},
|
|
|
|
{"att:athena-forward-to", PID_ATT_FORWARDTO, 0, VT_LPSTR},
|
|
|
|
{"att:athena-store-fdrid", PID_ATT_STOREFOLDERID,0, VT_LPSTR},
|
|
|
|
{"att:athena-ghosted", PID_ATT_GHOSTED, 0, VT_LPSTR},
|
|
|
|
{"att:athena-uncachedsize", PID_ATT_UNCACHEDSIZE, 0, VT_LPSTR},
|
|
|
|
{"att:athena-combined", PID_ATT_COMBINED, 0, VT_LPSTR},
|
|
|
|
{"att:auto-inlined", PID_ATT_AUTOINLINED, 0, VT_LPSTR},
|
|
|
|
{"Disposition-Notification-To", PID_HDR_DISP_NOTIFICATION_TO, 0, VT_LPSTR},
|
|
|
|
{"par:Content-Type:reply-type", PID_PAR_REPLYTYPE, 0, VT_LPSTR},
|
|
|
|
{"par:Content-Type:format", PID_PAR_FORMAT , 0, VT_LPSTR},
|
|
|
|
{"att:format", PID_ATT_FORMAT , 0, VT_LPSTR},
|
|
|
|
{"In-Reply-To", PID_HDR_INREPLYTO, 0, VT_LPSTR},
|
|
|
|
{"att:athena-account-name", PID_ATT_ACCOUNTNAME, 0, VT_LPSTR},
|
|
|
|
{NULL, 0, 0, 0}
|
2007-11-26 13:01:52 +01:00
|
|
|
};
|
|
|
|
|
2007-11-26 13:03:08 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
char *name;
|
|
|
|
char *value;
|
|
|
|
} param_t;
|
|
|
|
|
2007-11-26 13:01:52 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
const property_t *prop;
|
|
|
|
PROPVARIANT value;
|
2007-11-26 13:03:08 +01:00
|
|
|
struct list params;
|
2007-11-26 13:01:52 +01:00
|
|
|
} header_t;
|
|
|
|
|
2007-11-14 13:44:19 +01:00
|
|
|
typedef struct MimeBody
|
|
|
|
{
|
2013-03-04 00:33:16 +01:00
|
|
|
IMimeBody IMimeBody_iface;
|
|
|
|
LONG ref;
|
2007-11-14 13:44:19 +01:00
|
|
|
|
|
|
|
HBODY handle;
|
2007-11-26 13:01:52 +01:00
|
|
|
|
|
|
|
struct list headers;
|
|
|
|
struct list new_props; /* FIXME: This should be in a PropertySchema */
|
|
|
|
DWORD next_prop_id;
|
2007-11-26 13:03:35 +01:00
|
|
|
char *content_pri_type;
|
|
|
|
char *content_sub_type;
|
2007-11-26 13:04:08 +01:00
|
|
|
ENCODINGTYPE encoding;
|
2007-11-26 13:04:51 +01:00
|
|
|
void *data;
|
|
|
|
IID data_iid;
|
2007-12-20 16:14:35 +01:00
|
|
|
BODYOFFSETS body_offsets;
|
2007-11-14 13:44:19 +01:00
|
|
|
} MimeBody;
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
typedef struct
|
2016-04-19 11:26:02 +02:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
IStream IStream_iface;
|
2016-04-19 11:26:02 +02:00
|
|
|
LONG ref;
|
2017-01-27 15:59:08 +01:00
|
|
|
IStream *base;
|
|
|
|
ULARGE_INTEGER pos, start, length;
|
|
|
|
} sub_stream_t;
|
2016-04-19 11:26:02 +02:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static inline sub_stream_t *impl_from_IStream(IStream *iface)
|
2016-04-19 11:26:02 +02:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
return CONTAINING_RECORD(iface, sub_stream_t, IStream_iface);
|
2016-04-19 11:26:02 +02:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI sub_stream_QueryInterface(IStream *iface, REFIID riid, void **ppv)
|
2007-11-26 13:01:52 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
sub_stream_t *This = impl_from_IStream(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppv);
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if(IsEqualIID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID(riid, &IID_ISequentialStream) ||
|
|
|
|
IsEqualIID(riid, &IID_IStream))
|
|
|
|
{
|
|
|
|
IStream_AddRef(iface);
|
|
|
|
*ppv = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
return E_NOINTERFACE;
|
2007-11-26 13:01:52 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static ULONG WINAPI sub_stream_AddRef(IStream *iface)
|
|
|
|
{
|
|
|
|
sub_stream_t *This = impl_from_IStream(iface);
|
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
2007-11-26 13:01:12 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI sub_stream_Release(IStream *iface)
|
2007-11-26 13:01:12 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
sub_stream_t *This = impl_from_IStream(iface);
|
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
2007-11-26 13:01:12 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2007-11-26 13:01:12 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
if(!ref)
|
2007-11-26 13:01:12 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
IStream_Release(This->base);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
return ref;
|
|
|
|
}
|
2007-11-26 13:01:12 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI sub_stream_Read(
|
|
|
|
IStream* iface,
|
|
|
|
void *pv,
|
|
|
|
ULONG cb,
|
|
|
|
ULONG *pcbRead)
|
|
|
|
{
|
|
|
|
sub_stream_t *This = impl_from_IStream(iface);
|
|
|
|
HRESULT hr;
|
|
|
|
LARGE_INTEGER tmp_pos;
|
2007-11-26 13:01:12 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
TRACE("(%p, %d, %p)\n", pv, cb, pcbRead);
|
2007-11-26 13:01:12 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
tmp_pos.QuadPart = This->pos.QuadPart + This->start.QuadPart;
|
|
|
|
IStream_Seek(This->base, tmp_pos, STREAM_SEEK_SET, NULL);
|
2007-11-26 13:01:12 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
if(This->pos.QuadPart + cb > This->length.QuadPart)
|
|
|
|
cb = This->length.QuadPart - This->pos.QuadPart;
|
2007-11-26 13:01:12 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
hr = IStream_Read(This->base, pv, cb, pcbRead);
|
2007-11-26 13:01:12 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
This->pos.QuadPart += *pcbRead;
|
|
|
|
|
2007-11-26 13:01:12 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI sub_stream_Write(
|
|
|
|
IStream* iface,
|
|
|
|
const void *pv,
|
|
|
|
ULONG cb,
|
|
|
|
ULONG *pcbWritten)
|
2007-11-26 13:01:52 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
FIXME("stub\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2007-11-26 13:01:52 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI sub_stream_Seek(
|
|
|
|
IStream* iface,
|
|
|
|
LARGE_INTEGER dlibMove,
|
|
|
|
DWORD dwOrigin,
|
|
|
|
ULARGE_INTEGER *plibNewPosition)
|
|
|
|
{
|
|
|
|
sub_stream_t *This = impl_from_IStream(iface);
|
|
|
|
LARGE_INTEGER new_pos;
|
2007-11-26 13:01:52 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
TRACE("(%08x.%08x, %x, %p)\n", dlibMove.u.HighPart, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
|
2007-11-26 13:01:52 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
switch(dwOrigin)
|
2007-11-26 13:01:52 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
case STREAM_SEEK_SET:
|
|
|
|
new_pos = dlibMove;
|
|
|
|
break;
|
|
|
|
case STREAM_SEEK_CUR:
|
|
|
|
new_pos.QuadPart = This->pos.QuadPart + dlibMove.QuadPart;
|
|
|
|
break;
|
|
|
|
case STREAM_SEEK_END:
|
|
|
|
new_pos.QuadPart = This->length.QuadPart + dlibMove.QuadPart;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return STG_E_INVALIDFUNCTION;
|
2007-11-26 13:01:52 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
if(new_pos.QuadPart < 0) new_pos.QuadPart = 0;
|
|
|
|
else if(new_pos.QuadPart > This->length.QuadPart) new_pos.QuadPart = This->length.QuadPart;
|
2007-11-26 13:01:52 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
This->pos.QuadPart = new_pos.QuadPart;
|
2007-11-26 13:01:52 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
if(plibNewPosition) *plibNewPosition = This->pos;
|
|
|
|
return S_OK;
|
2007-11-26 13:01:52 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI sub_stream_SetSize(
|
|
|
|
IStream* iface,
|
|
|
|
ULARGE_INTEGER libNewSize)
|
2007-11-26 13:02:35 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
FIXME("stub\n");
|
|
|
|
return E_NOTIMPL;
|
2007-11-26 13:02:35 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI sub_stream_CopyTo(
|
|
|
|
IStream* iface,
|
|
|
|
IStream *pstm,
|
|
|
|
ULARGE_INTEGER cb,
|
|
|
|
ULARGE_INTEGER *pcbRead,
|
|
|
|
ULARGE_INTEGER *pcbWritten)
|
2007-12-18 16:37:21 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
HRESULT hr = S_OK;
|
|
|
|
BYTE tmpBuffer[128];
|
|
|
|
ULONG bytesRead, bytesWritten, copySize;
|
|
|
|
ULARGE_INTEGER totalBytesRead;
|
|
|
|
ULARGE_INTEGER totalBytesWritten;
|
2007-12-18 16:37:21 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
TRACE("(%p)->(%p, %d, %p, %p)\n", iface, pstm, cb.u.LowPart, pcbRead, pcbWritten);
|
2007-12-18 16:37:21 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
totalBytesRead.QuadPart = 0;
|
|
|
|
totalBytesWritten.QuadPart = 0;
|
|
|
|
|
|
|
|
while ( cb.QuadPart > 0 )
|
2007-12-18 16:37:21 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
if ( cb.QuadPart >= sizeof(tmpBuffer) )
|
|
|
|
copySize = sizeof(tmpBuffer);
|
|
|
|
else
|
|
|
|
copySize = cb.u.LowPart;
|
2007-12-18 16:37:21 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
hr = IStream_Read(iface, tmpBuffer, copySize, &bytesRead);
|
|
|
|
if (FAILED(hr)) break;
|
2007-11-26 13:03:08 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
totalBytesRead.QuadPart += bytesRead;
|
2007-11-26 13:03:08 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
if (bytesRead)
|
|
|
|
{
|
|
|
|
hr = IStream_Write(pstm, tmpBuffer, bytesRead, &bytesWritten);
|
|
|
|
if (FAILED(hr)) break;
|
|
|
|
totalBytesWritten.QuadPart += bytesWritten;
|
|
|
|
}
|
2007-11-26 13:03:08 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
if (bytesRead != copySize)
|
|
|
|
cb.QuadPart = 0;
|
|
|
|
else
|
|
|
|
cb.QuadPart -= bytesRead;
|
2007-11-26 13:03:08 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
if (pcbRead) pcbRead->QuadPart = totalBytesRead.QuadPart;
|
|
|
|
if (pcbWritten) pcbWritten->QuadPart = totalBytesWritten.QuadPart;
|
2007-11-26 13:03:08 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
return hr;
|
2007-11-26 13:03:08 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI sub_stream_Commit(
|
|
|
|
IStream* iface,
|
|
|
|
DWORD grfCommitFlags)
|
2007-11-26 13:03:08 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
FIXME("stub\n");
|
|
|
|
return E_NOTIMPL;
|
2007-11-26 13:03:08 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI sub_stream_Revert(
|
|
|
|
IStream* iface)
|
2007-11-26 13:01:52 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
FIXME("stub\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2007-11-26 13:01:52 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI sub_stream_LockRegion(
|
|
|
|
IStream* iface,
|
|
|
|
ULARGE_INTEGER libOffset,
|
|
|
|
ULARGE_INTEGER cb,
|
|
|
|
DWORD dwLockType)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return E_NOTIMPL;
|
2007-11-26 13:01:52 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI sub_stream_UnlockRegion(
|
|
|
|
IStream* iface,
|
|
|
|
ULARGE_INTEGER libOffset,
|
|
|
|
ULARGE_INTEGER cb,
|
|
|
|
DWORD dwLockType)
|
2007-11-26 13:03:35 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
FIXME("stub\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2007-11-26 13:03:35 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI sub_stream_Stat(
|
|
|
|
IStream* iface,
|
|
|
|
STATSTG *pstatstg,
|
|
|
|
DWORD grfStatFlag)
|
|
|
|
{
|
|
|
|
sub_stream_t *This = impl_from_IStream(iface);
|
|
|
|
FIXME("(%p)->(%p, %08x)\n", This, pstatstg, grfStatFlag);
|
|
|
|
memset(pstatstg, 0, sizeof(*pstatstg));
|
|
|
|
pstatstg->cbSize = This->length;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2007-11-26 13:03:35 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI sub_stream_Clone(
|
|
|
|
IStream* iface,
|
|
|
|
IStream **ppstm)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return E_NOTIMPL;
|
2007-11-26 13:03:35 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static struct IStreamVtbl sub_stream_vtbl =
|
2007-11-26 13:01:12 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
sub_stream_QueryInterface,
|
|
|
|
sub_stream_AddRef,
|
|
|
|
sub_stream_Release,
|
|
|
|
sub_stream_Read,
|
|
|
|
sub_stream_Write,
|
|
|
|
sub_stream_Seek,
|
|
|
|
sub_stream_SetSize,
|
|
|
|
sub_stream_CopyTo,
|
|
|
|
sub_stream_Commit,
|
|
|
|
sub_stream_Revert,
|
|
|
|
sub_stream_LockRegion,
|
|
|
|
sub_stream_UnlockRegion,
|
|
|
|
sub_stream_Stat,
|
|
|
|
sub_stream_Clone
|
|
|
|
};
|
2007-11-26 13:01:12 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT create_sub_stream(IStream *stream, ULARGE_INTEGER start, ULARGE_INTEGER length, IStream **out)
|
|
|
|
{
|
|
|
|
sub_stream_t *This;
|
2007-11-26 13:01:12 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
*out = NULL;
|
|
|
|
This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
|
|
|
|
if(!This) return E_OUTOFMEMORY;
|
2007-11-26 13:03:35 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
This->IStream_iface.lpVtbl = &sub_stream_vtbl;
|
|
|
|
This->ref = 1;
|
|
|
|
This->start = start;
|
|
|
|
This->length = length;
|
|
|
|
This->pos.QuadPart = 0;
|
|
|
|
IStream_AddRef(stream);
|
|
|
|
This->base = stream;
|
2007-11-26 13:01:52 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
*out = &This->IStream_iface;
|
|
|
|
return S_OK;
|
2007-11-26 13:01:12 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:35 +01:00
|
|
|
static HRESULT get_stream_size(IStream *stream, ULARGE_INTEGER *size)
|
|
|
|
{
|
|
|
|
STATSTG statstg = {NULL};
|
|
|
|
LARGE_INTEGER zero;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IStream_Stat(stream, &statstg, STATFLAG_NONAME);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
*size = statstg.cbSize;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
zero.QuadPart = 0;
|
|
|
|
return IStream_Seek(stream, zero, STREAM_SEEK_END, size);
|
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static inline MimeBody *impl_from_IMimeBody(IMimeBody *iface)
|
2007-11-26 13:03:08 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
return CONTAINING_RECORD(iface, MimeBody, IMimeBody_iface);
|
2007-11-26 13:03:08 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
typedef struct propschema
|
2007-11-26 13:01:52 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
IMimePropertySchema IMimePropertySchema_iface;
|
|
|
|
LONG ref;
|
|
|
|
} propschema;
|
2007-11-26 13:01:52 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static inline propschema *impl_from_IMimePropertySchema(IMimePropertySchema *iface)
|
2007-11-26 13:01:52 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
return CONTAINING_RECORD(iface, propschema, IMimePropertySchema_iface);
|
2007-11-26 13:01:52 +01:00
|
|
|
}
|
2007-11-26 13:01:12 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static LPSTR strdupA(LPCSTR str)
|
2007-11-26 13:04:51 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
char *ret;
|
|
|
|
int len = strlen(str);
|
|
|
|
ret = HeapAlloc(GetProcessHeap(), 0, len + 1);
|
|
|
|
memcpy(ret, str, len + 1);
|
|
|
|
return ret;
|
2007-11-26 13:04:51 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
#define PARSER_BUF_SIZE 1024
|
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
* copy_headers_to_buf [internal]
|
|
|
|
*
|
|
|
|
* Copies the headers into a '\0' terminated memory block and leave
|
|
|
|
* the stream's current position set to after the blank line.
|
|
|
|
*/
|
|
|
|
static HRESULT copy_headers_to_buf(IStream *stm, char **ptr)
|
2007-12-18 16:26:32 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
char *buf = NULL;
|
|
|
|
DWORD size = PARSER_BUF_SIZE, offset = 0, last_end = 0;
|
|
|
|
HRESULT hr;
|
|
|
|
BOOL done = FALSE;
|
2007-12-18 16:26:32 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
*ptr = NULL;
|
2007-12-18 16:26:32 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
do
|
2007-12-18 16:26:32 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
char *end;
|
|
|
|
DWORD read;
|
|
|
|
|
|
|
|
if(!buf)
|
|
|
|
buf = HeapAlloc(GetProcessHeap(), 0, size + 1);
|
|
|
|
else
|
2016-05-30 12:19:16 +02:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
size *= 2;
|
|
|
|
buf = HeapReAlloc(GetProcessHeap(), 0, buf, size + 1);
|
2016-05-30 12:19:16 +02:00
|
|
|
}
|
2017-01-27 15:59:08 +01:00
|
|
|
if(!buf)
|
2007-12-18 16:26:32 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
goto fail;
|
2007-12-18 16:26:32 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
hr = IStream_Read(stm, buf + offset, size - offset, &read);
|
|
|
|
if(FAILED(hr)) goto fail;
|
2007-12-18 16:26:32 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
offset += read;
|
|
|
|
buf[offset] = '\0';
|
2016-05-30 12:19:16 +02:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
if(read == 0) done = TRUE;
|
|
|
|
|
|
|
|
while(!done && (end = strstr(buf + last_end, "\r\n")))
|
2016-05-30 12:19:16 +02:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
DWORD new_end = end - buf + 2;
|
|
|
|
if(new_end - last_end == 2)
|
2016-05-30 12:19:16 +02:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
LARGE_INTEGER off;
|
2017-01-31 11:46:15 +01:00
|
|
|
off.QuadPart = (LONGLONG)new_end - offset;
|
|
|
|
IStream_Seek(stm, off, STREAM_SEEK_CUR, NULL);
|
2017-01-27 15:59:08 +01:00
|
|
|
buf[new_end] = '\0';
|
|
|
|
done = TRUE;
|
2016-05-30 12:19:16 +02:00
|
|
|
}
|
2017-01-27 15:59:08 +01:00
|
|
|
else
|
|
|
|
last_end = new_end;
|
2016-05-30 12:19:16 +02:00
|
|
|
}
|
2017-01-27 15:59:08 +01:00
|
|
|
} while(!done);
|
2016-05-30 12:19:16 +02:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
*ptr = buf;
|
|
|
|
return S_OK;
|
2016-05-30 12:19:16 +02:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
fail:
|
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
|
|
|
return hr;
|
2016-05-30 12:19:16 +02:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static header_t *read_prop(MimeBody *body, char **ptr)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
char *colon = strchr(*ptr, ':');
|
|
|
|
const property_t *prop;
|
|
|
|
header_t *ret;
|
2007-11-14 13:44:19 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
if(!colon) return NULL;
|
2007-11-14 13:44:19 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
*colon = '\0';
|
|
|
|
|
|
|
|
for(prop = default_props; prop->name; prop++)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
if(!lstrcmpiA(*ptr, prop->name))
|
|
|
|
{
|
|
|
|
TRACE("%s: found match with default property id %d\n", *ptr, prop->id);
|
|
|
|
break;
|
|
|
|
}
|
2007-11-14 13:44:19 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
if(!prop->name)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
property_list_entry_t *prop_entry;
|
|
|
|
LIST_FOR_EACH_ENTRY(prop_entry, &body->new_props, property_list_entry_t, entry)
|
|
|
|
{
|
|
|
|
if(!lstrcmpiA(*ptr, prop_entry->prop.name))
|
|
|
|
{
|
|
|
|
TRACE("%s: found match with already added new property id %d\n", *ptr, prop_entry->prop.id);
|
|
|
|
prop = &prop_entry->prop;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!prop->name)
|
|
|
|
{
|
|
|
|
prop_entry = HeapAlloc(GetProcessHeap(), 0, sizeof(*prop_entry));
|
|
|
|
prop_entry->prop.name = strdupA(*ptr);
|
|
|
|
prop_entry->prop.id = body->next_prop_id++;
|
|
|
|
prop_entry->prop.flags = 0;
|
|
|
|
prop_entry->prop.default_vt = VT_LPSTR;
|
|
|
|
list_add_tail(&body->new_props, &prop_entry->entry);
|
|
|
|
prop = &prop_entry->prop;
|
|
|
|
TRACE("%s: allocating new prop id %d\n", *ptr, prop_entry->prop.id);
|
|
|
|
}
|
2007-11-14 13:44:19 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
ret = HeapAlloc(GetProcessHeap(), 0, sizeof(*ret));
|
|
|
|
ret->prop = prop;
|
|
|
|
PropVariantInit(&ret->value);
|
|
|
|
list_init(&ret->params);
|
|
|
|
*ptr = colon + 1;
|
|
|
|
|
|
|
|
return ret;
|
2007-11-14 13:44:19 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static void unfold_header(char *header, int len)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
char *start = header, *cp = header;
|
2013-03-04 00:33:16 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
do {
|
|
|
|
while(*cp == ' ' || *cp == '\t')
|
|
|
|
{
|
|
|
|
cp++;
|
|
|
|
len--;
|
|
|
|
}
|
|
|
|
if(cp != start)
|
|
|
|
memmove(start, cp, len + 1);
|
2013-03-04 00:33:16 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
cp = strstr(start, "\r\n");
|
|
|
|
len -= (cp - start);
|
|
|
|
start = cp;
|
|
|
|
*start = ' ';
|
|
|
|
start++;
|
|
|
|
len--;
|
|
|
|
cp += 2;
|
|
|
|
} while(*cp == ' ' || *cp == '\t');
|
|
|
|
|
|
|
|
*(start - 1) = '\0';
|
2007-11-14 13:44:19 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static char *unquote_string(const char *str)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
BOOL quoted = FALSE;
|
|
|
|
char *ret, *cp;
|
2007-11-14 13:44:19 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
while(*str == ' ' || *str == '\t') str++;
|
2007-11-14 13:44:19 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
if(*str == '"')
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
quoted = TRUE;
|
|
|
|
str++;
|
2007-11-14 13:44:19 +01:00
|
|
|
}
|
2017-01-27 15:59:08 +01:00
|
|
|
ret = strdupA(str);
|
|
|
|
for(cp = ret; *cp; cp++)
|
|
|
|
{
|
|
|
|
if(*cp == '\\')
|
|
|
|
memmove(cp, cp + 1, strlen(cp + 1) + 1);
|
|
|
|
else if(*cp == '"')
|
|
|
|
{
|
|
|
|
if(!quoted)
|
|
|
|
{
|
|
|
|
WARN("quote in unquoted string\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*cp = '\0';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
2007-11-14 13:44:19 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static void add_param(header_t *header, const char *p)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
const char *key = p, *value, *cp = p;
|
|
|
|
param_t *param;
|
|
|
|
char *name;
|
2007-11-14 13:44:19 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
TRACE("got param %s\n", p);
|
2007-11-14 13:44:19 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
while (*key == ' ' || *key == '\t' ) key++;
|
2007-11-14 13:44:19 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
cp = strchr(key, '=');
|
|
|
|
if(!cp)
|
|
|
|
{
|
|
|
|
WARN("malformed parameter - skipping\n");
|
|
|
|
return;
|
|
|
|
}
|
2007-11-14 13:44:19 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
name = HeapAlloc(GetProcessHeap(), 0, cp - key + 1);
|
|
|
|
memcpy(name, key, cp - key);
|
|
|
|
name[cp - key] = '\0';
|
2007-11-14 13:44:19 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
value = cp + 1;
|
2007-11-14 13:44:19 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
param = HeapAlloc(GetProcessHeap(), 0, sizeof(*param));
|
|
|
|
param->name = name;
|
|
|
|
param->value = unquote_string(value);
|
|
|
|
list_add_tail(&header->params, ¶m->entry);
|
2007-11-14 13:44:19 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static void split_params(header_t *header, char *value)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
char *cp = value, *start = value;
|
|
|
|
BOOL in_quotes = FALSE, done_value = FALSE;
|
2016-06-23 10:51:01 +02:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
while(*cp)
|
2016-06-23 10:51:01 +02:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
if(!in_quotes && *cp == ';')
|
|
|
|
{
|
|
|
|
*cp = '\0';
|
|
|
|
if(done_value) add_param(header, start);
|
|
|
|
done_value = TRUE;
|
|
|
|
start = cp + 1;
|
|
|
|
}
|
|
|
|
else if(*cp == '"')
|
|
|
|
in_quotes = !in_quotes;
|
|
|
|
cp++;
|
2016-06-23 10:51:01 +02:00
|
|
|
}
|
2017-01-27 15:59:08 +01:00
|
|
|
if(done_value) add_param(header, start);
|
2007-11-14 13:44:19 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static void read_value(header_t *header, char **cur)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
char *end = *cur, *value;
|
|
|
|
DWORD len;
|
2007-11-14 13:44:19 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
do {
|
|
|
|
end = strstr(end, "\r\n");
|
|
|
|
end += 2;
|
|
|
|
} while(*end == ' ' || *end == '\t');
|
2016-04-28 10:15:07 +02:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
len = end - *cur;
|
|
|
|
value = HeapAlloc(GetProcessHeap(), 0, len + 1);
|
|
|
|
memcpy(value, *cur, len);
|
|
|
|
value[len] = '\0';
|
2016-04-28 10:15:07 +02:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
unfold_header(value, len);
|
|
|
|
TRACE("value %s\n", debugstr_a(value));
|
2008-02-12 15:11:34 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
if(header->prop->flags & MPF_HASPARAMS)
|
2008-02-12 15:11:34 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
split_params(header, value);
|
|
|
|
TRACE("value w/o params %s\n", debugstr_a(value));
|
2008-02-12 15:11:34 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
header->value.vt = VT_LPSTR;
|
|
|
|
header->value.u.pszVal = value;
|
2016-04-28 10:15:07 +02:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
*cur = end;
|
2007-11-14 13:44:19 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static void init_content_type(MimeBody *body, header_t *header)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
char *slash;
|
|
|
|
DWORD len;
|
2016-04-28 10:14:55 +02:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
slash = strchr(header->value.u.pszVal, '/');
|
|
|
|
if(!slash)
|
|
|
|
{
|
|
|
|
WARN("malformed context type value\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
len = slash - header->value.u.pszVal;
|
|
|
|
body->content_pri_type = HeapAlloc(GetProcessHeap(), 0, len + 1);
|
|
|
|
memcpy(body->content_pri_type, header->value.u.pszVal, len);
|
|
|
|
body->content_pri_type[len] = '\0';
|
|
|
|
body->content_sub_type = strdupA(slash + 1);
|
2007-11-14 13:44:19 +01:00
|
|
|
}
|
|
|
|
|
2017-01-31 11:46:39 +01:00
|
|
|
static void init_content_encoding(MimeBody *body, header_t *header)
|
|
|
|
{
|
|
|
|
const char *encoding = header->value.u.pszVal;
|
|
|
|
|
|
|
|
if(!strcasecmp(encoding, "base64"))
|
|
|
|
body->encoding = IET_BASE64;
|
|
|
|
else if(!strcasecmp(encoding, "quoted-printable"))
|
|
|
|
body->encoding = IET_QP;
|
|
|
|
else if(!strcasecmp(encoding, "7bit"))
|
|
|
|
body->encoding = IET_7BIT;
|
|
|
|
else if(!strcasecmp(encoding, "8bit"))
|
|
|
|
body->encoding = IET_8BIT;
|
|
|
|
else
|
|
|
|
FIXME("unknown encoding %s\n", debugstr_a(encoding));
|
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT parse_headers(MimeBody *body, IStream *stm)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
char *header_buf, *cur_header_ptr;
|
|
|
|
HRESULT hr;
|
|
|
|
header_t *header;
|
2016-07-01 09:57:07 +02:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
hr = copy_headers_to_buf(stm, &header_buf);
|
|
|
|
if(FAILED(hr)) return hr;
|
2016-07-01 09:57:07 +02:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
cur_header_ptr = header_buf;
|
|
|
|
while((header = read_prop(body, &cur_header_ptr)))
|
2016-07-01 09:57:07 +02:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
read_value(header, &cur_header_ptr);
|
|
|
|
list_add_tail(&body->headers, &header->entry);
|
2016-07-01 09:57:07 +02:00
|
|
|
|
2017-01-31 11:46:39 +01:00
|
|
|
switch(header->prop->id) {
|
|
|
|
case PID_HDR_CNTTYPE:
|
2017-01-27 15:59:08 +01:00
|
|
|
init_content_type(body, header);
|
2017-01-31 11:46:39 +01:00
|
|
|
break;
|
|
|
|
case PID_HDR_CNTXFER:
|
|
|
|
init_content_encoding(body, header);
|
|
|
|
break;
|
|
|
|
}
|
2016-07-01 09:57:07 +02:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, header_buf);
|
|
|
|
return hr;
|
2007-11-14 13:44:19 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static void empty_param_list(struct list *list)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
param_t *param, *cursor2;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(param, cursor2, list, param_t, entry)
|
|
|
|
{
|
|
|
|
list_remove(¶m->entry);
|
|
|
|
HeapFree(GetProcessHeap(), 0, param->name);
|
|
|
|
HeapFree(GetProcessHeap(), 0, param->value);
|
|
|
|
HeapFree(GetProcessHeap(), 0, param);
|
|
|
|
}
|
2007-11-14 13:44:19 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static void empty_header_list(struct list *list)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
header_t *header, *cursor2;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(header, cursor2, list, header_t, entry)
|
|
|
|
{
|
|
|
|
list_remove(&header->entry);
|
|
|
|
PropVariantClear(&header->value);
|
|
|
|
empty_param_list(&header->params);
|
|
|
|
HeapFree(GetProcessHeap(), 0, header);
|
|
|
|
}
|
2007-11-14 13:44:19 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static void empty_new_prop_list(struct list *list)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
property_list_entry_t *prop, *cursor2;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(prop, cursor2, list, property_list_entry_t, entry)
|
|
|
|
{
|
|
|
|
list_remove(&prop->entry);
|
|
|
|
HeapFree(GetProcessHeap(), 0, (char *)prop->prop.name);
|
|
|
|
HeapFree(GetProcessHeap(), 0, prop);
|
|
|
|
}
|
2007-11-14 13:44:19 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static void release_data(REFIID riid, void *data)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
if(!data) return;
|
|
|
|
|
|
|
|
if(IsEqualIID(riid, &IID_IStream))
|
|
|
|
IStream_Release((IStream *)data);
|
|
|
|
else
|
|
|
|
FIXME("Unhandled data format %s\n", debugstr_guid(riid));
|
2007-11-14 13:44:19 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT find_prop(MimeBody *body, const char *name, header_t **prop)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
header_t *header;
|
|
|
|
|
|
|
|
*prop = NULL;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(header, &body->headers, header_t, entry)
|
|
|
|
{
|
|
|
|
if(ISPIDSTR(name))
|
|
|
|
{
|
|
|
|
if(STRTOPID(name) == header->prop->id)
|
|
|
|
{
|
|
|
|
*prop = header;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(!lstrcmpiA(name, header->prop->name))
|
|
|
|
{
|
|
|
|
*prop = header;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return MIME_E_NOT_FOUND;
|
2007-11-14 13:44:19 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static const property_t *find_default_prop(const char *name)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
const property_t *prop_def = NULL;
|
|
|
|
|
|
|
|
for(prop_def = default_props; prop_def->name; prop_def++)
|
|
|
|
{
|
|
|
|
if(ISPIDSTR(name))
|
|
|
|
{
|
|
|
|
if(STRTOPID(name) == prop_def->id)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(!lstrcmpiA(name, prop_def->name))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(prop_def->id)
|
|
|
|
TRACE("%s: found match with default property id %d\n", prop_def->name, prop_def->id);
|
|
|
|
else
|
|
|
|
prop_def = NULL;
|
|
|
|
|
|
|
|
return prop_def;
|
2007-11-14 13:44:19 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_QueryInterface(IMimeBody* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppvObject);
|
2007-12-18 16:26:32 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
*ppvObject = NULL;
|
2007-12-18 16:26:32 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID(riid, &IID_IPersist) ||
|
|
|
|
IsEqualIID(riid, &IID_IPersistStreamInit) ||
|
|
|
|
IsEqualIID(riid, &IID_IMimePropertySet) ||
|
|
|
|
IsEqualIID(riid, &IID_IMimeBody))
|
|
|
|
{
|
|
|
|
*ppvObject = iface;
|
|
|
|
}
|
2007-12-18 16:26:32 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
if(*ppvObject)
|
2007-12-18 16:26:32 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
IUnknown_AddRef((IUnknown*)*ppvObject);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2007-12-18 16:26:32 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
FIXME("no interface for %s\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
2007-12-18 16:26:32 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static ULONG WINAPI MimeBody_AddRef(IMimeBody *iface)
|
|
|
|
{
|
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
2007-12-18 16:26:32 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
2007-11-14 13:44:19 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static ULONG WINAPI MimeBody_Release(IMimeBody *iface)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2007-11-26 13:03:35 +01:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
2017-01-27 15:59:08 +01:00
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
2007-11-26 13:03:35 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2007-11-26 13:03:35 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
if (!ref)
|
2007-11-26 13:03:35 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
empty_header_list(&This->headers);
|
|
|
|
empty_new_prop_list(&This->new_props);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->content_pri_type);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->content_sub_type);
|
|
|
|
|
|
|
|
release_data(&This->data_iid, This->data);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
2007-11-26 13:03:35 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
return ref;
|
2007-11-14 13:44:19 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_GetClassID(
|
|
|
|
IMimeBody* iface,
|
|
|
|
CLSID* pClassID)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2016-04-15 09:50:33 +02:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
2017-01-27 15:59:08 +01:00
|
|
|
FIXME("(%p)->(%p) stub\n", This, pClassID);
|
2007-11-14 13:44:19 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI MimeBody_IsDirty(
|
|
|
|
IMimeBody* iface)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2016-04-15 09:50:33 +02:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
2017-01-27 15:59:08 +01:00
|
|
|
FIXME("(%p)->() stub\n", This);
|
2007-11-14 13:44:19 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_Load(IMimeBody *iface, IStream *pStm)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2016-04-15 09:50:33 +02:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
2017-01-27 15:59:08 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, pStm);
|
|
|
|
return parse_headers(This, pStm);
|
2007-11-14 13:44:19 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_Save(IMimeBody *iface, IStream *pStm, BOOL fClearDirty)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2016-04-15 09:50:33 +02:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
2017-01-27 15:59:08 +01:00
|
|
|
FIXME("(%p)->(%p, %d)\n", This, pStm, fClearDirty);
|
2007-11-14 13:44:19 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_GetSizeMax(
|
|
|
|
IMimeBody* iface,
|
|
|
|
ULARGE_INTEGER* pcbSize)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2016-04-15 09:50:33 +02:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
2017-01-27 15:59:08 +01:00
|
|
|
FIXME("(%p)->(%p) stub\n", This, pcbSize);
|
2007-11-14 13:44:19 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_InitNew(
|
|
|
|
IMimeBody* iface)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2008-09-22 15:36:13 +02:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
2017-01-27 15:59:08 +01:00
|
|
|
TRACE("(%p)->()\n", This);
|
2008-09-22 15:36:13 +02:00
|
|
|
return S_OK;
|
2007-11-14 13:44:19 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_GetPropInfo(
|
|
|
|
IMimeBody* iface,
|
|
|
|
LPCSTR pszName,
|
|
|
|
LPMIMEPROPINFO pInfo)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2016-04-15 09:50:33 +02:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
2017-01-27 15:59:08 +01:00
|
|
|
header_t *header;
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD supported = PIM_PROPID | PIM_VTDEFAULT;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s, %p) semi-stub\n", This, debugstr_a(pszName), pInfo);
|
|
|
|
|
|
|
|
if(!pszName || !pInfo)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
TRACE("mask 0x%04x\n", pInfo->dwMask);
|
|
|
|
|
|
|
|
if(pInfo->dwMask & ~supported)
|
|
|
|
FIXME("Unsupported mask flags 0x%04x\n", pInfo->dwMask & ~supported);
|
|
|
|
|
|
|
|
hr = find_prop(This, pszName, &header);
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
if(pInfo->dwMask & PIM_CHARSET)
|
|
|
|
pInfo->hCharset = 0;
|
|
|
|
if(pInfo->dwMask & PIM_FLAGS)
|
|
|
|
pInfo->dwFlags = 0x00000000;
|
|
|
|
if(pInfo->dwMask & PIM_ROWNUMBER)
|
|
|
|
pInfo->dwRowNumber = 0;
|
|
|
|
if(pInfo->dwMask & PIM_ENCODINGTYPE)
|
|
|
|
pInfo->ietEncoding = 0;
|
|
|
|
if(pInfo->dwMask & PIM_VALUES)
|
|
|
|
pInfo->cValues = 0;
|
|
|
|
if(pInfo->dwMask & PIM_PROPID)
|
|
|
|
pInfo->dwPropId = header->prop->id;
|
|
|
|
if(pInfo->dwMask & PIM_VTDEFAULT)
|
|
|
|
pInfo->vtDefault = header->prop->default_vt;
|
|
|
|
if(pInfo->dwMask & PIM_VTCURRENT)
|
|
|
|
pInfo->vtCurrent = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2007-11-14 13:44:19 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_SetPropInfo(
|
|
|
|
IMimeBody* iface,
|
|
|
|
LPCSTR pszName,
|
|
|
|
LPCMIMEPROPINFO pInfo)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2016-04-15 09:50:33 +02:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
2017-01-27 15:59:08 +01:00
|
|
|
FIXME("(%p)->(%s, %p) stub\n", This, debugstr_a(pszName), pInfo);
|
2007-11-14 13:44:19 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_GetProp(
|
|
|
|
IMimeBody* iface,
|
|
|
|
LPCSTR pszName,
|
|
|
|
DWORD dwFlags,
|
|
|
|
LPPROPVARIANT pValue)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2007-12-20 16:14:35 +01:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
2017-01-27 15:59:08 +01:00
|
|
|
header_t *header;
|
|
|
|
HRESULT hr;
|
2007-12-20 16:14:35 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
TRACE("(%p)->(%s, 0x%x, %p)\n", This, debugstr_a(pszName), dwFlags, pValue);
|
2007-12-20 16:14:35 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
if(!pszName || !pValue)
|
|
|
|
return E_INVALIDARG;
|
2007-11-14 13:44:19 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
if(!ISPIDSTR(pszName) && !lstrcmpiA(pszName, "att:pri-content-type"))
|
|
|
|
{
|
|
|
|
PropVariantClear(pValue);
|
|
|
|
pValue->vt = VT_LPSTR;
|
|
|
|
pValue->u.pszVal = strdupA(This->content_pri_type);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2007-11-26 13:04:08 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
hr = find_prop(This, pszName, &header);
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
TRACE("type %d->%d\n", header->value.vt, pValue->vt);
|
2007-11-26 13:04:08 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
hr = PropVariantChangeType(pValue, &header->value, 0, pValue->vt);
|
|
|
|
if(FAILED(hr))
|
|
|
|
FIXME("Conversion not currently supported (%d->%d)\n", header->value.vt, pValue->vt);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2007-11-14 13:44:19 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_SetProp(
|
|
|
|
IMimeBody* iface,
|
|
|
|
LPCSTR pszName,
|
|
|
|
DWORD dwFlags,
|
|
|
|
LPCPROPVARIANT pValue)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2007-11-26 13:04:08 +01:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
2017-01-27 15:59:08 +01:00
|
|
|
header_t *header;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s, 0x%x, %p)\n", This, debugstr_a(pszName), dwFlags, pValue);
|
|
|
|
|
|
|
|
if(!pszName || !pValue)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
hr = find_prop(This, pszName, &header);
|
|
|
|
if(hr != S_OK)
|
|
|
|
{
|
|
|
|
property_list_entry_t *prop_entry;
|
|
|
|
const property_t *prop = NULL;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(prop_entry, &This->new_props, property_list_entry_t, entry)
|
|
|
|
{
|
|
|
|
if(ISPIDSTR(pszName))
|
|
|
|
{
|
|
|
|
if(STRTOPID(pszName) == prop_entry->prop.id)
|
|
|
|
{
|
|
|
|
TRACE("Found match with already added new property id %d\n", prop_entry->prop.id);
|
|
|
|
prop = &prop_entry->prop;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(!lstrcmpiA(pszName, prop_entry->prop.name))
|
|
|
|
{
|
|
|
|
TRACE("Found match with already added new property id %d\n", prop_entry->prop.id);
|
|
|
|
prop = &prop_entry->prop;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
header = HeapAlloc(GetProcessHeap(), 0, sizeof(*header));
|
|
|
|
if(!header)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if(!prop)
|
|
|
|
{
|
|
|
|
const property_t *prop_def = NULL;
|
|
|
|
prop_entry = HeapAlloc(GetProcessHeap(), 0, sizeof(*prop_entry));
|
|
|
|
if(!prop_entry)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, header);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
prop_def = find_default_prop(pszName);
|
|
|
|
if(prop_def)
|
|
|
|
{
|
|
|
|
prop_entry->prop.name = strdupA(prop_def->name);
|
|
|
|
prop_entry->prop.id = prop_def->id;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(ISPIDSTR(pszName))
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, prop_entry);
|
|
|
|
HeapFree(GetProcessHeap(), 0, header);
|
|
|
|
return MIME_E_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
prop_entry->prop.name = strdupA(pszName);
|
|
|
|
prop_entry->prop.id = This->next_prop_id++;
|
|
|
|
}
|
|
|
|
|
|
|
|
prop_entry->prop.flags = 0;
|
|
|
|
prop_entry->prop.default_vt = pValue->vt;
|
|
|
|
list_add_tail(&This->new_props, &prop_entry->entry);
|
|
|
|
prop = &prop_entry->prop;
|
|
|
|
TRACE("Allocating new prop id %d\n", prop_entry->prop.id);
|
|
|
|
}
|
2007-11-26 13:04:08 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
header->prop = prop;
|
|
|
|
PropVariantInit(&header->value);
|
|
|
|
list_init(&header->params);
|
|
|
|
list_add_tail(&This->headers, &header->entry);
|
|
|
|
}
|
2007-11-26 13:04:08 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
PropVariantCopy(&header->value, pValue);
|
2007-11-14 13:44:19 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
return S_OK;
|
2007-11-14 13:44:19 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_AppendProp(
|
|
|
|
IMimeBody* iface,
|
|
|
|
LPCSTR pszName,
|
|
|
|
DWORD dwFlags,
|
|
|
|
LPPROPVARIANT pValue)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2016-04-15 09:50:33 +02:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
2017-01-27 15:59:08 +01:00
|
|
|
FIXME("(%p)->(%s, 0x%x, %p) stub\n", This, debugstr_a(pszName), dwFlags, pValue);
|
2007-11-14 13:44:19 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_DeleteProp(
|
|
|
|
IMimeBody* iface,
|
|
|
|
LPCSTR pszName)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2008-02-08 13:24:38 +01:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
2017-01-27 15:59:08 +01:00
|
|
|
header_t *cursor;
|
|
|
|
BOOL found;
|
2007-11-14 13:44:19 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
TRACE("(%p)->(%s) stub\n", This, debugstr_a(pszName));
|
2007-11-26 13:04:51 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
LIST_FOR_EACH_ENTRY(cursor, &This->headers, header_t, entry)
|
2007-11-26 13:04:51 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
if(ISPIDSTR(pszName))
|
|
|
|
found = STRTOPID(pszName) == cursor->prop->id;
|
|
|
|
else
|
|
|
|
found = !lstrcmpiA(pszName, cursor->prop->name);
|
2007-11-26 13:04:51 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
if(found)
|
|
|
|
{
|
|
|
|
list_remove(&cursor->entry);
|
|
|
|
HeapFree(GetProcessHeap(), 0, cursor);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
2007-11-26 13:04:51 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
return MIME_E_NOT_FOUND;
|
2007-11-14 13:44:19 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_CopyProps(
|
|
|
|
IMimeBody* iface,
|
|
|
|
ULONG cNames,
|
|
|
|
LPCSTR* prgszName,
|
|
|
|
IMimePropertySet* pPropertySet)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2016-04-15 09:50:33 +02:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
2017-01-27 15:59:08 +01:00
|
|
|
FIXME("(%p)->(%d, %p, %p) stub\n", This, cNames, prgszName, pPropertySet);
|
2007-11-14 13:44:19 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_MoveProps(
|
|
|
|
IMimeBody* iface,
|
|
|
|
ULONG cNames,
|
|
|
|
LPCSTR* prgszName,
|
|
|
|
IMimePropertySet* pPropertySet)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2016-04-15 09:50:33 +02:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
2017-01-27 15:59:08 +01:00
|
|
|
FIXME("(%p)->(%d, %p, %p) stub\n", This, cNames, prgszName, pPropertySet);
|
2007-11-14 13:44:19 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_DeleteExcept(
|
|
|
|
IMimeBody* iface,
|
|
|
|
ULONG cNames,
|
|
|
|
LPCSTR* prgszName)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2016-04-15 09:50:33 +02:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
2017-01-27 15:59:08 +01:00
|
|
|
FIXME("(%p)->(%d, %p) stub\n", This, cNames, prgszName);
|
2007-11-14 13:44:19 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_QueryProp(
|
|
|
|
IMimeBody* iface,
|
|
|
|
LPCSTR pszName,
|
|
|
|
LPCSTR pszCriteria,
|
|
|
|
boolean fSubString,
|
|
|
|
boolean fCaseSensitive)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2016-04-15 09:50:33 +02:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
2017-01-27 15:59:08 +01:00
|
|
|
FIXME("(%p)->(%s, %s, %d, %d) stub\n", This, debugstr_a(pszName), debugstr_a(pszCriteria), fSubString, fCaseSensitive);
|
2007-11-14 13:44:19 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_GetCharset(
|
|
|
|
IMimeBody* iface,
|
|
|
|
LPHCHARSET phCharset)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
2017-01-27 15:59:08 +01:00
|
|
|
FIXME("(%p)->(%p) stub\n", This, phCharset);
|
|
|
|
*phCharset = NULL;
|
|
|
|
return S_OK;
|
2007-11-14 13:44:19 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_SetCharset(
|
|
|
|
IMimeBody* iface,
|
|
|
|
HCHARSET hCharset,
|
|
|
|
CSETAPPLYTYPE applytype)
|
2007-11-14 13:44:19 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
|
|
|
FIXME("(%p)->(%p, %d) stub\n", This, hCharset, applytype);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2007-11-14 13:44:19 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_GetParameters(
|
|
|
|
IMimeBody* iface,
|
|
|
|
LPCSTR pszName,
|
|
|
|
ULONG* pcParams,
|
|
|
|
LPMIMEPARAMINFO* pprgParam)
|
2007-12-20 16:14:35 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
|
|
|
HRESULT hr;
|
|
|
|
header_t *header;
|
2007-12-20 16:14:35 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
TRACE("(%p)->(%s, %p, %p)\n", iface, debugstr_a(pszName), pcParams, pprgParam);
|
2007-12-20 16:14:35 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
*pprgParam = NULL;
|
|
|
|
*pcParams = 0;
|
2007-11-26 13:01:52 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
hr = find_prop(This, pszName, &header);
|
|
|
|
if(hr != S_OK) return hr;
|
2007-11-14 13:44:19 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
*pcParams = list_count(&header->params);
|
|
|
|
if(*pcParams)
|
|
|
|
{
|
|
|
|
IMimeAllocator *alloc;
|
|
|
|
param_t *param;
|
|
|
|
MIMEPARAMINFO *info;
|
2007-11-14 13:44:19 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
MimeOleGetAllocator(&alloc);
|
2007-11-14 13:44:19 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
*pprgParam = info = IMimeAllocator_Alloc(alloc, *pcParams * sizeof(**pprgParam));
|
|
|
|
LIST_FOR_EACH_ENTRY(param, &header->params, param_t, entry)
|
|
|
|
{
|
|
|
|
int len;
|
2007-12-20 16:14:35 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
len = strlen(param->name) + 1;
|
|
|
|
info->pszName = IMimeAllocator_Alloc(alloc, len);
|
|
|
|
memcpy(info->pszName, param->name, len);
|
|
|
|
len = strlen(param->value) + 1;
|
|
|
|
info->pszData = IMimeAllocator_Alloc(alloc, len);
|
|
|
|
memcpy(info->pszData, param->value, len);
|
|
|
|
info++;
|
|
|
|
}
|
|
|
|
IMimeAllocator_Release(alloc);
|
|
|
|
}
|
|
|
|
return S_OK;
|
2013-03-04 00:35:05 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_IsContentType(
|
|
|
|
IMimeBody* iface,
|
|
|
|
LPCSTR pszPriType,
|
|
|
|
LPCSTR pszSubType)
|
2013-03-04 00:35:05 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
2013-03-04 00:35:05 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
TRACE("(%p)->(%s, %s)\n", This, debugstr_a(pszPriType), debugstr_a(pszSubType));
|
|
|
|
if(pszPriType)
|
2013-03-04 00:35:05 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
const char *pri = This->content_pri_type;
|
|
|
|
if(!pri) pri = "text";
|
|
|
|
if(lstrcmpiA(pri, pszPriType)) return S_FALSE;
|
2013-03-04 00:35:05 +01:00
|
|
|
}
|
2017-01-27 15:59:08 +01:00
|
|
|
|
|
|
|
if(pszSubType)
|
2013-03-04 00:35:05 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
const char *sub = This->content_sub_type;
|
|
|
|
if(!sub) sub = "plain";
|
|
|
|
if(lstrcmpiA(sub, pszSubType)) return S_FALSE;
|
2013-03-04 00:35:05 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
2013-03-04 00:35:05 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_BindToObject(
|
|
|
|
IMimeBody* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject)
|
2008-02-12 12:18:09 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
|
|
|
FIXME("(%p)->(%s, %p) stub\n", This, debugstr_guid(riid), ppvObject);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2008-02-12 12:18:09 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_Clone(
|
|
|
|
IMimeBody* iface,
|
|
|
|
IMimePropertySet** ppPropertySet)
|
2008-02-12 12:18:09 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
|
|
|
FIXME("(%p)->(%p) stub\n", This, ppPropertySet);
|
|
|
|
return E_NOTIMPL;
|
2008-02-12 12:18:09 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_SetOption(
|
|
|
|
IMimeBody* iface,
|
|
|
|
const TYPEDID oid,
|
|
|
|
LPCPROPVARIANT pValue)
|
2008-02-12 12:18:09 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
|
|
|
HRESULT hr = E_NOTIMPL;
|
|
|
|
TRACE("(%p)->(%08x, %p)\n", This, oid, pValue);
|
2008-02-12 12:18:09 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
if(pValue->vt != TYPEDID_TYPE(oid))
|
|
|
|
{
|
|
|
|
WARN("Called with vartype %04x and oid %08x\n", pValue->vt, oid);
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
2008-02-12 12:18:09 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
switch(oid)
|
2008-02-12 12:18:09 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
case OID_SECURITY_HWND_OWNER:
|
|
|
|
FIXME("OID_SECURITY_HWND_OWNER (value %08x): ignoring\n", pValue->u.ulVal);
|
|
|
|
hr = S_OK;
|
|
|
|
break;
|
|
|
|
case OID_TRANSMIT_BODY_ENCODING:
|
|
|
|
FIXME("OID_TRANSMIT_BODY_ENCODING (value %08x): ignoring\n", pValue->u.ulVal);
|
|
|
|
hr = S_OK;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("Unhandled oid %08x\n", oid);
|
2008-02-12 12:18:09 +01:00
|
|
|
}
|
2017-01-27 15:59:08 +01:00
|
|
|
|
|
|
|
return hr;
|
2008-02-12 12:18:09 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_GetOption(
|
|
|
|
IMimeBody* iface,
|
|
|
|
const TYPEDID oid,
|
|
|
|
LPPROPVARIANT pValue)
|
2008-02-12 12:18:09 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
|
|
|
FIXME("(%p)->(%08x, %p): stub\n", This, oid, pValue);
|
|
|
|
return E_NOTIMPL;
|
2008-02-12 12:18:09 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_EnumProps(
|
|
|
|
IMimeBody* iface,
|
|
|
|
DWORD dwFlags,
|
|
|
|
IMimeEnumProperties** ppEnum)
|
2008-02-12 12:18:09 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
|
|
|
FIXME("(%p)->(0x%x, %p) stub\n", This, dwFlags, ppEnum);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2008-02-12 12:18:09 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_IsType(
|
|
|
|
IMimeBody* iface,
|
|
|
|
IMSGBODYTYPE bodytype)
|
|
|
|
{
|
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
2013-03-04 00:36:06 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
TRACE("(%p)->(%d)\n", This, bodytype);
|
|
|
|
switch(bodytype)
|
2008-02-12 12:18:09 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
case IBT_EMPTY:
|
|
|
|
return This->data ? S_FALSE : S_OK;
|
|
|
|
default:
|
|
|
|
FIXME("Unimplemented bodytype %d - returning S_OK\n", bodytype);
|
2008-02-12 12:18:09 +01:00
|
|
|
}
|
2017-01-27 15:59:08 +01:00
|
|
|
return S_OK;
|
2008-02-12 12:18:09 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_SetDisplayName(
|
|
|
|
IMimeBody* iface,
|
|
|
|
LPCSTR pszDisplay)
|
2008-02-12 12:18:09 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
|
|
|
FIXME("(%p)->(%s) stub\n", This, debugstr_a(pszDisplay));
|
|
|
|
return E_NOTIMPL;
|
2008-02-12 12:18:09 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_GetDisplayName(
|
|
|
|
IMimeBody* iface,
|
|
|
|
LPSTR* ppszDisplay)
|
2008-02-12 12:18:09 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
|
|
|
FIXME("(%p)->(%p) stub\n", This, ppszDisplay);
|
2008-02-12 12:18:09 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_GetOffsets(
|
|
|
|
IMimeBody* iface,
|
|
|
|
LPBODYOFFSETS pOffsets)
|
2008-02-12 12:18:09 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
|
|
|
TRACE("(%p)->(%p)\n", This, pOffsets);
|
2008-02-12 12:18:09 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
*pOffsets = This->body_offsets;
|
2008-02-12 12:18:09 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
if(This->body_offsets.cbBodyEnd == 0) return MIME_E_NO_DATA;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2008-02-12 12:18:09 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_GetCurrentEncoding(
|
|
|
|
IMimeBody* iface,
|
|
|
|
ENCODINGTYPE* pietEncoding)
|
|
|
|
{
|
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
2008-02-12 12:18:09 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, pietEncoding);
|
2008-02-12 12:18:09 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
*pietEncoding = This->encoding;
|
2008-02-12 12:18:09 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_SetCurrentEncoding(
|
|
|
|
IMimeBody* iface,
|
|
|
|
ENCODINGTYPE ietEncoding)
|
2008-02-12 12:18:09 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d)\n", This, ietEncoding);
|
|
|
|
|
|
|
|
This->encoding = ietEncoding;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeBody_GetEstimatedSize(
|
|
|
|
IMimeBody* iface,
|
|
|
|
ENCODINGTYPE ietEncoding,
|
|
|
|
ULONG* pcbSize)
|
|
|
|
{
|
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
|
|
|
FIXME("(%p)->(%d, %p) stub\n", This, ietEncoding, pcbSize);
|
2008-02-12 12:18:09 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_GetDataHere(
|
|
|
|
IMimeBody* iface,
|
|
|
|
ENCODINGTYPE ietEncoding,
|
|
|
|
IStream* pStream)
|
|
|
|
{
|
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
|
|
|
FIXME("(%p)->(%d, %p) stub\n", This, ietEncoding, pStream);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2017-01-27 16:01:07 +01:00
|
|
|
static const signed char base64_decode_table[] =
|
|
|
|
{
|
|
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x00 */
|
|
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x10 */
|
|
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, /* 0x20 */
|
|
|
|
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, /* 0x30 */
|
|
|
|
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 0x40 */
|
|
|
|
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, /* 0x50 */
|
|
|
|
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, /* 0x60 */
|
|
|
|
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1 /* 0x70 */
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT decode_base64(IStream *input, IStream **ret_stream)
|
|
|
|
{
|
|
|
|
const unsigned char *ptr, *end;
|
|
|
|
unsigned char buf[1024];
|
|
|
|
LARGE_INTEGER pos;
|
|
|
|
unsigned char *ret;
|
|
|
|
unsigned char in[4];
|
|
|
|
IStream *output;
|
|
|
|
DWORD size;
|
|
|
|
int n = 0;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
pos.QuadPart = 0;
|
|
|
|
hres = IStream_Seek(input, pos, STREAM_SEEK_SET, NULL);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = CreateStreamOnHGlobal(NULL, TRUE, &output);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
hres = IStream_Read(input, buf, sizeof(buf), &size);
|
|
|
|
if(FAILED(hres) || !size)
|
|
|
|
break;
|
|
|
|
|
|
|
|
ptr = ret = buf;
|
|
|
|
end = buf + size;
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
/* skip invalid chars */
|
|
|
|
while(ptr < end &&
|
|
|
|
(*ptr >= sizeof(base64_decode_table)/sizeof(*base64_decode_table)
|
|
|
|
|| base64_decode_table[*ptr] == -1))
|
|
|
|
ptr++;
|
|
|
|
if(ptr == end)
|
|
|
|
break;
|
|
|
|
|
|
|
|
in[n++] = base64_decode_table[*ptr++];
|
|
|
|
switch(n) {
|
|
|
|
case 2:
|
|
|
|
*ret++ = in[0] << 2 | in[1] >> 4;
|
|
|
|
continue;
|
|
|
|
case 3:
|
|
|
|
*ret++ = in[1] << 4 | in[2] >> 2;
|
|
|
|
continue;
|
|
|
|
case 4:
|
|
|
|
*ret++ = ((in[2] << 6) & 0xc0) | in[3];
|
|
|
|
n = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ret > buf) {
|
|
|
|
hres = IStream_Write(output, buf, ret - buf, NULL);
|
|
|
|
if(FAILED(hres))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
hres = IStream_Seek(output, pos, STREAM_SEEK_SET, NULL);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
IStream_Release(output);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ret_stream = output;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-02-01 11:23:39 +01:00
|
|
|
static int hex_digit(char c)
|
|
|
|
{
|
|
|
|
if('0' <= c && c <= '9')
|
|
|
|
return c - '0';
|
|
|
|
if('A' <= c && c <= 'F')
|
|
|
|
return c - 'A' + 10;
|
|
|
|
if('a' <= c && c <= 'f')
|
|
|
|
return c - 'a' + 10;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT decode_qp(IStream *input, IStream **ret_stream)
|
|
|
|
{
|
|
|
|
const unsigned char *ptr, *end;
|
|
|
|
unsigned char *ret, prev = 0;
|
|
|
|
unsigned char buf[1024];
|
|
|
|
LARGE_INTEGER pos;
|
|
|
|
IStream *output;
|
|
|
|
DWORD size;
|
|
|
|
int n = -1;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
pos.QuadPart = 0;
|
|
|
|
hres = IStream_Seek(input, pos, STREAM_SEEK_SET, NULL);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = CreateStreamOnHGlobal(NULL, TRUE, &output);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
hres = IStream_Read(input, buf, sizeof(buf), &size);
|
|
|
|
if(FAILED(hres) || !size)
|
|
|
|
break;
|
|
|
|
|
|
|
|
ptr = ret = buf;
|
|
|
|
end = buf + size;
|
|
|
|
|
|
|
|
while(ptr < end) {
|
|
|
|
unsigned char byte = *ptr++;
|
|
|
|
|
|
|
|
switch(n) {
|
|
|
|
case -1:
|
|
|
|
if(byte == '=')
|
|
|
|
n = 0;
|
|
|
|
else
|
|
|
|
*ret++ = byte;
|
|
|
|
continue;
|
|
|
|
case 0:
|
|
|
|
prev = byte;
|
|
|
|
n = 1;
|
|
|
|
continue;
|
|
|
|
case 1:
|
|
|
|
if(prev != '\r' || byte != '\n') {
|
|
|
|
int h1 = hex_digit(prev), h2 = hex_digit(byte);
|
|
|
|
if(h1 != -1 && h2 != -1)
|
|
|
|
*ret++ = (h1 << 4) | h2;
|
|
|
|
else
|
|
|
|
*ret++ = '=';
|
|
|
|
}
|
|
|
|
n = -1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ret > buf) {
|
|
|
|
hres = IStream_Write(output, buf, ret - buf, NULL);
|
|
|
|
if(FAILED(hres))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
hres = IStream_Seek(output, pos, STREAM_SEEK_SET, NULL);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
IStream_Release(output);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ret_stream = output;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_GetData(
|
|
|
|
IMimeBody* iface,
|
|
|
|
ENCODINGTYPE ietEncoding,
|
|
|
|
IStream** ppStream)
|
2008-02-12 12:18:09 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
2017-01-27 15:59:35 +01:00
|
|
|
ULARGE_INTEGER start, size;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2017-01-27 16:01:07 +01:00
|
|
|
TRACE("(%p)->(%d %p)\n", This, ietEncoding, ppStream);
|
|
|
|
|
|
|
|
if(This->encoding != ietEncoding) {
|
|
|
|
switch(This->encoding) {
|
|
|
|
case IET_BASE64:
|
2017-02-01 11:23:39 +01:00
|
|
|
hres = decode_base64(This->data, ppStream);
|
|
|
|
break;
|
|
|
|
case IET_QP:
|
|
|
|
hres = decode_qp(This->data, ppStream);
|
|
|
|
break;
|
2017-01-27 16:01:07 +01:00
|
|
|
default:
|
|
|
|
FIXME("Decoding %d is not supported.\n", This->encoding);
|
2017-02-01 11:23:39 +01:00
|
|
|
hres = S_FALSE;
|
2017-01-27 16:01:07 +01:00
|
|
|
}
|
2017-02-01 11:23:39 +01:00
|
|
|
if(ietEncoding != IET_BINARY)
|
|
|
|
FIXME("Encoding %d is not supported.\n", ietEncoding);
|
|
|
|
if(hres != S_FALSE)
|
|
|
|
return hres;
|
2017-01-27 16:01:07 +01:00
|
|
|
}
|
2008-02-14 14:53:49 +01:00
|
|
|
|
2017-01-27 15:59:35 +01:00
|
|
|
start.QuadPart = 0;
|
|
|
|
hres = get_stream_size(This->data, &size);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
hres = create_sub_stream(This->data, start, size, ppStream);
|
|
|
|
return hres;
|
2017-01-27 15:59:08 +01:00
|
|
|
}
|
2008-02-14 14:53:49 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_SetData(
|
|
|
|
IMimeBody* iface,
|
|
|
|
ENCODINGTYPE ietEncoding,
|
|
|
|
LPCSTR pszPriType,
|
|
|
|
LPCSTR pszSubType,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID pvObject)
|
|
|
|
{
|
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
|
|
|
TRACE("(%p)->(%d, %s, %s, %s %p)\n", This, ietEncoding, debugstr_a(pszPriType), debugstr_a(pszSubType),
|
|
|
|
debugstr_guid(riid), pvObject);
|
2008-02-14 14:53:49 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
if(IsEqualIID(riid, &IID_IStream))
|
|
|
|
IStream_AddRef((IStream *)pvObject);
|
|
|
|
else
|
2008-02-14 14:53:49 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
FIXME("Unhandled object type %s\n", debugstr_guid(riid));
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
2008-02-14 14:53:49 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
if(This->data)
|
|
|
|
FIXME("release old data\n");
|
2008-02-14 14:53:49 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
This->data_iid = *riid;
|
|
|
|
This->data = pvObject;
|
2008-02-14 14:53:49 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
IMimeBody_SetCurrentEncoding(iface, ietEncoding);
|
2008-02-14 14:53:49 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
/* FIXME: Update the content type.
|
|
|
|
If pszPriType == NULL use 'application'
|
|
|
|
If pszSubType == NULL use 'octet-stream' */
|
2008-02-14 14:53:49 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
return S_OK;
|
2008-02-12 12:18:09 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_EmptyData(
|
|
|
|
IMimeBody* iface)
|
2008-02-12 12:18:09 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
|
|
|
FIXME("(%p)->() stub\n", This);
|
2008-02-12 12:18:09 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_CopyTo(
|
|
|
|
IMimeBody* iface,
|
|
|
|
IMimeBody* pBody)
|
2008-02-12 12:18:09 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
|
|
|
FIXME("(%p)->(%p) stub\n", This, pBody);
|
2008-02-12 12:18:09 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_GetTransmitInfo(
|
|
|
|
IMimeBody* iface,
|
|
|
|
LPTRANSMITINFO pTransmitInfo)
|
2008-02-12 12:18:09 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
|
|
|
FIXME("(%p)->(%p) stub\n", This, pTransmitInfo);
|
2008-02-12 12:18:09 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_SaveToFile(
|
|
|
|
IMimeBody* iface,
|
|
|
|
ENCODINGTYPE ietEncoding,
|
|
|
|
LPCSTR pszFilePath)
|
2008-02-12 12:18:09 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
|
|
|
FIXME("(%p)->(%d, %s) stub\n", This, ietEncoding, debugstr_a(pszFilePath));
|
2008-02-12 12:18:09 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT WINAPI MimeBody_GetHandle(
|
|
|
|
IMimeBody* iface,
|
|
|
|
LPHBODY phBody)
|
2008-02-12 12:18:09 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
MimeBody *This = impl_from_IMimeBody(iface);
|
|
|
|
TRACE("(%p)->(%p)\n", iface, phBody);
|
2008-02-12 12:18:09 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
if(!phBody)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*phBody = This->handle;
|
|
|
|
return This->handle ? S_OK : MIME_E_NO_DATA;
|
2008-02-12 12:18:09 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static IMimeBodyVtbl body_vtbl =
|
2008-02-12 12:18:09 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
MimeBody_QueryInterface,
|
|
|
|
MimeBody_AddRef,
|
|
|
|
MimeBody_Release,
|
|
|
|
MimeBody_GetClassID,
|
|
|
|
MimeBody_IsDirty,
|
|
|
|
MimeBody_Load,
|
|
|
|
MimeBody_Save,
|
|
|
|
MimeBody_GetSizeMax,
|
|
|
|
MimeBody_InitNew,
|
|
|
|
MimeBody_GetPropInfo,
|
|
|
|
MimeBody_SetPropInfo,
|
|
|
|
MimeBody_GetProp,
|
|
|
|
MimeBody_SetProp,
|
|
|
|
MimeBody_AppendProp,
|
|
|
|
MimeBody_DeleteProp,
|
|
|
|
MimeBody_CopyProps,
|
|
|
|
MimeBody_MoveProps,
|
|
|
|
MimeBody_DeleteExcept,
|
|
|
|
MimeBody_QueryProp,
|
|
|
|
MimeBody_GetCharset,
|
|
|
|
MimeBody_SetCharset,
|
|
|
|
MimeBody_GetParameters,
|
|
|
|
MimeBody_IsContentType,
|
|
|
|
MimeBody_BindToObject,
|
|
|
|
MimeBody_Clone,
|
|
|
|
MimeBody_SetOption,
|
|
|
|
MimeBody_GetOption,
|
|
|
|
MimeBody_EnumProps,
|
|
|
|
MimeBody_IsType,
|
|
|
|
MimeBody_SetDisplayName,
|
|
|
|
MimeBody_GetDisplayName,
|
|
|
|
MimeBody_GetOffsets,
|
|
|
|
MimeBody_GetCurrentEncoding,
|
|
|
|
MimeBody_SetCurrentEncoding,
|
|
|
|
MimeBody_GetEstimatedSize,
|
|
|
|
MimeBody_GetDataHere,
|
|
|
|
MimeBody_GetData,
|
|
|
|
MimeBody_SetData,
|
|
|
|
MimeBody_EmptyData,
|
|
|
|
MimeBody_CopyTo,
|
|
|
|
MimeBody_GetTransmitInfo,
|
|
|
|
MimeBody_SaveToFile,
|
|
|
|
MimeBody_GetHandle
|
2008-02-12 12:18:09 +01:00
|
|
|
};
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
static HRESULT MimeBody_set_offsets(MimeBody *body, const BODYOFFSETS *offsets)
|
2008-02-12 12:18:09 +01:00
|
|
|
{
|
2017-01-27 15:59:08 +01:00
|
|
|
TRACE("setting offsets to %d, %d, %d, %d\n", offsets->cbBoundaryStart,
|
|
|
|
offsets->cbHeaderStart, offsets->cbBodyStart, offsets->cbBodyEnd);
|
|
|
|
|
|
|
|
body->body_offsets = *offsets;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define FIRST_CUSTOM_PROP_ID 0x100
|
|
|
|
|
|
|
|
static MimeBody *mimebody_create(void)
|
|
|
|
{
|
|
|
|
MimeBody *This;
|
|
|
|
BODYOFFSETS body_offsets;
|
2008-02-12 12:18:09 +01:00
|
|
|
|
|
|
|
This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
|
2017-01-27 15:59:08 +01:00
|
|
|
if (!This)
|
|
|
|
return NULL;
|
2008-02-12 12:18:09 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
This->IMimeBody_iface.lpVtbl = &body_vtbl;
|
2013-03-04 00:36:06 +01:00
|
|
|
This->ref = 1;
|
2017-01-27 15:59:08 +01:00
|
|
|
This->handle = NULL;
|
|
|
|
list_init(&This->headers);
|
|
|
|
list_init(&This->new_props);
|
|
|
|
This->next_prop_id = FIRST_CUSTOM_PROP_ID;
|
|
|
|
This->content_pri_type = NULL;
|
|
|
|
This->content_sub_type = NULL;
|
|
|
|
This->encoding = IET_7BIT;
|
|
|
|
This->data = NULL;
|
|
|
|
This->data_iid = IID_NULL;
|
2008-02-12 12:18:09 +01:00
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
body_offsets.cbBoundaryStart = body_offsets.cbHeaderStart = 0;
|
|
|
|
body_offsets.cbBodyStart = body_offsets.cbBodyEnd = 0;
|
|
|
|
MimeBody_set_offsets(This, &body_offsets);
|
|
|
|
|
|
|
|
return This;
|
2008-02-12 12:18:09 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 15:59:08 +01:00
|
|
|
HRESULT MimeBody_create(IUnknown *outer, void **ppv)
|
|
|
|
{
|
|
|
|
MimeBody *mb;
|
|
|
|
|
|
|
|
if(outer)
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
|
|
|
|
if ((mb = mimebody_create()))
|
|
|
|
{
|
|
|
|
*ppv = &mb->IMimeBody_iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
}
|
2008-02-12 12:18:09 +01:00
|
|
|
|
2008-02-11 12:54:14 +01:00
|
|
|
typedef struct body_t
|
|
|
|
{
|
|
|
|
struct list entry;
|
2010-04-08 21:14:15 +02:00
|
|
|
DWORD index;
|
2013-03-04 00:35:05 +01:00
|
|
|
MimeBody *mime_body;
|
2008-02-11 12:54:14 +01:00
|
|
|
|
|
|
|
struct body_t *parent;
|
|
|
|
struct list children;
|
|
|
|
} body_t;
|
|
|
|
|
2007-11-02 12:53:26 +01:00
|
|
|
typedef struct MimeMessage
|
2007-11-02 12:49:29 +01:00
|
|
|
{
|
2013-03-04 00:28:47 +01:00
|
|
|
IMimeMessage IMimeMessage_iface;
|
|
|
|
LONG ref;
|
2008-02-08 13:17:43 +01:00
|
|
|
IStream *stream;
|
2008-02-11 12:54:14 +01:00
|
|
|
|
|
|
|
struct list body_tree;
|
2010-04-08 21:14:15 +02:00
|
|
|
DWORD next_index;
|
2007-11-02 12:53:26 +01:00
|
|
|
} MimeMessage;
|
|
|
|
|
2013-03-04 00:28:47 +01:00
|
|
|
static inline MimeMessage *impl_from_IMimeMessage(IMimeMessage *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, MimeMessage, IMimeMessage_iface);
|
|
|
|
}
|
|
|
|
|
2007-11-02 12:53:26 +01:00
|
|
|
static HRESULT WINAPI MimeMessage_QueryInterface(IMimeMessage *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID(riid, &IID_IPersist) ||
|
|
|
|
IsEqualIID(riid, &IID_IPersistStreamInit) ||
|
|
|
|
IsEqualIID(riid, &IID_IMimeMessageTree) ||
|
|
|
|
IsEqualIID(riid, &IID_IMimeMessage))
|
|
|
|
{
|
|
|
|
*ppv = iface;
|
2012-08-13 11:11:26 +02:00
|
|
|
IMimeMessage_AddRef(iface);
|
2007-11-02 12:53:26 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("no interface for %s\n", debugstr_guid(riid));
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI MimeMessage_AddRef(IMimeMessage *iface)
|
|
|
|
{
|
2013-03-04 00:28:47 +01:00
|
|
|
MimeMessage *This = impl_from_IMimeMessage(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
2007-11-02 12:53:26 +01:00
|
|
|
}
|
|
|
|
|
2008-02-11 12:54:14 +01:00
|
|
|
static void empty_body_list(struct list *list)
|
|
|
|
{
|
|
|
|
body_t *body, *cursor2;
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(body, cursor2, list, body_t, entry)
|
|
|
|
{
|
|
|
|
empty_body_list(&body->children);
|
|
|
|
list_remove(&body->entry);
|
2013-03-04 00:35:05 +01:00
|
|
|
IMimeBody_Release(&body->mime_body->IMimeBody_iface);
|
2008-02-11 12:54:14 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, body);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-02 12:53:26 +01:00
|
|
|
static ULONG WINAPI MimeMessage_Release(IMimeMessage *iface)
|
|
|
|
{
|
2013-03-04 00:28:47 +01:00
|
|
|
MimeMessage *This = impl_from_IMimeMessage(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
2007-11-02 12:53:26 +01:00
|
|
|
|
2013-03-04 00:28:47 +01:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2007-11-02 12:53:26 +01:00
|
|
|
|
2013-03-04 00:28:47 +01:00
|
|
|
if (!ref)
|
2007-11-02 12:53:26 +01:00
|
|
|
{
|
2008-02-11 12:54:14 +01:00
|
|
|
empty_body_list(&This->body_tree);
|
|
|
|
|
2008-02-08 13:17:43 +01:00
|
|
|
if(This->stream) IStream_Release(This->stream);
|
2007-11-02 12:53:26 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
|
2013-03-04 00:28:47 +01:00
|
|
|
return ref;
|
2007-11-02 12:53:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** IPersist methods ***/
|
|
|
|
static HRESULT WINAPI MimeMessage_GetClassID(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
CLSID *pClassID)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p)\n", iface, pClassID);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** IPersistStreamInit methods ***/
|
|
|
|
static HRESULT WINAPI MimeMessage_IsDirty(
|
|
|
|
IMimeMessage *iface)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->()\n", iface);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-03-04 00:35:05 +01:00
|
|
|
static body_t *new_body_entry(MimeBody *mime_body, DWORD index, body_t *parent)
|
2008-02-11 12:54:14 +01:00
|
|
|
{
|
|
|
|
body_t *body = HeapAlloc(GetProcessHeap(), 0, sizeof(*body));
|
|
|
|
if(body)
|
|
|
|
{
|
|
|
|
body->mime_body = mime_body;
|
2010-04-08 21:14:15 +02:00
|
|
|
body->index = index;
|
2008-02-11 12:54:14 +01:00
|
|
|
list_init(&body->children);
|
|
|
|
body->parent = parent;
|
2016-07-12 10:02:34 +02:00
|
|
|
|
|
|
|
mime_body->handle = UlongToHandle(body->index);
|
2008-02-11 12:54:14 +01:00
|
|
|
}
|
|
|
|
return body;
|
|
|
|
}
|
|
|
|
|
2008-02-12 12:36:31 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
BODYOFFSETS offsets;
|
|
|
|
} offset_entry_t;
|
|
|
|
|
|
|
|
static HRESULT create_body_offset_list(IStream *stm, const char *boundary, struct list *body_offsets)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
2017-01-31 11:46:23 +01:00
|
|
|
DWORD read, boundary_start;
|
2008-02-12 12:36:31 +01:00
|
|
|
int boundary_len = strlen(boundary);
|
2017-01-31 11:46:23 +01:00
|
|
|
char *buf, *ptr, *overlap;
|
2008-02-12 12:36:31 +01:00
|
|
|
DWORD start = 0, overlap_no;
|
|
|
|
offset_entry_t *cur_body = NULL;
|
2017-01-31 11:46:23 +01:00
|
|
|
BOOL is_first_line = TRUE;
|
2008-02-12 12:36:31 +01:00
|
|
|
ULARGE_INTEGER cur;
|
|
|
|
LARGE_INTEGER zero;
|
|
|
|
|
|
|
|
list_init(body_offsets);
|
|
|
|
|
|
|
|
overlap_no = boundary_len + 5;
|
|
|
|
|
|
|
|
overlap = buf = HeapAlloc(GetProcessHeap(), 0, overlap_no + PARSER_BUF_SIZE + 1);
|
|
|
|
|
|
|
|
zero.QuadPart = 0;
|
|
|
|
hr = IStream_Seek(stm, zero, STREAM_SEEK_CUR, &cur);
|
2008-02-18 11:54:22 +01:00
|
|
|
start = cur.u.LowPart;
|
2008-02-12 12:36:31 +01:00
|
|
|
|
|
|
|
do {
|
|
|
|
hr = IStream_Read(stm, overlap, PARSER_BUF_SIZE, &read);
|
|
|
|
if(FAILED(hr)) goto end;
|
|
|
|
if(read == 0) break;
|
|
|
|
overlap[read] = '\0';
|
|
|
|
|
|
|
|
ptr = buf;
|
2017-01-31 11:46:23 +01:00
|
|
|
while(1) {
|
|
|
|
if(is_first_line) {
|
|
|
|
is_first_line = FALSE;
|
|
|
|
}else {
|
|
|
|
ptr = strstr(ptr, "\r\n");
|
|
|
|
if(!ptr)
|
2008-02-12 12:36:31 +01:00
|
|
|
break;
|
2017-01-31 11:46:23 +01:00
|
|
|
ptr += 2;
|
|
|
|
}
|
2008-02-12 12:36:31 +01:00
|
|
|
|
2017-01-31 11:46:23 +01:00
|
|
|
boundary_start = start + ptr - buf;
|
|
|
|
|
|
|
|
if(*ptr == '-' && *(ptr + 1) == '-' && !memcmp(ptr + 2, boundary, boundary_len)) {
|
|
|
|
ptr += boundary_len + 2;
|
|
|
|
|
|
|
|
if(*ptr == '\r' && *(ptr + 1) == '\n')
|
2008-02-12 12:36:31 +01:00
|
|
|
{
|
2017-01-31 11:46:23 +01:00
|
|
|
ptr += 2;
|
2008-02-12 12:36:31 +01:00
|
|
|
if(cur_body)
|
|
|
|
{
|
2017-01-31 11:46:23 +01:00
|
|
|
cur_body->offsets.cbBodyEnd = boundary_start - 2;
|
2008-02-12 12:36:31 +01:00
|
|
|
list_add_tail(body_offsets, &cur_body->entry);
|
|
|
|
}
|
|
|
|
cur_body = HeapAlloc(GetProcessHeap(), 0, sizeof(*cur_body));
|
2017-01-31 11:46:23 +01:00
|
|
|
cur_body->offsets.cbBoundaryStart = boundary_start;
|
|
|
|
cur_body->offsets.cbHeaderStart = start + ptr - buf;
|
2008-02-12 12:36:31 +01:00
|
|
|
}
|
2017-01-31 11:46:23 +01:00
|
|
|
else if(*ptr == '-' && *(ptr + 1) == '-')
|
2008-02-12 12:36:31 +01:00
|
|
|
{
|
|
|
|
if(cur_body)
|
|
|
|
{
|
2017-01-31 11:46:23 +01:00
|
|
|
cur_body->offsets.cbBodyEnd = boundary_start - 2;
|
2008-02-12 12:36:31 +01:00
|
|
|
list_add_tail(body_offsets, &cur_body->entry);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-01-31 11:46:23 +01:00
|
|
|
}
|
2008-02-12 12:36:31 +01:00
|
|
|
|
|
|
|
if(overlap == buf) /* 1st iteration */
|
|
|
|
{
|
2015-04-19 11:50:42 +02:00
|
|
|
memmove(buf, buf + PARSER_BUF_SIZE - overlap_no, overlap_no);
|
2008-02-12 12:36:31 +01:00
|
|
|
overlap = buf + overlap_no;
|
|
|
|
start += read - overlap_no;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-04-19 11:50:42 +02:00
|
|
|
memmove(buf, buf + PARSER_BUF_SIZE, overlap_no);
|
2008-02-12 12:36:31 +01:00
|
|
|
start += read;
|
|
|
|
}
|
|
|
|
} while(1);
|
|
|
|
|
|
|
|
end:
|
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2008-02-11 12:54:14 +01:00
|
|
|
static body_t *create_sub_body(MimeMessage *msg, IStream *pStm, BODYOFFSETS *offset, body_t *parent)
|
|
|
|
{
|
2017-01-31 11:46:31 +01:00
|
|
|
ULARGE_INTEGER start, length;
|
2013-03-04 00:35:05 +01:00
|
|
|
MimeBody *mime_body;
|
2008-02-11 12:54:14 +01:00
|
|
|
HRESULT hr;
|
|
|
|
body_t *body;
|
2017-01-31 11:46:31 +01:00
|
|
|
LARGE_INTEGER pos;
|
|
|
|
|
|
|
|
pos.QuadPart = offset->cbHeaderStart;
|
|
|
|
IStream_Seek(pStm, pos, STREAM_SEEK_SET, NULL);
|
2008-02-11 12:54:14 +01:00
|
|
|
|
2013-03-04 00:35:05 +01:00
|
|
|
mime_body = mimebody_create();
|
|
|
|
IMimeBody_Load(&mime_body->IMimeBody_iface, pStm);
|
2017-01-31 11:46:31 +01:00
|
|
|
|
|
|
|
pos.QuadPart = 0;
|
|
|
|
hr = IStream_Seek(pStm, pos, STREAM_SEEK_CUR, &start);
|
|
|
|
offset->cbBodyStart = start.QuadPart;
|
2013-03-04 00:35:05 +01:00
|
|
|
if (parent) MimeBody_set_offsets(mime_body, offset);
|
2017-01-31 11:46:31 +01:00
|
|
|
|
|
|
|
length.QuadPart = offset->cbBodyEnd - offset->cbBodyStart;
|
|
|
|
create_sub_stream(pStm, start, length, (IStream**)&mime_body->data);
|
|
|
|
mime_body->data_iid = IID_IStream;
|
|
|
|
|
2010-04-08 21:14:15 +02:00
|
|
|
body = new_body_entry(mime_body, msg->next_index++, parent);
|
2008-02-11 12:54:14 +01:00
|
|
|
|
2013-03-04 00:35:05 +01:00
|
|
|
if(IMimeBody_IsContentType(&mime_body->IMimeBody_iface, "multipart", NULL) == S_OK)
|
2008-02-12 12:36:31 +01:00
|
|
|
{
|
|
|
|
MIMEPARAMINFO *param_info;
|
|
|
|
ULONG count, i;
|
|
|
|
IMimeAllocator *alloc;
|
|
|
|
|
2013-03-04 00:35:05 +01:00
|
|
|
hr = IMimeBody_GetParameters(&mime_body->IMimeBody_iface, "Content-Type", &count,
|
|
|
|
¶m_info);
|
2008-02-12 12:36:31 +01:00
|
|
|
if(hr != S_OK || count == 0) return body;
|
|
|
|
|
|
|
|
MimeOleGetAllocator(&alloc);
|
|
|
|
|
|
|
|
for(i = 0; i < count; i++)
|
|
|
|
{
|
2016-05-02 13:01:58 +02:00
|
|
|
if(!lstrcmpiA(param_info[i].pszName, "boundary"))
|
2008-02-12 12:36:31 +01:00
|
|
|
{
|
|
|
|
struct list offset_list;
|
|
|
|
offset_entry_t *cur, *cursor2;
|
|
|
|
hr = create_body_offset_list(pStm, param_info[i].pszData, &offset_list);
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(cur, cursor2, &offset_list, offset_entry_t, entry)
|
|
|
|
{
|
|
|
|
body_t *sub_body;
|
2017-01-31 11:46:31 +01:00
|
|
|
|
|
|
|
sub_body = create_sub_body(msg, pStm, &cur->offsets, body);
|
2008-02-12 12:36:31 +01:00
|
|
|
list_add_tail(&body->children, &sub_body->entry);
|
|
|
|
list_remove(&cur->entry);
|
|
|
|
HeapFree(GetProcessHeap(), 0, cur);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
IMimeAllocator_FreeParamInfoArray(alloc, count, param_info, TRUE);
|
|
|
|
IMimeAllocator_Release(alloc);
|
|
|
|
}
|
2008-02-11 12:54:14 +01:00
|
|
|
return body;
|
|
|
|
}
|
|
|
|
|
2013-03-04 00:28:47 +01:00
|
|
|
static HRESULT WINAPI MimeMessage_Load(IMimeMessage *iface, IStream *pStm)
|
2008-02-08 13:17:43 +01:00
|
|
|
{
|
2013-03-04 00:28:47 +01:00
|
|
|
MimeMessage *This = impl_from_IMimeMessage(iface);
|
2008-02-11 12:54:14 +01:00
|
|
|
body_t *root_body;
|
|
|
|
BODYOFFSETS offsets;
|
|
|
|
ULARGE_INTEGER cur;
|
|
|
|
LARGE_INTEGER zero;
|
2008-02-08 13:17:43 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", iface, pStm);
|
|
|
|
|
|
|
|
if(This->stream)
|
|
|
|
{
|
|
|
|
FIXME("already loaded a message\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2016-04-14 12:11:14 +02:00
|
|
|
empty_body_list(&This->body_tree);
|
|
|
|
|
2008-02-08 13:17:43 +01:00
|
|
|
IStream_AddRef(pStm);
|
|
|
|
This->stream = pStm;
|
2008-02-11 12:54:14 +01:00
|
|
|
offsets.cbBoundaryStart = offsets.cbHeaderStart = 0;
|
|
|
|
offsets.cbBodyStart = offsets.cbBodyEnd = 0;
|
|
|
|
|
|
|
|
root_body = create_sub_body(This, pStm, &offsets, NULL);
|
|
|
|
|
|
|
|
zero.QuadPart = 0;
|
|
|
|
IStream_Seek(pStm, zero, STREAM_SEEK_END, &cur);
|
2008-02-18 11:54:22 +01:00
|
|
|
offsets.cbBodyEnd = cur.u.LowPart;
|
2013-03-04 00:35:05 +01:00
|
|
|
MimeBody_set_offsets(root_body->mime_body, &offsets);
|
2008-02-11 12:54:14 +01:00
|
|
|
|
|
|
|
list_add_head(&This->body_tree, &root_body->entry);
|
2008-02-08 13:17:43 +01:00
|
|
|
|
|
|
|
return S_OK;
|
2007-11-02 12:53:26 +01:00
|
|
|
}
|
|
|
|
|
2013-03-04 00:36:06 +01:00
|
|
|
static HRESULT WINAPI MimeMessage_Save(IMimeMessage *iface, IStream *pStm, BOOL fClearDirty)
|
2007-11-02 12:53:26 +01:00
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p, %s)\n", iface, pStm, fClearDirty ? "TRUE" : "FALSE");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_GetSizeMax(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
ULARGE_INTEGER *pcbSize)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p)\n", iface, pcbSize);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_InitNew(
|
|
|
|
IMimeMessage *iface)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->()\n", iface);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** IMimeMessageTree methods ***/
|
2013-03-04 00:28:47 +01:00
|
|
|
static HRESULT WINAPI MimeMessage_GetMessageSource(IMimeMessage *iface, IStream **ppStream,
|
|
|
|
DWORD dwFlags)
|
2007-11-02 12:53:26 +01:00
|
|
|
{
|
2013-03-04 00:28:47 +01:00
|
|
|
MimeMessage *This = impl_from_IMimeMessage(iface);
|
|
|
|
|
2007-11-02 12:53:26 +01:00
|
|
|
FIXME("(%p)->(%p, 0x%x)\n", iface, ppStream, dwFlags);
|
2008-02-12 15:30:59 +01:00
|
|
|
|
|
|
|
IStream_AddRef(This->stream);
|
|
|
|
*ppStream = This->stream;
|
|
|
|
return S_OK;
|
2007-11-02 12:53:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_GetMessageSize(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
ULONG *pcbSize,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p, 0x%x)\n", iface, pcbSize, dwFlags);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_LoadOffsetTable(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
IStream *pStream)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p)\n", iface, pStream);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_SaveOffsetTable(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
IStream *pStream,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p, 0x%x)\n", iface, pStream, dwFlags);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_GetFlags(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
DWORD *pdwFlags)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p)\n", iface, pdwFlags);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_Commit(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(0x%x)\n", iface, dwFlags);
|
2016-07-01 09:57:30 +02:00
|
|
|
return S_OK;
|
2007-11-02 12:53:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_HandsOffStorage(
|
|
|
|
IMimeMessage *iface)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->()\n", iface);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2008-02-11 13:04:49 +01:00
|
|
|
static HRESULT find_body(struct list *list, HBODY hbody, body_t **body)
|
|
|
|
{
|
|
|
|
body_t *cur;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if(hbody == HBODY_ROOT)
|
|
|
|
{
|
|
|
|
*body = LIST_ENTRY(list_head(list), body_t, entry);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(cur, list, body_t, entry)
|
|
|
|
{
|
2010-04-08 21:14:15 +02:00
|
|
|
if(cur->index == HandleToUlong(hbody))
|
2008-02-11 13:04:49 +01:00
|
|
|
{
|
|
|
|
*body = cur;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
hr = find_body(&cur->children, hbody, body);
|
|
|
|
if(hr == S_OK) return S_OK;
|
|
|
|
}
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2013-03-04 00:28:47 +01:00
|
|
|
static HRESULT WINAPI MimeMessage_BindToObject(IMimeMessage *iface, const HBODY hBody, REFIID riid,
|
|
|
|
void **ppvObject)
|
2007-11-02 12:53:26 +01:00
|
|
|
{
|
2013-03-04 00:28:47 +01:00
|
|
|
MimeMessage *This = impl_from_IMimeMessage(iface);
|
2008-02-11 13:04:49 +01:00
|
|
|
HRESULT hr;
|
|
|
|
body_t *body;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p, %s, %p)\n", iface, hBody, debugstr_guid(riid), ppvObject);
|
|
|
|
|
|
|
|
hr = find_body(&This->body_tree, hBody, &body);
|
|
|
|
|
|
|
|
if(hr != S_OK) return hr;
|
|
|
|
|
|
|
|
if(IsEqualIID(riid, &IID_IMimeBody))
|
|
|
|
{
|
2013-03-04 00:35:05 +01:00
|
|
|
IMimeBody_AddRef(&body->mime_body->IMimeBody_iface);
|
|
|
|
*ppvObject = &body->mime_body->IMimeBody_iface;
|
2008-02-11 13:04:49 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
2007-11-02 12:49:29 +01:00
|
|
|
}
|
|
|
|
|
2007-11-02 12:53:26 +01:00
|
|
|
static HRESULT WINAPI MimeMessage_SaveBody(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
HBODY hBody,
|
|
|
|
DWORD dwFlags,
|
|
|
|
IStream *pStream)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p, 0x%x, %p)\n", iface, hBody, dwFlags, pStream);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2008-02-12 12:49:47 +01:00
|
|
|
static HRESULT get_body(MimeMessage *msg, BODYLOCATION location, HBODY pivot, body_t **out)
|
|
|
|
{
|
|
|
|
body_t *root = LIST_ENTRY(list_head(&msg->body_tree), body_t, entry);
|
|
|
|
body_t *body;
|
|
|
|
HRESULT hr;
|
|
|
|
struct list *list;
|
|
|
|
|
|
|
|
if(location == IBL_ROOT)
|
|
|
|
{
|
|
|
|
*out = root;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = find_body(&msg->body_tree, pivot, &body);
|
|
|
|
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
switch(location)
|
|
|
|
{
|
|
|
|
case IBL_PARENT:
|
2016-07-12 10:02:46 +02:00
|
|
|
if(body->parent)
|
|
|
|
*out = body->parent;
|
|
|
|
else
|
|
|
|
hr = MIME_E_NOT_FOUND;
|
2008-02-12 12:49:47 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IBL_FIRST:
|
|
|
|
list = list_head(&body->children);
|
|
|
|
if(list)
|
|
|
|
*out = LIST_ENTRY(list, body_t, entry);
|
|
|
|
else
|
|
|
|
hr = MIME_E_NOT_FOUND;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IBL_LAST:
|
|
|
|
list = list_tail(&body->children);
|
|
|
|
if(list)
|
|
|
|
*out = LIST_ENTRY(list, body_t, entry);
|
|
|
|
else
|
|
|
|
hr = MIME_E_NOT_FOUND;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IBL_NEXT:
|
|
|
|
list = list_next(&body->parent->children, &body->entry);
|
|
|
|
if(list)
|
|
|
|
*out = LIST_ENTRY(list, body_t, entry);
|
|
|
|
else
|
|
|
|
hr = MIME_E_NOT_FOUND;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IBL_PREVIOUS:
|
|
|
|
list = list_prev(&body->parent->children, &body->entry);
|
|
|
|
if(list)
|
|
|
|
*out = LIST_ENTRY(list, body_t, entry);
|
|
|
|
else
|
|
|
|
hr = MIME_E_NOT_FOUND;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
hr = E_FAIL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-02 12:53:26 +01:00
|
|
|
static HRESULT WINAPI MimeMessage_InsertBody(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
BODYLOCATION location,
|
|
|
|
HBODY hPivot,
|
|
|
|
LPHBODY phBody)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%d, %p, %p)\n", iface, location, hPivot, phBody);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-03-04 00:28:47 +01:00
|
|
|
static HRESULT WINAPI MimeMessage_GetBody(IMimeMessage *iface, BODYLOCATION location, HBODY hPivot,
|
|
|
|
HBODY *phBody)
|
2007-11-02 12:53:26 +01:00
|
|
|
{
|
2013-03-04 00:28:47 +01:00
|
|
|
MimeMessage *This = impl_from_IMimeMessage(iface);
|
2008-02-12 12:49:47 +01:00
|
|
|
body_t *body;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d, %p, %p)\n", iface, location, hPivot, phBody);
|
|
|
|
|
2016-07-12 10:02:46 +02:00
|
|
|
if(!phBody)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*phBody = NULL;
|
|
|
|
|
2008-02-12 12:49:47 +01:00
|
|
|
hr = get_body(This, location, hPivot, &body);
|
|
|
|
|
2010-04-08 21:14:15 +02:00
|
|
|
if(hr == S_OK) *phBody = UlongToHandle(body->index);
|
2008-02-12 12:49:47 +01:00
|
|
|
|
|
|
|
return hr;
|
2007-11-02 12:53:26 +01:00
|
|
|
}
|
|
|
|
|
2007-11-02 12:54:03 +01:00
|
|
|
static HRESULT WINAPI MimeMessage_DeleteBody(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
HBODY hBody,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p, %08x)\n", iface, hBody, dwFlags);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2007-11-02 12:53:26 +01:00
|
|
|
static HRESULT WINAPI MimeMessage_MoveBody(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
HBODY hBody,
|
|
|
|
BODYLOCATION location)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%d)\n", iface, location);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2008-02-12 12:59:36 +01:00
|
|
|
static void count_children(body_t *body, boolean recurse, ULONG *count)
|
|
|
|
{
|
|
|
|
body_t *child;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(child, &body->children, body_t, entry)
|
|
|
|
{
|
|
|
|
(*count)++;
|
|
|
|
if(recurse) count_children(child, recurse, count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-04 00:28:47 +01:00
|
|
|
static HRESULT WINAPI MimeMessage_CountBodies(IMimeMessage *iface, HBODY hParent, boolean fRecurse,
|
|
|
|
ULONG *pcBodies)
|
2007-11-02 12:53:26 +01:00
|
|
|
{
|
2008-02-12 12:59:36 +01:00
|
|
|
HRESULT hr;
|
2013-03-04 00:28:47 +01:00
|
|
|
MimeMessage *This = impl_from_IMimeMessage(iface);
|
2008-02-12 12:59:36 +01:00
|
|
|
body_t *body;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p, %s, %p)\n", iface, hParent, fRecurse ? "TRUE" : "FALSE", pcBodies);
|
|
|
|
|
|
|
|
hr = find_body(&This->body_tree, hParent, &body);
|
|
|
|
if(hr != S_OK) return hr;
|
|
|
|
|
|
|
|
*pcBodies = 1;
|
|
|
|
count_children(body, fRecurse, pcBodies);
|
|
|
|
|
|
|
|
return S_OK;
|
2007-11-02 12:53:26 +01:00
|
|
|
}
|
|
|
|
|
2013-03-04 00:29:53 +01:00
|
|
|
static HRESULT find_next(MimeMessage *This, body_t *body, FINDBODY *find, HBODY *out)
|
2008-02-12 13:18:26 +01:00
|
|
|
{
|
2010-04-08 21:15:15 +02:00
|
|
|
struct list *ptr;
|
2008-02-12 13:18:26 +01:00
|
|
|
HBODY next;
|
|
|
|
|
2010-04-08 21:15:15 +02:00
|
|
|
for (;;)
|
2008-02-12 13:18:26 +01:00
|
|
|
{
|
2010-04-08 21:15:15 +02:00
|
|
|
if (!body) ptr = list_head( &This->body_tree );
|
2008-02-12 13:18:26 +01:00
|
|
|
else
|
|
|
|
{
|
2010-04-08 21:15:15 +02:00
|
|
|
ptr = list_head( &body->children );
|
|
|
|
while (!ptr)
|
|
|
|
{
|
|
|
|
if (!body->parent) return MIME_E_NOT_FOUND;
|
|
|
|
if (!(ptr = list_next( &body->parent->children, &body->entry ))) body = body->parent;
|
|
|
|
}
|
2008-02-12 13:18:26 +01:00
|
|
|
}
|
|
|
|
|
2010-04-08 21:15:15 +02:00
|
|
|
body = LIST_ENTRY( ptr, body_t, entry );
|
|
|
|
next = UlongToHandle( body->index );
|
|
|
|
find->dwReserved = body->index;
|
2013-03-04 00:35:05 +01:00
|
|
|
if (IMimeBody_IsContentType(&body->mime_body->IMimeBody_iface, find->pszPriType,
|
|
|
|
find->pszSubType) == S_OK)
|
2010-04-08 21:15:15 +02:00
|
|
|
{
|
|
|
|
*out = next;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2008-02-12 13:18:26 +01:00
|
|
|
}
|
2010-04-08 21:15:15 +02:00
|
|
|
return MIME_E_NOT_FOUND;
|
2008-02-12 13:18:26 +01:00
|
|
|
}
|
|
|
|
|
2013-03-04 00:29:53 +01:00
|
|
|
static HRESULT WINAPI MimeMessage_FindFirst(IMimeMessage *iface, FINDBODY *pFindBody, HBODY *phBody)
|
2007-11-02 12:53:26 +01:00
|
|
|
{
|
2013-03-04 00:29:53 +01:00
|
|
|
MimeMessage *This = impl_from_IMimeMessage(iface);
|
|
|
|
|
2008-02-12 13:18:26 +01:00
|
|
|
TRACE("(%p)->(%p, %p)\n", iface, pFindBody, phBody);
|
|
|
|
|
|
|
|
pFindBody->dwReserved = 0;
|
2013-03-04 00:29:53 +01:00
|
|
|
return find_next(This, NULL, pFindBody, phBody);
|
2007-11-02 12:53:26 +01:00
|
|
|
}
|
|
|
|
|
2013-03-04 00:28:47 +01:00
|
|
|
static HRESULT WINAPI MimeMessage_FindNext(IMimeMessage *iface, FINDBODY *pFindBody, HBODY *phBody)
|
2007-11-02 12:53:26 +01:00
|
|
|
{
|
2013-03-04 00:28:47 +01:00
|
|
|
MimeMessage *This = impl_from_IMimeMessage(iface);
|
2010-04-08 21:15:15 +02:00
|
|
|
body_t *body;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2008-02-12 13:18:26 +01:00
|
|
|
TRACE("(%p)->(%p, %p)\n", iface, pFindBody, phBody);
|
|
|
|
|
2010-04-08 21:15:15 +02:00
|
|
|
hr = find_body( &This->body_tree, UlongToHandle( pFindBody->dwReserved ), &body );
|
|
|
|
if (hr != S_OK) return MIME_E_NOT_FOUND;
|
2013-03-04 00:29:53 +01:00
|
|
|
return find_next(This, body, pFindBody, phBody);
|
2007-11-02 12:53:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_ResolveURL(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
HBODY hRelated,
|
|
|
|
LPCSTR pszBase,
|
|
|
|
LPCSTR pszURL,
|
|
|
|
DWORD dwFlags,
|
|
|
|
LPHBODY phBody)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p, %s, %s, 0x%x, %p)\n", iface, hRelated, pszBase, pszURL, dwFlags, phBody);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_ToMultipart(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
HBODY hBody,
|
|
|
|
LPCSTR pszSubType,
|
|
|
|
LPHBODY phMultipart)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p, %s, %p)\n", iface, hBody, pszSubType, phMultipart);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_GetBodyOffsets(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
HBODY hBody,
|
|
|
|
LPBODYOFFSETS pOffsets)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p, %p)\n", iface, hBody, pOffsets);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_GetCharset(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
LPHCHARSET phCharset)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p)\n", iface, phCharset);
|
2008-02-12 15:20:37 +01:00
|
|
|
*phCharset = NULL;
|
|
|
|
return S_OK;
|
2007-11-02 12:53:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_SetCharset(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
HCHARSET hCharset,
|
|
|
|
CSETAPPLYTYPE applytype)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p, %d)\n", iface, hCharset, applytype);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_IsBodyType(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
HBODY hBody,
|
|
|
|
IMSGBODYTYPE bodytype)
|
|
|
|
{
|
2008-02-12 13:27:05 +01:00
|
|
|
HRESULT hr;
|
|
|
|
IMimeBody *mime_body;
|
|
|
|
TRACE("(%p)->(%p, %d)\n", iface, hBody, bodytype);
|
|
|
|
|
|
|
|
hr = IMimeMessage_BindToObject(iface, hBody, &IID_IMimeBody, (void**)&mime_body);
|
|
|
|
if(hr != S_OK) return hr;
|
|
|
|
|
|
|
|
hr = IMimeBody_IsType(mime_body, bodytype);
|
|
|
|
MimeBody_Release(mime_body);
|
|
|
|
return hr;
|
2007-11-02 12:53:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_IsContentType(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
HBODY hBody,
|
|
|
|
LPCSTR pszPriType,
|
|
|
|
LPCSTR pszSubType)
|
|
|
|
{
|
2008-02-12 13:27:05 +01:00
|
|
|
HRESULT hr;
|
|
|
|
IMimeBody *mime_body;
|
2011-09-18 19:50:27 +02:00
|
|
|
TRACE("(%p)->(%p, %s, %s)\n", iface, hBody, debugstr_a(pszPriType),
|
|
|
|
debugstr_a(pszSubType));
|
2008-02-12 13:27:05 +01:00
|
|
|
|
|
|
|
hr = IMimeMessage_BindToObject(iface, hBody, &IID_IMimeBody, (void**)&mime_body);
|
|
|
|
if(FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
hr = IMimeBody_IsContentType(mime_body, pszPriType, pszSubType);
|
|
|
|
IMimeBody_Release(mime_body);
|
|
|
|
return hr;
|
2007-11-02 12:53:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_QueryBodyProp(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
HBODY hBody,
|
|
|
|
LPCSTR pszName,
|
|
|
|
LPCSTR pszCriteria,
|
|
|
|
boolean fSubString,
|
|
|
|
boolean fCaseSensitive)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p, %s, %s, %s, %s)\n", iface, hBody, pszName, pszCriteria, fSubString ? "TRUE" : "FALSE", fCaseSensitive ? "TRUE" : "FALSE");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_GetBodyProp(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
HBODY hBody,
|
|
|
|
LPCSTR pszName,
|
|
|
|
DWORD dwFlags,
|
|
|
|
LPPROPVARIANT pValue)
|
|
|
|
{
|
2008-02-12 13:27:05 +01:00
|
|
|
HRESULT hr;
|
|
|
|
IMimeBody *mime_body;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p, %s, 0x%x, %p)\n", iface, hBody, pszName, dwFlags, pValue);
|
|
|
|
|
|
|
|
hr = IMimeMessage_BindToObject(iface, hBody, &IID_IMimeBody, (void**)&mime_body);
|
|
|
|
if(hr != S_OK) return hr;
|
|
|
|
|
|
|
|
hr = IMimeBody_GetProp(mime_body, pszName, dwFlags, pValue);
|
|
|
|
IMimeBody_Release(mime_body);
|
|
|
|
|
|
|
|
return hr;
|
2007-11-02 12:53:26 +01:00
|
|
|
}
|
|
|
|
|
2007-11-02 12:54:03 +01:00
|
|
|
static HRESULT WINAPI MimeMessage_SetBodyProp(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
HBODY hBody,
|
|
|
|
LPCSTR pszName,
|
|
|
|
DWORD dwFlags,
|
|
|
|
LPCPROPVARIANT pValue)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p, %s, 0x%x, %p)\n", iface, hBody, pszName, dwFlags, pValue);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2007-11-02 12:53:26 +01:00
|
|
|
static HRESULT WINAPI MimeMessage_DeleteBodyProp(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
HBODY hBody,
|
|
|
|
LPCSTR pszName)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p, %s)\n", iface, hBody, pszName);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_SetOption(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
const TYPEDID oid,
|
|
|
|
LPCPROPVARIANT pValue)
|
|
|
|
{
|
2016-05-03 11:17:36 +02:00
|
|
|
HRESULT hr = S_OK;
|
2008-09-22 11:47:38 +02:00
|
|
|
TRACE("(%p)->(%08x, %p)\n", iface, oid, pValue);
|
|
|
|
|
2016-05-03 11:17:36 +02:00
|
|
|
/* Message ID is checked before type.
|
|
|
|
* OID 0x4D -> 0x56 and 0x58 aren't defined but will filtered out later.
|
|
|
|
*/
|
|
|
|
if(TYPEDID_ID(oid) < TYPEDID_ID(OID_ALLOW_8BIT_HEADER) || TYPEDID_ID(oid) > TYPEDID_ID(OID_SECURITY_2KEY_CERT_BAG_64))
|
|
|
|
{
|
|
|
|
WARN("oid (%08x) out of range\n", oid);
|
|
|
|
return MIME_E_INVALID_OPTION_ID;
|
|
|
|
}
|
|
|
|
|
2008-09-22 11:47:38 +02:00
|
|
|
if(pValue->vt != TYPEDID_TYPE(oid))
|
|
|
|
{
|
|
|
|
WARN("Called with vartype %04x and oid %08x\n", pValue->vt, oid);
|
2016-05-03 11:17:36 +02:00
|
|
|
return S_OK;
|
2008-09-22 11:47:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
switch(oid)
|
|
|
|
{
|
|
|
|
case OID_HIDE_TNEF_ATTACHMENTS:
|
|
|
|
FIXME("OID_HIDE_TNEF_ATTACHMENTS (value %d): ignoring\n", pValue->u.boolVal);
|
|
|
|
break;
|
|
|
|
case OID_SHOW_MACBINARY:
|
|
|
|
FIXME("OID_SHOW_MACBINARY (value %d): ignoring\n", pValue->u.boolVal);
|
|
|
|
break;
|
2016-05-03 11:17:45 +02:00
|
|
|
case OID_SAVEBODY_KEEPBOUNDARY:
|
|
|
|
FIXME("OID_SAVEBODY_KEEPBOUNDARY (value %d): ignoring\n", pValue->u.boolVal);
|
|
|
|
break;
|
2016-07-01 09:57:18 +02:00
|
|
|
case OID_CLEANUP_TREE_ON_SAVE:
|
|
|
|
FIXME("OID_CLEANUP_TREE_ON_SAVE (value %d): ignoring\n", pValue->u.boolVal);
|
|
|
|
break;
|
2008-09-22 11:47:38 +02:00
|
|
|
default:
|
|
|
|
FIXME("Unhandled oid %08x\n", oid);
|
2016-05-03 11:17:36 +02:00
|
|
|
hr = MIME_E_INVALID_OPTION_ID;
|
2008-09-22 11:47:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2007-11-02 12:53:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_GetOption(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
const TYPEDID oid,
|
|
|
|
LPPROPVARIANT pValue)
|
|
|
|
{
|
2008-02-14 13:37:43 +01:00
|
|
|
FIXME("(%p)->(%08x, %p)\n", iface, oid, pValue);
|
2007-11-02 12:53:26 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** IMimeMessage methods ***/
|
|
|
|
static HRESULT WINAPI MimeMessage_CreateWebPage(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
IStream *pRootStm,
|
|
|
|
LPWEBPAGEOPTIONS pOptions,
|
|
|
|
IMimeMessageCallback *pCallback,
|
|
|
|
IMoniker **ppMoniker)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p, %p, %p, %p)\n", iface, pRootStm, pOptions, pCallback, ppMoniker);
|
|
|
|
*ppMoniker = NULL;
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_GetProp(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
LPCSTR pszName,
|
|
|
|
DWORD dwFlags,
|
|
|
|
LPPROPVARIANT pValue)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%s, 0x%x, %p)\n", iface, pszName, dwFlags, pValue);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_SetProp(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
LPCSTR pszName,
|
|
|
|
DWORD dwFlags,
|
|
|
|
LPCPROPVARIANT pValue)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%s, 0x%x, %p)\n", iface, pszName, dwFlags, pValue);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_DeleteProp(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
LPCSTR pszName)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%s)\n", iface, pszName);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_QueryProp(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
LPCSTR pszName,
|
|
|
|
LPCSTR pszCriteria,
|
|
|
|
boolean fSubString,
|
|
|
|
boolean fCaseSensitive)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%s, %s, %s, %s)\n", iface, pszName, pszCriteria, fSubString ? "TRUE" : "FALSE", fCaseSensitive ? "TRUE" : "FALSE");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_GetTextBody(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
DWORD dwTxtType,
|
|
|
|
ENCODINGTYPE ietEncoding,
|
|
|
|
IStream **pStream,
|
|
|
|
LPHBODY phBody)
|
|
|
|
{
|
2008-02-12 14:36:16 +01:00
|
|
|
HRESULT hr;
|
|
|
|
HBODY hbody;
|
|
|
|
FINDBODY find_struct;
|
|
|
|
IMimeBody *mime_body;
|
|
|
|
static char text[] = "text";
|
|
|
|
static char plain[] = "plain";
|
|
|
|
static char html[] = "html";
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d, %d, %p, %p)\n", iface, dwTxtType, ietEncoding, pStream, phBody);
|
|
|
|
|
|
|
|
find_struct.pszPriType = text;
|
|
|
|
|
|
|
|
switch(dwTxtType)
|
|
|
|
{
|
|
|
|
case TXT_PLAIN:
|
|
|
|
find_struct.pszSubType = plain;
|
|
|
|
break;
|
|
|
|
case TXT_HTML:
|
|
|
|
find_struct.pszSubType = html;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return MIME_E_INVALID_TEXT_TYPE;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IMimeMessage_FindFirst(iface, &find_struct, &hbody);
|
|
|
|
if(hr != S_OK)
|
|
|
|
{
|
|
|
|
TRACE("not found hr %08x\n", hr);
|
|
|
|
*phBody = NULL;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMimeMessage_BindToObject(iface, hbody, &IID_IMimeBody, (void**)&mime_body);
|
|
|
|
|
|
|
|
IMimeBody_GetData(mime_body, ietEncoding, pStream);
|
|
|
|
*phBody = hbody;
|
|
|
|
IMimeBody_Release(mime_body);
|
|
|
|
return hr;
|
2007-11-02 12:53:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_SetTextBody(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
DWORD dwTxtType,
|
|
|
|
ENCODINGTYPE ietEncoding,
|
|
|
|
HBODY hAlternative,
|
|
|
|
IStream *pStream,
|
|
|
|
LPHBODY phBody)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%d, %d, %p, %p, %p)\n", iface, dwTxtType, ietEncoding, hAlternative, pStream, phBody);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_AttachObject(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
REFIID riid,
|
|
|
|
void *pvObject,
|
|
|
|
LPHBODY phBody)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%s, %p, %p)\n", iface, debugstr_guid(riid), pvObject, phBody);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_AttachFile(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
LPCSTR pszFilePath,
|
|
|
|
IStream *pstmFile,
|
|
|
|
LPHBODY phBody)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%s, %p, %p)\n", iface, pszFilePath, pstmFile, phBody);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_AttachURL(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
LPCSTR pszBase,
|
|
|
|
LPCSTR pszURL,
|
|
|
|
DWORD dwFlags,
|
|
|
|
IStream *pstmURL,
|
|
|
|
LPSTR *ppszCIDURL,
|
|
|
|
LPHBODY phBody)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%s, %s, 0x%x, %p, %p, %p)\n", iface, pszBase, pszURL, dwFlags, pstmURL, ppszCIDURL, phBody);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_GetAttachments(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
ULONG *pcAttach,
|
|
|
|
LPHBODY *pprghAttach)
|
|
|
|
{
|
2008-02-12 14:49:28 +01:00
|
|
|
HRESULT hr;
|
|
|
|
FINDBODY find_struct;
|
|
|
|
HBODY hbody;
|
|
|
|
LPHBODY array;
|
|
|
|
ULONG size = 10;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p, %p)\n", iface, pcAttach, pprghAttach);
|
|
|
|
|
|
|
|
*pcAttach = 0;
|
|
|
|
array = CoTaskMemAlloc(size * sizeof(HBODY));
|
|
|
|
|
|
|
|
find_struct.pszPriType = find_struct.pszSubType = NULL;
|
|
|
|
hr = IMimeMessage_FindFirst(iface, &find_struct, &hbody);
|
|
|
|
while(hr == S_OK)
|
|
|
|
{
|
|
|
|
hr = IMimeMessage_IsContentType(iface, hbody, "multipart", NULL);
|
|
|
|
TRACE("IsCT rets %08x %d\n", hr, *pcAttach);
|
|
|
|
if(hr != S_OK)
|
|
|
|
{
|
|
|
|
if(*pcAttach + 1 > size)
|
|
|
|
{
|
|
|
|
size *= 2;
|
|
|
|
array = CoTaskMemRealloc(array, size * sizeof(HBODY));
|
|
|
|
}
|
|
|
|
array[*pcAttach] = hbody;
|
|
|
|
(*pcAttach)++;
|
|
|
|
}
|
|
|
|
hr = IMimeMessage_FindNext(iface, &find_struct, &hbody);
|
|
|
|
}
|
|
|
|
|
|
|
|
*pprghAttach = array;
|
|
|
|
return S_OK;
|
2007-11-02 12:53:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_GetAddressTable(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
IMimeAddressTable **ppTable)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p)\n", iface, ppTable);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_GetSender(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
LPADDRESSPROPS pAddress)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p)\n", iface, pAddress);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_GetAddressTypes(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
DWORD dwAdrTypes,
|
|
|
|
DWORD dwProps,
|
|
|
|
LPADDRESSLIST pList)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%d, %d, %p)\n", iface, dwAdrTypes, dwProps, pList);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_GetAddressFormat(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
DWORD dwAdrTypes,
|
|
|
|
ADDRESSFORMAT format,
|
|
|
|
LPSTR *ppszFormat)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%d, %d, %p)\n", iface, dwAdrTypes, format, ppszFormat);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_EnumAddressTypes(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
DWORD dwAdrTypes,
|
|
|
|
DWORD dwProps,
|
|
|
|
IMimeEnumAddressTypes **ppEnum)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%d, %d, %p)\n", iface, dwAdrTypes, dwProps, ppEnum);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_SplitMessage(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
ULONG cbMaxPart,
|
|
|
|
IMimeMessageParts **ppParts)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%d, %p)\n", iface, cbMaxPart, ppParts);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeMessage_GetRootMoniker(
|
|
|
|
IMimeMessage *iface,
|
|
|
|
IMoniker **ppMoniker)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p)\n", iface, ppMoniker);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMimeMessageVtbl MimeMessageVtbl =
|
|
|
|
{
|
|
|
|
MimeMessage_QueryInterface,
|
|
|
|
MimeMessage_AddRef,
|
|
|
|
MimeMessage_Release,
|
|
|
|
MimeMessage_GetClassID,
|
|
|
|
MimeMessage_IsDirty,
|
|
|
|
MimeMessage_Load,
|
|
|
|
MimeMessage_Save,
|
|
|
|
MimeMessage_GetSizeMax,
|
|
|
|
MimeMessage_InitNew,
|
|
|
|
MimeMessage_GetMessageSource,
|
|
|
|
MimeMessage_GetMessageSize,
|
|
|
|
MimeMessage_LoadOffsetTable,
|
|
|
|
MimeMessage_SaveOffsetTable,
|
|
|
|
MimeMessage_GetFlags,
|
|
|
|
MimeMessage_Commit,
|
|
|
|
MimeMessage_HandsOffStorage,
|
|
|
|
MimeMessage_BindToObject,
|
|
|
|
MimeMessage_SaveBody,
|
|
|
|
MimeMessage_InsertBody,
|
|
|
|
MimeMessage_GetBody,
|
2007-11-02 12:54:03 +01:00
|
|
|
MimeMessage_DeleteBody,
|
2007-11-02 12:53:26 +01:00
|
|
|
MimeMessage_MoveBody,
|
|
|
|
MimeMessage_CountBodies,
|
|
|
|
MimeMessage_FindFirst,
|
|
|
|
MimeMessage_FindNext,
|
|
|
|
MimeMessage_ResolveURL,
|
|
|
|
MimeMessage_ToMultipart,
|
|
|
|
MimeMessage_GetBodyOffsets,
|
|
|
|
MimeMessage_GetCharset,
|
|
|
|
MimeMessage_SetCharset,
|
|
|
|
MimeMessage_IsBodyType,
|
|
|
|
MimeMessage_IsContentType,
|
|
|
|
MimeMessage_QueryBodyProp,
|
|
|
|
MimeMessage_GetBodyProp,
|
2007-11-02 12:54:03 +01:00
|
|
|
MimeMessage_SetBodyProp,
|
2007-11-02 12:53:26 +01:00
|
|
|
MimeMessage_DeleteBodyProp,
|
|
|
|
MimeMessage_SetOption,
|
|
|
|
MimeMessage_GetOption,
|
|
|
|
MimeMessage_CreateWebPage,
|
|
|
|
MimeMessage_GetProp,
|
|
|
|
MimeMessage_SetProp,
|
|
|
|
MimeMessage_DeleteProp,
|
|
|
|
MimeMessage_QueryProp,
|
|
|
|
MimeMessage_GetTextBody,
|
|
|
|
MimeMessage_SetTextBody,
|
|
|
|
MimeMessage_AttachObject,
|
|
|
|
MimeMessage_AttachFile,
|
|
|
|
MimeMessage_AttachURL,
|
|
|
|
MimeMessage_GetAttachments,
|
|
|
|
MimeMessage_GetAddressTable,
|
|
|
|
MimeMessage_GetSender,
|
|
|
|
MimeMessage_GetAddressTypes,
|
|
|
|
MimeMessage_GetAddressFormat,
|
|
|
|
MimeMessage_EnumAddressTypes,
|
|
|
|
MimeMessage_SplitMessage,
|
|
|
|
MimeMessage_GetRootMoniker,
|
|
|
|
};
|
|
|
|
|
2008-11-04 11:35:07 +01:00
|
|
|
HRESULT MimeMessage_create(IUnknown *outer, void **obj)
|
2007-11-02 12:49:29 +01:00
|
|
|
{
|
2007-11-02 12:53:26 +01:00
|
|
|
MimeMessage *This;
|
2016-04-14 12:11:14 +02:00
|
|
|
MimeBody *mime_body;
|
|
|
|
body_t *root_body;
|
2007-11-02 12:53:26 +01:00
|
|
|
|
2008-11-04 11:35:07 +01:00
|
|
|
TRACE("(%p, %p)\n", outer, obj);
|
2007-11-02 12:53:26 +01:00
|
|
|
|
2008-11-04 11:35:07 +01:00
|
|
|
if (outer)
|
2007-11-02 12:53:26 +01:00
|
|
|
{
|
|
|
|
FIXME("outer unknown not supported yet\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2007-11-02 12:49:29 +01:00
|
|
|
|
2008-11-04 11:35:07 +01:00
|
|
|
*obj = NULL;
|
2007-11-02 12:53:26 +01:00
|
|
|
|
|
|
|
This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
|
|
|
|
if (!This) return E_OUTOFMEMORY;
|
|
|
|
|
2013-03-04 00:28:47 +01:00
|
|
|
This->IMimeMessage_iface.lpVtbl = &MimeMessageVtbl;
|
|
|
|
This->ref = 1;
|
2008-02-08 13:17:43 +01:00
|
|
|
This->stream = NULL;
|
2008-02-12 23:52:24 +01:00
|
|
|
list_init(&This->body_tree);
|
2010-04-08 21:14:15 +02:00
|
|
|
This->next_index = 1;
|
2007-11-02 12:53:26 +01:00
|
|
|
|
2016-04-14 12:11:14 +02:00
|
|
|
mime_body = mimebody_create();
|
|
|
|
root_body = new_body_entry(mime_body, This->next_index++, NULL);
|
|
|
|
list_add_head(&This->body_tree, &root_body->entry);
|
|
|
|
|
2013-03-04 00:28:47 +01:00
|
|
|
*obj = &This->IMimeMessage_iface;
|
2007-11-02 12:53:26 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-11-04 11:35:07 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MimeOleCreateMessage (INETCOMM.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI MimeOleCreateMessage(IUnknown *pUnkOuter, IMimeMessage **ppMessage)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %p)\n", pUnkOuter, ppMessage);
|
|
|
|
return MimeMessage_create(NULL, (void **)ppMessage);
|
|
|
|
}
|
|
|
|
|
2007-11-02 12:53:26 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MimeOleSetCompatMode (INETCOMM.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI MimeOleSetCompatMode(DWORD dwMode)
|
|
|
|
{
|
|
|
|
FIXME("(0x%x)\n", dwMode);
|
|
|
|
return S_OK;
|
2007-11-02 12:49:29 +01:00
|
|
|
}
|
2007-11-02 12:52:27 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MimeOleCreateVirtualStream (INETCOMM.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI MimeOleCreateVirtualStream(IStream **ppStream)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
FIXME("(%p)\n", ppStream);
|
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, ppStream);
|
|
|
|
return hr;
|
|
|
|
}
|
2007-11-05 18:02:40 +01:00
|
|
|
|
|
|
|
typedef struct MimeSecurity
|
|
|
|
{
|
2013-03-04 00:31:56 +01:00
|
|
|
IMimeSecurity IMimeSecurity_iface;
|
|
|
|
LONG ref;
|
2007-11-05 18:02:40 +01:00
|
|
|
} MimeSecurity;
|
|
|
|
|
2013-03-04 00:31:56 +01:00
|
|
|
static inline MimeSecurity *impl_from_IMimeSecurity(IMimeSecurity *iface)
|
2007-11-05 18:02:40 +01:00
|
|
|
{
|
2013-03-04 00:31:56 +01:00
|
|
|
return CONTAINING_RECORD(iface, MimeSecurity, IMimeSecurity_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeSecurity_QueryInterface(IMimeSecurity *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppv);
|
2007-11-05 18:02:40 +01:00
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID(riid, &IID_IMimeSecurity))
|
|
|
|
{
|
2013-03-04 00:31:56 +01:00
|
|
|
*ppv = iface;
|
2012-08-13 11:11:26 +02:00
|
|
|
IMimeSecurity_AddRef(iface);
|
2007-11-05 18:02:40 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("no interface for %s\n", debugstr_guid(riid));
|
2013-03-04 00:31:56 +01:00
|
|
|
*ppv = NULL;
|
2007-11-05 18:02:40 +01:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2013-03-04 00:31:56 +01:00
|
|
|
static ULONG WINAPI MimeSecurity_AddRef(IMimeSecurity *iface)
|
2007-11-05 18:02:40 +01:00
|
|
|
{
|
2013-03-04 00:31:56 +01:00
|
|
|
MimeSecurity *This = impl_from_IMimeSecurity(iface);
|
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
2007-11-05 18:02:40 +01:00
|
|
|
}
|
|
|
|
|
2013-03-04 00:31:56 +01:00
|
|
|
static ULONG WINAPI MimeSecurity_Release(IMimeSecurity *iface)
|
2007-11-05 18:02:40 +01:00
|
|
|
{
|
2013-03-04 00:31:56 +01:00
|
|
|
MimeSecurity *This = impl_from_IMimeSecurity(iface);
|
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
2007-11-05 18:02:40 +01:00
|
|
|
|
2013-03-04 00:31:56 +01:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2007-11-05 18:02:40 +01:00
|
|
|
|
2013-03-04 00:31:56 +01:00
|
|
|
if (!ref)
|
2007-11-05 18:02:40 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
|
2013-03-04 00:31:56 +01:00
|
|
|
return ref;
|
2007-11-05 18:02:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeSecurity_InitNew(
|
|
|
|
IMimeSecurity* iface)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(): stub\n", iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeSecurity_CheckInit(
|
|
|
|
IMimeSecurity* iface)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(): stub\n", iface);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeSecurity_EncodeMessage(
|
|
|
|
IMimeSecurity* iface,
|
|
|
|
IMimeMessageTree* pTree,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p, %08x): stub\n", iface, pTree, dwFlags);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeSecurity_EncodeBody(
|
|
|
|
IMimeSecurity* iface,
|
|
|
|
IMimeMessageTree* pTree,
|
|
|
|
HBODY hEncodeRoot,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p, %p, %08x): stub\n", iface, pTree, hEncodeRoot, dwFlags);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeSecurity_DecodeMessage(
|
|
|
|
IMimeSecurity* iface,
|
|
|
|
IMimeMessageTree* pTree,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p, %08x): stub\n", iface, pTree, dwFlags);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeSecurity_DecodeBody(
|
|
|
|
IMimeSecurity* iface,
|
|
|
|
IMimeMessageTree* pTree,
|
|
|
|
HBODY hDecodeRoot,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p, %p, %08x): stub\n", iface, pTree, hDecodeRoot, dwFlags);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeSecurity_EnumCertificates(
|
|
|
|
IMimeSecurity* iface,
|
|
|
|
HCAPICERTSTORE hc,
|
|
|
|
DWORD dwUsage,
|
|
|
|
PCX509CERT pPrev,
|
|
|
|
PCX509CERT* ppCert)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p, %08x, %p, %p): stub\n", iface, hc, dwUsage, pPrev, ppCert);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeSecurity_GetCertificateName(
|
|
|
|
IMimeSecurity* iface,
|
|
|
|
const PCX509CERT pX509Cert,
|
|
|
|
const CERTNAMETYPE cn,
|
|
|
|
LPSTR* ppszName)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p, %08x, %p): stub\n", iface, pX509Cert, cn, ppszName);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeSecurity_GetMessageType(
|
|
|
|
IMimeSecurity* iface,
|
|
|
|
const HWND hwndParent,
|
|
|
|
IMimeBody* pBody,
|
|
|
|
DWORD* pdwSecType)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p, %p, %p): stub\n", iface, hwndParent, pBody, pdwSecType);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeSecurity_GetCertData(
|
|
|
|
IMimeSecurity* iface,
|
|
|
|
const PCX509CERT pX509Cert,
|
|
|
|
const CERTDATAID dataid,
|
|
|
|
LPPROPVARIANT pValue)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p, %x, %p): stub\n", iface, pX509Cert, dataid, pValue);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const IMimeSecurityVtbl MimeSecurityVtbl =
|
|
|
|
{
|
|
|
|
MimeSecurity_QueryInterface,
|
|
|
|
MimeSecurity_AddRef,
|
|
|
|
MimeSecurity_Release,
|
|
|
|
MimeSecurity_InitNew,
|
|
|
|
MimeSecurity_CheckInit,
|
|
|
|
MimeSecurity_EncodeMessage,
|
|
|
|
MimeSecurity_EncodeBody,
|
|
|
|
MimeSecurity_DecodeMessage,
|
|
|
|
MimeSecurity_DecodeBody,
|
|
|
|
MimeSecurity_EnumCertificates,
|
|
|
|
MimeSecurity_GetCertificateName,
|
|
|
|
MimeSecurity_GetMessageType,
|
|
|
|
MimeSecurity_GetCertData
|
|
|
|
};
|
|
|
|
|
2008-11-04 11:35:07 +01:00
|
|
|
HRESULT MimeSecurity_create(IUnknown *outer, void **obj)
|
2007-11-05 18:02:40 +01:00
|
|
|
{
|
|
|
|
MimeSecurity *This;
|
|
|
|
|
2008-11-04 11:35:07 +01:00
|
|
|
*obj = NULL;
|
2007-11-05 18:02:40 +01:00
|
|
|
|
2008-11-04 11:35:07 +01:00
|
|
|
if (outer) return CLASS_E_NOAGGREGATION;
|
2007-11-05 18:02:40 +01:00
|
|
|
|
|
|
|
This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
|
|
|
|
if (!This) return E_OUTOFMEMORY;
|
|
|
|
|
2013-03-04 00:31:56 +01:00
|
|
|
This->IMimeSecurity_iface.lpVtbl = &MimeSecurityVtbl;
|
|
|
|
This->ref = 1;
|
2007-11-05 18:02:40 +01:00
|
|
|
|
2013-03-04 00:31:56 +01:00
|
|
|
*obj = &This->IMimeSecurity_iface;
|
2007-11-05 18:02:40 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
2007-12-18 12:50:22 +01:00
|
|
|
|
2008-11-04 11:35:07 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MimeOleCreateSecurity (INETCOMM.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI MimeOleCreateSecurity(IMimeSecurity **ppSecurity)
|
|
|
|
{
|
|
|
|
return MimeSecurity_create(NULL, (void **)ppSecurity);
|
|
|
|
}
|
2007-12-18 12:50:22 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI MimeAlloc_QueryInterface(
|
|
|
|
IMimeAllocator* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void **obj)
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), obj);
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID(riid, &IID_IMalloc) ||
|
|
|
|
IsEqualIID(riid, &IID_IMimeAllocator))
|
|
|
|
{
|
|
|
|
*obj = iface;
|
2012-08-13 11:11:26 +02:00
|
|
|
IMimeAllocator_AddRef(iface);
|
2007-12-18 12:50:22 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("no interface for %s\n", debugstr_guid(riid));
|
|
|
|
*obj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI MimeAlloc_AddRef(
|
|
|
|
IMimeAllocator* iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI MimeAlloc_Release(
|
|
|
|
IMimeAllocator* iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LPVOID WINAPI MimeAlloc_Alloc(
|
|
|
|
IMimeAllocator* iface,
|
2016-01-19 17:19:09 +01:00
|
|
|
SIZE_T cb)
|
2007-12-18 12:50:22 +01:00
|
|
|
{
|
|
|
|
return CoTaskMemAlloc(cb);
|
|
|
|
}
|
|
|
|
|
|
|
|
static LPVOID WINAPI MimeAlloc_Realloc(
|
|
|
|
IMimeAllocator* iface,
|
|
|
|
LPVOID pv,
|
2016-01-19 17:19:09 +01:00
|
|
|
SIZE_T cb)
|
2007-12-18 12:50:22 +01:00
|
|
|
{
|
|
|
|
return CoTaskMemRealloc(pv, cb);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI MimeAlloc_Free(
|
|
|
|
IMimeAllocator* iface,
|
|
|
|
LPVOID pv)
|
|
|
|
{
|
2008-03-29 20:10:31 +01:00
|
|
|
CoTaskMemFree(pv);
|
2007-12-18 12:50:22 +01:00
|
|
|
}
|
|
|
|
|
2016-01-19 17:19:09 +01:00
|
|
|
static SIZE_T WINAPI MimeAlloc_GetSize(
|
2007-12-18 12:50:22 +01:00
|
|
|
IMimeAllocator* iface,
|
|
|
|
LPVOID pv)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int WINAPI MimeAlloc_DidAlloc(
|
|
|
|
IMimeAllocator* iface,
|
|
|
|
LPVOID pv)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI MimeAlloc_HeapMinimize(
|
|
|
|
IMimeAllocator* iface)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeAlloc_FreeParamInfoArray(
|
|
|
|
IMimeAllocator* iface,
|
|
|
|
ULONG cParams,
|
|
|
|
LPMIMEPARAMINFO prgParam,
|
|
|
|
boolean fFreeArray)
|
|
|
|
{
|
|
|
|
ULONG i;
|
|
|
|
TRACE("(%p)->(%d, %p, %d)\n", iface, cParams, prgParam, fFreeArray);
|
|
|
|
|
|
|
|
for(i = 0; i < cParams; i++)
|
|
|
|
{
|
|
|
|
IMimeAllocator_Free(iface, prgParam[i].pszName);
|
|
|
|
IMimeAllocator_Free(iface, prgParam[i].pszData);
|
|
|
|
}
|
|
|
|
if(fFreeArray) IMimeAllocator_Free(iface, prgParam);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeAlloc_FreeAddressList(
|
|
|
|
IMimeAllocator* iface,
|
|
|
|
LPADDRESSLIST pList)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeAlloc_FreeAddressProps(
|
|
|
|
IMimeAllocator* iface,
|
|
|
|
LPADDRESSPROPS pAddress)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeAlloc_ReleaseObjects(
|
|
|
|
IMimeAllocator* iface,
|
|
|
|
ULONG cObjects,
|
|
|
|
IUnknown **prgpUnknown,
|
|
|
|
boolean fFreeArray)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeAlloc_FreeEnumHeaderRowArray(
|
|
|
|
IMimeAllocator* iface,
|
|
|
|
ULONG cRows,
|
|
|
|
LPENUMHEADERROW prgRow,
|
|
|
|
boolean fFreeArray)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeAlloc_FreeEnumPropertyArray(
|
|
|
|
IMimeAllocator* iface,
|
|
|
|
ULONG cProps,
|
|
|
|
LPENUMPROPERTY prgProp,
|
|
|
|
boolean fFreeArray)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeAlloc_FreeThumbprint(
|
|
|
|
IMimeAllocator* iface,
|
|
|
|
THUMBBLOB *pthumbprint)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI MimeAlloc_PropVariantClear(
|
|
|
|
IMimeAllocator* iface,
|
|
|
|
LPPROPVARIANT pProp)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static IMimeAllocatorVtbl mime_alloc_vtbl =
|
|
|
|
{
|
|
|
|
MimeAlloc_QueryInterface,
|
|
|
|
MimeAlloc_AddRef,
|
|
|
|
MimeAlloc_Release,
|
|
|
|
MimeAlloc_Alloc,
|
|
|
|
MimeAlloc_Realloc,
|
|
|
|
MimeAlloc_Free,
|
|
|
|
MimeAlloc_GetSize,
|
|
|
|
MimeAlloc_DidAlloc,
|
|
|
|
MimeAlloc_HeapMinimize,
|
|
|
|
MimeAlloc_FreeParamInfoArray,
|
|
|
|
MimeAlloc_FreeAddressList,
|
|
|
|
MimeAlloc_FreeAddressProps,
|
|
|
|
MimeAlloc_ReleaseObjects,
|
|
|
|
MimeAlloc_FreeEnumHeaderRowArray,
|
|
|
|
MimeAlloc_FreeEnumPropertyArray,
|
|
|
|
MimeAlloc_FreeThumbprint,
|
|
|
|
MimeAlloc_PropVariantClear
|
|
|
|
};
|
|
|
|
|
2013-03-04 00:32:40 +01:00
|
|
|
static IMimeAllocator mime_allocator =
|
2007-12-18 12:50:22 +01:00
|
|
|
{
|
|
|
|
&mime_alloc_vtbl
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT MimeAllocator_create(IUnknown *outer, void **obj)
|
|
|
|
{
|
|
|
|
if(outer) return CLASS_E_NOAGGREGATION;
|
|
|
|
|
|
|
|
*obj = &mime_allocator;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI MimeOleGetAllocator(IMimeAllocator **alloc)
|
|
|
|
{
|
|
|
|
return MimeAllocator_create(NULL, (void**)alloc);
|
|
|
|
}
|
2008-11-11 10:17:38 +01:00
|
|
|
|
|
|
|
HRESULT VirtualStream_create(IUnknown *outer, void **obj)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p)\n", outer, obj);
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
if (outer) return CLASS_E_NOAGGREGATION;
|
|
|
|
|
|
|
|
return MimeOleCreateVirtualStream((IStream **)obj);
|
|
|
|
}
|
2016-04-15 09:50:47 +02:00
|
|
|
|
2016-04-19 11:26:02 +02:00
|
|
|
/* IMimePropertySchema Interface */
|
|
|
|
static HRESULT WINAPI propschema_QueryInterface(IMimePropertySchema *iface, REFIID riid, void **out)
|
|
|
|
{
|
|
|
|
propschema *This = impl_from_IMimePropertySchema(iface);
|
|
|
|
TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), out);
|
|
|
|
|
|
|
|
*out = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID(riid, &IID_IMimePropertySchema))
|
|
|
|
{
|
|
|
|
*out = iface;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("no interface for %s\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMimePropertySchema_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI propschema_AddRef(IMimePropertySchema *iface)
|
|
|
|
{
|
|
|
|
propschema *This = impl_from_IMimePropertySchema(iface);
|
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI propschema_Release(IMimePropertySchema *iface)
|
|
|
|
{
|
|
|
|
propschema *This = impl_from_IMimePropertySchema(iface);
|
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
if (!ref)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI propschema_RegisterProperty(IMimePropertySchema *iface, const char *name, DWORD flags,
|
|
|
|
DWORD rownumber, VARTYPE vtdefault, DWORD *propid)
|
|
|
|
{
|
|
|
|
propschema *This = impl_from_IMimePropertySchema(iface);
|
|
|
|
FIXME("(%p)->(%s, %x, %d, %d, %p) stub\n", This, debugstr_a(name), flags, rownumber, vtdefault, propid);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI propschema_ModifyProperty(IMimePropertySchema *iface, const char *name, DWORD flags,
|
|
|
|
DWORD rownumber, VARTYPE vtdefault)
|
|
|
|
{
|
|
|
|
propschema *This = impl_from_IMimePropertySchema(iface);
|
|
|
|
FIXME("(%p)->(%s, %x, %d, %d) stub\n", This, debugstr_a(name), flags, rownumber, vtdefault);
|
2016-05-25 08:13:44 +02:00
|
|
|
return S_OK;
|
2016-04-19 11:26:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI propschema_GetPropertyId(IMimePropertySchema *iface, const char *name, DWORD *propid)
|
|
|
|
{
|
|
|
|
propschema *This = impl_from_IMimePropertySchema(iface);
|
|
|
|
FIXME("(%p)->(%s, %p) stub\n", This, debugstr_a(name), propid);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI propschema_GetPropertyName(IMimePropertySchema *iface, DWORD propid, char **name)
|
|
|
|
{
|
|
|
|
propschema *This = impl_from_IMimePropertySchema(iface);
|
|
|
|
FIXME("(%p)->(%d, %p) stub\n", This, propid, name);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI propschema_RegisterAddressType(IMimePropertySchema *iface, const char *name, DWORD *adrtype)
|
2016-04-15 09:50:47 +02:00
|
|
|
{
|
2016-04-19 11:26:02 +02:00
|
|
|
propschema *This = impl_from_IMimePropertySchema(iface);
|
|
|
|
FIXME("(%p)->(%s, %p) stub\n", This, debugstr_a(name), adrtype);
|
2016-04-15 09:50:47 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2016-04-19 11:26:02 +02:00
|
|
|
|
|
|
|
static IMimePropertySchemaVtbl prop_schema_vtbl =
|
|
|
|
{
|
|
|
|
propschema_QueryInterface,
|
|
|
|
propschema_AddRef,
|
|
|
|
propschema_Release,
|
|
|
|
propschema_RegisterProperty,
|
|
|
|
propschema_ModifyProperty,
|
|
|
|
propschema_GetPropertyId,
|
|
|
|
propschema_GetPropertyName,
|
|
|
|
propschema_RegisterAddressType
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
HRESULT WINAPI MimeOleGetPropertySchema(IMimePropertySchema **schema)
|
|
|
|
{
|
|
|
|
propschema *This;
|
|
|
|
|
|
|
|
TRACE("(%p) stub\n", schema);
|
|
|
|
|
|
|
|
This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
|
|
|
|
if (!This)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
This->IMimePropertySchema_iface.lpVtbl = &prop_schema_vtbl;
|
|
|
|
This->ref = 1;
|
|
|
|
|
|
|
|
*schema = &This->IMimePropertySchema_iface;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2016-04-28 10:15:19 +02:00
|
|
|
|
|
|
|
HRESULT WINAPI MimeGetAddressFormatW(REFIID riid, void *object, DWORD addr_type,
|
|
|
|
ADDRESSFORMAT addr_format, WCHAR **address)
|
|
|
|
{
|
|
|
|
FIXME("(%s, %p, %d, %d, %p) stub\n", debugstr_guid(riid), object, addr_type, addr_format, address);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2016-08-15 22:53:45 +02:00
|
|
|
|
2017-02-01 11:22:27 +01:00
|
|
|
static HRESULT WINAPI mime_obj_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
FIXME("(%s %p)\n", debugstr_guid(riid), ppv);
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI mime_obj_AddRef(IUnknown *iface)
|
|
|
|
{
|
|
|
|
TRACE("\n");
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI mime_obj_Release(IUnknown *iface)
|
|
|
|
{
|
|
|
|
TRACE("\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IUnknownVtbl mime_obj_vtbl = {
|
|
|
|
mime_obj_QueryInterface,
|
|
|
|
mime_obj_AddRef,
|
|
|
|
mime_obj_Release
|
|
|
|
};
|
|
|
|
|
|
|
|
static IUnknown mime_obj = { &mime_obj_vtbl };
|
|
|
|
|
2016-08-15 22:53:45 +02:00
|
|
|
HRESULT WINAPI MimeOleObjectFromMoniker(BINDF bindf, IMoniker *moniker, IBindCtx *binding,
|
|
|
|
REFIID riid, void **out, IMoniker **moniker_new)
|
|
|
|
{
|
2017-02-01 11:22:27 +01:00
|
|
|
WCHAR *display_name, *mhtml_url;
|
|
|
|
size_t len;
|
|
|
|
HRESULT hres;
|
2016-08-15 22:53:45 +02:00
|
|
|
|
2017-02-01 11:22:27 +01:00
|
|
|
static const WCHAR mhtml_prefixW[] = {'m','h','t','m','l',':'};
|
|
|
|
|
|
|
|
WARN("(0x%08x, %p, %p, %s, %p, %p) semi-stub\n", bindf, moniker, binding, debugstr_guid(riid), out, moniker_new);
|
|
|
|
|
|
|
|
if(!IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
FIXME("Unsupported riid %s\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = IMoniker_GetDisplayName(moniker, NULL, NULL, &display_name);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
TRACE("display name %s\n", debugstr_w(display_name));
|
|
|
|
|
|
|
|
len = strlenW(display_name);
|
|
|
|
mhtml_url = heap_alloc((len+1)*sizeof(WCHAR) + sizeof(mhtml_prefixW));
|
|
|
|
if(!mhtml_url)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
memcpy(mhtml_url, mhtml_prefixW, sizeof(mhtml_prefixW));
|
|
|
|
strcpyW(mhtml_url + sizeof(mhtml_prefixW)/sizeof(WCHAR), display_name);
|
|
|
|
HeapFree(GetProcessHeap(), 0, display_name);
|
|
|
|
|
|
|
|
hres = CreateURLMoniker(NULL, mhtml_url, moniker_new);
|
|
|
|
heap_free(mhtml_url);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
/* FIXME: We most likely should start binding here and return something more meaningful as mime object. */
|
|
|
|
*out = &mime_obj;
|
|
|
|
return S_OK;
|
2016-08-15 22:53:45 +02:00
|
|
|
}
|