4 * Copyright 2006 Robert Shearman for CodeWeavers
5 * Copyright 2007 Huw Davies for CodeWeavers
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "inetcomm_private.h"
28 DWORD flags
; /* MIMEPROPFLAGS */
36 } property_list_entry_t
;
38 static const property_t default_props
[] =
40 {"References", PID_HDR_REFS
, 0, VT_LPSTR
},
41 {"Subject", PID_HDR_SUBJECT
, 0, VT_LPSTR
},
42 {"From", PID_HDR_FROM
, MPF_ADDRESS
, VT_LPSTR
},
43 {"Message-ID", PID_HDR_MESSAGEID
, 0, VT_LPSTR
},
44 {"Return-Path", PID_HDR_RETURNPATH
, MPF_ADDRESS
, VT_LPSTR
},
45 {"Date", PID_HDR_DATE
, 0, VT_LPSTR
},
46 {"Received", PID_HDR_RECEIVED
, 0, VT_LPSTR
},
47 {"Reply-To", PID_HDR_REPLYTO
, MPF_ADDRESS
, VT_LPSTR
},
48 {"X-Mailer", PID_HDR_XMAILER
, 0, VT_LPSTR
},
49 {"Bcc", PID_HDR_BCC
, MPF_ADDRESS
, VT_LPSTR
},
50 {"MIME-Version", PID_HDR_MIMEVER
, MPF_MIME
, VT_LPSTR
},
51 {"Content-Type", PID_HDR_CNTTYPE
, MPF_MIME
| MPF_HASPARAMS
, VT_LPSTR
},
52 {"Content-Transfer-Encoding", PID_HDR_CNTXFER
, MPF_MIME
, VT_LPSTR
},
53 {"Content-ID", PID_HDR_CNTID
, MPF_MIME
, VT_LPSTR
},
54 {"Content-Disposition", PID_HDR_CNTDISP
, MPF_MIME
| MPF_HASPARAMS
, VT_LPSTR
},
55 {"To", PID_HDR_TO
, MPF_ADDRESS
, VT_LPSTR
},
56 {"Cc", PID_HDR_CC
, MPF_ADDRESS
, VT_LPSTR
},
57 {"Sender", PID_HDR_SENDER
, MPF_ADDRESS
, VT_LPSTR
},
58 {"In-Reply-To", PID_HDR_INREPLYTO
, 0, VT_LPSTR
},
72 const property_t
*prop
;
77 typedef struct MimeBody
79 IMimeBody IMimeBody_iface
;
85 struct list new_props
; /* FIXME: This should be in a PropertySchema */
87 char *content_pri_type
;
88 char *content_sub_type
;
89 ENCODINGTYPE encoding
;
92 BODYOFFSETS body_offsets
;
95 static inline MimeBody
*impl_from_IMimeBody(IMimeBody
*iface
)
97 return CONTAINING_RECORD(iface
, MimeBody
, IMimeBody_iface
);
100 static LPSTR
strdupA(LPCSTR str
)
103 int len
= strlen(str
);
104 ret
= HeapAlloc(GetProcessHeap(), 0, len
+ 1);
105 memcpy(ret
, str
, len
+ 1);
109 #define PARSER_BUF_SIZE 1024
111 /*****************************************************
112 * copy_headers_to_buf [internal]
114 * Copies the headers into a '\0' terminated memory block and leave
115 * the stream's current position set to after the blank line.
117 static HRESULT
copy_headers_to_buf(IStream
*stm
, char **ptr
)
120 DWORD size
= PARSER_BUF_SIZE
, offset
= 0, last_end
= 0;
132 buf
= HeapAlloc(GetProcessHeap(), 0, size
+ 1);
136 buf
= HeapReAlloc(GetProcessHeap(), 0, buf
, size
+ 1);
144 hr
= IStream_Read(stm
, buf
+ offset
, size
- offset
, &read
);
145 if(FAILED(hr
)) goto fail
;
150 if(read
== 0) done
= 1;
152 while(!done
&& (end
= strstr(buf
+ last_end
, "\r\n")))
154 DWORD new_end
= end
- buf
+ 2;
155 if(new_end
- last_end
== 2)
158 off
.QuadPart
= new_end
;
159 IStream_Seek(stm
, off
, STREAM_SEEK_SET
, NULL
);
172 HeapFree(GetProcessHeap(), 0, buf
);
176 static header_t
*read_prop(MimeBody
*body
, char **ptr
)
178 char *colon
= strchr(*ptr
, ':');
179 const property_t
*prop
;
182 if(!colon
) return NULL
;
186 for(prop
= default_props
; prop
->name
; prop
++)
188 if(!strcasecmp(*ptr
, prop
->name
))
190 TRACE("%s: found match with default property id %d\n", *ptr
, prop
->id
);
197 property_list_entry_t
*prop_entry
;
198 LIST_FOR_EACH_ENTRY(prop_entry
, &body
->new_props
, property_list_entry_t
, entry
)
200 if(!strcasecmp(*ptr
, prop_entry
->prop
.name
))
202 TRACE("%s: found match with already added new property id %d\n", *ptr
, prop_entry
->prop
.id
);
203 prop
= &prop_entry
->prop
;
209 prop_entry
= HeapAlloc(GetProcessHeap(), 0, sizeof(*prop_entry
));
210 prop_entry
->prop
.name
= strdupA(*ptr
);
211 prop_entry
->prop
.id
= body
->next_prop_id
++;
212 prop_entry
->prop
.flags
= 0;
213 prop_entry
->prop
.default_vt
= VT_LPSTR
;
214 list_add_tail(&body
->new_props
, &prop_entry
->entry
);
215 prop
= &prop_entry
->prop
;
216 TRACE("%s: allocating new prop id %d\n", *ptr
, prop_entry
->prop
.id
);
220 ret
= HeapAlloc(GetProcessHeap(), 0, sizeof(*ret
));
222 PropVariantInit(&ret
->value
);
223 list_init(&ret
->params
);
229 static void unfold_header(char *header
, int len
)
231 char *start
= header
, *cp
= header
;
234 while(*cp
== ' ' || *cp
== '\t')
240 memmove(start
, cp
, len
+ 1);
242 cp
= strstr(start
, "\r\n");
249 } while(*cp
== ' ' || *cp
== '\t');
254 static char *unquote_string(const char *str
)
259 while(*str
== ' ' || *str
== '\t') str
++;
267 for(cp
= ret
; *cp
; cp
++)
270 memmove(cp
, cp
+ 1, strlen(cp
+ 1) + 1);
275 WARN("quote in unquoted string\n");
287 static void add_param(header_t
*header
, const char *p
)
289 const char *key
= p
, *value
, *cp
= p
;
293 TRACE("got param %s\n", p
);
295 while (*key
== ' ' || *key
== '\t' ) key
++;
297 cp
= strchr(key
, '=');
300 WARN("malformed parameter - skipping\n");
304 name
= HeapAlloc(GetProcessHeap(), 0, cp
- key
+ 1);
305 memcpy(name
, key
, cp
- key
);
306 name
[cp
- key
] = '\0';
310 param
= HeapAlloc(GetProcessHeap(), 0, sizeof(*param
));
312 param
->value
= unquote_string(value
);
313 list_add_tail(&header
->params
, ¶m
->entry
);
316 static void split_params(header_t
*header
, char *value
)
318 char *cp
= value
, *start
= value
;
324 if(!in_quote
&& *cp
== ';')
327 if(done_value
) add_param(header
, start
);
332 in_quote
= !in_quote
;
335 if(done_value
) add_param(header
, start
);
338 static void read_value(header_t
*header
, char **cur
)
340 char *end
= *cur
, *value
;
344 end
= strstr(end
, "\r\n");
346 } while(*end
== ' ' || *end
== '\t');
349 value
= HeapAlloc(GetProcessHeap(), 0, len
+ 1);
350 memcpy(value
, *cur
, len
);
353 unfold_header(value
, len
);
354 TRACE("value %s\n", debugstr_a(value
));
356 if(header
->prop
->flags
& MPF_HASPARAMS
)
358 split_params(header
, value
);
359 TRACE("value w/o params %s\n", debugstr_a(value
));
362 header
->value
.vt
= VT_LPSTR
;
363 header
->value
.u
.pszVal
= value
;
368 static void init_content_type(MimeBody
*body
, header_t
*header
)
373 if(header
->prop
->id
!= PID_HDR_CNTTYPE
)
375 ERR("called with header %s\n", header
->prop
->name
);
379 slash
= strchr(header
->value
.u
.pszVal
, '/');
382 WARN("malformed context type value\n");
385 len
= slash
- header
->value
.u
.pszVal
;
386 body
->content_pri_type
= HeapAlloc(GetProcessHeap(), 0, len
+ 1);
387 memcpy(body
->content_pri_type
, header
->value
.u
.pszVal
, len
);
388 body
->content_pri_type
[len
] = '\0';
389 body
->content_sub_type
= strdupA(slash
+ 1);
392 static HRESULT
parse_headers(MimeBody
*body
, IStream
*stm
)
394 char *header_buf
, *cur_header_ptr
;
398 hr
= copy_headers_to_buf(stm
, &header_buf
);
399 if(FAILED(hr
)) return hr
;
401 cur_header_ptr
= header_buf
;
402 while((header
= read_prop(body
, &cur_header_ptr
)))
404 read_value(header
, &cur_header_ptr
);
405 list_add_tail(&body
->headers
, &header
->entry
);
407 if(header
->prop
->id
== PID_HDR_CNTTYPE
)
408 init_content_type(body
, header
);
411 HeapFree(GetProcessHeap(), 0, header_buf
);
415 static void empty_param_list(struct list
*list
)
417 param_t
*param
, *cursor2
;
419 LIST_FOR_EACH_ENTRY_SAFE(param
, cursor2
, list
, param_t
, entry
)
421 list_remove(¶m
->entry
);
422 HeapFree(GetProcessHeap(), 0, param
->name
);
423 HeapFree(GetProcessHeap(), 0, param
->value
);
424 HeapFree(GetProcessHeap(), 0, param
);
428 static void empty_header_list(struct list
*list
)
430 header_t
*header
, *cursor2
;
432 LIST_FOR_EACH_ENTRY_SAFE(header
, cursor2
, list
, header_t
, entry
)
434 list_remove(&header
->entry
);
435 PropVariantClear(&header
->value
);
436 empty_param_list(&header
->params
);
437 HeapFree(GetProcessHeap(), 0, header
);
441 static void empty_new_prop_list(struct list
*list
)
443 property_list_entry_t
*prop
, *cursor2
;
445 LIST_FOR_EACH_ENTRY_SAFE(prop
, cursor2
, list
, property_list_entry_t
, entry
)
447 list_remove(&prop
->entry
);
448 HeapFree(GetProcessHeap(), 0, (char *)prop
->prop
.name
);
449 HeapFree(GetProcessHeap(), 0, prop
);
453 static void release_data(REFIID riid
, void *data
)
457 if(IsEqualIID(riid
, &IID_IStream
))
458 IStream_Release((IStream
*)data
);
460 FIXME("Unhandled data format %s\n", debugstr_guid(riid
));
463 static HRESULT
find_prop(MimeBody
*body
, const char *name
, header_t
**prop
)
469 LIST_FOR_EACH_ENTRY(header
, &body
->headers
, header_t
, entry
)
471 if(!strcasecmp(name
, header
->prop
->name
))
478 return MIME_E_NOT_FOUND
;
481 static HRESULT WINAPI
MimeBody_QueryInterface(IMimeBody
* iface
,
485 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ppvObject
);
489 if (IsEqualIID(riid
, &IID_IUnknown
) ||
490 IsEqualIID(riid
, &IID_IPersist
) ||
491 IsEqualIID(riid
, &IID_IPersistStreamInit
) ||
492 IsEqualIID(riid
, &IID_IMimePropertySet
) ||
493 IsEqualIID(riid
, &IID_IMimeBody
))
500 IUnknown_AddRef((IUnknown
*)*ppvObject
);
504 FIXME("no interface for %s\n", debugstr_guid(riid
));
505 return E_NOINTERFACE
;
508 static ULONG WINAPI
MimeBody_AddRef(IMimeBody
*iface
)
510 MimeBody
*This
= impl_from_IMimeBody(iface
);
511 LONG ref
= InterlockedIncrement(&This
->ref
);
513 TRACE("(%p) ref=%d\n", This
, ref
);
518 static ULONG WINAPI
MimeBody_Release(IMimeBody
*iface
)
520 MimeBody
*This
= impl_from_IMimeBody(iface
);
521 LONG ref
= InterlockedDecrement(&This
->ref
);
523 TRACE("(%p) ref=%d\n", This
, ref
);
527 empty_header_list(&This
->headers
);
528 empty_new_prop_list(&This
->new_props
);
530 HeapFree(GetProcessHeap(), 0, This
->content_pri_type
);
531 HeapFree(GetProcessHeap(), 0, This
->content_sub_type
);
533 release_data(&This
->data_iid
, This
->data
);
535 HeapFree(GetProcessHeap(), 0, This
);
541 static HRESULT WINAPI
MimeBody_GetClassID(
550 static HRESULT WINAPI
MimeBody_IsDirty(
557 static HRESULT WINAPI
MimeBody_Load(IMimeBody
*iface
, IStream
*pStm
)
559 MimeBody
*This
= impl_from_IMimeBody(iface
);
560 TRACE("(%p)->(%p)\n", iface
, pStm
);
561 return parse_headers(This
, pStm
);
564 static HRESULT WINAPI
MimeBody_Save(IMimeBody
*iface
, IStream
*pStm
, BOOL fClearDirty
)
570 static HRESULT WINAPI
MimeBody_GetSizeMax(
572 ULARGE_INTEGER
* pcbSize
)
578 static HRESULT WINAPI
MimeBody_InitNew(
581 TRACE("%p->()\n", iface
);
585 static HRESULT WINAPI
MimeBody_GetPropInfo(
588 LPMIMEPROPINFO pInfo
)
594 static HRESULT WINAPI
MimeBody_SetPropInfo(
597 LPCMIMEPROPINFO pInfo
)
603 static HRESULT WINAPI
MimeBody_GetProp(
607 LPPROPVARIANT pValue
)
609 MimeBody
*This
= impl_from_IMimeBody(iface
);
610 TRACE("(%p)->(%s, %d, %p)\n", This
, pszName
, dwFlags
, pValue
);
612 if(!strcasecmp(pszName
, "att:pri-content-type"))
614 PropVariantClear(pValue
);
615 pValue
->vt
= VT_LPSTR
;
616 pValue
->u
.pszVal
= strdupA(This
->content_pri_type
);
624 static HRESULT WINAPI
MimeBody_SetProp(
628 LPCPROPVARIANT pValue
)
634 static HRESULT WINAPI
MimeBody_AppendProp(
638 LPPROPVARIANT pValue
)
644 static HRESULT WINAPI
MimeBody_DeleteProp(
652 static HRESULT WINAPI
MimeBody_CopyProps(
656 IMimePropertySet
* pPropertySet
)
662 static HRESULT WINAPI
MimeBody_MoveProps(
666 IMimePropertySet
* pPropertySet
)
672 static HRESULT WINAPI
MimeBody_DeleteExcept(
681 static HRESULT WINAPI
MimeBody_QueryProp(
686 boolean fCaseSensitive
)
692 static HRESULT WINAPI
MimeBody_GetCharset(
694 LPHCHARSET phCharset
)
701 static HRESULT WINAPI
MimeBody_SetCharset(
704 CSETAPPLYTYPE applytype
)
710 static HRESULT WINAPI
MimeBody_GetParameters(
714 LPMIMEPARAMINFO
* pprgParam
)
716 MimeBody
*This
= impl_from_IMimeBody(iface
);
720 TRACE("(%p)->(%s, %p, %p)\n", iface
, debugstr_a(pszName
), pcParams
, pprgParam
);
725 hr
= find_prop(This
, pszName
, &header
);
726 if(hr
!= S_OK
) return hr
;
728 *pcParams
= list_count(&header
->params
);
731 IMimeAllocator
*alloc
;
735 MimeOleGetAllocator(&alloc
);
737 *pprgParam
= info
= IMimeAllocator_Alloc(alloc
, *pcParams
* sizeof(**pprgParam
));
738 LIST_FOR_EACH_ENTRY(param
, &header
->params
, param_t
, entry
)
742 len
= strlen(param
->name
) + 1;
743 info
->pszName
= IMimeAllocator_Alloc(alloc
, len
);
744 memcpy(info
->pszName
, param
->name
, len
);
745 len
= strlen(param
->value
) + 1;
746 info
->pszData
= IMimeAllocator_Alloc(alloc
, len
);
747 memcpy(info
->pszData
, param
->value
, len
);
750 IMimeAllocator_Release(alloc
);
755 static HRESULT WINAPI
MimeBody_IsContentType(
760 MimeBody
*This
= impl_from_IMimeBody(iface
);
762 TRACE("(%p)->(%s, %s)\n", This
, debugstr_a(pszPriType
), debugstr_a(pszSubType
));
765 const char *pri
= This
->content_pri_type
;
766 if(!pri
) pri
= "text";
767 if(strcasecmp(pri
, pszPriType
)) return S_FALSE
;
772 const char *sub
= This
->content_sub_type
;
773 if(!sub
) sub
= "plain";
774 if(strcasecmp(sub
, pszSubType
)) return S_FALSE
;
780 static HRESULT WINAPI
MimeBody_BindToObject(
789 static HRESULT WINAPI
MimeBody_Clone(
791 IMimePropertySet
** ppPropertySet
)
797 static HRESULT WINAPI
MimeBody_SetOption(
800 LPCPROPVARIANT pValue
)
802 HRESULT hr
= E_NOTIMPL
;
803 TRACE("(%p)->(%08x, %p)\n", iface
, oid
, pValue
);
805 if(pValue
->vt
!= TYPEDID_TYPE(oid
))
807 WARN("Called with vartype %04x and oid %08x\n", pValue
->vt
, oid
);
813 case OID_SECURITY_HWND_OWNER
:
814 FIXME("OID_SECURITY_HWND_OWNER (value %08x): ignoring\n", pValue
->u
.ulVal
);
818 FIXME("Unhandled oid %08x\n", oid
);
824 static HRESULT WINAPI
MimeBody_GetOption(
827 LPPROPVARIANT pValue
)
829 FIXME("(%p)->(%08x, %p): stub\n", iface
, oid
, pValue
);
833 static HRESULT WINAPI
MimeBody_EnumProps(
836 IMimeEnumProperties
** ppEnum
)
842 static HRESULT WINAPI
MimeBody_IsType(
844 IMSGBODYTYPE bodytype
)
846 MimeBody
*This
= impl_from_IMimeBody(iface
);
848 TRACE("(%p)->(%d)\n", iface
, bodytype
);
852 return This
->data
? S_FALSE
: S_OK
;
854 FIXME("Unimplemented bodytype %d - returning S_OK\n", bodytype
);
859 static HRESULT WINAPI
MimeBody_SetDisplayName(
867 static HRESULT WINAPI
MimeBody_GetDisplayName(
875 static HRESULT WINAPI
MimeBody_GetOffsets(
877 LPBODYOFFSETS pOffsets
)
879 MimeBody
*This
= impl_from_IMimeBody(iface
);
880 TRACE("(%p)->(%p)\n", This
, pOffsets
);
882 *pOffsets
= This
->body_offsets
;
884 if(This
->body_offsets
.cbBodyEnd
== 0) return MIME_E_NO_DATA
;
888 static HRESULT WINAPI
MimeBody_GetCurrentEncoding(
890 ENCODINGTYPE
* pietEncoding
)
892 MimeBody
*This
= impl_from_IMimeBody(iface
);
894 TRACE("(%p)->(%p)\n", This
, pietEncoding
);
896 *pietEncoding
= This
->encoding
;
900 static HRESULT WINAPI
MimeBody_SetCurrentEncoding(
902 ENCODINGTYPE ietEncoding
)
904 MimeBody
*This
= impl_from_IMimeBody(iface
);
906 TRACE("(%p)->(%d)\n", This
, ietEncoding
);
908 This
->encoding
= ietEncoding
;
912 static HRESULT WINAPI
MimeBody_GetEstimatedSize(
914 ENCODINGTYPE ietEncoding
,
921 static HRESULT WINAPI
MimeBody_GetDataHere(
923 ENCODINGTYPE ietEncoding
,
930 static HRESULT WINAPI
MimeBody_GetData(
932 ENCODINGTYPE ietEncoding
,
935 MimeBody
*This
= impl_from_IMimeBody(iface
);
936 FIXME("(%p)->(%d, %p). Ignoring encoding type.\n", This
, ietEncoding
, ppStream
);
938 *ppStream
= This
->data
;
939 IStream_AddRef(*ppStream
);
943 static HRESULT WINAPI
MimeBody_SetData(
945 ENCODINGTYPE ietEncoding
,
951 MimeBody
*This
= impl_from_IMimeBody(iface
);
952 TRACE("(%p)->(%d, %s, %s, %s %p)\n", This
, ietEncoding
, debugstr_a(pszPriType
), debugstr_a(pszSubType
),
953 debugstr_guid(riid
), pvObject
);
955 if(IsEqualIID(riid
, &IID_IStream
))
956 IStream_AddRef((IStream
*)pvObject
);
959 FIXME("Unhandled object type %s\n", debugstr_guid(riid
));
964 FIXME("release old data\n");
966 This
->data_iid
= *riid
;
967 This
->data
= pvObject
;
969 IMimeBody_SetCurrentEncoding(iface
, ietEncoding
);
971 /* FIXME: Update the content type.
972 If pszPriType == NULL use 'application'
973 If pszSubType == NULL use 'octet-stream' */
978 static HRESULT WINAPI
MimeBody_EmptyData(
985 static HRESULT WINAPI
MimeBody_CopyTo(
993 static HRESULT WINAPI
MimeBody_GetTransmitInfo(
995 LPTRANSMITINFO pTransmitInfo
)
1001 static HRESULT WINAPI
MimeBody_SaveToFile(
1003 ENCODINGTYPE ietEncoding
,
1010 static HRESULT WINAPI
MimeBody_GetHandle(
1014 MimeBody
*This
= impl_from_IMimeBody(iface
);
1015 TRACE("(%p)->(%p)\n", iface
, phBody
);
1017 *phBody
= This
->handle
;
1018 return This
->handle
? S_OK
: MIME_E_NO_DATA
;
1021 static IMimeBodyVtbl body_vtbl
=
1023 MimeBody_QueryInterface
,
1026 MimeBody_GetClassID
,
1030 MimeBody_GetSizeMax
,
1032 MimeBody_GetPropInfo
,
1033 MimeBody_SetPropInfo
,
1036 MimeBody_AppendProp
,
1037 MimeBody_DeleteProp
,
1040 MimeBody_DeleteExcept
,
1042 MimeBody_GetCharset
,
1043 MimeBody_SetCharset
,
1044 MimeBody_GetParameters
,
1045 MimeBody_IsContentType
,
1046 MimeBody_BindToObject
,
1052 MimeBody_SetDisplayName
,
1053 MimeBody_GetDisplayName
,
1054 MimeBody_GetOffsets
,
1055 MimeBody_GetCurrentEncoding
,
1056 MimeBody_SetCurrentEncoding
,
1057 MimeBody_GetEstimatedSize
,
1058 MimeBody_GetDataHere
,
1063 MimeBody_GetTransmitInfo
,
1064 MimeBody_SaveToFile
,
1068 static HRESULT
MimeBody_set_offsets(MimeBody
*body
, const BODYOFFSETS
*offsets
)
1070 TRACE("setting offsets to %d, %d, %d, %d\n", offsets
->cbBoundaryStart
,
1071 offsets
->cbHeaderStart
, offsets
->cbBodyStart
, offsets
->cbBodyEnd
);
1073 body
->body_offsets
= *offsets
;
1077 #define FIRST_CUSTOM_PROP_ID 0x100
1079 static MimeBody
*mimebody_create(void)
1082 BODYOFFSETS body_offsets
;
1084 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
1088 This
->IMimeBody_iface
.lpVtbl
= &body_vtbl
;
1090 This
->handle
= NULL
;
1091 list_init(&This
->headers
);
1092 list_init(&This
->new_props
);
1093 This
->next_prop_id
= FIRST_CUSTOM_PROP_ID
;
1094 This
->content_pri_type
= NULL
;
1095 This
->content_sub_type
= NULL
;
1096 This
->encoding
= IET_7BIT
;
1098 This
->data_iid
= IID_NULL
;
1100 body_offsets
.cbBoundaryStart
= body_offsets
.cbHeaderStart
= 0;
1101 body_offsets
.cbBodyStart
= body_offsets
.cbBodyEnd
= 0;
1102 MimeBody_set_offsets(This
, &body_offsets
);
1107 HRESULT
MimeBody_create(IUnknown
*outer
, void **ppv
)
1112 return CLASS_E_NOAGGREGATION
;
1114 if ((mb
= mimebody_create()))
1116 *ppv
= &mb
->IMimeBody_iface
;
1122 return E_OUTOFMEMORY
;
1130 IStream IStream_iface
;
1133 ULARGE_INTEGER pos
, start
, length
;
1136 static inline sub_stream_t
*impl_from_IStream(IStream
*iface
)
1138 return CONTAINING_RECORD(iface
, sub_stream_t
, IStream_iface
);
1141 static HRESULT WINAPI
sub_stream_QueryInterface(IStream
*iface
, REFIID riid
, void **ppv
)
1143 sub_stream_t
*This
= impl_from_IStream(iface
);
1145 TRACE("(%p)->(%s, %p)\n", This
, debugstr_guid(riid
), ppv
);
1148 if(IsEqualIID(riid
, &IID_IUnknown
) ||
1149 IsEqualIID(riid
, &IID_ISequentialStream
) ||
1150 IsEqualIID(riid
, &IID_IStream
))
1152 IStream_AddRef(iface
);
1156 return E_NOINTERFACE
;
1159 static ULONG WINAPI
sub_stream_AddRef(IStream
*iface
)
1161 sub_stream_t
*This
= impl_from_IStream(iface
);
1162 LONG ref
= InterlockedIncrement(&This
->ref
);
1164 TRACE("(%p) ref=%d\n", This
, ref
);
1169 static ULONG WINAPI
sub_stream_Release(IStream
*iface
)
1171 sub_stream_t
*This
= impl_from_IStream(iface
);
1172 LONG ref
= InterlockedDecrement(&This
->ref
);
1174 TRACE("(%p) ref=%d\n", This
, ref
);
1178 IStream_Release(This
->base
);
1179 HeapFree(GetProcessHeap(), 0, This
);
1184 static HRESULT WINAPI
sub_stream_Read(
1190 sub_stream_t
*This
= impl_from_IStream(iface
);
1192 ULARGE_INTEGER base_pos
;
1193 LARGE_INTEGER tmp_pos
;
1195 TRACE("(%p, %d, %p)\n", pv
, cb
, pcbRead
);
1197 tmp_pos
.QuadPart
= 0;
1198 IStream_Seek(This
->base
, tmp_pos
, STREAM_SEEK_CUR
, &base_pos
);
1199 tmp_pos
.QuadPart
= This
->pos
.QuadPart
+ This
->start
.QuadPart
;
1200 IStream_Seek(This
->base
, tmp_pos
, STREAM_SEEK_SET
, NULL
);
1202 if(This
->pos
.QuadPart
+ cb
> This
->length
.QuadPart
)
1203 cb
= This
->length
.QuadPart
- This
->pos
.QuadPart
;
1205 hr
= IStream_Read(This
->base
, pv
, cb
, pcbRead
);
1207 This
->pos
.QuadPart
+= *pcbRead
;
1209 tmp_pos
.QuadPart
= base_pos
.QuadPart
;
1210 IStream_Seek(This
->base
, tmp_pos
, STREAM_SEEK_SET
, NULL
);
1215 static HRESULT WINAPI
sub_stream_Write(
1225 static HRESULT WINAPI
sub_stream_Seek(
1227 LARGE_INTEGER dlibMove
,
1229 ULARGE_INTEGER
*plibNewPosition
)
1231 sub_stream_t
*This
= impl_from_IStream(iface
);
1232 LARGE_INTEGER new_pos
;
1234 TRACE("(%08x.%08x, %x, %p)\n", dlibMove
.u
.HighPart
, dlibMove
.u
.LowPart
, dwOrigin
, plibNewPosition
);
1238 case STREAM_SEEK_SET
:
1241 case STREAM_SEEK_CUR
:
1242 new_pos
.QuadPart
= This
->pos
.QuadPart
+ dlibMove
.QuadPart
;
1244 case STREAM_SEEK_END
:
1245 new_pos
.QuadPart
= This
->length
.QuadPart
+ dlibMove
.QuadPart
;
1248 return STG_E_INVALIDFUNCTION
;
1251 if(new_pos
.QuadPart
< 0) new_pos
.QuadPart
= 0;
1252 else if(new_pos
.QuadPart
> This
->length
.QuadPart
) new_pos
.QuadPart
= This
->length
.QuadPart
;
1254 This
->pos
.QuadPart
= new_pos
.QuadPart
;
1256 if(plibNewPosition
) *plibNewPosition
= This
->pos
;
1260 static HRESULT WINAPI
sub_stream_SetSize(
1262 ULARGE_INTEGER libNewSize
)
1268 static HRESULT WINAPI
sub_stream_CopyTo(
1272 ULARGE_INTEGER
*pcbRead
,
1273 ULARGE_INTEGER
*pcbWritten
)
1276 BYTE tmpBuffer
[128];
1277 ULONG bytesRead
, bytesWritten
, copySize
;
1278 ULARGE_INTEGER totalBytesRead
;
1279 ULARGE_INTEGER totalBytesWritten
;
1281 TRACE("(%p)->(%p, %d, %p, %p)\n", iface
, pstm
, cb
.u
.LowPart
, pcbRead
, pcbWritten
);
1283 totalBytesRead
.QuadPart
= 0;
1284 totalBytesWritten
.QuadPart
= 0;
1286 while ( cb
.QuadPart
> 0 )
1288 if ( cb
.QuadPart
>= sizeof(tmpBuffer
) )
1289 copySize
= sizeof(tmpBuffer
);
1291 copySize
= cb
.u
.LowPart
;
1293 hr
= IStream_Read(iface
, tmpBuffer
, copySize
, &bytesRead
);
1294 if (FAILED(hr
)) break;
1296 totalBytesRead
.QuadPart
+= bytesRead
;
1300 hr
= IStream_Write(pstm
, tmpBuffer
, bytesRead
, &bytesWritten
);
1301 if (FAILED(hr
)) break;
1302 totalBytesWritten
.QuadPart
+= bytesWritten
;
1305 if (bytesRead
!= copySize
)
1308 cb
.QuadPart
-= bytesRead
;
1311 if (pcbRead
) pcbRead
->QuadPart
= totalBytesRead
.QuadPart
;
1312 if (pcbWritten
) pcbWritten
->QuadPart
= totalBytesWritten
.QuadPart
;
1317 static HRESULT WINAPI
sub_stream_Commit(
1319 DWORD grfCommitFlags
)
1325 static HRESULT WINAPI
sub_stream_Revert(
1332 static HRESULT WINAPI
sub_stream_LockRegion(
1334 ULARGE_INTEGER libOffset
,
1342 static HRESULT WINAPI
sub_stream_UnlockRegion(
1344 ULARGE_INTEGER libOffset
,
1352 static HRESULT WINAPI
sub_stream_Stat(
1357 sub_stream_t
*This
= impl_from_IStream(iface
);
1358 FIXME("(%p)->(%p, %08x)\n", This
, pstatstg
, grfStatFlag
);
1359 memset(pstatstg
, 0, sizeof(*pstatstg
));
1360 pstatstg
->cbSize
= This
->length
;
1364 static HRESULT WINAPI
sub_stream_Clone(
1372 static struct IStreamVtbl sub_stream_vtbl
=
1374 sub_stream_QueryInterface
,
1384 sub_stream_LockRegion
,
1385 sub_stream_UnlockRegion
,
1390 static HRESULT
create_sub_stream(IStream
*stream
, ULARGE_INTEGER start
, ULARGE_INTEGER length
, IStream
**out
)
1395 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
1396 if(!This
) return E_OUTOFMEMORY
;
1398 This
->IStream_iface
.lpVtbl
= &sub_stream_vtbl
;
1400 This
->start
= start
;
1401 This
->length
= length
;
1402 This
->pos
.QuadPart
= 0;
1403 IStream_AddRef(stream
);
1404 This
->base
= stream
;
1406 *out
= &This
->IStream_iface
;
1411 typedef struct body_t
1415 MimeBody
*mime_body
;
1417 struct body_t
*parent
;
1418 struct list children
;
1421 typedef struct MimeMessage
1423 IMimeMessage IMimeMessage_iface
;
1427 struct list body_tree
;
1431 static inline MimeMessage
*impl_from_IMimeMessage(IMimeMessage
*iface
)
1433 return CONTAINING_RECORD(iface
, MimeMessage
, IMimeMessage_iface
);
1436 static HRESULT WINAPI
MimeMessage_QueryInterface(IMimeMessage
*iface
, REFIID riid
, void **ppv
)
1438 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ppv
);
1440 if (IsEqualIID(riid
, &IID_IUnknown
) ||
1441 IsEqualIID(riid
, &IID_IPersist
) ||
1442 IsEqualIID(riid
, &IID_IPersistStreamInit
) ||
1443 IsEqualIID(riid
, &IID_IMimeMessageTree
) ||
1444 IsEqualIID(riid
, &IID_IMimeMessage
))
1447 IMimeMessage_AddRef(iface
);
1451 FIXME("no interface for %s\n", debugstr_guid(riid
));
1453 return E_NOINTERFACE
;
1456 static ULONG WINAPI
MimeMessage_AddRef(IMimeMessage
*iface
)
1458 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
1459 ULONG ref
= InterlockedIncrement(&This
->ref
);
1461 TRACE("(%p) ref=%d\n", This
, ref
);
1466 static void empty_body_list(struct list
*list
)
1468 body_t
*body
, *cursor2
;
1469 LIST_FOR_EACH_ENTRY_SAFE(body
, cursor2
, list
, body_t
, entry
)
1471 empty_body_list(&body
->children
);
1472 list_remove(&body
->entry
);
1473 IMimeBody_Release(&body
->mime_body
->IMimeBody_iface
);
1474 HeapFree(GetProcessHeap(), 0, body
);
1478 static ULONG WINAPI
MimeMessage_Release(IMimeMessage
*iface
)
1480 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
1481 ULONG ref
= InterlockedDecrement(&This
->ref
);
1483 TRACE("(%p) ref=%d\n", This
, ref
);
1487 empty_body_list(&This
->body_tree
);
1489 if(This
->stream
) IStream_Release(This
->stream
);
1490 HeapFree(GetProcessHeap(), 0, This
);
1496 /*** IPersist methods ***/
1497 static HRESULT WINAPI
MimeMessage_GetClassID(
1498 IMimeMessage
*iface
,
1501 FIXME("(%p)->(%p)\n", iface
, pClassID
);
1505 /*** IPersistStreamInit methods ***/
1506 static HRESULT WINAPI
MimeMessage_IsDirty(
1507 IMimeMessage
*iface
)
1509 FIXME("(%p)->()\n", iface
);
1513 static body_t
*new_body_entry(MimeBody
*mime_body
, DWORD index
, body_t
*parent
)
1515 body_t
*body
= HeapAlloc(GetProcessHeap(), 0, sizeof(*body
));
1518 body
->mime_body
= mime_body
;
1519 body
->index
= index
;
1520 list_init(&body
->children
);
1521 body
->parent
= parent
;
1529 BODYOFFSETS offsets
;
1532 static HRESULT
create_body_offset_list(IStream
*stm
, const char *boundary
, struct list
*body_offsets
)
1536 int boundary_len
= strlen(boundary
);
1537 char *buf
, *nl_boundary
, *ptr
, *overlap
;
1538 DWORD start
= 0, overlap_no
;
1539 offset_entry_t
*cur_body
= NULL
;
1543 list_init(body_offsets
);
1544 nl_boundary
= HeapAlloc(GetProcessHeap(), 0, 4 + boundary_len
+ 1);
1545 memcpy(nl_boundary
, "\r\n--", 4);
1546 memcpy(nl_boundary
+ 4, boundary
, boundary_len
+ 1);
1548 overlap_no
= boundary_len
+ 5;
1550 overlap
= buf
= HeapAlloc(GetProcessHeap(), 0, overlap_no
+ PARSER_BUF_SIZE
+ 1);
1553 hr
= IStream_Seek(stm
, zero
, STREAM_SEEK_CUR
, &cur
);
1554 start
= cur
.u
.LowPart
;
1557 hr
= IStream_Read(stm
, overlap
, PARSER_BUF_SIZE
, &read
);
1558 if(FAILED(hr
)) goto end
;
1559 if(read
== 0) break;
1560 overlap
[read
] = '\0';
1564 ptr
= strstr(ptr
, nl_boundary
);
1567 DWORD boundary_start
= start
+ ptr
- buf
;
1568 char *end
= ptr
+ boundary_len
+ 4;
1570 if(*end
== '\0' || *(end
+ 1) == '\0')
1573 if(*end
== '\r' && *(end
+ 1) == '\n')
1577 cur_body
->offsets
.cbBodyEnd
= boundary_start
;
1578 list_add_tail(body_offsets
, &cur_body
->entry
);
1580 cur_body
= HeapAlloc(GetProcessHeap(), 0, sizeof(*cur_body
));
1581 cur_body
->offsets
.cbBoundaryStart
= boundary_start
+ 2; /* doesn't including the leading \r\n */
1582 cur_body
->offsets
.cbHeaderStart
= boundary_start
+ boundary_len
+ 6;
1584 else if(*end
== '-' && *(end
+ 1) == '-')
1588 cur_body
->offsets
.cbBodyEnd
= boundary_start
;
1589 list_add_tail(body_offsets
, &cur_body
->entry
);
1597 if(overlap
== buf
) /* 1st iteration */
1599 memcpy(buf
, buf
+ PARSER_BUF_SIZE
- overlap_no
, overlap_no
);
1600 overlap
= buf
+ overlap_no
;
1601 start
+= read
- overlap_no
;
1605 memcpy(buf
, buf
+ PARSER_BUF_SIZE
, overlap_no
);
1611 HeapFree(GetProcessHeap(), 0, nl_boundary
);
1612 HeapFree(GetProcessHeap(), 0, buf
);
1616 static body_t
*create_sub_body(MimeMessage
*msg
, IStream
*pStm
, BODYOFFSETS
*offset
, body_t
*parent
)
1618 MimeBody
*mime_body
;
1624 mime_body
= mimebody_create();
1625 IMimeBody_Load(&mime_body
->IMimeBody_iface
, pStm
);
1627 hr
= IStream_Seek(pStm
, zero
, STREAM_SEEK_CUR
, &cur
);
1628 offset
->cbBodyStart
= cur
.u
.LowPart
+ offset
->cbHeaderStart
;
1629 if (parent
) MimeBody_set_offsets(mime_body
, offset
);
1630 IMimeBody_SetData(&mime_body
->IMimeBody_iface
, IET_BINARY
, NULL
, NULL
, &IID_IStream
, pStm
);
1631 body
= new_body_entry(mime_body
, msg
->next_index
++, parent
);
1633 if(IMimeBody_IsContentType(&mime_body
->IMimeBody_iface
, "multipart", NULL
) == S_OK
)
1635 MIMEPARAMINFO
*param_info
;
1637 IMimeAllocator
*alloc
;
1639 hr
= IMimeBody_GetParameters(&mime_body
->IMimeBody_iface
, "Content-Type", &count
,
1641 if(hr
!= S_OK
|| count
== 0) return body
;
1643 MimeOleGetAllocator(&alloc
);
1645 for(i
= 0; i
< count
; i
++)
1647 if(!strcasecmp(param_info
[i
].pszName
, "boundary"))
1649 struct list offset_list
;
1650 offset_entry_t
*cur
, *cursor2
;
1651 hr
= create_body_offset_list(pStm
, param_info
[i
].pszData
, &offset_list
);
1652 LIST_FOR_EACH_ENTRY_SAFE(cur
, cursor2
, &offset_list
, offset_entry_t
, entry
)
1655 IStream
*sub_stream
;
1656 ULARGE_INTEGER start
, length
;
1658 start
.QuadPart
= cur
->offsets
.cbHeaderStart
;
1659 length
.QuadPart
= cur
->offsets
.cbBodyEnd
- cur
->offsets
.cbHeaderStart
;
1660 create_sub_stream(pStm
, start
, length
, &sub_stream
);
1661 sub_body
= create_sub_body(msg
, sub_stream
, &cur
->offsets
, body
);
1662 IStream_Release(sub_stream
);
1663 list_add_tail(&body
->children
, &sub_body
->entry
);
1664 list_remove(&cur
->entry
);
1665 HeapFree(GetProcessHeap(), 0, cur
);
1670 IMimeAllocator_FreeParamInfoArray(alloc
, count
, param_info
, TRUE
);
1671 IMimeAllocator_Release(alloc
);
1676 static HRESULT WINAPI
MimeMessage_Load(IMimeMessage
*iface
, IStream
*pStm
)
1678 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
1680 BODYOFFSETS offsets
;
1684 TRACE("(%p)->(%p)\n", iface
, pStm
);
1688 FIXME("already loaded a message\n");
1692 IStream_AddRef(pStm
);
1693 This
->stream
= pStm
;
1694 offsets
.cbBoundaryStart
= offsets
.cbHeaderStart
= 0;
1695 offsets
.cbBodyStart
= offsets
.cbBodyEnd
= 0;
1697 root_body
= create_sub_body(This
, pStm
, &offsets
, NULL
);
1700 IStream_Seek(pStm
, zero
, STREAM_SEEK_END
, &cur
);
1701 offsets
.cbBodyEnd
= cur
.u
.LowPart
;
1702 MimeBody_set_offsets(root_body
->mime_body
, &offsets
);
1704 list_add_head(&This
->body_tree
, &root_body
->entry
);
1709 static HRESULT WINAPI
MimeMessage_Save(IMimeMessage
*iface
, IStream
*pStm
, BOOL fClearDirty
)
1711 FIXME("(%p)->(%p, %s)\n", iface
, pStm
, fClearDirty
? "TRUE" : "FALSE");
1715 static HRESULT WINAPI
MimeMessage_GetSizeMax(
1716 IMimeMessage
*iface
,
1717 ULARGE_INTEGER
*pcbSize
)
1719 FIXME("(%p)->(%p)\n", iface
, pcbSize
);
1723 static HRESULT WINAPI
MimeMessage_InitNew(
1724 IMimeMessage
*iface
)
1726 FIXME("(%p)->()\n", iface
);
1730 /*** IMimeMessageTree methods ***/
1731 static HRESULT WINAPI
MimeMessage_GetMessageSource(IMimeMessage
*iface
, IStream
**ppStream
,
1734 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
1736 FIXME("(%p)->(%p, 0x%x)\n", iface
, ppStream
, dwFlags
);
1738 IStream_AddRef(This
->stream
);
1739 *ppStream
= This
->stream
;
1743 static HRESULT WINAPI
MimeMessage_GetMessageSize(
1744 IMimeMessage
*iface
,
1748 FIXME("(%p)->(%p, 0x%x)\n", iface
, pcbSize
, dwFlags
);
1752 static HRESULT WINAPI
MimeMessage_LoadOffsetTable(
1753 IMimeMessage
*iface
,
1756 FIXME("(%p)->(%p)\n", iface
, pStream
);
1760 static HRESULT WINAPI
MimeMessage_SaveOffsetTable(
1761 IMimeMessage
*iface
,
1765 FIXME("(%p)->(%p, 0x%x)\n", iface
, pStream
, dwFlags
);
1770 static HRESULT WINAPI
MimeMessage_GetFlags(
1771 IMimeMessage
*iface
,
1774 FIXME("(%p)->(%p)\n", iface
, pdwFlags
);
1778 static HRESULT WINAPI
MimeMessage_Commit(
1779 IMimeMessage
*iface
,
1782 FIXME("(%p)->(0x%x)\n", iface
, dwFlags
);
1787 static HRESULT WINAPI
MimeMessage_HandsOffStorage(
1788 IMimeMessage
*iface
)
1790 FIXME("(%p)->()\n", iface
);
1794 static HRESULT
find_body(struct list
*list
, HBODY hbody
, body_t
**body
)
1799 if(hbody
== HBODY_ROOT
)
1801 *body
= LIST_ENTRY(list_head(list
), body_t
, entry
);
1805 LIST_FOR_EACH_ENTRY(cur
, list
, body_t
, entry
)
1807 if(cur
->index
== HandleToUlong(hbody
))
1812 hr
= find_body(&cur
->children
, hbody
, body
);
1813 if(hr
== S_OK
) return S_OK
;
1818 static HRESULT WINAPI
MimeMessage_BindToObject(IMimeMessage
*iface
, const HBODY hBody
, REFIID riid
,
1821 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
1825 TRACE("(%p)->(%p, %s, %p)\n", iface
, hBody
, debugstr_guid(riid
), ppvObject
);
1827 hr
= find_body(&This
->body_tree
, hBody
, &body
);
1829 if(hr
!= S_OK
) return hr
;
1831 if(IsEqualIID(riid
, &IID_IMimeBody
))
1833 IMimeBody_AddRef(&body
->mime_body
->IMimeBody_iface
);
1834 *ppvObject
= &body
->mime_body
->IMimeBody_iface
;
1838 return E_NOINTERFACE
;
1841 static HRESULT WINAPI
MimeMessage_SaveBody(
1842 IMimeMessage
*iface
,
1847 FIXME("(%p)->(%p, 0x%x, %p)\n", iface
, hBody
, dwFlags
, pStream
);
1851 static HRESULT
get_body(MimeMessage
*msg
, BODYLOCATION location
, HBODY pivot
, body_t
**out
)
1853 body_t
*root
= LIST_ENTRY(list_head(&msg
->body_tree
), body_t
, entry
);
1858 if(location
== IBL_ROOT
)
1864 hr
= find_body(&msg
->body_tree
, pivot
, &body
);
1871 *out
= body
->parent
;
1875 list
= list_head(&body
->children
);
1877 *out
= LIST_ENTRY(list
, body_t
, entry
);
1879 hr
= MIME_E_NOT_FOUND
;
1883 list
= list_tail(&body
->children
);
1885 *out
= LIST_ENTRY(list
, body_t
, entry
);
1887 hr
= MIME_E_NOT_FOUND
;
1891 list
= list_next(&body
->parent
->children
, &body
->entry
);
1893 *out
= LIST_ENTRY(list
, body_t
, entry
);
1895 hr
= MIME_E_NOT_FOUND
;
1899 list
= list_prev(&body
->parent
->children
, &body
->entry
);
1901 *out
= LIST_ENTRY(list
, body_t
, entry
);
1903 hr
= MIME_E_NOT_FOUND
;
1916 static HRESULT WINAPI
MimeMessage_InsertBody(
1917 IMimeMessage
*iface
,
1918 BODYLOCATION location
,
1922 FIXME("(%p)->(%d, %p, %p)\n", iface
, location
, hPivot
, phBody
);
1926 static HRESULT WINAPI
MimeMessage_GetBody(IMimeMessage
*iface
, BODYLOCATION location
, HBODY hPivot
,
1929 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
1933 TRACE("(%p)->(%d, %p, %p)\n", iface
, location
, hPivot
, phBody
);
1935 hr
= get_body(This
, location
, hPivot
, &body
);
1937 if(hr
== S_OK
) *phBody
= UlongToHandle(body
->index
);
1942 static HRESULT WINAPI
MimeMessage_DeleteBody(
1943 IMimeMessage
*iface
,
1947 FIXME("(%p)->(%p, %08x)\n", iface
, hBody
, dwFlags
);
1951 static HRESULT WINAPI
MimeMessage_MoveBody(
1952 IMimeMessage
*iface
,
1954 BODYLOCATION location
)
1956 FIXME("(%p)->(%d)\n", iface
, location
);
1960 static void count_children(body_t
*body
, boolean recurse
, ULONG
*count
)
1964 LIST_FOR_EACH_ENTRY(child
, &body
->children
, body_t
, entry
)
1967 if(recurse
) count_children(child
, recurse
, count
);
1971 static HRESULT WINAPI
MimeMessage_CountBodies(IMimeMessage
*iface
, HBODY hParent
, boolean fRecurse
,
1975 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
1978 TRACE("(%p)->(%p, %s, %p)\n", iface
, hParent
, fRecurse
? "TRUE" : "FALSE", pcBodies
);
1980 hr
= find_body(&This
->body_tree
, hParent
, &body
);
1981 if(hr
!= S_OK
) return hr
;
1984 count_children(body
, fRecurse
, pcBodies
);
1989 static HRESULT
find_next(MimeMessage
*This
, body_t
*body
, FINDBODY
*find
, HBODY
*out
)
1996 if (!body
) ptr
= list_head( &This
->body_tree
);
1999 ptr
= list_head( &body
->children
);
2002 if (!body
->parent
) return MIME_E_NOT_FOUND
;
2003 if (!(ptr
= list_next( &body
->parent
->children
, &body
->entry
))) body
= body
->parent
;
2007 body
= LIST_ENTRY( ptr
, body_t
, entry
);
2008 next
= UlongToHandle( body
->index
);
2009 find
->dwReserved
= body
->index
;
2010 if (IMimeBody_IsContentType(&body
->mime_body
->IMimeBody_iface
, find
->pszPriType
,
2011 find
->pszSubType
) == S_OK
)
2017 return MIME_E_NOT_FOUND
;
2020 static HRESULT WINAPI
MimeMessage_FindFirst(IMimeMessage
*iface
, FINDBODY
*pFindBody
, HBODY
*phBody
)
2022 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2024 TRACE("(%p)->(%p, %p)\n", iface
, pFindBody
, phBody
);
2026 pFindBody
->dwReserved
= 0;
2027 return find_next(This
, NULL
, pFindBody
, phBody
);
2030 static HRESULT WINAPI
MimeMessage_FindNext(IMimeMessage
*iface
, FINDBODY
*pFindBody
, HBODY
*phBody
)
2032 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2036 TRACE("(%p)->(%p, %p)\n", iface
, pFindBody
, phBody
);
2038 hr
= find_body( &This
->body_tree
, UlongToHandle( pFindBody
->dwReserved
), &body
);
2039 if (hr
!= S_OK
) return MIME_E_NOT_FOUND
;
2040 return find_next(This
, body
, pFindBody
, phBody
);
2043 static HRESULT WINAPI
MimeMessage_ResolveURL(
2044 IMimeMessage
*iface
,
2051 FIXME("(%p)->(%p, %s, %s, 0x%x, %p)\n", iface
, hRelated
, pszBase
, pszURL
, dwFlags
, phBody
);
2055 static HRESULT WINAPI
MimeMessage_ToMultipart(
2056 IMimeMessage
*iface
,
2059 LPHBODY phMultipart
)
2061 FIXME("(%p)->(%p, %s, %p)\n", iface
, hBody
, pszSubType
, phMultipart
);
2065 static HRESULT WINAPI
MimeMessage_GetBodyOffsets(
2066 IMimeMessage
*iface
,
2068 LPBODYOFFSETS pOffsets
)
2070 FIXME("(%p)->(%p, %p)\n", iface
, hBody
, pOffsets
);
2074 static HRESULT WINAPI
MimeMessage_GetCharset(
2075 IMimeMessage
*iface
,
2076 LPHCHARSET phCharset
)
2078 FIXME("(%p)->(%p)\n", iface
, phCharset
);
2083 static HRESULT WINAPI
MimeMessage_SetCharset(
2084 IMimeMessage
*iface
,
2086 CSETAPPLYTYPE applytype
)
2088 FIXME("(%p)->(%p, %d)\n", iface
, hCharset
, applytype
);
2092 static HRESULT WINAPI
MimeMessage_IsBodyType(
2093 IMimeMessage
*iface
,
2095 IMSGBODYTYPE bodytype
)
2098 IMimeBody
*mime_body
;
2099 TRACE("(%p)->(%p, %d)\n", iface
, hBody
, bodytype
);
2101 hr
= IMimeMessage_BindToObject(iface
, hBody
, &IID_IMimeBody
, (void**)&mime_body
);
2102 if(hr
!= S_OK
) return hr
;
2104 hr
= IMimeBody_IsType(mime_body
, bodytype
);
2105 MimeBody_Release(mime_body
);
2109 static HRESULT WINAPI
MimeMessage_IsContentType(
2110 IMimeMessage
*iface
,
2116 IMimeBody
*mime_body
;
2117 TRACE("(%p)->(%p, %s, %s)\n", iface
, hBody
, debugstr_a(pszPriType
),
2118 debugstr_a(pszSubType
));
2120 hr
= IMimeMessage_BindToObject(iface
, hBody
, &IID_IMimeBody
, (void**)&mime_body
);
2121 if(FAILED(hr
)) return hr
;
2123 hr
= IMimeBody_IsContentType(mime_body
, pszPriType
, pszSubType
);
2124 IMimeBody_Release(mime_body
);
2128 static HRESULT WINAPI
MimeMessage_QueryBodyProp(
2129 IMimeMessage
*iface
,
2134 boolean fCaseSensitive
)
2136 FIXME("(%p)->(%p, %s, %s, %s, %s)\n", iface
, hBody
, pszName
, pszCriteria
, fSubString
? "TRUE" : "FALSE", fCaseSensitive
? "TRUE" : "FALSE");
2140 static HRESULT WINAPI
MimeMessage_GetBodyProp(
2141 IMimeMessage
*iface
,
2145 LPPROPVARIANT pValue
)
2148 IMimeBody
*mime_body
;
2150 TRACE("(%p)->(%p, %s, 0x%x, %p)\n", iface
, hBody
, pszName
, dwFlags
, pValue
);
2152 hr
= IMimeMessage_BindToObject(iface
, hBody
, &IID_IMimeBody
, (void**)&mime_body
);
2153 if(hr
!= S_OK
) return hr
;
2155 hr
= IMimeBody_GetProp(mime_body
, pszName
, dwFlags
, pValue
);
2156 IMimeBody_Release(mime_body
);
2161 static HRESULT WINAPI
MimeMessage_SetBodyProp(
2162 IMimeMessage
*iface
,
2166 LPCPROPVARIANT pValue
)
2168 FIXME("(%p)->(%p, %s, 0x%x, %p)\n", iface
, hBody
, pszName
, dwFlags
, pValue
);
2172 static HRESULT WINAPI
MimeMessage_DeleteBodyProp(
2173 IMimeMessage
*iface
,
2177 FIXME("(%p)->(%p, %s)\n", iface
, hBody
, pszName
);
2181 static HRESULT WINAPI
MimeMessage_SetOption(
2182 IMimeMessage
*iface
,
2184 LPCPROPVARIANT pValue
)
2186 HRESULT hr
= E_NOTIMPL
;
2187 TRACE("(%p)->(%08x, %p)\n", iface
, oid
, pValue
);
2189 if(pValue
->vt
!= TYPEDID_TYPE(oid
))
2191 WARN("Called with vartype %04x and oid %08x\n", pValue
->vt
, oid
);
2192 return E_INVALIDARG
;
2197 case OID_HIDE_TNEF_ATTACHMENTS
:
2198 FIXME("OID_HIDE_TNEF_ATTACHMENTS (value %d): ignoring\n", pValue
->u
.boolVal
);
2201 case OID_SHOW_MACBINARY
:
2202 FIXME("OID_SHOW_MACBINARY (value %d): ignoring\n", pValue
->u
.boolVal
);
2206 FIXME("Unhandled oid %08x\n", oid
);
2212 static HRESULT WINAPI
MimeMessage_GetOption(
2213 IMimeMessage
*iface
,
2215 LPPROPVARIANT pValue
)
2217 FIXME("(%p)->(%08x, %p)\n", iface
, oid
, pValue
);
2221 /*** IMimeMessage methods ***/
2222 static HRESULT WINAPI
MimeMessage_CreateWebPage(
2223 IMimeMessage
*iface
,
2225 LPWEBPAGEOPTIONS pOptions
,
2226 IMimeMessageCallback
*pCallback
,
2227 IMoniker
**ppMoniker
)
2229 FIXME("(%p)->(%p, %p, %p, %p)\n", iface
, pRootStm
, pOptions
, pCallback
, ppMoniker
);
2234 static HRESULT WINAPI
MimeMessage_GetProp(
2235 IMimeMessage
*iface
,
2238 LPPROPVARIANT pValue
)
2240 FIXME("(%p)->(%s, 0x%x, %p)\n", iface
, pszName
, dwFlags
, pValue
);
2244 static HRESULT WINAPI
MimeMessage_SetProp(
2245 IMimeMessage
*iface
,
2248 LPCPROPVARIANT pValue
)
2250 FIXME("(%p)->(%s, 0x%x, %p)\n", iface
, pszName
, dwFlags
, pValue
);
2254 static HRESULT WINAPI
MimeMessage_DeleteProp(
2255 IMimeMessage
*iface
,
2258 FIXME("(%p)->(%s)\n", iface
, pszName
);
2262 static HRESULT WINAPI
MimeMessage_QueryProp(
2263 IMimeMessage
*iface
,
2267 boolean fCaseSensitive
)
2269 FIXME("(%p)->(%s, %s, %s, %s)\n", iface
, pszName
, pszCriteria
, fSubString
? "TRUE" : "FALSE", fCaseSensitive
? "TRUE" : "FALSE");
2273 static HRESULT WINAPI
MimeMessage_GetTextBody(
2274 IMimeMessage
*iface
,
2276 ENCODINGTYPE ietEncoding
,
2282 FINDBODY find_struct
;
2283 IMimeBody
*mime_body
;
2284 static char text
[] = "text";
2285 static char plain
[] = "plain";
2286 static char html
[] = "html";
2288 TRACE("(%p)->(%d, %d, %p, %p)\n", iface
, dwTxtType
, ietEncoding
, pStream
, phBody
);
2290 find_struct
.pszPriType
= text
;
2295 find_struct
.pszSubType
= plain
;
2298 find_struct
.pszSubType
= html
;
2301 return MIME_E_INVALID_TEXT_TYPE
;
2304 hr
= IMimeMessage_FindFirst(iface
, &find_struct
, &hbody
);
2307 TRACE("not found hr %08x\n", hr
);
2312 IMimeMessage_BindToObject(iface
, hbody
, &IID_IMimeBody
, (void**)&mime_body
);
2314 IMimeBody_GetData(mime_body
, ietEncoding
, pStream
);
2316 IMimeBody_Release(mime_body
);
2320 static HRESULT WINAPI
MimeMessage_SetTextBody(
2321 IMimeMessage
*iface
,
2323 ENCODINGTYPE ietEncoding
,
2328 FIXME("(%p)->(%d, %d, %p, %p, %p)\n", iface
, dwTxtType
, ietEncoding
, hAlternative
, pStream
, phBody
);
2332 static HRESULT WINAPI
MimeMessage_AttachObject(
2333 IMimeMessage
*iface
,
2338 FIXME("(%p)->(%s, %p, %p)\n", iface
, debugstr_guid(riid
), pvObject
, phBody
);
2342 static HRESULT WINAPI
MimeMessage_AttachFile(
2343 IMimeMessage
*iface
,
2348 FIXME("(%p)->(%s, %p, %p)\n", iface
, pszFilePath
, pstmFile
, phBody
);
2352 static HRESULT WINAPI
MimeMessage_AttachURL(
2353 IMimeMessage
*iface
,
2361 FIXME("(%p)->(%s, %s, 0x%x, %p, %p, %p)\n", iface
, pszBase
, pszURL
, dwFlags
, pstmURL
, ppszCIDURL
, phBody
);
2365 static HRESULT WINAPI
MimeMessage_GetAttachments(
2366 IMimeMessage
*iface
,
2368 LPHBODY
*pprghAttach
)
2371 FINDBODY find_struct
;
2376 TRACE("(%p)->(%p, %p)\n", iface
, pcAttach
, pprghAttach
);
2379 array
= CoTaskMemAlloc(size
* sizeof(HBODY
));
2381 find_struct
.pszPriType
= find_struct
.pszSubType
= NULL
;
2382 hr
= IMimeMessage_FindFirst(iface
, &find_struct
, &hbody
);
2385 hr
= IMimeMessage_IsContentType(iface
, hbody
, "multipart", NULL
);
2386 TRACE("IsCT rets %08x %d\n", hr
, *pcAttach
);
2389 if(*pcAttach
+ 1 > size
)
2392 array
= CoTaskMemRealloc(array
, size
* sizeof(HBODY
));
2394 array
[*pcAttach
] = hbody
;
2397 hr
= IMimeMessage_FindNext(iface
, &find_struct
, &hbody
);
2400 *pprghAttach
= array
;
2404 static HRESULT WINAPI
MimeMessage_GetAddressTable(
2405 IMimeMessage
*iface
,
2406 IMimeAddressTable
**ppTable
)
2408 FIXME("(%p)->(%p)\n", iface
, ppTable
);
2412 static HRESULT WINAPI
MimeMessage_GetSender(
2413 IMimeMessage
*iface
,
2414 LPADDRESSPROPS pAddress
)
2416 FIXME("(%p)->(%p)\n", iface
, pAddress
);
2420 static HRESULT WINAPI
MimeMessage_GetAddressTypes(
2421 IMimeMessage
*iface
,
2424 LPADDRESSLIST pList
)
2426 FIXME("(%p)->(%d, %d, %p)\n", iface
, dwAdrTypes
, dwProps
, pList
);
2430 static HRESULT WINAPI
MimeMessage_GetAddressFormat(
2431 IMimeMessage
*iface
,
2433 ADDRESSFORMAT format
,
2436 FIXME("(%p)->(%d, %d, %p)\n", iface
, dwAdrTypes
, format
, ppszFormat
);
2440 static HRESULT WINAPI
MimeMessage_EnumAddressTypes(
2441 IMimeMessage
*iface
,
2444 IMimeEnumAddressTypes
**ppEnum
)
2446 FIXME("(%p)->(%d, %d, %p)\n", iface
, dwAdrTypes
, dwProps
, ppEnum
);
2450 static HRESULT WINAPI
MimeMessage_SplitMessage(
2451 IMimeMessage
*iface
,
2453 IMimeMessageParts
**ppParts
)
2455 FIXME("(%p)->(%d, %p)\n", iface
, cbMaxPart
, ppParts
);
2459 static HRESULT WINAPI
MimeMessage_GetRootMoniker(
2460 IMimeMessage
*iface
,
2461 IMoniker
**ppMoniker
)
2463 FIXME("(%p)->(%p)\n", iface
, ppMoniker
);
2467 static const IMimeMessageVtbl MimeMessageVtbl
=
2469 MimeMessage_QueryInterface
,
2471 MimeMessage_Release
,
2472 MimeMessage_GetClassID
,
2473 MimeMessage_IsDirty
,
2476 MimeMessage_GetSizeMax
,
2477 MimeMessage_InitNew
,
2478 MimeMessage_GetMessageSource
,
2479 MimeMessage_GetMessageSize
,
2480 MimeMessage_LoadOffsetTable
,
2481 MimeMessage_SaveOffsetTable
,
2482 MimeMessage_GetFlags
,
2484 MimeMessage_HandsOffStorage
,
2485 MimeMessage_BindToObject
,
2486 MimeMessage_SaveBody
,
2487 MimeMessage_InsertBody
,
2488 MimeMessage_GetBody
,
2489 MimeMessage_DeleteBody
,
2490 MimeMessage_MoveBody
,
2491 MimeMessage_CountBodies
,
2492 MimeMessage_FindFirst
,
2493 MimeMessage_FindNext
,
2494 MimeMessage_ResolveURL
,
2495 MimeMessage_ToMultipart
,
2496 MimeMessage_GetBodyOffsets
,
2497 MimeMessage_GetCharset
,
2498 MimeMessage_SetCharset
,
2499 MimeMessage_IsBodyType
,
2500 MimeMessage_IsContentType
,
2501 MimeMessage_QueryBodyProp
,
2502 MimeMessage_GetBodyProp
,
2503 MimeMessage_SetBodyProp
,
2504 MimeMessage_DeleteBodyProp
,
2505 MimeMessage_SetOption
,
2506 MimeMessage_GetOption
,
2507 MimeMessage_CreateWebPage
,
2508 MimeMessage_GetProp
,
2509 MimeMessage_SetProp
,
2510 MimeMessage_DeleteProp
,
2511 MimeMessage_QueryProp
,
2512 MimeMessage_GetTextBody
,
2513 MimeMessage_SetTextBody
,
2514 MimeMessage_AttachObject
,
2515 MimeMessage_AttachFile
,
2516 MimeMessage_AttachURL
,
2517 MimeMessage_GetAttachments
,
2518 MimeMessage_GetAddressTable
,
2519 MimeMessage_GetSender
,
2520 MimeMessage_GetAddressTypes
,
2521 MimeMessage_GetAddressFormat
,
2522 MimeMessage_EnumAddressTypes
,
2523 MimeMessage_SplitMessage
,
2524 MimeMessage_GetRootMoniker
,
2527 HRESULT
MimeMessage_create(IUnknown
*outer
, void **obj
)
2531 TRACE("(%p, %p)\n", outer
, obj
);
2535 FIXME("outer unknown not supported yet\n");
2541 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
2542 if (!This
) return E_OUTOFMEMORY
;
2544 This
->IMimeMessage_iface
.lpVtbl
= &MimeMessageVtbl
;
2546 This
->stream
= NULL
;
2547 list_init(&This
->body_tree
);
2548 This
->next_index
= 1;
2550 *obj
= &This
->IMimeMessage_iface
;
2554 /***********************************************************************
2555 * MimeOleCreateMessage (INETCOMM.@)
2557 HRESULT WINAPI
MimeOleCreateMessage(IUnknown
*pUnkOuter
, IMimeMessage
**ppMessage
)
2559 TRACE("(%p, %p)\n", pUnkOuter
, ppMessage
);
2560 return MimeMessage_create(NULL
, (void **)ppMessage
);
2563 /***********************************************************************
2564 * MimeOleSetCompatMode (INETCOMM.@)
2566 HRESULT WINAPI
MimeOleSetCompatMode(DWORD dwMode
)
2568 FIXME("(0x%x)\n", dwMode
);
2572 /***********************************************************************
2573 * MimeOleCreateVirtualStream (INETCOMM.@)
2575 HRESULT WINAPI
MimeOleCreateVirtualStream(IStream
**ppStream
)
2578 FIXME("(%p)\n", ppStream
);
2580 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, ppStream
);
2584 typedef struct MimeSecurity
2586 IMimeSecurity IMimeSecurity_iface
;
2590 static inline MimeSecurity
*impl_from_IMimeSecurity(IMimeSecurity
*iface
)
2592 return CONTAINING_RECORD(iface
, MimeSecurity
, IMimeSecurity_iface
);
2595 static HRESULT WINAPI
MimeSecurity_QueryInterface(IMimeSecurity
*iface
, REFIID riid
, void **ppv
)
2597 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ppv
);
2599 if (IsEqualIID(riid
, &IID_IUnknown
) ||
2600 IsEqualIID(riid
, &IID_IMimeSecurity
))
2603 IMimeSecurity_AddRef(iface
);
2607 FIXME("no interface for %s\n", debugstr_guid(riid
));
2609 return E_NOINTERFACE
;
2612 static ULONG WINAPI
MimeSecurity_AddRef(IMimeSecurity
*iface
)
2614 MimeSecurity
*This
= impl_from_IMimeSecurity(iface
);
2615 LONG ref
= InterlockedIncrement(&This
->ref
);
2617 TRACE("(%p) ref=%d\n", This
, ref
);
2622 static ULONG WINAPI
MimeSecurity_Release(IMimeSecurity
*iface
)
2624 MimeSecurity
*This
= impl_from_IMimeSecurity(iface
);
2625 LONG ref
= InterlockedDecrement(&This
->ref
);
2627 TRACE("(%p) ref=%d\n", This
, ref
);
2630 HeapFree(GetProcessHeap(), 0, This
);
2635 static HRESULT WINAPI
MimeSecurity_InitNew(
2636 IMimeSecurity
* iface
)
2638 FIXME("(%p)->(): stub\n", iface
);
2642 static HRESULT WINAPI
MimeSecurity_CheckInit(
2643 IMimeSecurity
* iface
)
2645 FIXME("(%p)->(): stub\n", iface
);
2649 static HRESULT WINAPI
MimeSecurity_EncodeMessage(
2650 IMimeSecurity
* iface
,
2651 IMimeMessageTree
* pTree
,
2654 FIXME("(%p)->(%p, %08x): stub\n", iface
, pTree
, dwFlags
);
2658 static HRESULT WINAPI
MimeSecurity_EncodeBody(
2659 IMimeSecurity
* iface
,
2660 IMimeMessageTree
* pTree
,
2664 FIXME("(%p)->(%p, %p, %08x): stub\n", iface
, pTree
, hEncodeRoot
, dwFlags
);
2668 static HRESULT WINAPI
MimeSecurity_DecodeMessage(
2669 IMimeSecurity
* iface
,
2670 IMimeMessageTree
* pTree
,
2673 FIXME("(%p)->(%p, %08x): stub\n", iface
, pTree
, dwFlags
);
2677 static HRESULT WINAPI
MimeSecurity_DecodeBody(
2678 IMimeSecurity
* iface
,
2679 IMimeMessageTree
* pTree
,
2683 FIXME("(%p)->(%p, %p, %08x): stub\n", iface
, pTree
, hDecodeRoot
, dwFlags
);
2687 static HRESULT WINAPI
MimeSecurity_EnumCertificates(
2688 IMimeSecurity
* iface
,
2694 FIXME("(%p)->(%p, %08x, %p, %p): stub\n", iface
, hc
, dwUsage
, pPrev
, ppCert
);
2698 static HRESULT WINAPI
MimeSecurity_GetCertificateName(
2699 IMimeSecurity
* iface
,
2700 const PCX509CERT pX509Cert
,
2701 const CERTNAMETYPE cn
,
2704 FIXME("(%p)->(%p, %08x, %p): stub\n", iface
, pX509Cert
, cn
, ppszName
);
2708 static HRESULT WINAPI
MimeSecurity_GetMessageType(
2709 IMimeSecurity
* iface
,
2710 const HWND hwndParent
,
2714 FIXME("(%p)->(%p, %p, %p): stub\n", iface
, hwndParent
, pBody
, pdwSecType
);
2718 static HRESULT WINAPI
MimeSecurity_GetCertData(
2719 IMimeSecurity
* iface
,
2720 const PCX509CERT pX509Cert
,
2721 const CERTDATAID dataid
,
2722 LPPROPVARIANT pValue
)
2724 FIXME("(%p)->(%p, %x, %p): stub\n", iface
, pX509Cert
, dataid
, pValue
);
2729 static const IMimeSecurityVtbl MimeSecurityVtbl
=
2731 MimeSecurity_QueryInterface
,
2732 MimeSecurity_AddRef
,
2733 MimeSecurity_Release
,
2734 MimeSecurity_InitNew
,
2735 MimeSecurity_CheckInit
,
2736 MimeSecurity_EncodeMessage
,
2737 MimeSecurity_EncodeBody
,
2738 MimeSecurity_DecodeMessage
,
2739 MimeSecurity_DecodeBody
,
2740 MimeSecurity_EnumCertificates
,
2741 MimeSecurity_GetCertificateName
,
2742 MimeSecurity_GetMessageType
,
2743 MimeSecurity_GetCertData
2746 HRESULT
MimeSecurity_create(IUnknown
*outer
, void **obj
)
2752 if (outer
) return CLASS_E_NOAGGREGATION
;
2754 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
2755 if (!This
) return E_OUTOFMEMORY
;
2757 This
->IMimeSecurity_iface
.lpVtbl
= &MimeSecurityVtbl
;
2760 *obj
= &This
->IMimeSecurity_iface
;
2764 /***********************************************************************
2765 * MimeOleCreateSecurity (INETCOMM.@)
2767 HRESULT WINAPI
MimeOleCreateSecurity(IMimeSecurity
**ppSecurity
)
2769 return MimeSecurity_create(NULL
, (void **)ppSecurity
);
2772 static HRESULT WINAPI
MimeAlloc_QueryInterface(
2773 IMimeAllocator
* iface
,
2777 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), obj
);
2779 if (IsEqualIID(riid
, &IID_IUnknown
) ||
2780 IsEqualIID(riid
, &IID_IMalloc
) ||
2781 IsEqualIID(riid
, &IID_IMimeAllocator
))
2784 IMimeAllocator_AddRef(iface
);
2788 FIXME("no interface for %s\n", debugstr_guid(riid
));
2790 return E_NOINTERFACE
;
2793 static ULONG WINAPI
MimeAlloc_AddRef(
2794 IMimeAllocator
* iface
)
2799 static ULONG WINAPI
MimeAlloc_Release(
2800 IMimeAllocator
* iface
)
2805 static LPVOID WINAPI
MimeAlloc_Alloc(
2806 IMimeAllocator
* iface
,
2809 return CoTaskMemAlloc(cb
);
2812 static LPVOID WINAPI
MimeAlloc_Realloc(
2813 IMimeAllocator
* iface
,
2817 return CoTaskMemRealloc(pv
, cb
);
2820 static void WINAPI
MimeAlloc_Free(
2821 IMimeAllocator
* iface
,
2827 static ULONG WINAPI
MimeAlloc_GetSize(
2828 IMimeAllocator
* iface
,
2835 static int WINAPI
MimeAlloc_DidAlloc(
2836 IMimeAllocator
* iface
,
2843 static void WINAPI
MimeAlloc_HeapMinimize(
2844 IMimeAllocator
* iface
)
2850 static HRESULT WINAPI
MimeAlloc_FreeParamInfoArray(
2851 IMimeAllocator
* iface
,
2853 LPMIMEPARAMINFO prgParam
,
2857 TRACE("(%p)->(%d, %p, %d)\n", iface
, cParams
, prgParam
, fFreeArray
);
2859 for(i
= 0; i
< cParams
; i
++)
2861 IMimeAllocator_Free(iface
, prgParam
[i
].pszName
);
2862 IMimeAllocator_Free(iface
, prgParam
[i
].pszData
);
2864 if(fFreeArray
) IMimeAllocator_Free(iface
, prgParam
);
2868 static HRESULT WINAPI
MimeAlloc_FreeAddressList(
2869 IMimeAllocator
* iface
,
2870 LPADDRESSLIST pList
)
2876 static HRESULT WINAPI
MimeAlloc_FreeAddressProps(
2877 IMimeAllocator
* iface
,
2878 LPADDRESSPROPS pAddress
)
2884 static HRESULT WINAPI
MimeAlloc_ReleaseObjects(
2885 IMimeAllocator
* iface
,
2887 IUnknown
**prgpUnknown
,
2895 static HRESULT WINAPI
MimeAlloc_FreeEnumHeaderRowArray(
2896 IMimeAllocator
* iface
,
2898 LPENUMHEADERROW prgRow
,
2905 static HRESULT WINAPI
MimeAlloc_FreeEnumPropertyArray(
2906 IMimeAllocator
* iface
,
2908 LPENUMPROPERTY prgProp
,
2915 static HRESULT WINAPI
MimeAlloc_FreeThumbprint(
2916 IMimeAllocator
* iface
,
2917 THUMBBLOB
*pthumbprint
)
2924 static HRESULT WINAPI
MimeAlloc_PropVariantClear(
2925 IMimeAllocator
* iface
,
2926 LPPROPVARIANT pProp
)
2932 static IMimeAllocatorVtbl mime_alloc_vtbl
=
2934 MimeAlloc_QueryInterface
,
2942 MimeAlloc_HeapMinimize
,
2943 MimeAlloc_FreeParamInfoArray
,
2944 MimeAlloc_FreeAddressList
,
2945 MimeAlloc_FreeAddressProps
,
2946 MimeAlloc_ReleaseObjects
,
2947 MimeAlloc_FreeEnumHeaderRowArray
,
2948 MimeAlloc_FreeEnumPropertyArray
,
2949 MimeAlloc_FreeThumbprint
,
2950 MimeAlloc_PropVariantClear
2953 static IMimeAllocator mime_allocator
=
2958 HRESULT
MimeAllocator_create(IUnknown
*outer
, void **obj
)
2960 if(outer
) return CLASS_E_NOAGGREGATION
;
2962 *obj
= &mime_allocator
;
2966 HRESULT WINAPI
MimeOleGetAllocator(IMimeAllocator
**alloc
)
2968 return MimeAllocator_create(NULL
, (void**)alloc
);
2971 HRESULT
VirtualStream_create(IUnknown
*outer
, void **obj
)
2973 FIXME("(%p, %p)\n", outer
, obj
);
2976 if (outer
) return CLASS_E_NOAGGREGATION
;
2978 return MimeOleCreateVirtualStream((IStream
**)obj
);