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
23 #define NONAMELESSUNION
35 #include "wine/list.h"
36 #include "wine/debug.h"
38 #include "inetcomm_private.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(inetcomm
);
46 DWORD flags
; /* MIMEPROPFLAGS */
54 } property_list_entry_t
;
56 static const property_t default_props
[] =
58 {"References", PID_HDR_REFS
, 0, VT_LPSTR
},
59 {"Subject", PID_HDR_SUBJECT
, 0, VT_LPSTR
},
60 {"From", PID_HDR_FROM
, MPF_ADDRESS
, VT_LPSTR
},
61 {"Message-ID", PID_HDR_MESSAGEID
, 0, VT_LPSTR
},
62 {"Return-Path", PID_HDR_RETURNPATH
, MPF_ADDRESS
, VT_LPSTR
},
63 {"Date", PID_HDR_DATE
, 0, VT_LPSTR
},
64 {"Received", PID_HDR_RECEIVED
, 0, VT_LPSTR
},
65 {"Reply-To", PID_HDR_REPLYTO
, MPF_ADDRESS
, VT_LPSTR
},
66 {"X-Mailer", PID_HDR_XMAILER
, 0, VT_LPSTR
},
67 {"Bcc", PID_HDR_BCC
, MPF_ADDRESS
, VT_LPSTR
},
68 {"MIME-Version", PID_HDR_MIMEVER
, MPF_MIME
, VT_LPSTR
},
69 {"Content-Type", PID_HDR_CNTTYPE
, MPF_MIME
| MPF_HASPARAMS
, VT_LPSTR
},
70 {"Content-Transfer-Encoding", PID_HDR_CNTXFER
, MPF_MIME
, VT_LPSTR
},
71 {"Content-ID", PID_HDR_CNTID
, MPF_MIME
, VT_LPSTR
},
72 {"Content-Disposition", PID_HDR_CNTDISP
, MPF_MIME
, VT_LPSTR
},
73 {"To", PID_HDR_TO
, MPF_ADDRESS
, VT_LPSTR
},
74 {"Cc", PID_HDR_CC
, MPF_ADDRESS
, VT_LPSTR
},
75 {"Sender", PID_HDR_SENDER
, MPF_ADDRESS
, VT_LPSTR
},
76 {"In-Reply-To", PID_HDR_INREPLYTO
, 0, VT_LPSTR
},
90 const property_t
*prop
;
95 typedef struct MimeBody
97 const IMimeBodyVtbl
*lpVtbl
;
103 struct list new_props
; /* FIXME: This should be in a PropertySchema */
105 char *content_pri_type
;
106 char *content_sub_type
;
107 ENCODINGTYPE encoding
;
110 BODYOFFSETS body_offsets
;
113 static inline MimeBody
*impl_from_IMimeBody( IMimeBody
*iface
)
115 return (MimeBody
*)((char*)iface
- FIELD_OFFSET(MimeBody
, lpVtbl
));
118 static LPSTR
strdupA(LPCSTR str
)
121 int len
= strlen(str
);
122 ret
= HeapAlloc(GetProcessHeap(), 0, len
+ 1);
123 memcpy(ret
, str
, len
+ 1);
127 #define PARSER_BUF_SIZE 1024
129 /*****************************************************
130 * copy_headers_to_buf [internal]
132 * Copies the headers into a '\0' terminated memory block and leave
133 * the stream's current position set to after the blank line.
135 static HRESULT
copy_headers_to_buf(IStream
*stm
, char **ptr
)
138 DWORD size
= PARSER_BUF_SIZE
, offset
= 0, last_end
= 0;
150 buf
= HeapAlloc(GetProcessHeap(), 0, size
+ 1);
154 buf
= HeapReAlloc(GetProcessHeap(), 0, buf
, size
+ 1);
162 hr
= IStream_Read(stm
, buf
+ offset
, size
- offset
, &read
);
163 if(FAILED(hr
)) goto fail
;
168 if(read
== 0) done
= 1;
170 while(!done
&& (end
= strstr(buf
+ last_end
, "\r\n")))
172 DWORD new_end
= end
- buf
+ 2;
173 if(new_end
- last_end
== 2)
176 off
.QuadPart
= new_end
;
177 IStream_Seek(stm
, off
, STREAM_SEEK_SET
, NULL
);
190 HeapFree(GetProcessHeap(), 0, buf
);
194 static header_t
*read_prop(MimeBody
*body
, char **ptr
)
196 char *colon
= strchr(*ptr
, ':');
197 const property_t
*prop
;
200 if(!colon
) return NULL
;
204 for(prop
= default_props
; prop
->name
; prop
++)
206 if(!strcasecmp(*ptr
, prop
->name
))
208 TRACE("%s: found match with default property id %d\n", *ptr
, prop
->id
);
215 property_list_entry_t
*prop_entry
;
216 LIST_FOR_EACH_ENTRY(prop_entry
, &body
->new_props
, property_list_entry_t
, entry
)
218 if(!strcasecmp(*ptr
, prop_entry
->prop
.name
))
220 TRACE("%s: found match with already added new property id %d\n", *ptr
, prop_entry
->prop
.id
);
221 prop
= &prop_entry
->prop
;
227 prop_entry
= HeapAlloc(GetProcessHeap(), 0, sizeof(*prop_entry
));
228 prop_entry
->prop
.name
= strdupA(*ptr
);
229 prop_entry
->prop
.id
= body
->next_prop_id
++;
230 prop_entry
->prop
.flags
= 0;
231 prop_entry
->prop
.default_vt
= VT_LPSTR
;
232 list_add_tail(&body
->new_props
, &prop_entry
->entry
);
233 prop
= &prop_entry
->prop
;
234 TRACE("%s: allocating new prop id %d\n", *ptr
, prop_entry
->prop
.id
);
238 ret
= HeapAlloc(GetProcessHeap(), 0, sizeof(*ret
));
240 PropVariantInit(&ret
->value
);
241 list_init(&ret
->params
);
247 static void unfold_header(char *header
, int len
)
249 char *start
= header
, *cp
= header
;
252 while(*cp
== ' ' || *cp
== '\t')
258 memmove(start
, cp
, len
+ 1);
260 cp
= strstr(start
, "\r\n");
267 } while(*cp
== ' ' || *cp
== '\t');
272 static char *unquote_string(const char *str
)
277 while(*str
== ' ' || *str
== '\t') str
++;
285 for(cp
= ret
; *cp
; cp
++)
288 memmove(cp
, cp
+ 1, strlen(cp
+ 1) + 1);
293 WARN("quote in unquoted string\n");
305 static void add_param(header_t
*header
, const char *p
)
307 const char *key
= p
, *value
, *cp
= p
;
311 TRACE("got param %s\n", p
);
313 while (*key
== ' ' || *key
== '\t' ) key
++;
315 cp
= strchr(key
, '=');
318 WARN("malformed parameter - skipping\n");
322 name
= HeapAlloc(GetProcessHeap(), 0, cp
- key
+ 1);
323 memcpy(name
, key
, cp
- key
);
324 name
[cp
- key
] = '\0';
328 param
= HeapAlloc(GetProcessHeap(), 0, sizeof(*param
));
330 param
->value
= unquote_string(value
);
331 list_add_tail(&header
->params
, ¶m
->entry
);
334 static void split_params(header_t
*header
, char *value
)
336 char *cp
= value
, *start
= value
;
342 if(!in_quote
&& *cp
== ';')
345 if(done_value
) add_param(header
, start
);
350 in_quote
= !in_quote
;
353 if(done_value
) add_param(header
, start
);
356 static void read_value(header_t
*header
, char **cur
)
358 char *end
= *cur
, *value
;
362 end
= strstr(end
, "\r\n");
364 } while(*end
== ' ' || *end
== '\t');
367 value
= HeapAlloc(GetProcessHeap(), 0, len
+ 1);
368 memcpy(value
, *cur
, len
);
371 unfold_header(value
, len
);
372 TRACE("value %s\n", debugstr_a(value
));
374 if(header
->prop
->flags
& MPF_HASPARAMS
)
376 split_params(header
, value
);
377 TRACE("value w/o params %s\n", debugstr_a(value
));
380 header
->value
.vt
= VT_LPSTR
;
381 header
->value
.u
.pszVal
= value
;
386 static void init_content_type(MimeBody
*body
, header_t
*header
)
391 if(header
->prop
->id
!= PID_HDR_CNTTYPE
)
393 ERR("called with header %s\n", header
->prop
->name
);
397 slash
= strchr(header
->value
.u
.pszVal
, '/');
400 WARN("malformed context type value\n");
403 len
= slash
- header
->value
.u
.pszVal
;
404 body
->content_pri_type
= HeapAlloc(GetProcessHeap(), 0, len
+ 1);
405 memcpy(body
->content_pri_type
, header
->value
.u
.pszVal
, len
);
406 body
->content_pri_type
[len
] = '\0';
407 body
->content_sub_type
= strdupA(slash
+ 1);
410 static HRESULT
parse_headers(MimeBody
*body
, IStream
*stm
)
412 char *header_buf
, *cur_header_ptr
;
416 hr
= copy_headers_to_buf(stm
, &header_buf
);
417 if(FAILED(hr
)) return hr
;
419 cur_header_ptr
= header_buf
;
420 while((header
= read_prop(body
, &cur_header_ptr
)))
422 read_value(header
, &cur_header_ptr
);
423 list_add_tail(&body
->headers
, &header
->entry
);
425 if(header
->prop
->id
== PID_HDR_CNTTYPE
)
426 init_content_type(body
, header
);
429 HeapFree(GetProcessHeap(), 0, header_buf
);
433 static void empty_param_list(struct list
*list
)
435 param_t
*param
, *cursor2
;
437 LIST_FOR_EACH_ENTRY_SAFE(param
, cursor2
, list
, param_t
, entry
)
439 list_remove(¶m
->entry
);
440 HeapFree(GetProcessHeap(), 0, param
->name
);
441 HeapFree(GetProcessHeap(), 0, param
->value
);
442 HeapFree(GetProcessHeap(), 0, param
);
446 static void empty_header_list(struct list
*list
)
448 header_t
*header
, *cursor2
;
450 LIST_FOR_EACH_ENTRY_SAFE(header
, cursor2
, list
, header_t
, entry
)
452 list_remove(&header
->entry
);
453 PropVariantClear(&header
->value
);
454 empty_param_list(&header
->params
);
455 HeapFree(GetProcessHeap(), 0, header
);
459 static void empty_new_prop_list(struct list
*list
)
461 property_list_entry_t
*prop
, *cursor2
;
463 LIST_FOR_EACH_ENTRY_SAFE(prop
, cursor2
, list
, property_list_entry_t
, entry
)
465 list_remove(&prop
->entry
);
466 HeapFree(GetProcessHeap(), 0, (char *)prop
->prop
.name
);
467 HeapFree(GetProcessHeap(), 0, prop
);
471 static void release_data(REFIID riid
, void *data
)
475 if(IsEqualIID(riid
, &IID_IStream
))
476 IStream_Release((IStream
*)data
);
478 FIXME("Unhandled data format %s\n", debugstr_guid(riid
));
481 static HRESULT
find_prop(MimeBody
*body
, const char *name
, header_t
**prop
)
487 LIST_FOR_EACH_ENTRY(header
, &body
->headers
, header_t
, entry
)
489 if(!strcasecmp(name
, header
->prop
->name
))
496 return MIME_E_NOT_FOUND
;
499 static HRESULT WINAPI
MimeBody_QueryInterface(IMimeBody
* iface
,
503 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ppvObject
);
507 if (IsEqualIID(riid
, &IID_IUnknown
) ||
508 IsEqualIID(riid
, &IID_IPersist
) ||
509 IsEqualIID(riid
, &IID_IPersistStreamInit
) ||
510 IsEqualIID(riid
, &IID_IMimePropertySet
) ||
511 IsEqualIID(riid
, &IID_IMimeBody
))
518 IUnknown_AddRef((IUnknown
*)*ppvObject
);
522 FIXME("no interface for %s\n", debugstr_guid(riid
));
523 return E_NOINTERFACE
;
526 static ULONG WINAPI
MimeBody_AddRef(IMimeBody
* iface
)
528 MimeBody
*This
= impl_from_IMimeBody(iface
);
529 TRACE("(%p)->()\n", iface
);
530 return InterlockedIncrement(&This
->refs
);
533 static ULONG WINAPI
MimeBody_Release(IMimeBody
* iface
)
535 MimeBody
*This
= impl_from_IMimeBody(iface
);
538 TRACE("(%p)->()\n", iface
);
540 refs
= InterlockedDecrement(&This
->refs
);
543 empty_header_list(&This
->headers
);
544 empty_new_prop_list(&This
->new_props
);
546 HeapFree(GetProcessHeap(), 0, This
->content_pri_type
);
547 HeapFree(GetProcessHeap(), 0, This
->content_sub_type
);
549 release_data(&This
->data_iid
, This
->data
);
551 HeapFree(GetProcessHeap(), 0, This
);
557 static HRESULT WINAPI
MimeBody_GetClassID(
566 static HRESULT WINAPI
MimeBody_IsDirty(
573 static HRESULT WINAPI
MimeBody_Load(
577 MimeBody
*This
= impl_from_IMimeBody(iface
);
578 TRACE("(%p)->(%p)\n", iface
, pStm
);
579 return parse_headers(This
, pStm
);
582 static HRESULT WINAPI
MimeBody_Save(
591 static HRESULT WINAPI
MimeBody_GetSizeMax(
593 ULARGE_INTEGER
* pcbSize
)
599 static HRESULT WINAPI
MimeBody_InitNew(
602 TRACE("%p->()\n", iface
);
606 static HRESULT WINAPI
MimeBody_GetPropInfo(
609 LPMIMEPROPINFO pInfo
)
615 static HRESULT WINAPI
MimeBody_SetPropInfo(
618 LPCMIMEPROPINFO pInfo
)
624 static HRESULT WINAPI
MimeBody_GetProp(
628 LPPROPVARIANT pValue
)
634 static HRESULT WINAPI
MimeBody_SetProp(
638 LPCPROPVARIANT pValue
)
644 static HRESULT WINAPI
MimeBody_AppendProp(
648 LPPROPVARIANT pValue
)
654 static HRESULT WINAPI
MimeBody_DeleteProp(
662 static HRESULT WINAPI
MimeBody_CopyProps(
666 IMimePropertySet
* pPropertySet
)
672 static HRESULT WINAPI
MimeBody_MoveProps(
676 IMimePropertySet
* pPropertySet
)
682 static HRESULT WINAPI
MimeBody_DeleteExcept(
691 static HRESULT WINAPI
MimeBody_QueryProp(
696 boolean fCaseSensitive
)
702 static HRESULT WINAPI
MimeBody_GetCharset(
704 LPHCHARSET phCharset
)
710 static HRESULT WINAPI
MimeBody_SetCharset(
713 CSETAPPLYTYPE applytype
)
719 static HRESULT WINAPI
MimeBody_GetParameters(
723 LPMIMEPARAMINFO
* pprgParam
)
725 MimeBody
*This
= impl_from_IMimeBody(iface
);
729 TRACE("(%p)->(%s, %p, %p)\n", iface
, debugstr_a(pszName
), pcParams
, pprgParam
);
734 hr
= find_prop(This
, pszName
, &header
);
735 if(hr
!= S_OK
) return hr
;
737 *pcParams
= list_count(&header
->params
);
740 IMimeAllocator
*alloc
;
744 MimeOleGetAllocator(&alloc
);
746 *pprgParam
= info
= IMimeAllocator_Alloc(alloc
, *pcParams
* sizeof(**pprgParam
));
747 LIST_FOR_EACH_ENTRY(param
, &header
->params
, param_t
, entry
)
751 len
= strlen(param
->name
) + 1;
752 info
->pszName
= IMimeAllocator_Alloc(alloc
, len
);
753 memcpy(info
->pszName
, param
->name
, len
);
754 len
= strlen(param
->value
) + 1;
755 info
->pszData
= IMimeAllocator_Alloc(alloc
, len
);
756 memcpy(info
->pszData
, param
->value
, len
);
759 IMimeAllocator_Release(alloc
);
764 static HRESULT WINAPI
MimeBody_IsContentType(
769 MimeBody
*This
= impl_from_IMimeBody(iface
);
771 TRACE("(%p)->(%s, %s)\n", This
, debugstr_a(pszPriType
), debugstr_a(pszSubType
));
774 const char *pri
= This
->content_pri_type
;
775 if(!pri
) pri
= "text";
776 if(strcasecmp(pri
, pszPriType
)) return S_FALSE
;
781 const char *sub
= This
->content_sub_type
;
782 if(!sub
) sub
= "plain";
783 if(strcasecmp(sub
, pszSubType
)) return S_FALSE
;
789 static HRESULT WINAPI
MimeBody_BindToObject(
798 static HRESULT WINAPI
MimeBody_Clone(
800 IMimePropertySet
** ppPropertySet
)
806 static HRESULT WINAPI
MimeBody_SetOption(
809 LPCPROPVARIANT pValue
)
815 static HRESULT WINAPI
MimeBody_GetOption(
818 LPPROPVARIANT pValue
)
824 static HRESULT WINAPI
MimeBody_EnumProps(
827 IMimeEnumProperties
** ppEnum
)
833 static HRESULT WINAPI
MimeBody_IsType(
835 IMSGBODYTYPE bodytype
)
841 static HRESULT WINAPI
MimeBody_SetDisplayName(
849 static HRESULT WINAPI
MimeBody_GetDisplayName(
857 static HRESULT WINAPI
MimeBody_GetOffsets(
859 LPBODYOFFSETS pOffsets
)
861 MimeBody
*This
= impl_from_IMimeBody(iface
);
862 TRACE("(%p)->(%p)\n", This
, pOffsets
);
864 *pOffsets
= This
->body_offsets
;
866 if(This
->body_offsets
.cbBodyEnd
== 0) return MIME_E_NO_DATA
;
870 static HRESULT WINAPI
MimeBody_GetCurrentEncoding(
872 ENCODINGTYPE
* pietEncoding
)
874 MimeBody
*This
= impl_from_IMimeBody(iface
);
876 TRACE("(%p)->(%p)\n", This
, pietEncoding
);
878 *pietEncoding
= This
->encoding
;
882 static HRESULT WINAPI
MimeBody_SetCurrentEncoding(
884 ENCODINGTYPE ietEncoding
)
886 MimeBody
*This
= impl_from_IMimeBody(iface
);
888 TRACE("(%p)->(%d)\n", This
, ietEncoding
);
890 This
->encoding
= ietEncoding
;
894 static HRESULT WINAPI
MimeBody_GetEstimatedSize(
896 ENCODINGTYPE ietEncoding
,
903 static HRESULT WINAPI
MimeBody_GetDataHere(
905 ENCODINGTYPE ietEncoding
,
912 static HRESULT WINAPI
MimeBody_GetData(
914 ENCODINGTYPE ietEncoding
,
917 MimeBody
*This
= impl_from_IMimeBody(iface
);
918 FIXME("(%p)->(%d, %p). Ignoring encoding type.\n", This
, ietEncoding
, ppStream
);
920 *ppStream
= This
->data
;
921 IStream_AddRef(*ppStream
);
925 static HRESULT WINAPI
MimeBody_SetData(
927 ENCODINGTYPE ietEncoding
,
933 MimeBody
*This
= impl_from_IMimeBody(iface
);
934 TRACE("(%p)->(%d, %s, %s, %s %p)\n", This
, ietEncoding
, debugstr_a(pszPriType
), debugstr_a(pszSubType
),
935 debugstr_guid(riid
), pvObject
);
937 if(IsEqualIID(riid
, &IID_IStream
))
938 IStream_AddRef((IStream
*)pvObject
);
941 FIXME("Unhandled object type %s\n", debugstr_guid(riid
));
946 FIXME("release old data\n");
948 This
->data_iid
= *riid
;
949 This
->data
= pvObject
;
951 IMimeBody_SetCurrentEncoding(iface
, ietEncoding
);
953 /* FIXME: Update the content type.
954 If pszPriType == NULL use 'application'
955 If pszSubType == NULL use 'octet-stream' */
960 static HRESULT WINAPI
MimeBody_EmptyData(
967 static HRESULT WINAPI
MimeBody_CopyTo(
975 static HRESULT WINAPI
MimeBody_GetTransmitInfo(
977 LPTRANSMITINFO pTransmitInfo
)
983 static HRESULT WINAPI
MimeBody_SaveToFile(
985 ENCODINGTYPE ietEncoding
,
992 static HRESULT WINAPI
MimeBody_GetHandle(
996 MimeBody
*This
= impl_from_IMimeBody(iface
);
997 TRACE("(%p)->(%p)\n", iface
, phBody
);
999 *phBody
= This
->handle
;
1000 return This
->handle
? S_OK
: MIME_E_NO_DATA
;
1003 static IMimeBodyVtbl body_vtbl
=
1005 MimeBody_QueryInterface
,
1008 MimeBody_GetClassID
,
1012 MimeBody_GetSizeMax
,
1014 MimeBody_GetPropInfo
,
1015 MimeBody_SetPropInfo
,
1018 MimeBody_AppendProp
,
1019 MimeBody_DeleteProp
,
1022 MimeBody_DeleteExcept
,
1024 MimeBody_GetCharset
,
1025 MimeBody_SetCharset
,
1026 MimeBody_GetParameters
,
1027 MimeBody_IsContentType
,
1028 MimeBody_BindToObject
,
1034 MimeBody_SetDisplayName
,
1035 MimeBody_GetDisplayName
,
1036 MimeBody_GetOffsets
,
1037 MimeBody_GetCurrentEncoding
,
1038 MimeBody_SetCurrentEncoding
,
1039 MimeBody_GetEstimatedSize
,
1040 MimeBody_GetDataHere
,
1045 MimeBody_GetTransmitInfo
,
1046 MimeBody_SaveToFile
,
1050 static HRESULT
MimeBody_set_offsets(MimeBody
*body
, const BODYOFFSETS
*offsets
)
1052 TRACE("setting offsets to %d, %d, %d, %d\n", offsets
->cbBoundaryStart
,
1053 offsets
->cbHeaderStart
, offsets
->cbBodyStart
, offsets
->cbBodyEnd
);
1055 body
->body_offsets
= *offsets
;
1059 #define FIRST_CUSTOM_PROP_ID 0x100
1061 HRESULT
MimeBody_create(IUnknown
*outer
, void **obj
)
1064 BODYOFFSETS body_offsets
;
1068 if(outer
) return CLASS_E_NOAGGREGATION
;
1070 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
1071 if (!This
) return E_OUTOFMEMORY
;
1073 This
->lpVtbl
= &body_vtbl
;
1075 This
->handle
= NULL
;
1076 list_init(&This
->headers
);
1077 list_init(&This
->new_props
);
1078 This
->next_prop_id
= FIRST_CUSTOM_PROP_ID
;
1079 This
->content_pri_type
= NULL
;
1080 This
->content_sub_type
= NULL
;
1081 This
->encoding
= IET_7BIT
;
1083 This
->data_iid
= IID_NULL
;
1085 body_offsets
.cbBoundaryStart
= body_offsets
.cbHeaderStart
= 0;
1086 body_offsets
.cbBodyStart
= body_offsets
.cbBodyEnd
= 0;
1087 MimeBody_set_offsets(This
, &body_offsets
);
1089 *obj
= (IMimeBody
*)&This
->lpVtbl
;
1095 IStreamVtbl
*lpVtbl
;
1099 ULARGE_INTEGER pos
, start
, length
;
1102 static inline sub_stream_t
*impl_from_IStream( IStream
*iface
)
1104 return (sub_stream_t
*)((char*)iface
- FIELD_OFFSET(sub_stream_t
, lpVtbl
));
1107 static HRESULT WINAPI
sub_stream_QueryInterface(
1112 sub_stream_t
*This
= impl_from_IStream(iface
);
1114 TRACE("(%p)->(%s, %p)\n", This
, debugstr_guid(riid
), ppvObject
);
1117 if(IsEqualIID(riid
, &IID_IUnknown
) ||
1118 IsEqualIID(riid
, &IID_ISequentialStream
) ||
1119 IsEqualIID(riid
, &IID_IStream
))
1121 IStream_AddRef(iface
);
1125 return E_NOINTERFACE
;
1128 static ULONG WINAPI
sub_stream_AddRef(
1131 sub_stream_t
*This
= impl_from_IStream(iface
);
1133 TRACE("(%p)\n", This
);
1134 return InterlockedIncrement(&This
->refs
);
1137 static ULONG WINAPI
sub_stream_Release(
1140 sub_stream_t
*This
= impl_from_IStream(iface
);
1143 TRACE("(%p)\n", This
);
1144 refs
= InterlockedDecrement(&This
->refs
);
1147 IStream_Release(This
->base
);
1148 HeapFree(GetProcessHeap(), 0, This
);
1153 static HRESULT WINAPI
sub_stream_Read(
1159 sub_stream_t
*This
= impl_from_IStream(iface
);
1161 ULARGE_INTEGER base_pos
;
1162 LARGE_INTEGER tmp_pos
;
1164 TRACE("(%p, %d, %p)\n", pv
, cb
, pcbRead
);
1166 tmp_pos
.QuadPart
= 0;
1167 IStream_Seek(This
->base
, tmp_pos
, STREAM_SEEK_CUR
, &base_pos
);
1168 tmp_pos
.QuadPart
= This
->pos
.QuadPart
+ This
->start
.QuadPart
;
1169 IStream_Seek(This
->base
, tmp_pos
, STREAM_SEEK_SET
, NULL
);
1171 if(This
->pos
.QuadPart
+ cb
> This
->length
.QuadPart
)
1172 cb
= This
->length
.QuadPart
- This
->pos
.QuadPart
;
1174 hr
= IStream_Read(This
->base
, pv
, cb
, pcbRead
);
1176 This
->pos
.QuadPart
+= *pcbRead
;
1178 tmp_pos
.QuadPart
= base_pos
.QuadPart
;
1179 IStream_Seek(This
->base
, tmp_pos
, STREAM_SEEK_SET
, NULL
);
1184 static HRESULT WINAPI
sub_stream_Write(
1194 static HRESULT WINAPI
sub_stream_Seek(
1196 LARGE_INTEGER dlibMove
,
1198 ULARGE_INTEGER
*plibNewPosition
)
1200 sub_stream_t
*This
= impl_from_IStream(iface
);
1201 LARGE_INTEGER new_pos
;
1203 TRACE("(%08x.%08x, %x, %p)\n", dlibMove
.u
.HighPart
, dlibMove
.u
.LowPart
, dwOrigin
, plibNewPosition
);
1207 case STREAM_SEEK_SET
:
1210 case STREAM_SEEK_CUR
:
1211 new_pos
.QuadPart
= This
->pos
.QuadPart
+ dlibMove
.QuadPart
;
1213 case STREAM_SEEK_END
:
1214 new_pos
.QuadPart
= This
->length
.QuadPart
+ dlibMove
.QuadPart
;
1218 if(new_pos
.QuadPart
< 0) new_pos
.QuadPart
= 0;
1219 else if(new_pos
.QuadPart
> This
->length
.QuadPart
) new_pos
.QuadPart
= This
->length
.QuadPart
;
1221 This
->pos
.QuadPart
= new_pos
.QuadPart
;
1223 if(plibNewPosition
) *plibNewPosition
= This
->pos
;
1227 static HRESULT WINAPI
sub_stream_SetSize(
1229 ULARGE_INTEGER libNewSize
)
1235 static HRESULT WINAPI
sub_stream_CopyTo(
1239 ULARGE_INTEGER
*pcbRead
,
1240 ULARGE_INTEGER
*pcbWritten
)
1246 static HRESULT WINAPI
sub_stream_Commit(
1248 DWORD grfCommitFlags
)
1254 static HRESULT WINAPI
sub_stream_Revert(
1261 static HRESULT WINAPI
sub_stream_LockRegion(
1263 ULARGE_INTEGER libOffset
,
1271 static HRESULT WINAPI
sub_stream_UnlockRegion(
1273 ULARGE_INTEGER libOffset
,
1281 static HRESULT WINAPI
sub_stream_Stat(
1286 sub_stream_t
*This
= impl_from_IStream(iface
);
1287 FIXME("(%p)->(%p, %08x)\n", This
, pstatstg
, grfStatFlag
);
1288 memset(pstatstg
, 0, sizeof(*pstatstg
));
1289 pstatstg
->cbSize
= This
->length
;
1293 static HRESULT WINAPI
sub_stream_Clone(
1301 static struct IStreamVtbl sub_stream_vtbl
=
1303 sub_stream_QueryInterface
,
1313 sub_stream_LockRegion
,
1314 sub_stream_UnlockRegion
,
1319 static HRESULT
create_sub_stream(IStream
*stream
, ULARGE_INTEGER start
, ULARGE_INTEGER length
, IStream
**out
)
1324 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
1325 if(!This
) return E_OUTOFMEMORY
;
1327 This
->lpVtbl
= &sub_stream_vtbl
;
1329 This
->start
= start
;
1330 This
->length
= length
;
1331 This
->pos
.QuadPart
= 0;
1332 IStream_AddRef(stream
);
1333 This
->base
= stream
;
1335 *out
= (IStream
*)&This
->lpVtbl
;
1340 typedef struct body_t
1344 IMimeBody
*mime_body
;
1346 struct body_t
*parent
;
1347 struct list children
;
1350 typedef struct MimeMessage
1352 const IMimeMessageVtbl
*lpVtbl
;
1357 struct list body_tree
;
1361 static HRESULT WINAPI
MimeMessage_QueryInterface(IMimeMessage
*iface
, REFIID riid
, void **ppv
)
1363 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ppv
);
1365 if (IsEqualIID(riid
, &IID_IUnknown
) ||
1366 IsEqualIID(riid
, &IID_IPersist
) ||
1367 IsEqualIID(riid
, &IID_IPersistStreamInit
) ||
1368 IsEqualIID(riid
, &IID_IMimeMessageTree
) ||
1369 IsEqualIID(riid
, &IID_IMimeMessage
))
1372 IUnknown_AddRef(iface
);
1376 FIXME("no interface for %s\n", debugstr_guid(riid
));
1378 return E_NOINTERFACE
;
1381 static ULONG WINAPI
MimeMessage_AddRef(IMimeMessage
*iface
)
1383 MimeMessage
*This
= (MimeMessage
*)iface
;
1384 TRACE("(%p)->()\n", iface
);
1385 return InterlockedIncrement(&This
->refs
);
1388 static void empty_body_list(struct list
*list
)
1390 body_t
*body
, *cursor2
;
1391 LIST_FOR_EACH_ENTRY_SAFE(body
, cursor2
, list
, body_t
, entry
)
1393 empty_body_list(&body
->children
);
1394 list_remove(&body
->entry
);
1395 IMimeBody_Release(body
->mime_body
);
1396 HeapFree(GetProcessHeap(), 0, body
);
1400 static ULONG WINAPI
MimeMessage_Release(IMimeMessage
*iface
)
1402 MimeMessage
*This
= (MimeMessage
*)iface
;
1405 TRACE("(%p)->()\n", iface
);
1407 refs
= InterlockedDecrement(&This
->refs
);
1410 empty_body_list(&This
->body_tree
);
1412 if(This
->stream
) IStream_Release(This
->stream
);
1413 HeapFree(GetProcessHeap(), 0, This
);
1419 /*** IPersist methods ***/
1420 static HRESULT WINAPI
MimeMessage_GetClassID(
1421 IMimeMessage
*iface
,
1424 FIXME("(%p)->(%p)\n", iface
, pClassID
);
1428 /*** IPersistStreamInit methods ***/
1429 static HRESULT WINAPI
MimeMessage_IsDirty(
1430 IMimeMessage
*iface
)
1432 FIXME("(%p)->()\n", iface
);
1436 static body_t
*new_body_entry(IMimeBody
*mime_body
, HBODY hbody
, body_t
*parent
)
1438 body_t
*body
= HeapAlloc(GetProcessHeap(), 0, sizeof(*body
));
1441 body
->mime_body
= mime_body
;
1442 body
->hbody
= hbody
;
1443 list_init(&body
->children
);
1444 body
->parent
= parent
;
1452 BODYOFFSETS offsets
;
1455 static HRESULT
create_body_offset_list(IStream
*stm
, const char *boundary
, struct list
*body_offsets
)
1459 int boundary_len
= strlen(boundary
);
1460 char *buf
, *nl_boundary
, *ptr
, *overlap
;
1461 DWORD total_read
= 0;
1462 DWORD start
= 0, overlap_no
;
1463 offset_entry_t
*cur_body
= NULL
;
1467 list_init(body_offsets
);
1468 nl_boundary
= HeapAlloc(GetProcessHeap(), 0, 4 + boundary_len
+ 1);
1469 memcpy(nl_boundary
, "\r\n--", 4);
1470 memcpy(nl_boundary
+ 4, boundary
, boundary_len
+ 1);
1472 overlap_no
= boundary_len
+ 5;
1474 overlap
= buf
= HeapAlloc(GetProcessHeap(), 0, overlap_no
+ PARSER_BUF_SIZE
+ 1);
1477 hr
= IStream_Seek(stm
, zero
, STREAM_SEEK_CUR
, &cur
);
1478 start
= cur
.LowPart
;
1481 hr
= IStream_Read(stm
, overlap
, PARSER_BUF_SIZE
, &read
);
1482 if(FAILED(hr
)) goto end
;
1483 if(read
== 0) break;
1485 overlap
[read
] = '\0';
1489 ptr
= strstr(ptr
, nl_boundary
);
1492 DWORD boundary_start
= start
+ ptr
- buf
;
1493 char *end
= ptr
+ boundary_len
+ 4;
1495 if(*end
== '\0' || *(end
+ 1) == '\0')
1498 if(*end
== '\r' && *(end
+ 1) == '\n')
1502 cur_body
->offsets
.cbBodyEnd
= boundary_start
;
1503 list_add_tail(body_offsets
, &cur_body
->entry
);
1505 cur_body
= HeapAlloc(GetProcessHeap(), 0, sizeof(*cur_body
));
1506 cur_body
->offsets
.cbBoundaryStart
= boundary_start
+ 2; /* doesn't including the leading \r\n */
1507 cur_body
->offsets
.cbHeaderStart
= boundary_start
+ boundary_len
+ 6;
1509 else if(*end
== '-' && *(end
+ 1) == '-')
1513 cur_body
->offsets
.cbBodyEnd
= boundary_start
;
1514 list_add_tail(body_offsets
, &cur_body
->entry
);
1522 if(overlap
== buf
) /* 1st iteration */
1524 memcpy(buf
, buf
+ PARSER_BUF_SIZE
- overlap_no
, overlap_no
);
1525 overlap
= buf
+ overlap_no
;
1526 start
+= read
- overlap_no
;
1530 memcpy(buf
, buf
+ PARSER_BUF_SIZE
, overlap_no
);
1536 HeapFree(GetProcessHeap(), 0, buf
);
1540 static body_t
*create_sub_body(MimeMessage
*msg
, IStream
*pStm
, BODYOFFSETS
*offset
, body_t
*parent
)
1542 IMimeBody
*mime_body
;
1548 MimeBody_create(NULL
, (void**)&mime_body
);
1549 IMimeBody_Load(mime_body
, pStm
);
1551 hr
= IStream_Seek(pStm
, zero
, STREAM_SEEK_CUR
, &cur
);
1552 offset
->cbBodyStart
= cur
.LowPart
+ offset
->cbHeaderStart
;
1553 if(parent
) MimeBody_set_offsets(impl_from_IMimeBody(mime_body
), offset
);
1554 IMimeBody_SetData(mime_body
, IET_BINARY
, NULL
, NULL
, &IID_IStream
, pStm
);
1555 body
= new_body_entry(mime_body
, msg
->next_hbody
, parent
);
1556 msg
->next_hbody
= (HBODY
)((DWORD
)msg
->next_hbody
+ 1);
1558 if(IMimeBody_IsContentType(mime_body
, "multipart", NULL
) == S_OK
)
1560 MIMEPARAMINFO
*param_info
;
1562 IMimeAllocator
*alloc
;
1564 hr
= IMimeBody_GetParameters(mime_body
, "Content-Type", &count
, ¶m_info
);
1565 if(hr
!= S_OK
|| count
== 0) return body
;
1567 MimeOleGetAllocator(&alloc
);
1569 for(i
= 0; i
< count
; i
++)
1571 if(!strcasecmp(param_info
[i
].pszName
, "boundary"))
1573 struct list offset_list
;
1574 offset_entry_t
*cur
, *cursor2
;
1575 hr
= create_body_offset_list(pStm
, param_info
[i
].pszData
, &offset_list
);
1576 LIST_FOR_EACH_ENTRY_SAFE(cur
, cursor2
, &offset_list
, offset_entry_t
, entry
)
1579 IStream
*sub_stream
;
1580 ULARGE_INTEGER start
, length
;
1582 start
.LowPart
= cur
->offsets
.cbHeaderStart
;
1583 length
.LowPart
= cur
->offsets
.cbBodyEnd
- cur
->offsets
.cbHeaderStart
;
1584 create_sub_stream(pStm
, start
, length
, &sub_stream
);
1585 sub_body
= create_sub_body(msg
, sub_stream
, &cur
->offsets
, body
);
1586 IStream_Release(sub_stream
);
1587 list_add_tail(&body
->children
, &sub_body
->entry
);
1588 list_remove(&cur
->entry
);
1589 HeapFree(GetProcessHeap(), 0, cur
);
1594 IMimeAllocator_FreeParamInfoArray(alloc
, count
, param_info
, TRUE
);
1595 IMimeAllocator_Release(alloc
);
1600 static HRESULT WINAPI
MimeMessage_Load(
1601 IMimeMessage
*iface
,
1604 MimeMessage
*This
= (MimeMessage
*)iface
;
1606 BODYOFFSETS offsets
;
1610 TRACE("(%p)->(%p)\n", iface
, pStm
);
1614 FIXME("already loaded a message\n");
1618 IStream_AddRef(pStm
);
1619 This
->stream
= pStm
;
1620 offsets
.cbBoundaryStart
= offsets
.cbHeaderStart
= 0;
1621 offsets
.cbBodyStart
= offsets
.cbBodyEnd
= 0;
1623 root_body
= create_sub_body(This
, pStm
, &offsets
, NULL
);
1626 IStream_Seek(pStm
, zero
, STREAM_SEEK_END
, &cur
);
1627 offsets
.cbBodyEnd
= cur
.LowPart
;
1628 MimeBody_set_offsets(impl_from_IMimeBody(root_body
->mime_body
), &offsets
);
1630 list_add_head(&This
->body_tree
, &root_body
->entry
);
1635 static HRESULT WINAPI
MimeMessage_Save(
1636 IMimeMessage
*iface
,
1640 FIXME("(%p)->(%p, %s)\n", iface
, pStm
, fClearDirty
? "TRUE" : "FALSE");
1644 static HRESULT WINAPI
MimeMessage_GetSizeMax(
1645 IMimeMessage
*iface
,
1646 ULARGE_INTEGER
*pcbSize
)
1648 FIXME("(%p)->(%p)\n", iface
, pcbSize
);
1652 static HRESULT WINAPI
MimeMessage_InitNew(
1653 IMimeMessage
*iface
)
1655 FIXME("(%p)->()\n", iface
);
1659 /*** IMimeMessageTree methods ***/
1660 static HRESULT WINAPI
MimeMessage_GetMessageSource(
1661 IMimeMessage
*iface
,
1665 FIXME("(%p)->(%p, 0x%x)\n", iface
, ppStream
, dwFlags
);
1669 static HRESULT WINAPI
MimeMessage_GetMessageSize(
1670 IMimeMessage
*iface
,
1674 FIXME("(%p)->(%p, 0x%x)\n", iface
, pcbSize
, dwFlags
);
1678 static HRESULT WINAPI
MimeMessage_LoadOffsetTable(
1679 IMimeMessage
*iface
,
1682 FIXME("(%p)->(%p)\n", iface
, pStream
);
1686 static HRESULT WINAPI
MimeMessage_SaveOffsetTable(
1687 IMimeMessage
*iface
,
1691 FIXME("(%p)->(%p, 0x%x)\n", iface
, pStream
, dwFlags
);
1696 static HRESULT WINAPI
MimeMessage_GetFlags(
1697 IMimeMessage
*iface
,
1700 FIXME("(%p)->(%p)\n", iface
, pdwFlags
);
1704 static HRESULT WINAPI
MimeMessage_Commit(
1705 IMimeMessage
*iface
,
1708 FIXME("(%p)->(0x%x)\n", iface
, dwFlags
);
1713 static HRESULT WINAPI
MimeMessage_HandsOffStorage(
1714 IMimeMessage
*iface
)
1716 FIXME("(%p)->()\n", iface
);
1720 static HRESULT
find_body(struct list
*list
, HBODY hbody
, body_t
**body
)
1725 if(hbody
== HBODY_ROOT
)
1727 *body
= LIST_ENTRY(list_head(list
), body_t
, entry
);
1731 LIST_FOR_EACH_ENTRY(cur
, list
, body_t
, entry
)
1733 if(cur
->hbody
== hbody
)
1738 hr
= find_body(&cur
->children
, hbody
, body
);
1739 if(hr
== S_OK
) return S_OK
;
1744 static HRESULT WINAPI
MimeMessage_BindToObject(
1745 IMimeMessage
*iface
,
1750 MimeMessage
*This
= (MimeMessage
*)iface
;
1754 TRACE("(%p)->(%p, %s, %p)\n", iface
, hBody
, debugstr_guid(riid
), ppvObject
);
1756 hr
= find_body(&This
->body_tree
, hBody
, &body
);
1758 if(hr
!= S_OK
) return hr
;
1760 if(IsEqualIID(riid
, &IID_IMimeBody
))
1762 IMimeBody_AddRef(body
->mime_body
);
1763 *ppvObject
= body
->mime_body
;
1767 return E_NOINTERFACE
;
1770 static HRESULT WINAPI
MimeMessage_SaveBody(
1771 IMimeMessage
*iface
,
1776 FIXME("(%p)->(%p, 0x%x, %p)\n", iface
, hBody
, dwFlags
, pStream
);
1780 static HRESULT
get_body(MimeMessage
*msg
, BODYLOCATION location
, HBODY pivot
, body_t
**out
)
1782 body_t
*root
= LIST_ENTRY(list_head(&msg
->body_tree
), body_t
, entry
);
1787 if(location
== IBL_ROOT
)
1793 hr
= find_body(&msg
->body_tree
, pivot
, &body
);
1800 *out
= body
->parent
;
1804 list
= list_head(&body
->children
);
1806 *out
= LIST_ENTRY(list
, body_t
, entry
);
1808 hr
= MIME_E_NOT_FOUND
;
1812 list
= list_tail(&body
->children
);
1814 *out
= LIST_ENTRY(list
, body_t
, entry
);
1816 hr
= MIME_E_NOT_FOUND
;
1820 list
= list_next(&body
->parent
->children
, &body
->entry
);
1822 *out
= LIST_ENTRY(list
, body_t
, entry
);
1824 hr
= MIME_E_NOT_FOUND
;
1828 list
= list_prev(&body
->parent
->children
, &body
->entry
);
1830 *out
= LIST_ENTRY(list
, body_t
, entry
);
1832 hr
= MIME_E_NOT_FOUND
;
1845 static HRESULT WINAPI
MimeMessage_InsertBody(
1846 IMimeMessage
*iface
,
1847 BODYLOCATION location
,
1851 FIXME("(%p)->(%d, %p, %p)\n", iface
, location
, hPivot
, phBody
);
1855 static HRESULT WINAPI
MimeMessage_GetBody(
1856 IMimeMessage
*iface
,
1857 BODYLOCATION location
,
1861 MimeMessage
*This
= (MimeMessage
*)iface
;
1865 TRACE("(%p)->(%d, %p, %p)\n", iface
, location
, hPivot
, phBody
);
1867 hr
= get_body(This
, location
, hPivot
, &body
);
1869 if(hr
== S_OK
) *phBody
= body
->hbody
;
1874 static HRESULT WINAPI
MimeMessage_DeleteBody(
1875 IMimeMessage
*iface
,
1879 FIXME("(%p)->(%p, %08x)\n", iface
, hBody
, dwFlags
);
1883 static HRESULT WINAPI
MimeMessage_MoveBody(
1884 IMimeMessage
*iface
,
1886 BODYLOCATION location
)
1888 FIXME("(%p)->(%d)\n", iface
, location
);
1892 static void count_children(body_t
*body
, boolean recurse
, ULONG
*count
)
1896 LIST_FOR_EACH_ENTRY(child
, &body
->children
, body_t
, entry
)
1899 if(recurse
) count_children(child
, recurse
, count
);
1903 static HRESULT WINAPI
MimeMessage_CountBodies(
1904 IMimeMessage
*iface
,
1910 MimeMessage
*This
= (MimeMessage
*)iface
;
1913 TRACE("(%p)->(%p, %s, %p)\n", iface
, hParent
, fRecurse
? "TRUE" : "FALSE", pcBodies
);
1915 hr
= find_body(&This
->body_tree
, hParent
, &body
);
1916 if(hr
!= S_OK
) return hr
;
1919 count_children(body
, fRecurse
, pcBodies
);
1924 static HRESULT WINAPI
MimeMessage_FindFirst(
1925 IMimeMessage
*iface
,
1926 LPFINDBODY pFindBody
,
1929 FIXME("(%p)->(%p, %p)\n", iface
, pFindBody
, phBody
);
1933 static HRESULT WINAPI
MimeMessage_FindNext(
1934 IMimeMessage
*iface
,
1935 LPFINDBODY pFindBody
,
1938 FIXME("(%p)->(%p, %p)\n", iface
, pFindBody
, phBody
);
1942 static HRESULT WINAPI
MimeMessage_ResolveURL(
1943 IMimeMessage
*iface
,
1950 FIXME("(%p)->(%p, %s, %s, 0x%x, %p)\n", iface
, hRelated
, pszBase
, pszURL
, dwFlags
, phBody
);
1954 static HRESULT WINAPI
MimeMessage_ToMultipart(
1955 IMimeMessage
*iface
,
1958 LPHBODY phMultipart
)
1960 FIXME("(%p)->(%p, %s, %p)\n", iface
, hBody
, pszSubType
, phMultipart
);
1964 static HRESULT WINAPI
MimeMessage_GetBodyOffsets(
1965 IMimeMessage
*iface
,
1967 LPBODYOFFSETS pOffsets
)
1969 FIXME("(%p)->(%p, %p)\n", iface
, hBody
, pOffsets
);
1973 static HRESULT WINAPI
MimeMessage_GetCharset(
1974 IMimeMessage
*iface
,
1975 LPHCHARSET phCharset
)
1977 FIXME("(%p)->(%p)\n", iface
, phCharset
);
1981 static HRESULT WINAPI
MimeMessage_SetCharset(
1982 IMimeMessage
*iface
,
1984 CSETAPPLYTYPE applytype
)
1986 FIXME("(%p)->(%p, %d)\n", iface
, hCharset
, applytype
);
1990 static HRESULT WINAPI
MimeMessage_IsBodyType(
1991 IMimeMessage
*iface
,
1993 IMSGBODYTYPE bodytype
)
1995 FIXME("(%p)->(%p, %d)\n", iface
, hBody
, bodytype
);
1999 static HRESULT WINAPI
MimeMessage_IsContentType(
2000 IMimeMessage
*iface
,
2005 FIXME("(%p)->(%p, %s, %s)\n", iface
, hBody
, pszPriType
, pszSubType
);
2009 static HRESULT WINAPI
MimeMessage_QueryBodyProp(
2010 IMimeMessage
*iface
,
2015 boolean fCaseSensitive
)
2017 FIXME("(%p)->(%p, %s, %s, %s, %s)\n", iface
, hBody
, pszName
, pszCriteria
, fSubString
? "TRUE" : "FALSE", fCaseSensitive
? "TRUE" : "FALSE");
2021 static HRESULT WINAPI
MimeMessage_GetBodyProp(
2022 IMimeMessage
*iface
,
2026 LPPROPVARIANT pValue
)
2028 FIXME("(%p)->(%p, %s, 0x%x, %p)\n", iface
, hBody
, pszName
, dwFlags
, pValue
);
2032 static HRESULT WINAPI
MimeMessage_SetBodyProp(
2033 IMimeMessage
*iface
,
2037 LPCPROPVARIANT pValue
)
2039 FIXME("(%p)->(%p, %s, 0x%x, %p)\n", iface
, hBody
, pszName
, dwFlags
, pValue
);
2043 static HRESULT WINAPI
MimeMessage_DeleteBodyProp(
2044 IMimeMessage
*iface
,
2048 FIXME("(%p)->(%p, %s)\n", iface
, hBody
, pszName
);
2052 static HRESULT WINAPI
MimeMessage_SetOption(
2053 IMimeMessage
*iface
,
2055 LPCPROPVARIANT pValue
)
2057 FIXME("(%p)->(%d, %p)\n", iface
, oid
, pValue
);
2061 static HRESULT WINAPI
MimeMessage_GetOption(
2062 IMimeMessage
*iface
,
2064 LPPROPVARIANT pValue
)
2066 FIXME("(%p)->(%d, %p)\n", iface
, oid
, pValue
);
2070 /*** IMimeMessage methods ***/
2071 static HRESULT WINAPI
MimeMessage_CreateWebPage(
2072 IMimeMessage
*iface
,
2074 LPWEBPAGEOPTIONS pOptions
,
2075 IMimeMessageCallback
*pCallback
,
2076 IMoniker
**ppMoniker
)
2078 FIXME("(%p)->(%p, %p, %p, %p)\n", iface
, pRootStm
, pOptions
, pCallback
, ppMoniker
);
2083 static HRESULT WINAPI
MimeMessage_GetProp(
2084 IMimeMessage
*iface
,
2087 LPPROPVARIANT pValue
)
2089 FIXME("(%p)->(%s, 0x%x, %p)\n", iface
, pszName
, dwFlags
, pValue
);
2093 static HRESULT WINAPI
MimeMessage_SetProp(
2094 IMimeMessage
*iface
,
2097 LPCPROPVARIANT pValue
)
2099 FIXME("(%p)->(%s, 0x%x, %p)\n", iface
, pszName
, dwFlags
, pValue
);
2103 static HRESULT WINAPI
MimeMessage_DeleteProp(
2104 IMimeMessage
*iface
,
2107 FIXME("(%p)->(%s)\n", iface
, pszName
);
2111 static HRESULT WINAPI
MimeMessage_QueryProp(
2112 IMimeMessage
*iface
,
2116 boolean fCaseSensitive
)
2118 FIXME("(%p)->(%s, %s, %s, %s)\n", iface
, pszName
, pszCriteria
, fSubString
? "TRUE" : "FALSE", fCaseSensitive
? "TRUE" : "FALSE");
2122 static HRESULT WINAPI
MimeMessage_GetTextBody(
2123 IMimeMessage
*iface
,
2125 ENCODINGTYPE ietEncoding
,
2129 FIXME("(%p)->(%d, %d, %p, %p)\n", iface
, dwTxtType
, ietEncoding
, pStream
, phBody
);
2133 static HRESULT WINAPI
MimeMessage_SetTextBody(
2134 IMimeMessage
*iface
,
2136 ENCODINGTYPE ietEncoding
,
2141 FIXME("(%p)->(%d, %d, %p, %p, %p)\n", iface
, dwTxtType
, ietEncoding
, hAlternative
, pStream
, phBody
);
2145 static HRESULT WINAPI
MimeMessage_AttachObject(
2146 IMimeMessage
*iface
,
2151 FIXME("(%p)->(%s, %p, %p)\n", iface
, debugstr_guid(riid
), pvObject
, phBody
);
2155 static HRESULT WINAPI
MimeMessage_AttachFile(
2156 IMimeMessage
*iface
,
2161 FIXME("(%p)->(%s, %p, %p)\n", iface
, pszFilePath
, pstmFile
, phBody
);
2165 static HRESULT WINAPI
MimeMessage_AttachURL(
2166 IMimeMessage
*iface
,
2174 FIXME("(%p)->(%s, %s, 0x%x, %p, %p, %p)\n", iface
, pszBase
, pszURL
, dwFlags
, pstmURL
, ppszCIDURL
, phBody
);
2178 static HRESULT WINAPI
MimeMessage_GetAttachments(
2179 IMimeMessage
*iface
,
2181 LPHBODY
*pprghAttach
)
2183 FIXME("(%p)->(%p, %p)\n", iface
, pcAttach
, pprghAttach
);
2187 static HRESULT WINAPI
MimeMessage_GetAddressTable(
2188 IMimeMessage
*iface
,
2189 IMimeAddressTable
**ppTable
)
2191 FIXME("(%p)->(%p)\n", iface
, ppTable
);
2195 static HRESULT WINAPI
MimeMessage_GetSender(
2196 IMimeMessage
*iface
,
2197 LPADDRESSPROPS pAddress
)
2199 FIXME("(%p)->(%p)\n", iface
, pAddress
);
2203 static HRESULT WINAPI
MimeMessage_GetAddressTypes(
2204 IMimeMessage
*iface
,
2207 LPADDRESSLIST pList
)
2209 FIXME("(%p)->(%d, %d, %p)\n", iface
, dwAdrTypes
, dwProps
, pList
);
2213 static HRESULT WINAPI
MimeMessage_GetAddressFormat(
2214 IMimeMessage
*iface
,
2216 ADDRESSFORMAT format
,
2219 FIXME("(%p)->(%d, %d, %p)\n", iface
, dwAdrTypes
, format
, ppszFormat
);
2223 static HRESULT WINAPI
MimeMessage_EnumAddressTypes(
2224 IMimeMessage
*iface
,
2227 IMimeEnumAddressTypes
**ppEnum
)
2229 FIXME("(%p)->(%d, %d, %p)\n", iface
, dwAdrTypes
, dwProps
, ppEnum
);
2233 static HRESULT WINAPI
MimeMessage_SplitMessage(
2234 IMimeMessage
*iface
,
2236 IMimeMessageParts
**ppParts
)
2238 FIXME("(%p)->(%d, %p)\n", iface
, cbMaxPart
, ppParts
);
2242 static HRESULT WINAPI
MimeMessage_GetRootMoniker(
2243 IMimeMessage
*iface
,
2244 IMoniker
**ppMoniker
)
2246 FIXME("(%p)->(%p)\n", iface
, ppMoniker
);
2250 static const IMimeMessageVtbl MimeMessageVtbl
=
2252 MimeMessage_QueryInterface
,
2254 MimeMessage_Release
,
2255 MimeMessage_GetClassID
,
2256 MimeMessage_IsDirty
,
2259 MimeMessage_GetSizeMax
,
2260 MimeMessage_InitNew
,
2261 MimeMessage_GetMessageSource
,
2262 MimeMessage_GetMessageSize
,
2263 MimeMessage_LoadOffsetTable
,
2264 MimeMessage_SaveOffsetTable
,
2265 MimeMessage_GetFlags
,
2267 MimeMessage_HandsOffStorage
,
2268 MimeMessage_BindToObject
,
2269 MimeMessage_SaveBody
,
2270 MimeMessage_InsertBody
,
2271 MimeMessage_GetBody
,
2272 MimeMessage_DeleteBody
,
2273 MimeMessage_MoveBody
,
2274 MimeMessage_CountBodies
,
2275 MimeMessage_FindFirst
,
2276 MimeMessage_FindNext
,
2277 MimeMessage_ResolveURL
,
2278 MimeMessage_ToMultipart
,
2279 MimeMessage_GetBodyOffsets
,
2280 MimeMessage_GetCharset
,
2281 MimeMessage_SetCharset
,
2282 MimeMessage_IsBodyType
,
2283 MimeMessage_IsContentType
,
2284 MimeMessage_QueryBodyProp
,
2285 MimeMessage_GetBodyProp
,
2286 MimeMessage_SetBodyProp
,
2287 MimeMessage_DeleteBodyProp
,
2288 MimeMessage_SetOption
,
2289 MimeMessage_GetOption
,
2290 MimeMessage_CreateWebPage
,
2291 MimeMessage_GetProp
,
2292 MimeMessage_SetProp
,
2293 MimeMessage_DeleteProp
,
2294 MimeMessage_QueryProp
,
2295 MimeMessage_GetTextBody
,
2296 MimeMessage_SetTextBody
,
2297 MimeMessage_AttachObject
,
2298 MimeMessage_AttachFile
,
2299 MimeMessage_AttachURL
,
2300 MimeMessage_GetAttachments
,
2301 MimeMessage_GetAddressTable
,
2302 MimeMessage_GetSender
,
2303 MimeMessage_GetAddressTypes
,
2304 MimeMessage_GetAddressFormat
,
2305 MimeMessage_EnumAddressTypes
,
2306 MimeMessage_SplitMessage
,
2307 MimeMessage_GetRootMoniker
,
2310 /***********************************************************************
2311 * MimeOleCreateMessage (INETCOMM.@)
2313 HRESULT WINAPI
MimeOleCreateMessage(IUnknown
*pUnkOuter
, IMimeMessage
**ppMessage
)
2317 TRACE("(%p, %p)\n", pUnkOuter
, ppMessage
);
2321 FIXME("outer unknown not supported yet\n");
2327 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
2328 if (!This
) return E_OUTOFMEMORY
;
2330 This
->lpVtbl
= &MimeMessageVtbl
;
2332 This
->stream
= NULL
;
2333 list_init(&This
->body_tree
);
2334 This
->next_hbody
= (HBODY
)1;
2336 *ppMessage
= (IMimeMessage
*)&This
->lpVtbl
;
2340 /***********************************************************************
2341 * MimeOleSetCompatMode (INETCOMM.@)
2343 HRESULT WINAPI
MimeOleSetCompatMode(DWORD dwMode
)
2345 FIXME("(0x%x)\n", dwMode
);
2349 /***********************************************************************
2350 * MimeOleCreateVirtualStream (INETCOMM.@)
2352 HRESULT WINAPI
MimeOleCreateVirtualStream(IStream
**ppStream
)
2355 FIXME("(%p)\n", ppStream
);
2357 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, ppStream
);
2361 typedef struct MimeSecurity
2363 const IMimeSecurityVtbl
*lpVtbl
;
2368 static HRESULT WINAPI
MimeSecurity_QueryInterface(
2369 IMimeSecurity
* iface
,
2373 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), obj
);
2375 if (IsEqualIID(riid
, &IID_IUnknown
) ||
2376 IsEqualIID(riid
, &IID_IMimeSecurity
))
2379 IUnknown_AddRef(iface
);
2383 FIXME("no interface for %s\n", debugstr_guid(riid
));
2385 return E_NOINTERFACE
;
2388 static ULONG WINAPI
MimeSecurity_AddRef(
2389 IMimeSecurity
* iface
)
2391 MimeSecurity
*This
= (MimeSecurity
*)iface
;
2392 TRACE("(%p)->()\n", iface
);
2393 return InterlockedIncrement(&This
->refs
);
2396 static ULONG WINAPI
MimeSecurity_Release(
2397 IMimeSecurity
* iface
)
2399 MimeSecurity
*This
= (MimeSecurity
*)iface
;
2402 TRACE("(%p)->()\n", iface
);
2404 refs
= InterlockedDecrement(&This
->refs
);
2407 HeapFree(GetProcessHeap(), 0, This
);
2413 static HRESULT WINAPI
MimeSecurity_InitNew(
2414 IMimeSecurity
* iface
)
2416 FIXME("(%p)->(): stub\n", iface
);
2420 static HRESULT WINAPI
MimeSecurity_CheckInit(
2421 IMimeSecurity
* iface
)
2423 FIXME("(%p)->(): stub\n", iface
);
2427 static HRESULT WINAPI
MimeSecurity_EncodeMessage(
2428 IMimeSecurity
* iface
,
2429 IMimeMessageTree
* pTree
,
2432 FIXME("(%p)->(%p, %08x): stub\n", iface
, pTree
, dwFlags
);
2436 static HRESULT WINAPI
MimeSecurity_EncodeBody(
2437 IMimeSecurity
* iface
,
2438 IMimeMessageTree
* pTree
,
2442 FIXME("(%p)->(%p, %p, %08x): stub\n", iface
, pTree
, hEncodeRoot
, dwFlags
);
2446 static HRESULT WINAPI
MimeSecurity_DecodeMessage(
2447 IMimeSecurity
* iface
,
2448 IMimeMessageTree
* pTree
,
2451 FIXME("(%p)->(%p, %08x): stub\n", iface
, pTree
, dwFlags
);
2455 static HRESULT WINAPI
MimeSecurity_DecodeBody(
2456 IMimeSecurity
* iface
,
2457 IMimeMessageTree
* pTree
,
2461 FIXME("(%p)->(%p, %p, %08x): stub\n", iface
, pTree
, hDecodeRoot
, dwFlags
);
2465 static HRESULT WINAPI
MimeSecurity_EnumCertificates(
2466 IMimeSecurity
* iface
,
2472 FIXME("(%p)->(%p, %08x, %p, %p): stub\n", iface
, hc
, dwUsage
, pPrev
, ppCert
);
2476 static HRESULT WINAPI
MimeSecurity_GetCertificateName(
2477 IMimeSecurity
* iface
,
2478 const PCX509CERT pX509Cert
,
2479 const CERTNAMETYPE cn
,
2482 FIXME("(%p)->(%p, %08x, %p): stub\n", iface
, pX509Cert
, cn
, ppszName
);
2486 static HRESULT WINAPI
MimeSecurity_GetMessageType(
2487 IMimeSecurity
* iface
,
2488 const HWND hwndParent
,
2492 FIXME("(%p)->(%p, %p, %p): stub\n", iface
, hwndParent
, pBody
, pdwSecType
);
2496 static HRESULT WINAPI
MimeSecurity_GetCertData(
2497 IMimeSecurity
* iface
,
2498 const PCX509CERT pX509Cert
,
2499 const CERTDATAID dataid
,
2500 LPPROPVARIANT pValue
)
2502 FIXME("(%p)->(%p, %x, %p): stub\n", iface
, pX509Cert
, dataid
, pValue
);
2507 static const IMimeSecurityVtbl MimeSecurityVtbl
=
2509 MimeSecurity_QueryInterface
,
2510 MimeSecurity_AddRef
,
2511 MimeSecurity_Release
,
2512 MimeSecurity_InitNew
,
2513 MimeSecurity_CheckInit
,
2514 MimeSecurity_EncodeMessage
,
2515 MimeSecurity_EncodeBody
,
2516 MimeSecurity_DecodeMessage
,
2517 MimeSecurity_DecodeBody
,
2518 MimeSecurity_EnumCertificates
,
2519 MimeSecurity_GetCertificateName
,
2520 MimeSecurity_GetMessageType
,
2521 MimeSecurity_GetCertData
2524 /***********************************************************************
2525 * MimeOleCreateSecurity (INETCOMM.@)
2527 HRESULT WINAPI
MimeOleCreateSecurity(IMimeSecurity
**ppSecurity
)
2531 TRACE("(%p)\n", ppSecurity
);
2535 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
2536 if (!This
) return E_OUTOFMEMORY
;
2538 This
->lpVtbl
= &MimeSecurityVtbl
;
2541 *ppSecurity
= (IMimeSecurity
*)&This
->lpVtbl
;
2548 IMimeAllocatorVtbl
*lpVtbl
;
2551 static HRESULT WINAPI
MimeAlloc_QueryInterface(
2552 IMimeAllocator
* iface
,
2556 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), obj
);
2558 if (IsEqualIID(riid
, &IID_IUnknown
) ||
2559 IsEqualIID(riid
, &IID_IMalloc
) ||
2560 IsEqualIID(riid
, &IID_IMimeAllocator
))
2563 IUnknown_AddRef(iface
);
2567 FIXME("no interface for %s\n", debugstr_guid(riid
));
2569 return E_NOINTERFACE
;
2572 static ULONG WINAPI
MimeAlloc_AddRef(
2573 IMimeAllocator
* iface
)
2578 static ULONG WINAPI
MimeAlloc_Release(
2579 IMimeAllocator
* iface
)
2584 static LPVOID WINAPI
MimeAlloc_Alloc(
2585 IMimeAllocator
* iface
,
2588 return CoTaskMemAlloc(cb
);
2591 static LPVOID WINAPI
MimeAlloc_Realloc(
2592 IMimeAllocator
* iface
,
2596 return CoTaskMemRealloc(pv
, cb
);
2599 static void WINAPI
MimeAlloc_Free(
2600 IMimeAllocator
* iface
,
2603 return CoTaskMemFree(pv
);
2606 static ULONG WINAPI
MimeAlloc_GetSize(
2607 IMimeAllocator
* iface
,
2614 static int WINAPI
MimeAlloc_DidAlloc(
2615 IMimeAllocator
* iface
,
2622 static void WINAPI
MimeAlloc_HeapMinimize(
2623 IMimeAllocator
* iface
)
2629 static HRESULT WINAPI
MimeAlloc_FreeParamInfoArray(
2630 IMimeAllocator
* iface
,
2632 LPMIMEPARAMINFO prgParam
,
2636 TRACE("(%p)->(%d, %p, %d)\n", iface
, cParams
, prgParam
, fFreeArray
);
2638 for(i
= 0; i
< cParams
; i
++)
2640 IMimeAllocator_Free(iface
, prgParam
[i
].pszName
);
2641 IMimeAllocator_Free(iface
, prgParam
[i
].pszData
);
2643 if(fFreeArray
) IMimeAllocator_Free(iface
, prgParam
);
2647 static HRESULT WINAPI
MimeAlloc_FreeAddressList(
2648 IMimeAllocator
* iface
,
2649 LPADDRESSLIST pList
)
2655 static HRESULT WINAPI
MimeAlloc_FreeAddressProps(
2656 IMimeAllocator
* iface
,
2657 LPADDRESSPROPS pAddress
)
2663 static HRESULT WINAPI
MimeAlloc_ReleaseObjects(
2664 IMimeAllocator
* iface
,
2666 IUnknown
**prgpUnknown
,
2674 static HRESULT WINAPI
MimeAlloc_FreeEnumHeaderRowArray(
2675 IMimeAllocator
* iface
,
2677 LPENUMHEADERROW prgRow
,
2684 static HRESULT WINAPI
MimeAlloc_FreeEnumPropertyArray(
2685 IMimeAllocator
* iface
,
2687 LPENUMPROPERTY prgProp
,
2694 static HRESULT WINAPI
MimeAlloc_FreeThumbprint(
2695 IMimeAllocator
* iface
,
2696 THUMBBLOB
*pthumbprint
)
2703 static HRESULT WINAPI
MimeAlloc_PropVariantClear(
2704 IMimeAllocator
* iface
,
2705 LPPROPVARIANT pProp
)
2711 static IMimeAllocatorVtbl mime_alloc_vtbl
=
2713 MimeAlloc_QueryInterface
,
2721 MimeAlloc_HeapMinimize
,
2722 MimeAlloc_FreeParamInfoArray
,
2723 MimeAlloc_FreeAddressList
,
2724 MimeAlloc_FreeAddressProps
,
2725 MimeAlloc_ReleaseObjects
,
2726 MimeAlloc_FreeEnumHeaderRowArray
,
2727 MimeAlloc_FreeEnumPropertyArray
,
2728 MimeAlloc_FreeThumbprint
,
2729 MimeAlloc_PropVariantClear
2732 static MimeAllocator mime_allocator
=
2737 HRESULT
MimeAllocator_create(IUnknown
*outer
, void **obj
)
2739 if(outer
) return CLASS_E_NOAGGREGATION
;
2741 *obj
= &mime_allocator
;
2745 HRESULT WINAPI
MimeOleGetAllocator(IMimeAllocator
**alloc
)
2747 return MimeAllocator_create(NULL
, (void**)alloc
);