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
;
112 static inline MimeBody
*impl_from_IMimeBody( IMimeBody
*iface
)
114 return (MimeBody
*)((char*)iface
- FIELD_OFFSET(MimeBody
, lpVtbl
));
117 static LPSTR
strdupA(LPCSTR str
)
120 int len
= strlen(str
);
121 ret
= HeapAlloc(GetProcessHeap(), 0, len
+ 1);
122 memcpy(ret
, str
, len
+ 1);
126 #define PARSER_BUF_SIZE 1024
128 /*****************************************************
129 * copy_headers_to_buf [internal]
131 * Copies the headers into a '\0' terminated memory block and leave
132 * the stream's current position set to after the blank line.
134 static HRESULT
copy_headers_to_buf(IStream
*stm
, char **ptr
)
137 DWORD size
= PARSER_BUF_SIZE
, offset
= 0, last_end
= 0;
149 buf
= HeapAlloc(GetProcessHeap(), 0, size
+ 1);
153 buf
= HeapReAlloc(GetProcessHeap(), 0, buf
, size
+ 1);
161 hr
= IStream_Read(stm
, buf
+ offset
, size
- offset
, &read
);
162 if(FAILED(hr
)) goto fail
;
167 if(read
== 0) done
= 1;
169 while(!done
&& (end
= strstr(buf
+ last_end
, "\r\n")))
171 DWORD new_end
= end
- buf
+ 2;
172 if(new_end
- last_end
== 2)
175 off
.QuadPart
= new_end
;
176 IStream_Seek(stm
, off
, STREAM_SEEK_SET
, NULL
);
189 HeapFree(GetProcessHeap(), 0, buf
);
193 static header_t
*read_prop(MimeBody
*body
, char **ptr
)
195 char *colon
= strchr(*ptr
, ':');
196 const property_t
*prop
;
199 if(!colon
) return NULL
;
203 for(prop
= default_props
; prop
->name
; prop
++)
205 if(!strcasecmp(*ptr
, prop
->name
))
207 TRACE("%s: found match with default property id %d\n", *ptr
, prop
->id
);
214 property_list_entry_t
*prop_entry
;
215 LIST_FOR_EACH_ENTRY(prop_entry
, &body
->new_props
, property_list_entry_t
, entry
)
217 if(!strcasecmp(*ptr
, prop_entry
->prop
.name
))
219 TRACE("%s: found match with already added new property id %d\n", *ptr
, prop_entry
->prop
.id
);
220 prop
= &prop_entry
->prop
;
226 prop_entry
= HeapAlloc(GetProcessHeap(), 0, sizeof(*prop_entry
));
227 prop_entry
->prop
.name
= strdupA(*ptr
);
228 prop_entry
->prop
.id
= body
->next_prop_id
++;
229 prop_entry
->prop
.flags
= 0;
230 prop_entry
->prop
.default_vt
= VT_LPSTR
;
231 list_add_tail(&body
->new_props
, &prop_entry
->entry
);
232 prop
= &prop_entry
->prop
;
233 TRACE("%s: allocating new prop id %d\n", *ptr
, prop_entry
->prop
.id
);
237 ret
= HeapAlloc(GetProcessHeap(), 0, sizeof(*ret
));
239 PropVariantInit(&ret
->value
);
240 list_init(&ret
->params
);
246 static void unfold_header(char *header
, int len
)
248 char *start
= header
, *cp
= header
;
251 while(*cp
== ' ' || *cp
== '\t')
257 memmove(start
, cp
, len
+ 1);
259 cp
= strstr(start
, "\r\n");
266 } while(*cp
== ' ' || *cp
== '\t');
271 static void add_param(header_t
*header
, const char *p
)
273 const char *key
= p
, *value
, *cp
= p
;
277 TRACE("got param %s\n", p
);
279 while (*key
== ' ' || *key
== '\t' ) key
++;
281 cp
= strchr(key
, '=');
284 WARN("malformed parameter - skipping\n");
288 name
= HeapAlloc(GetProcessHeap(), 0, cp
- key
+ 1);
289 memcpy(name
, key
, cp
- key
);
290 name
[cp
- key
] = '\0';
294 param
= HeapAlloc(GetProcessHeap(), 0, sizeof(*param
));
296 param
->value
= strdupA(value
);
297 list_add_tail(&header
->params
, ¶m
->entry
);
300 static void split_params(header_t
*header
, char *value
)
302 char *cp
= value
, *start
= value
;
308 if(!in_quote
&& *cp
== ';')
311 if(done_value
) add_param(header
, start
);
316 in_quote
= !in_quote
;
319 if(done_value
) add_param(header
, start
);
322 static void read_value(header_t
*header
, char **cur
)
324 char *end
= *cur
, *value
;
328 end
= strstr(end
, "\r\n");
330 } while(*end
== ' ' || *end
== '\t');
333 value
= HeapAlloc(GetProcessHeap(), 0, len
+ 1);
334 memcpy(value
, *cur
, len
);
337 unfold_header(value
, len
);
338 TRACE("value %s\n", debugstr_a(value
));
340 if(header
->prop
->flags
& MPF_HASPARAMS
)
342 split_params(header
, value
);
343 TRACE("value w/o params %s\n", debugstr_a(value
));
346 header
->value
.vt
= VT_LPSTR
;
347 header
->value
.u
.pszVal
= value
;
352 static void init_content_type(MimeBody
*body
, header_t
*header
)
357 if(header
->prop
->id
!= PID_HDR_CNTTYPE
)
359 ERR("called with header %s\n", header
->prop
->name
);
363 slash
= strchr(header
->value
.u
.pszVal
, '/');
366 WARN("malformed context type value\n");
369 len
= slash
- header
->value
.u
.pszVal
;
370 body
->content_pri_type
= HeapAlloc(GetProcessHeap(), 0, len
+ 1);
371 memcpy(body
->content_pri_type
, header
->value
.u
.pszVal
, len
);
372 body
->content_pri_type
[len
] = '\0';
373 body
->content_sub_type
= strdupA(slash
+ 1);
376 static HRESULT
parse_headers(MimeBody
*body
, IStream
*stm
)
378 char *header_buf
, *cur_header_ptr
;
382 hr
= copy_headers_to_buf(stm
, &header_buf
);
383 if(FAILED(hr
)) return hr
;
385 cur_header_ptr
= header_buf
;
386 while((header
= read_prop(body
, &cur_header_ptr
)))
388 read_value(header
, &cur_header_ptr
);
389 list_add_tail(&body
->headers
, &header
->entry
);
391 if(header
->prop
->id
== PID_HDR_CNTTYPE
)
392 init_content_type(body
, header
);
395 HeapFree(GetProcessHeap(), 0, header_buf
);
399 static void empty_param_list(struct list
*list
)
401 param_t
*param
, *cursor2
;
403 LIST_FOR_EACH_ENTRY_SAFE(param
, cursor2
, list
, param_t
, entry
)
405 list_remove(¶m
->entry
);
406 HeapFree(GetProcessHeap(), 0, param
->name
);
407 HeapFree(GetProcessHeap(), 0, param
->value
);
408 HeapFree(GetProcessHeap(), 0, param
);
412 static void empty_header_list(struct list
*list
)
414 header_t
*header
, *cursor2
;
416 LIST_FOR_EACH_ENTRY_SAFE(header
, cursor2
, list
, header_t
, entry
)
418 list_remove(&header
->entry
);
419 PropVariantClear(&header
->value
);
420 empty_param_list(&header
->params
);
421 HeapFree(GetProcessHeap(), 0, header
);
425 static void empty_new_prop_list(struct list
*list
)
427 property_list_entry_t
*prop
, *cursor2
;
429 LIST_FOR_EACH_ENTRY_SAFE(prop
, cursor2
, list
, property_list_entry_t
, entry
)
431 list_remove(&prop
->entry
);
432 HeapFree(GetProcessHeap(), 0, (char *)prop
->prop
.name
);
433 HeapFree(GetProcessHeap(), 0, prop
);
437 static void release_data(REFIID riid
, void *data
)
441 if(IsEqualIID(riid
, &IID_IStream
))
442 IStream_Release((IStream
*)data
);
444 FIXME("Unhandled data format %s\n", debugstr_guid(riid
));
447 static HRESULT WINAPI
MimeBody_QueryInterface(IMimeBody
* iface
,
451 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ppvObject
);
455 if (IsEqualIID(riid
, &IID_IUnknown
) ||
456 IsEqualIID(riid
, &IID_IPersist
) ||
457 IsEqualIID(riid
, &IID_IPersistStreamInit
) ||
458 IsEqualIID(riid
, &IID_IMimePropertySet
) ||
459 IsEqualIID(riid
, &IID_IMimeBody
))
466 IUnknown_AddRef((IUnknown
*)*ppvObject
);
470 FIXME("no interface for %s\n", debugstr_guid(riid
));
471 return E_NOINTERFACE
;
474 static ULONG WINAPI
MimeBody_AddRef(IMimeBody
* iface
)
476 MimeBody
*This
= impl_from_IMimeBody(iface
);
477 TRACE("(%p)->()\n", iface
);
478 return InterlockedIncrement(&This
->refs
);
481 static ULONG WINAPI
MimeBody_Release(IMimeBody
* iface
)
483 MimeBody
*This
= impl_from_IMimeBody(iface
);
486 TRACE("(%p)->()\n", iface
);
488 refs
= InterlockedDecrement(&This
->refs
);
491 empty_header_list(&This
->headers
);
492 empty_new_prop_list(&This
->new_props
);
494 HeapFree(GetProcessHeap(), 0, This
->content_pri_type
);
495 HeapFree(GetProcessHeap(), 0, This
->content_sub_type
);
497 release_data(&This
->data_iid
, This
->data
);
499 HeapFree(GetProcessHeap(), 0, This
);
505 static HRESULT WINAPI
MimeBody_GetClassID(
514 static HRESULT WINAPI
MimeBody_IsDirty(
521 static HRESULT WINAPI
MimeBody_Load(
525 MimeBody
*This
= impl_from_IMimeBody(iface
);
526 TRACE("(%p)->(%p)\n", iface
, pStm
);
527 return parse_headers(This
, pStm
);
530 static HRESULT WINAPI
MimeBody_Save(
539 static HRESULT WINAPI
MimeBody_GetSizeMax(
541 ULARGE_INTEGER
* pcbSize
)
547 static HRESULT WINAPI
MimeBody_InitNew(
550 TRACE("%p->()\n", iface
);
554 static HRESULT WINAPI
MimeBody_GetPropInfo(
557 LPMIMEPROPINFO pInfo
)
563 static HRESULT WINAPI
MimeBody_SetPropInfo(
566 LPCMIMEPROPINFO pInfo
)
572 static HRESULT WINAPI
MimeBody_GetProp(
576 LPPROPVARIANT pValue
)
582 static HRESULT WINAPI
MimeBody_SetProp(
586 LPCPROPVARIANT pValue
)
592 static HRESULT WINAPI
MimeBody_AppendProp(
596 LPPROPVARIANT pValue
)
602 static HRESULT WINAPI
MimeBody_DeleteProp(
610 static HRESULT WINAPI
MimeBody_CopyProps(
614 IMimePropertySet
* pPropertySet
)
620 static HRESULT WINAPI
MimeBody_MoveProps(
624 IMimePropertySet
* pPropertySet
)
630 static HRESULT WINAPI
MimeBody_DeleteExcept(
639 static HRESULT WINAPI
MimeBody_QueryProp(
644 boolean fCaseSensitive
)
650 static HRESULT WINAPI
MimeBody_GetCharset(
652 LPHCHARSET phCharset
)
658 static HRESULT WINAPI
MimeBody_SetCharset(
661 CSETAPPLYTYPE applytype
)
667 static HRESULT WINAPI
MimeBody_GetParameters(
671 LPMIMEPARAMINFO
* pprgParam
)
677 static HRESULT WINAPI
MimeBody_IsContentType(
682 MimeBody
*This
= impl_from_IMimeBody(iface
);
684 TRACE("(%p)->(%s, %s)\n", This
, debugstr_a(pszPriType
), debugstr_a(pszSubType
));
687 const char *pri
= This
->content_pri_type
;
688 if(!pri
) pri
= "text";
689 if(strcasecmp(pri
, pszPriType
)) return S_FALSE
;
694 const char *sub
= This
->content_sub_type
;
695 if(!sub
) sub
= "plain";
696 if(strcasecmp(sub
, pszSubType
)) return S_FALSE
;
702 static HRESULT WINAPI
MimeBody_BindToObject(
711 static HRESULT WINAPI
MimeBody_Clone(
713 IMimePropertySet
** ppPropertySet
)
719 static HRESULT WINAPI
MimeBody_SetOption(
722 LPCPROPVARIANT pValue
)
728 static HRESULT WINAPI
MimeBody_GetOption(
731 LPPROPVARIANT pValue
)
737 static HRESULT WINAPI
MimeBody_EnumProps(
740 IMimeEnumProperties
** ppEnum
)
746 static HRESULT WINAPI
MimeBody_IsType(
748 IMSGBODYTYPE bodytype
)
754 static HRESULT WINAPI
MimeBody_SetDisplayName(
762 static HRESULT WINAPI
MimeBody_GetDisplayName(
770 static HRESULT WINAPI
MimeBody_GetOffsets(
772 LPBODYOFFSETS pOffsets
)
778 static HRESULT WINAPI
MimeBody_GetCurrentEncoding(
780 ENCODINGTYPE
* pietEncoding
)
782 MimeBody
*This
= impl_from_IMimeBody(iface
);
784 TRACE("(%p)->(%p)\n", This
, pietEncoding
);
786 *pietEncoding
= This
->encoding
;
790 static HRESULT WINAPI
MimeBody_SetCurrentEncoding(
792 ENCODINGTYPE ietEncoding
)
794 MimeBody
*This
= impl_from_IMimeBody(iface
);
796 TRACE("(%p)->(%d)\n", This
, ietEncoding
);
798 This
->encoding
= ietEncoding
;
802 static HRESULT WINAPI
MimeBody_GetEstimatedSize(
804 ENCODINGTYPE ietEncoding
,
811 static HRESULT WINAPI
MimeBody_GetDataHere(
813 ENCODINGTYPE ietEncoding
,
820 static HRESULT WINAPI
MimeBody_GetData(
822 ENCODINGTYPE ietEncoding
,
829 static HRESULT WINAPI
MimeBody_SetData(
831 ENCODINGTYPE ietEncoding
,
837 MimeBody
*This
= impl_from_IMimeBody(iface
);
838 TRACE("(%p)->(%d, %s, %s, %s %p)\n", This
, ietEncoding
, debugstr_a(pszPriType
), debugstr_a(pszSubType
),
839 debugstr_guid(riid
), pvObject
);
841 if(IsEqualIID(riid
, &IID_IStream
))
842 IStream_AddRef((IStream
*)pvObject
);
845 FIXME("Unhandled object type %s\n", debugstr_guid(riid
));
850 FIXME("release old data\n");
852 This
->data_iid
= *riid
;
853 This
->data
= pvObject
;
855 IMimeBody_SetCurrentEncoding(iface
, ietEncoding
);
857 /* FIXME: Update the content type.
858 If pszPriType == NULL use 'application'
859 If pszSubType == NULL use 'octet-stream' */
864 static HRESULT WINAPI
MimeBody_EmptyData(
871 static HRESULT WINAPI
MimeBody_CopyTo(
879 static HRESULT WINAPI
MimeBody_GetTransmitInfo(
881 LPTRANSMITINFO pTransmitInfo
)
887 static HRESULT WINAPI
MimeBody_SaveToFile(
889 ENCODINGTYPE ietEncoding
,
896 static HRESULT WINAPI
MimeBody_GetHandle(
900 MimeBody
*This
= impl_from_IMimeBody(iface
);
901 TRACE("(%p)->(%p)\n", iface
, phBody
);
903 *phBody
= This
->handle
;
904 return This
->handle
? S_OK
: MIME_E_NO_DATA
;
907 static IMimeBodyVtbl body_vtbl
=
909 MimeBody_QueryInterface
,
918 MimeBody_GetPropInfo
,
919 MimeBody_SetPropInfo
,
926 MimeBody_DeleteExcept
,
930 MimeBody_GetParameters
,
931 MimeBody_IsContentType
,
932 MimeBody_BindToObject
,
938 MimeBody_SetDisplayName
,
939 MimeBody_GetDisplayName
,
941 MimeBody_GetCurrentEncoding
,
942 MimeBody_SetCurrentEncoding
,
943 MimeBody_GetEstimatedSize
,
944 MimeBody_GetDataHere
,
949 MimeBody_GetTransmitInfo
,
954 #define FIRST_CUSTOM_PROP_ID 0x100
956 HRESULT
MimeBody_create(IUnknown
*outer
, void **obj
)
962 if(outer
) return CLASS_E_NOAGGREGATION
;
964 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
965 if (!This
) return E_OUTOFMEMORY
;
967 This
->lpVtbl
= &body_vtbl
;
970 list_init(&This
->headers
);
971 list_init(&This
->new_props
);
972 This
->next_prop_id
= FIRST_CUSTOM_PROP_ID
;
973 This
->content_pri_type
= NULL
;
974 This
->content_sub_type
= NULL
;
975 This
->encoding
= IET_7BIT
;
977 This
->data_iid
= IID_NULL
;
979 *obj
= (IMimeBody
*)&This
->lpVtbl
;
983 typedef struct MimeMessage
985 const IMimeMessageVtbl
*lpVtbl
;
990 static HRESULT WINAPI
MimeMessage_QueryInterface(IMimeMessage
*iface
, REFIID riid
, void **ppv
)
992 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ppv
);
994 if (IsEqualIID(riid
, &IID_IUnknown
) ||
995 IsEqualIID(riid
, &IID_IPersist
) ||
996 IsEqualIID(riid
, &IID_IPersistStreamInit
) ||
997 IsEqualIID(riid
, &IID_IMimeMessageTree
) ||
998 IsEqualIID(riid
, &IID_IMimeMessage
))
1001 IUnknown_AddRef(iface
);
1005 FIXME("no interface for %s\n", debugstr_guid(riid
));
1007 return E_NOINTERFACE
;
1010 static ULONG WINAPI
MimeMessage_AddRef(IMimeMessage
*iface
)
1012 MimeMessage
*This
= (MimeMessage
*)iface
;
1013 TRACE("(%p)->()\n", iface
);
1014 return InterlockedIncrement(&This
->refs
);
1017 static ULONG WINAPI
MimeMessage_Release(IMimeMessage
*iface
)
1019 MimeMessage
*This
= (MimeMessage
*)iface
;
1022 TRACE("(%p)->()\n", iface
);
1024 refs
= InterlockedDecrement(&This
->refs
);
1027 HeapFree(GetProcessHeap(), 0, This
);
1033 /*** IPersist methods ***/
1034 static HRESULT WINAPI
MimeMessage_GetClassID(
1035 IMimeMessage
*iface
,
1038 FIXME("(%p)->(%p)\n", iface
, pClassID
);
1042 /*** IPersistStreamInit methods ***/
1043 static HRESULT WINAPI
MimeMessage_IsDirty(
1044 IMimeMessage
*iface
)
1046 FIXME("(%p)->()\n", iface
);
1050 static HRESULT WINAPI
MimeMessage_Load(
1051 IMimeMessage
*iface
,
1053 FIXME("(%p)->(%p)\n", iface
, pStm
);
1057 static HRESULT WINAPI
MimeMessage_Save(
1058 IMimeMessage
*iface
,
1062 FIXME("(%p)->(%p, %s)\n", iface
, pStm
, fClearDirty
? "TRUE" : "FALSE");
1066 static HRESULT WINAPI
MimeMessage_GetSizeMax(
1067 IMimeMessage
*iface
,
1068 ULARGE_INTEGER
*pcbSize
)
1070 FIXME("(%p)->(%p)\n", iface
, pcbSize
);
1074 static HRESULT WINAPI
MimeMessage_InitNew(
1075 IMimeMessage
*iface
)
1077 FIXME("(%p)->()\n", iface
);
1081 /*** IMimeMessageTree methods ***/
1082 static HRESULT WINAPI
MimeMessage_GetMessageSource(
1083 IMimeMessage
*iface
,
1087 FIXME("(%p)->(%p, 0x%x)\n", iface
, ppStream
, dwFlags
);
1091 static HRESULT WINAPI
MimeMessage_GetMessageSize(
1092 IMimeMessage
*iface
,
1096 FIXME("(%p)->(%p, 0x%x)\n", iface
, pcbSize
, dwFlags
);
1100 static HRESULT WINAPI
MimeMessage_LoadOffsetTable(
1101 IMimeMessage
*iface
,
1104 FIXME("(%p)->(%p)\n", iface
, pStream
);
1108 static HRESULT WINAPI
MimeMessage_SaveOffsetTable(
1109 IMimeMessage
*iface
,
1113 FIXME("(%p)->(%p, 0x%x)\n", iface
, pStream
, dwFlags
);
1118 static HRESULT WINAPI
MimeMessage_GetFlags(
1119 IMimeMessage
*iface
,
1122 FIXME("(%p)->(%p)\n", iface
, pdwFlags
);
1126 static HRESULT WINAPI
MimeMessage_Commit(
1127 IMimeMessage
*iface
,
1130 FIXME("(%p)->(0x%x)\n", iface
, dwFlags
);
1135 static HRESULT WINAPI
MimeMessage_HandsOffStorage(
1136 IMimeMessage
*iface
)
1138 FIXME("(%p)->()\n", iface
);
1142 static HRESULT WINAPI
MimeMessage_BindToObject(
1143 IMimeMessage
*iface
,
1148 FIXME("(%p)->(%p, %s, %p)\n", iface
, hBody
, debugstr_guid(riid
), ppvObject
);
1152 static HRESULT WINAPI
MimeMessage_SaveBody(
1153 IMimeMessage
*iface
,
1158 FIXME("(%p)->(%p, 0x%x, %p)\n", iface
, hBody
, dwFlags
, pStream
);
1162 static HRESULT WINAPI
MimeMessage_InsertBody(
1163 IMimeMessage
*iface
,
1164 BODYLOCATION location
,
1168 FIXME("(%p)->(%d, %p, %p)\n", iface
, location
, hPivot
, phBody
);
1172 static HRESULT WINAPI
MimeMessage_GetBody(
1173 IMimeMessage
*iface
,
1174 BODYLOCATION location
,
1178 FIXME("(%p)->(%d, %p, %p)\n", iface
, location
, hPivot
, phBody
);
1182 static HRESULT WINAPI
MimeMessage_DeleteBody(
1183 IMimeMessage
*iface
,
1187 FIXME("(%p)->(%p, %08x)\n", iface
, hBody
, dwFlags
);
1191 static HRESULT WINAPI
MimeMessage_MoveBody(
1192 IMimeMessage
*iface
,
1194 BODYLOCATION location
)
1196 FIXME("(%p)->(%d)\n", iface
, location
);
1200 static HRESULT WINAPI
MimeMessage_CountBodies(
1201 IMimeMessage
*iface
,
1206 FIXME("(%p)->(%p, %s, %p)\n", iface
, hParent
, fRecurse
? "TRUE" : "FALSE", pcBodies
);
1210 static HRESULT WINAPI
MimeMessage_FindFirst(
1211 IMimeMessage
*iface
,
1212 LPFINDBODY pFindBody
,
1215 FIXME("(%p)->(%p, %p)\n", iface
, pFindBody
, phBody
);
1219 static HRESULT WINAPI
MimeMessage_FindNext(
1220 IMimeMessage
*iface
,
1221 LPFINDBODY pFindBody
,
1224 FIXME("(%p)->(%p, %p)\n", iface
, pFindBody
, phBody
);
1228 static HRESULT WINAPI
MimeMessage_ResolveURL(
1229 IMimeMessage
*iface
,
1236 FIXME("(%p)->(%p, %s, %s, 0x%x, %p)\n", iface
, hRelated
, pszBase
, pszURL
, dwFlags
, phBody
);
1240 static HRESULT WINAPI
MimeMessage_ToMultipart(
1241 IMimeMessage
*iface
,
1244 LPHBODY phMultipart
)
1246 FIXME("(%p)->(%p, %s, %p)\n", iface
, hBody
, pszSubType
, phMultipart
);
1250 static HRESULT WINAPI
MimeMessage_GetBodyOffsets(
1251 IMimeMessage
*iface
,
1253 LPBODYOFFSETS pOffsets
)
1255 FIXME("(%p)->(%p, %p)\n", iface
, hBody
, pOffsets
);
1259 static HRESULT WINAPI
MimeMessage_GetCharset(
1260 IMimeMessage
*iface
,
1261 LPHCHARSET phCharset
)
1263 FIXME("(%p)->(%p)\n", iface
, phCharset
);
1267 static HRESULT WINAPI
MimeMessage_SetCharset(
1268 IMimeMessage
*iface
,
1270 CSETAPPLYTYPE applytype
)
1272 FIXME("(%p)->(%p, %d)\n", iface
, hCharset
, applytype
);
1276 static HRESULT WINAPI
MimeMessage_IsBodyType(
1277 IMimeMessage
*iface
,
1279 IMSGBODYTYPE bodytype
)
1281 FIXME("(%p)->(%p, %d)\n", iface
, hBody
, bodytype
);
1285 static HRESULT WINAPI
MimeMessage_IsContentType(
1286 IMimeMessage
*iface
,
1291 FIXME("(%p)->(%p, %s, %s)\n", iface
, hBody
, pszPriType
, pszSubType
);
1295 static HRESULT WINAPI
MimeMessage_QueryBodyProp(
1296 IMimeMessage
*iface
,
1301 boolean fCaseSensitive
)
1303 FIXME("(%p)->(%p, %s, %s, %s, %s)\n", iface
, hBody
, pszName
, pszCriteria
, fSubString
? "TRUE" : "FALSE", fCaseSensitive
? "TRUE" : "FALSE");
1307 static HRESULT WINAPI
MimeMessage_GetBodyProp(
1308 IMimeMessage
*iface
,
1312 LPPROPVARIANT pValue
)
1314 FIXME("(%p)->(%p, %s, 0x%x, %p)\n", iface
, hBody
, pszName
, dwFlags
, pValue
);
1318 static HRESULT WINAPI
MimeMessage_SetBodyProp(
1319 IMimeMessage
*iface
,
1323 LPCPROPVARIANT pValue
)
1325 FIXME("(%p)->(%p, %s, 0x%x, %p)\n", iface
, hBody
, pszName
, dwFlags
, pValue
);
1329 static HRESULT WINAPI
MimeMessage_DeleteBodyProp(
1330 IMimeMessage
*iface
,
1334 FIXME("(%p)->(%p, %s)\n", iface
, hBody
, pszName
);
1338 static HRESULT WINAPI
MimeMessage_SetOption(
1339 IMimeMessage
*iface
,
1341 LPCPROPVARIANT pValue
)
1343 FIXME("(%p)->(%d, %p)\n", iface
, oid
, pValue
);
1347 static HRESULT WINAPI
MimeMessage_GetOption(
1348 IMimeMessage
*iface
,
1350 LPPROPVARIANT pValue
)
1352 FIXME("(%p)->(%d, %p)\n", iface
, oid
, pValue
);
1356 /*** IMimeMessage methods ***/
1357 static HRESULT WINAPI
MimeMessage_CreateWebPage(
1358 IMimeMessage
*iface
,
1360 LPWEBPAGEOPTIONS pOptions
,
1361 IMimeMessageCallback
*pCallback
,
1362 IMoniker
**ppMoniker
)
1364 FIXME("(%p)->(%p, %p, %p, %p)\n", iface
, pRootStm
, pOptions
, pCallback
, ppMoniker
);
1369 static HRESULT WINAPI
MimeMessage_GetProp(
1370 IMimeMessage
*iface
,
1373 LPPROPVARIANT pValue
)
1375 FIXME("(%p)->(%s, 0x%x, %p)\n", iface
, pszName
, dwFlags
, pValue
);
1379 static HRESULT WINAPI
MimeMessage_SetProp(
1380 IMimeMessage
*iface
,
1383 LPCPROPVARIANT pValue
)
1385 FIXME("(%p)->(%s, 0x%x, %p)\n", iface
, pszName
, dwFlags
, pValue
);
1389 static HRESULT WINAPI
MimeMessage_DeleteProp(
1390 IMimeMessage
*iface
,
1393 FIXME("(%p)->(%s)\n", iface
, pszName
);
1397 static HRESULT WINAPI
MimeMessage_QueryProp(
1398 IMimeMessage
*iface
,
1402 boolean fCaseSensitive
)
1404 FIXME("(%p)->(%s, %s, %s, %s)\n", iface
, pszName
, pszCriteria
, fSubString
? "TRUE" : "FALSE", fCaseSensitive
? "TRUE" : "FALSE");
1408 static HRESULT WINAPI
MimeMessage_GetTextBody(
1409 IMimeMessage
*iface
,
1411 ENCODINGTYPE ietEncoding
,
1415 FIXME("(%p)->(%d, %d, %p, %p)\n", iface
, dwTxtType
, ietEncoding
, pStream
, phBody
);
1419 static HRESULT WINAPI
MimeMessage_SetTextBody(
1420 IMimeMessage
*iface
,
1422 ENCODINGTYPE ietEncoding
,
1427 FIXME("(%p)->(%d, %d, %p, %p, %p)\n", iface
, dwTxtType
, ietEncoding
, hAlternative
, pStream
, phBody
);
1431 static HRESULT WINAPI
MimeMessage_AttachObject(
1432 IMimeMessage
*iface
,
1437 FIXME("(%p)->(%s, %p, %p)\n", iface
, debugstr_guid(riid
), pvObject
, phBody
);
1441 static HRESULT WINAPI
MimeMessage_AttachFile(
1442 IMimeMessage
*iface
,
1447 FIXME("(%p)->(%s, %p, %p)\n", iface
, pszFilePath
, pstmFile
, phBody
);
1451 static HRESULT WINAPI
MimeMessage_AttachURL(
1452 IMimeMessage
*iface
,
1460 FIXME("(%p)->(%s, %s, 0x%x, %p, %p, %p)\n", iface
, pszBase
, pszURL
, dwFlags
, pstmURL
, ppszCIDURL
, phBody
);
1464 static HRESULT WINAPI
MimeMessage_GetAttachments(
1465 IMimeMessage
*iface
,
1467 LPHBODY
*pprghAttach
)
1469 FIXME("(%p)->(%p, %p)\n", iface
, pcAttach
, pprghAttach
);
1473 static HRESULT WINAPI
MimeMessage_GetAddressTable(
1474 IMimeMessage
*iface
,
1475 IMimeAddressTable
**ppTable
)
1477 FIXME("(%p)->(%p)\n", iface
, ppTable
);
1481 static HRESULT WINAPI
MimeMessage_GetSender(
1482 IMimeMessage
*iface
,
1483 LPADDRESSPROPS pAddress
)
1485 FIXME("(%p)->(%p)\n", iface
, pAddress
);
1489 static HRESULT WINAPI
MimeMessage_GetAddressTypes(
1490 IMimeMessage
*iface
,
1493 LPADDRESSLIST pList
)
1495 FIXME("(%p)->(%d, %d, %p)\n", iface
, dwAdrTypes
, dwProps
, pList
);
1499 static HRESULT WINAPI
MimeMessage_GetAddressFormat(
1500 IMimeMessage
*iface
,
1502 ADDRESSFORMAT format
,
1505 FIXME("(%p)->(%d, %d, %p)\n", iface
, dwAdrTypes
, format
, ppszFormat
);
1509 static HRESULT WINAPI
MimeMessage_EnumAddressTypes(
1510 IMimeMessage
*iface
,
1513 IMimeEnumAddressTypes
**ppEnum
)
1515 FIXME("(%p)->(%d, %d, %p)\n", iface
, dwAdrTypes
, dwProps
, ppEnum
);
1519 static HRESULT WINAPI
MimeMessage_SplitMessage(
1520 IMimeMessage
*iface
,
1522 IMimeMessageParts
**ppParts
)
1524 FIXME("(%p)->(%d, %p)\n", iface
, cbMaxPart
, ppParts
);
1528 static HRESULT WINAPI
MimeMessage_GetRootMoniker(
1529 IMimeMessage
*iface
,
1530 IMoniker
**ppMoniker
)
1532 FIXME("(%p)->(%p)\n", iface
, ppMoniker
);
1536 static const IMimeMessageVtbl MimeMessageVtbl
=
1538 MimeMessage_QueryInterface
,
1540 MimeMessage_Release
,
1541 MimeMessage_GetClassID
,
1542 MimeMessage_IsDirty
,
1545 MimeMessage_GetSizeMax
,
1546 MimeMessage_InitNew
,
1547 MimeMessage_GetMessageSource
,
1548 MimeMessage_GetMessageSize
,
1549 MimeMessage_LoadOffsetTable
,
1550 MimeMessage_SaveOffsetTable
,
1551 MimeMessage_GetFlags
,
1553 MimeMessage_HandsOffStorage
,
1554 MimeMessage_BindToObject
,
1555 MimeMessage_SaveBody
,
1556 MimeMessage_InsertBody
,
1557 MimeMessage_GetBody
,
1558 MimeMessage_DeleteBody
,
1559 MimeMessage_MoveBody
,
1560 MimeMessage_CountBodies
,
1561 MimeMessage_FindFirst
,
1562 MimeMessage_FindNext
,
1563 MimeMessage_ResolveURL
,
1564 MimeMessage_ToMultipart
,
1565 MimeMessage_GetBodyOffsets
,
1566 MimeMessage_GetCharset
,
1567 MimeMessage_SetCharset
,
1568 MimeMessage_IsBodyType
,
1569 MimeMessage_IsContentType
,
1570 MimeMessage_QueryBodyProp
,
1571 MimeMessage_GetBodyProp
,
1572 MimeMessage_SetBodyProp
,
1573 MimeMessage_DeleteBodyProp
,
1574 MimeMessage_SetOption
,
1575 MimeMessage_GetOption
,
1576 MimeMessage_CreateWebPage
,
1577 MimeMessage_GetProp
,
1578 MimeMessage_SetProp
,
1579 MimeMessage_DeleteProp
,
1580 MimeMessage_QueryProp
,
1581 MimeMessage_GetTextBody
,
1582 MimeMessage_SetTextBody
,
1583 MimeMessage_AttachObject
,
1584 MimeMessage_AttachFile
,
1585 MimeMessage_AttachURL
,
1586 MimeMessage_GetAttachments
,
1587 MimeMessage_GetAddressTable
,
1588 MimeMessage_GetSender
,
1589 MimeMessage_GetAddressTypes
,
1590 MimeMessage_GetAddressFormat
,
1591 MimeMessage_EnumAddressTypes
,
1592 MimeMessage_SplitMessage
,
1593 MimeMessage_GetRootMoniker
,
1596 /***********************************************************************
1597 * MimeOleCreateMessage (INETCOMM.@)
1599 HRESULT WINAPI
MimeOleCreateMessage(IUnknown
*pUnkOuter
, IMimeMessage
**ppMessage
)
1603 TRACE("(%p, %p)\n", pUnkOuter
, ppMessage
);
1607 FIXME("outer unknown not supported yet\n");
1613 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
1614 if (!This
) return E_OUTOFMEMORY
;
1616 This
->lpVtbl
= &MimeMessageVtbl
;
1619 *ppMessage
= (IMimeMessage
*)&This
->lpVtbl
;
1623 /***********************************************************************
1624 * MimeOleSetCompatMode (INETCOMM.@)
1626 HRESULT WINAPI
MimeOleSetCompatMode(DWORD dwMode
)
1628 FIXME("(0x%x)\n", dwMode
);
1632 /***********************************************************************
1633 * MimeOleCreateVirtualStream (INETCOMM.@)
1635 HRESULT WINAPI
MimeOleCreateVirtualStream(IStream
**ppStream
)
1638 FIXME("(%p)\n", ppStream
);
1640 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, ppStream
);
1644 typedef struct MimeSecurity
1646 const IMimeSecurityVtbl
*lpVtbl
;
1651 static HRESULT WINAPI
MimeSecurity_QueryInterface(
1652 IMimeSecurity
* iface
,
1656 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), obj
);
1658 if (IsEqualIID(riid
, &IID_IUnknown
) ||
1659 IsEqualIID(riid
, &IID_IMimeSecurity
))
1662 IUnknown_AddRef(iface
);
1666 FIXME("no interface for %s\n", debugstr_guid(riid
));
1668 return E_NOINTERFACE
;
1671 static ULONG WINAPI
MimeSecurity_AddRef(
1672 IMimeSecurity
* iface
)
1674 MimeSecurity
*This
= (MimeSecurity
*)iface
;
1675 TRACE("(%p)->()\n", iface
);
1676 return InterlockedIncrement(&This
->refs
);
1679 static ULONG WINAPI
MimeSecurity_Release(
1680 IMimeSecurity
* iface
)
1682 MimeSecurity
*This
= (MimeSecurity
*)iface
;
1685 TRACE("(%p)->()\n", iface
);
1687 refs
= InterlockedDecrement(&This
->refs
);
1690 HeapFree(GetProcessHeap(), 0, This
);
1696 static HRESULT WINAPI
MimeSecurity_InitNew(
1697 IMimeSecurity
* iface
)
1699 FIXME("(%p)->(): stub\n", iface
);
1703 static HRESULT WINAPI
MimeSecurity_CheckInit(
1704 IMimeSecurity
* iface
)
1706 FIXME("(%p)->(): stub\n", iface
);
1710 static HRESULT WINAPI
MimeSecurity_EncodeMessage(
1711 IMimeSecurity
* iface
,
1712 IMimeMessageTree
* pTree
,
1715 FIXME("(%p)->(%p, %08x): stub\n", iface
, pTree
, dwFlags
);
1719 static HRESULT WINAPI
MimeSecurity_EncodeBody(
1720 IMimeSecurity
* iface
,
1721 IMimeMessageTree
* pTree
,
1725 FIXME("(%p)->(%p, %p, %08x): stub\n", iface
, pTree
, hEncodeRoot
, dwFlags
);
1729 static HRESULT WINAPI
MimeSecurity_DecodeMessage(
1730 IMimeSecurity
* iface
,
1731 IMimeMessageTree
* pTree
,
1734 FIXME("(%p)->(%p, %08x): stub\n", iface
, pTree
, dwFlags
);
1738 static HRESULT WINAPI
MimeSecurity_DecodeBody(
1739 IMimeSecurity
* iface
,
1740 IMimeMessageTree
* pTree
,
1744 FIXME("(%p)->(%p, %p, %08x): stub\n", iface
, pTree
, hDecodeRoot
, dwFlags
);
1748 static HRESULT WINAPI
MimeSecurity_EnumCertificates(
1749 IMimeSecurity
* iface
,
1755 FIXME("(%p)->(%p, %08x, %p, %p): stub\n", iface
, hc
, dwUsage
, pPrev
, ppCert
);
1759 static HRESULT WINAPI
MimeSecurity_GetCertificateName(
1760 IMimeSecurity
* iface
,
1761 const PCX509CERT pX509Cert
,
1762 const CERTNAMETYPE cn
,
1765 FIXME("(%p)->(%p, %08x, %p): stub\n", iface
, pX509Cert
, cn
, ppszName
);
1769 static HRESULT WINAPI
MimeSecurity_GetMessageType(
1770 IMimeSecurity
* iface
,
1771 const HWND hwndParent
,
1775 FIXME("(%p)->(%p, %p, %p): stub\n", iface
, hwndParent
, pBody
, pdwSecType
);
1779 static HRESULT WINAPI
MimeSecurity_GetCertData(
1780 IMimeSecurity
* iface
,
1781 const PCX509CERT pX509Cert
,
1782 const CERTDATAID dataid
,
1783 LPPROPVARIANT pValue
)
1785 FIXME("(%p)->(%p, %x, %p): stub\n", iface
, pX509Cert
, dataid
, pValue
);
1790 static const IMimeSecurityVtbl MimeSecurityVtbl
=
1792 MimeSecurity_QueryInterface
,
1793 MimeSecurity_AddRef
,
1794 MimeSecurity_Release
,
1795 MimeSecurity_InitNew
,
1796 MimeSecurity_CheckInit
,
1797 MimeSecurity_EncodeMessage
,
1798 MimeSecurity_EncodeBody
,
1799 MimeSecurity_DecodeMessage
,
1800 MimeSecurity_DecodeBody
,
1801 MimeSecurity_EnumCertificates
,
1802 MimeSecurity_GetCertificateName
,
1803 MimeSecurity_GetMessageType
,
1804 MimeSecurity_GetCertData
1807 /***********************************************************************
1808 * MimeOleCreateSecurity (INETCOMM.@)
1810 HRESULT WINAPI
MimeOleCreateSecurity(IMimeSecurity
**ppSecurity
)
1814 TRACE("(%p)\n", ppSecurity
);
1818 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
1819 if (!This
) return E_OUTOFMEMORY
;
1821 This
->lpVtbl
= &MimeSecurityVtbl
;
1824 *ppSecurity
= (IMimeSecurity
*)&This
->lpVtbl
;
1831 IMimeAllocatorVtbl
*lpVtbl
;
1834 static HRESULT WINAPI
MimeAlloc_QueryInterface(
1835 IMimeAllocator
* iface
,
1839 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), obj
);
1841 if (IsEqualIID(riid
, &IID_IUnknown
) ||
1842 IsEqualIID(riid
, &IID_IMalloc
) ||
1843 IsEqualIID(riid
, &IID_IMimeAllocator
))
1846 IUnknown_AddRef(iface
);
1850 FIXME("no interface for %s\n", debugstr_guid(riid
));
1852 return E_NOINTERFACE
;
1855 static ULONG WINAPI
MimeAlloc_AddRef(
1856 IMimeAllocator
* iface
)
1861 static ULONG WINAPI
MimeAlloc_Release(
1862 IMimeAllocator
* iface
)
1867 static LPVOID WINAPI
MimeAlloc_Alloc(
1868 IMimeAllocator
* iface
,
1871 return CoTaskMemAlloc(cb
);
1874 static LPVOID WINAPI
MimeAlloc_Realloc(
1875 IMimeAllocator
* iface
,
1879 return CoTaskMemRealloc(pv
, cb
);
1882 static void WINAPI
MimeAlloc_Free(
1883 IMimeAllocator
* iface
,
1886 return CoTaskMemFree(pv
);
1889 static ULONG WINAPI
MimeAlloc_GetSize(
1890 IMimeAllocator
* iface
,
1897 static int WINAPI
MimeAlloc_DidAlloc(
1898 IMimeAllocator
* iface
,
1905 static void WINAPI
MimeAlloc_HeapMinimize(
1906 IMimeAllocator
* iface
)
1912 static HRESULT WINAPI
MimeAlloc_FreeParamInfoArray(
1913 IMimeAllocator
* iface
,
1915 LPMIMEPARAMINFO prgParam
,
1919 TRACE("(%p)->(%d, %p, %d)\n", iface
, cParams
, prgParam
, fFreeArray
);
1921 for(i
= 0; i
< cParams
; i
++)
1923 IMimeAllocator_Free(iface
, prgParam
[i
].pszName
);
1924 IMimeAllocator_Free(iface
, prgParam
[i
].pszData
);
1926 if(fFreeArray
) IMimeAllocator_Free(iface
, prgParam
);
1930 static HRESULT WINAPI
MimeAlloc_FreeAddressList(
1931 IMimeAllocator
* iface
,
1932 LPADDRESSLIST pList
)
1938 static HRESULT WINAPI
MimeAlloc_FreeAddressProps(
1939 IMimeAllocator
* iface
,
1940 LPADDRESSPROPS pAddress
)
1946 static HRESULT WINAPI
MimeAlloc_ReleaseObjects(
1947 IMimeAllocator
* iface
,
1949 IUnknown
**prgpUnknown
,
1957 static HRESULT WINAPI
MimeAlloc_FreeEnumHeaderRowArray(
1958 IMimeAllocator
* iface
,
1960 LPENUMHEADERROW prgRow
,
1967 static HRESULT WINAPI
MimeAlloc_FreeEnumPropertyArray(
1968 IMimeAllocator
* iface
,
1970 LPENUMPROPERTY prgProp
,
1977 static HRESULT WINAPI
MimeAlloc_FreeThumbprint(
1978 IMimeAllocator
* iface
,
1979 THUMBBLOB
*pthumbprint
)
1986 static HRESULT WINAPI
MimeAlloc_PropVariantClear(
1987 IMimeAllocator
* iface
,
1988 LPPROPVARIANT pProp
)
1994 static IMimeAllocatorVtbl mime_alloc_vtbl
=
1996 MimeAlloc_QueryInterface
,
2004 MimeAlloc_HeapMinimize
,
2005 MimeAlloc_FreeParamInfoArray
,
2006 MimeAlloc_FreeAddressList
,
2007 MimeAlloc_FreeAddressProps
,
2008 MimeAlloc_ReleaseObjects
,
2009 MimeAlloc_FreeEnumHeaderRowArray
,
2010 MimeAlloc_FreeEnumPropertyArray
,
2011 MimeAlloc_FreeThumbprint
,
2012 MimeAlloc_PropVariantClear
2015 static MimeAllocator mime_allocator
=
2020 HRESULT
MimeAllocator_create(IUnknown
*outer
, void **obj
)
2022 if(outer
) return CLASS_E_NOAGGREGATION
;
2024 *obj
= &mime_allocator
;
2028 HRESULT WINAPI
MimeOleGetAllocator(IMimeAllocator
**alloc
)
2030 return MimeAllocator_create(NULL
, (void**)alloc
);