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
;
1093 typedef struct body_t
1097 IMimeBody
*mime_body
;
1099 struct body_t
*parent
;
1100 struct list children
;
1103 typedef struct MimeMessage
1105 const IMimeMessageVtbl
*lpVtbl
;
1110 struct list body_tree
;
1114 static HRESULT WINAPI
MimeMessage_QueryInterface(IMimeMessage
*iface
, REFIID riid
, void **ppv
)
1116 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ppv
);
1118 if (IsEqualIID(riid
, &IID_IUnknown
) ||
1119 IsEqualIID(riid
, &IID_IPersist
) ||
1120 IsEqualIID(riid
, &IID_IPersistStreamInit
) ||
1121 IsEqualIID(riid
, &IID_IMimeMessageTree
) ||
1122 IsEqualIID(riid
, &IID_IMimeMessage
))
1125 IUnknown_AddRef(iface
);
1129 FIXME("no interface for %s\n", debugstr_guid(riid
));
1131 return E_NOINTERFACE
;
1134 static ULONG WINAPI
MimeMessage_AddRef(IMimeMessage
*iface
)
1136 MimeMessage
*This
= (MimeMessage
*)iface
;
1137 TRACE("(%p)->()\n", iface
);
1138 return InterlockedIncrement(&This
->refs
);
1141 static void empty_body_list(struct list
*list
)
1143 body_t
*body
, *cursor2
;
1144 LIST_FOR_EACH_ENTRY_SAFE(body
, cursor2
, list
, body_t
, entry
)
1146 empty_body_list(&body
->children
);
1147 list_remove(&body
->entry
);
1148 IMimeBody_Release(body
->mime_body
);
1149 HeapFree(GetProcessHeap(), 0, body
);
1153 static ULONG WINAPI
MimeMessage_Release(IMimeMessage
*iface
)
1155 MimeMessage
*This
= (MimeMessage
*)iface
;
1158 TRACE("(%p)->()\n", iface
);
1160 refs
= InterlockedDecrement(&This
->refs
);
1163 empty_body_list(&This
->body_tree
);
1165 if(This
->stream
) IStream_Release(This
->stream
);
1166 HeapFree(GetProcessHeap(), 0, This
);
1172 /*** IPersist methods ***/
1173 static HRESULT WINAPI
MimeMessage_GetClassID(
1174 IMimeMessage
*iface
,
1177 FIXME("(%p)->(%p)\n", iface
, pClassID
);
1181 /*** IPersistStreamInit methods ***/
1182 static HRESULT WINAPI
MimeMessage_IsDirty(
1183 IMimeMessage
*iface
)
1185 FIXME("(%p)->()\n", iface
);
1189 static body_t
*new_body_entry(IMimeBody
*mime_body
, HBODY hbody
, body_t
*parent
)
1191 body_t
*body
= HeapAlloc(GetProcessHeap(), 0, sizeof(*body
));
1194 body
->mime_body
= mime_body
;
1195 body
->hbody
= hbody
;
1196 list_init(&body
->children
);
1197 body
->parent
= parent
;
1202 static body_t
*create_sub_body(MimeMessage
*msg
, IStream
*pStm
, BODYOFFSETS
*offset
, body_t
*parent
)
1204 IMimeBody
*mime_body
;
1210 MimeBody_create(NULL
, (void**)&mime_body
);
1211 IMimeBody_Load(mime_body
, pStm
);
1213 hr
= IStream_Seek(pStm
, zero
, STREAM_SEEK_CUR
, &cur
);
1214 offset
->cbBodyStart
= cur
.LowPart
;
1215 IMimeBody_SetData(mime_body
, IET_BINARY
, NULL
, NULL
, &IID_IStream
, pStm
);
1216 body
= new_body_entry(mime_body
, msg
->next_hbody
, parent
);
1217 msg
->next_hbody
= (HBODY
)((DWORD
)msg
->next_hbody
+ 1);
1222 static HRESULT WINAPI
MimeMessage_Load(
1223 IMimeMessage
*iface
,
1226 MimeMessage
*This
= (MimeMessage
*)iface
;
1228 BODYOFFSETS offsets
;
1232 TRACE("(%p)->(%p)\n", iface
, pStm
);
1236 FIXME("already loaded a message\n");
1240 IStream_AddRef(pStm
);
1241 This
->stream
= pStm
;
1242 offsets
.cbBoundaryStart
= offsets
.cbHeaderStart
= 0;
1243 offsets
.cbBodyStart
= offsets
.cbBodyEnd
= 0;
1245 root_body
= create_sub_body(This
, pStm
, &offsets
, NULL
);
1248 IStream_Seek(pStm
, zero
, STREAM_SEEK_END
, &cur
);
1249 offsets
.cbBodyEnd
= cur
.LowPart
;
1250 MimeBody_set_offsets(impl_from_IMimeBody(root_body
->mime_body
), &offsets
);
1252 list_add_head(&This
->body_tree
, &root_body
->entry
);
1257 static HRESULT WINAPI
MimeMessage_Save(
1258 IMimeMessage
*iface
,
1262 FIXME("(%p)->(%p, %s)\n", iface
, pStm
, fClearDirty
? "TRUE" : "FALSE");
1266 static HRESULT WINAPI
MimeMessage_GetSizeMax(
1267 IMimeMessage
*iface
,
1268 ULARGE_INTEGER
*pcbSize
)
1270 FIXME("(%p)->(%p)\n", iface
, pcbSize
);
1274 static HRESULT WINAPI
MimeMessage_InitNew(
1275 IMimeMessage
*iface
)
1277 FIXME("(%p)->()\n", iface
);
1281 /*** IMimeMessageTree methods ***/
1282 static HRESULT WINAPI
MimeMessage_GetMessageSource(
1283 IMimeMessage
*iface
,
1287 FIXME("(%p)->(%p, 0x%x)\n", iface
, ppStream
, dwFlags
);
1291 static HRESULT WINAPI
MimeMessage_GetMessageSize(
1292 IMimeMessage
*iface
,
1296 FIXME("(%p)->(%p, 0x%x)\n", iface
, pcbSize
, dwFlags
);
1300 static HRESULT WINAPI
MimeMessage_LoadOffsetTable(
1301 IMimeMessage
*iface
,
1304 FIXME("(%p)->(%p)\n", iface
, pStream
);
1308 static HRESULT WINAPI
MimeMessage_SaveOffsetTable(
1309 IMimeMessage
*iface
,
1313 FIXME("(%p)->(%p, 0x%x)\n", iface
, pStream
, dwFlags
);
1318 static HRESULT WINAPI
MimeMessage_GetFlags(
1319 IMimeMessage
*iface
,
1322 FIXME("(%p)->(%p)\n", iface
, pdwFlags
);
1326 static HRESULT WINAPI
MimeMessage_Commit(
1327 IMimeMessage
*iface
,
1330 FIXME("(%p)->(0x%x)\n", iface
, dwFlags
);
1335 static HRESULT WINAPI
MimeMessage_HandsOffStorage(
1336 IMimeMessage
*iface
)
1338 FIXME("(%p)->()\n", iface
);
1342 static HRESULT
find_body(struct list
*list
, HBODY hbody
, body_t
**body
)
1347 if(hbody
== HBODY_ROOT
)
1349 *body
= LIST_ENTRY(list_head(list
), body_t
, entry
);
1353 LIST_FOR_EACH_ENTRY(cur
, list
, body_t
, entry
)
1355 if(cur
->hbody
== hbody
)
1360 hr
= find_body(&cur
->children
, hbody
, body
);
1361 if(hr
== S_OK
) return S_OK
;
1366 static HRESULT WINAPI
MimeMessage_BindToObject(
1367 IMimeMessage
*iface
,
1372 MimeMessage
*This
= (MimeMessage
*)iface
;
1376 TRACE("(%p)->(%p, %s, %p)\n", iface
, hBody
, debugstr_guid(riid
), ppvObject
);
1378 hr
= find_body(&This
->body_tree
, hBody
, &body
);
1380 if(hr
!= S_OK
) return hr
;
1382 if(IsEqualIID(riid
, &IID_IMimeBody
))
1384 IMimeBody_AddRef(body
->mime_body
);
1385 *ppvObject
= body
->mime_body
;
1389 return E_NOINTERFACE
;
1392 static HRESULT WINAPI
MimeMessage_SaveBody(
1393 IMimeMessage
*iface
,
1398 FIXME("(%p)->(%p, 0x%x, %p)\n", iface
, hBody
, dwFlags
, pStream
);
1402 static HRESULT WINAPI
MimeMessage_InsertBody(
1403 IMimeMessage
*iface
,
1404 BODYLOCATION location
,
1408 FIXME("(%p)->(%d, %p, %p)\n", iface
, location
, hPivot
, phBody
);
1412 static HRESULT WINAPI
MimeMessage_GetBody(
1413 IMimeMessage
*iface
,
1414 BODYLOCATION location
,
1418 FIXME("(%p)->(%d, %p, %p)\n", iface
, location
, hPivot
, phBody
);
1422 static HRESULT WINAPI
MimeMessage_DeleteBody(
1423 IMimeMessage
*iface
,
1427 FIXME("(%p)->(%p, %08x)\n", iface
, hBody
, dwFlags
);
1431 static HRESULT WINAPI
MimeMessage_MoveBody(
1432 IMimeMessage
*iface
,
1434 BODYLOCATION location
)
1436 FIXME("(%p)->(%d)\n", iface
, location
);
1440 static HRESULT WINAPI
MimeMessage_CountBodies(
1441 IMimeMessage
*iface
,
1446 FIXME("(%p)->(%p, %s, %p)\n", iface
, hParent
, fRecurse
? "TRUE" : "FALSE", pcBodies
);
1450 static HRESULT WINAPI
MimeMessage_FindFirst(
1451 IMimeMessage
*iface
,
1452 LPFINDBODY pFindBody
,
1455 FIXME("(%p)->(%p, %p)\n", iface
, pFindBody
, phBody
);
1459 static HRESULT WINAPI
MimeMessage_FindNext(
1460 IMimeMessage
*iface
,
1461 LPFINDBODY pFindBody
,
1464 FIXME("(%p)->(%p, %p)\n", iface
, pFindBody
, phBody
);
1468 static HRESULT WINAPI
MimeMessage_ResolveURL(
1469 IMimeMessage
*iface
,
1476 FIXME("(%p)->(%p, %s, %s, 0x%x, %p)\n", iface
, hRelated
, pszBase
, pszURL
, dwFlags
, phBody
);
1480 static HRESULT WINAPI
MimeMessage_ToMultipart(
1481 IMimeMessage
*iface
,
1484 LPHBODY phMultipart
)
1486 FIXME("(%p)->(%p, %s, %p)\n", iface
, hBody
, pszSubType
, phMultipart
);
1490 static HRESULT WINAPI
MimeMessage_GetBodyOffsets(
1491 IMimeMessage
*iface
,
1493 LPBODYOFFSETS pOffsets
)
1495 FIXME("(%p)->(%p, %p)\n", iface
, hBody
, pOffsets
);
1499 static HRESULT WINAPI
MimeMessage_GetCharset(
1500 IMimeMessage
*iface
,
1501 LPHCHARSET phCharset
)
1503 FIXME("(%p)->(%p)\n", iface
, phCharset
);
1507 static HRESULT WINAPI
MimeMessage_SetCharset(
1508 IMimeMessage
*iface
,
1510 CSETAPPLYTYPE applytype
)
1512 FIXME("(%p)->(%p, %d)\n", iface
, hCharset
, applytype
);
1516 static HRESULT WINAPI
MimeMessage_IsBodyType(
1517 IMimeMessage
*iface
,
1519 IMSGBODYTYPE bodytype
)
1521 FIXME("(%p)->(%p, %d)\n", iface
, hBody
, bodytype
);
1525 static HRESULT WINAPI
MimeMessage_IsContentType(
1526 IMimeMessage
*iface
,
1531 FIXME("(%p)->(%p, %s, %s)\n", iface
, hBody
, pszPriType
, pszSubType
);
1535 static HRESULT WINAPI
MimeMessage_QueryBodyProp(
1536 IMimeMessage
*iface
,
1541 boolean fCaseSensitive
)
1543 FIXME("(%p)->(%p, %s, %s, %s, %s)\n", iface
, hBody
, pszName
, pszCriteria
, fSubString
? "TRUE" : "FALSE", fCaseSensitive
? "TRUE" : "FALSE");
1547 static HRESULT WINAPI
MimeMessage_GetBodyProp(
1548 IMimeMessage
*iface
,
1552 LPPROPVARIANT pValue
)
1554 FIXME("(%p)->(%p, %s, 0x%x, %p)\n", iface
, hBody
, pszName
, dwFlags
, pValue
);
1558 static HRESULT WINAPI
MimeMessage_SetBodyProp(
1559 IMimeMessage
*iface
,
1563 LPCPROPVARIANT pValue
)
1565 FIXME("(%p)->(%p, %s, 0x%x, %p)\n", iface
, hBody
, pszName
, dwFlags
, pValue
);
1569 static HRESULT WINAPI
MimeMessage_DeleteBodyProp(
1570 IMimeMessage
*iface
,
1574 FIXME("(%p)->(%p, %s)\n", iface
, hBody
, pszName
);
1578 static HRESULT WINAPI
MimeMessage_SetOption(
1579 IMimeMessage
*iface
,
1581 LPCPROPVARIANT pValue
)
1583 FIXME("(%p)->(%d, %p)\n", iface
, oid
, pValue
);
1587 static HRESULT WINAPI
MimeMessage_GetOption(
1588 IMimeMessage
*iface
,
1590 LPPROPVARIANT pValue
)
1592 FIXME("(%p)->(%d, %p)\n", iface
, oid
, pValue
);
1596 /*** IMimeMessage methods ***/
1597 static HRESULT WINAPI
MimeMessage_CreateWebPage(
1598 IMimeMessage
*iface
,
1600 LPWEBPAGEOPTIONS pOptions
,
1601 IMimeMessageCallback
*pCallback
,
1602 IMoniker
**ppMoniker
)
1604 FIXME("(%p)->(%p, %p, %p, %p)\n", iface
, pRootStm
, pOptions
, pCallback
, ppMoniker
);
1609 static HRESULT WINAPI
MimeMessage_GetProp(
1610 IMimeMessage
*iface
,
1613 LPPROPVARIANT pValue
)
1615 FIXME("(%p)->(%s, 0x%x, %p)\n", iface
, pszName
, dwFlags
, pValue
);
1619 static HRESULT WINAPI
MimeMessage_SetProp(
1620 IMimeMessage
*iface
,
1623 LPCPROPVARIANT pValue
)
1625 FIXME("(%p)->(%s, 0x%x, %p)\n", iface
, pszName
, dwFlags
, pValue
);
1629 static HRESULT WINAPI
MimeMessage_DeleteProp(
1630 IMimeMessage
*iface
,
1633 FIXME("(%p)->(%s)\n", iface
, pszName
);
1637 static HRESULT WINAPI
MimeMessage_QueryProp(
1638 IMimeMessage
*iface
,
1642 boolean fCaseSensitive
)
1644 FIXME("(%p)->(%s, %s, %s, %s)\n", iface
, pszName
, pszCriteria
, fSubString
? "TRUE" : "FALSE", fCaseSensitive
? "TRUE" : "FALSE");
1648 static HRESULT WINAPI
MimeMessage_GetTextBody(
1649 IMimeMessage
*iface
,
1651 ENCODINGTYPE ietEncoding
,
1655 FIXME("(%p)->(%d, %d, %p, %p)\n", iface
, dwTxtType
, ietEncoding
, pStream
, phBody
);
1659 static HRESULT WINAPI
MimeMessage_SetTextBody(
1660 IMimeMessage
*iface
,
1662 ENCODINGTYPE ietEncoding
,
1667 FIXME("(%p)->(%d, %d, %p, %p, %p)\n", iface
, dwTxtType
, ietEncoding
, hAlternative
, pStream
, phBody
);
1671 static HRESULT WINAPI
MimeMessage_AttachObject(
1672 IMimeMessage
*iface
,
1677 FIXME("(%p)->(%s, %p, %p)\n", iface
, debugstr_guid(riid
), pvObject
, phBody
);
1681 static HRESULT WINAPI
MimeMessage_AttachFile(
1682 IMimeMessage
*iface
,
1687 FIXME("(%p)->(%s, %p, %p)\n", iface
, pszFilePath
, pstmFile
, phBody
);
1691 static HRESULT WINAPI
MimeMessage_AttachURL(
1692 IMimeMessage
*iface
,
1700 FIXME("(%p)->(%s, %s, 0x%x, %p, %p, %p)\n", iface
, pszBase
, pszURL
, dwFlags
, pstmURL
, ppszCIDURL
, phBody
);
1704 static HRESULT WINAPI
MimeMessage_GetAttachments(
1705 IMimeMessage
*iface
,
1707 LPHBODY
*pprghAttach
)
1709 FIXME("(%p)->(%p, %p)\n", iface
, pcAttach
, pprghAttach
);
1713 static HRESULT WINAPI
MimeMessage_GetAddressTable(
1714 IMimeMessage
*iface
,
1715 IMimeAddressTable
**ppTable
)
1717 FIXME("(%p)->(%p)\n", iface
, ppTable
);
1721 static HRESULT WINAPI
MimeMessage_GetSender(
1722 IMimeMessage
*iface
,
1723 LPADDRESSPROPS pAddress
)
1725 FIXME("(%p)->(%p)\n", iface
, pAddress
);
1729 static HRESULT WINAPI
MimeMessage_GetAddressTypes(
1730 IMimeMessage
*iface
,
1733 LPADDRESSLIST pList
)
1735 FIXME("(%p)->(%d, %d, %p)\n", iface
, dwAdrTypes
, dwProps
, pList
);
1739 static HRESULT WINAPI
MimeMessage_GetAddressFormat(
1740 IMimeMessage
*iface
,
1742 ADDRESSFORMAT format
,
1745 FIXME("(%p)->(%d, %d, %p)\n", iface
, dwAdrTypes
, format
, ppszFormat
);
1749 static HRESULT WINAPI
MimeMessage_EnumAddressTypes(
1750 IMimeMessage
*iface
,
1753 IMimeEnumAddressTypes
**ppEnum
)
1755 FIXME("(%p)->(%d, %d, %p)\n", iface
, dwAdrTypes
, dwProps
, ppEnum
);
1759 static HRESULT WINAPI
MimeMessage_SplitMessage(
1760 IMimeMessage
*iface
,
1762 IMimeMessageParts
**ppParts
)
1764 FIXME("(%p)->(%d, %p)\n", iface
, cbMaxPart
, ppParts
);
1768 static HRESULT WINAPI
MimeMessage_GetRootMoniker(
1769 IMimeMessage
*iface
,
1770 IMoniker
**ppMoniker
)
1772 FIXME("(%p)->(%p)\n", iface
, ppMoniker
);
1776 static const IMimeMessageVtbl MimeMessageVtbl
=
1778 MimeMessage_QueryInterface
,
1780 MimeMessage_Release
,
1781 MimeMessage_GetClassID
,
1782 MimeMessage_IsDirty
,
1785 MimeMessage_GetSizeMax
,
1786 MimeMessage_InitNew
,
1787 MimeMessage_GetMessageSource
,
1788 MimeMessage_GetMessageSize
,
1789 MimeMessage_LoadOffsetTable
,
1790 MimeMessage_SaveOffsetTable
,
1791 MimeMessage_GetFlags
,
1793 MimeMessage_HandsOffStorage
,
1794 MimeMessage_BindToObject
,
1795 MimeMessage_SaveBody
,
1796 MimeMessage_InsertBody
,
1797 MimeMessage_GetBody
,
1798 MimeMessage_DeleteBody
,
1799 MimeMessage_MoveBody
,
1800 MimeMessage_CountBodies
,
1801 MimeMessage_FindFirst
,
1802 MimeMessage_FindNext
,
1803 MimeMessage_ResolveURL
,
1804 MimeMessage_ToMultipart
,
1805 MimeMessage_GetBodyOffsets
,
1806 MimeMessage_GetCharset
,
1807 MimeMessage_SetCharset
,
1808 MimeMessage_IsBodyType
,
1809 MimeMessage_IsContentType
,
1810 MimeMessage_QueryBodyProp
,
1811 MimeMessage_GetBodyProp
,
1812 MimeMessage_SetBodyProp
,
1813 MimeMessage_DeleteBodyProp
,
1814 MimeMessage_SetOption
,
1815 MimeMessage_GetOption
,
1816 MimeMessage_CreateWebPage
,
1817 MimeMessage_GetProp
,
1818 MimeMessage_SetProp
,
1819 MimeMessage_DeleteProp
,
1820 MimeMessage_QueryProp
,
1821 MimeMessage_GetTextBody
,
1822 MimeMessage_SetTextBody
,
1823 MimeMessage_AttachObject
,
1824 MimeMessage_AttachFile
,
1825 MimeMessage_AttachURL
,
1826 MimeMessage_GetAttachments
,
1827 MimeMessage_GetAddressTable
,
1828 MimeMessage_GetSender
,
1829 MimeMessage_GetAddressTypes
,
1830 MimeMessage_GetAddressFormat
,
1831 MimeMessage_EnumAddressTypes
,
1832 MimeMessage_SplitMessage
,
1833 MimeMessage_GetRootMoniker
,
1836 /***********************************************************************
1837 * MimeOleCreateMessage (INETCOMM.@)
1839 HRESULT WINAPI
MimeOleCreateMessage(IUnknown
*pUnkOuter
, IMimeMessage
**ppMessage
)
1843 TRACE("(%p, %p)\n", pUnkOuter
, ppMessage
);
1847 FIXME("outer unknown not supported yet\n");
1853 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
1854 if (!This
) return E_OUTOFMEMORY
;
1856 This
->lpVtbl
= &MimeMessageVtbl
;
1858 This
->stream
= NULL
;
1859 list_init(&This
->body_tree
);
1860 This
->next_hbody
= (HBODY
)1;
1862 *ppMessage
= (IMimeMessage
*)&This
->lpVtbl
;
1866 /***********************************************************************
1867 * MimeOleSetCompatMode (INETCOMM.@)
1869 HRESULT WINAPI
MimeOleSetCompatMode(DWORD dwMode
)
1871 FIXME("(0x%x)\n", dwMode
);
1875 /***********************************************************************
1876 * MimeOleCreateVirtualStream (INETCOMM.@)
1878 HRESULT WINAPI
MimeOleCreateVirtualStream(IStream
**ppStream
)
1881 FIXME("(%p)\n", ppStream
);
1883 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, ppStream
);
1887 typedef struct MimeSecurity
1889 const IMimeSecurityVtbl
*lpVtbl
;
1894 static HRESULT WINAPI
MimeSecurity_QueryInterface(
1895 IMimeSecurity
* iface
,
1899 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), obj
);
1901 if (IsEqualIID(riid
, &IID_IUnknown
) ||
1902 IsEqualIID(riid
, &IID_IMimeSecurity
))
1905 IUnknown_AddRef(iface
);
1909 FIXME("no interface for %s\n", debugstr_guid(riid
));
1911 return E_NOINTERFACE
;
1914 static ULONG WINAPI
MimeSecurity_AddRef(
1915 IMimeSecurity
* iface
)
1917 MimeSecurity
*This
= (MimeSecurity
*)iface
;
1918 TRACE("(%p)->()\n", iface
);
1919 return InterlockedIncrement(&This
->refs
);
1922 static ULONG WINAPI
MimeSecurity_Release(
1923 IMimeSecurity
* iface
)
1925 MimeSecurity
*This
= (MimeSecurity
*)iface
;
1928 TRACE("(%p)->()\n", iface
);
1930 refs
= InterlockedDecrement(&This
->refs
);
1933 HeapFree(GetProcessHeap(), 0, This
);
1939 static HRESULT WINAPI
MimeSecurity_InitNew(
1940 IMimeSecurity
* iface
)
1942 FIXME("(%p)->(): stub\n", iface
);
1946 static HRESULT WINAPI
MimeSecurity_CheckInit(
1947 IMimeSecurity
* iface
)
1949 FIXME("(%p)->(): stub\n", iface
);
1953 static HRESULT WINAPI
MimeSecurity_EncodeMessage(
1954 IMimeSecurity
* iface
,
1955 IMimeMessageTree
* pTree
,
1958 FIXME("(%p)->(%p, %08x): stub\n", iface
, pTree
, dwFlags
);
1962 static HRESULT WINAPI
MimeSecurity_EncodeBody(
1963 IMimeSecurity
* iface
,
1964 IMimeMessageTree
* pTree
,
1968 FIXME("(%p)->(%p, %p, %08x): stub\n", iface
, pTree
, hEncodeRoot
, dwFlags
);
1972 static HRESULT WINAPI
MimeSecurity_DecodeMessage(
1973 IMimeSecurity
* iface
,
1974 IMimeMessageTree
* pTree
,
1977 FIXME("(%p)->(%p, %08x): stub\n", iface
, pTree
, dwFlags
);
1981 static HRESULT WINAPI
MimeSecurity_DecodeBody(
1982 IMimeSecurity
* iface
,
1983 IMimeMessageTree
* pTree
,
1987 FIXME("(%p)->(%p, %p, %08x): stub\n", iface
, pTree
, hDecodeRoot
, dwFlags
);
1991 static HRESULT WINAPI
MimeSecurity_EnumCertificates(
1992 IMimeSecurity
* iface
,
1998 FIXME("(%p)->(%p, %08x, %p, %p): stub\n", iface
, hc
, dwUsage
, pPrev
, ppCert
);
2002 static HRESULT WINAPI
MimeSecurity_GetCertificateName(
2003 IMimeSecurity
* iface
,
2004 const PCX509CERT pX509Cert
,
2005 const CERTNAMETYPE cn
,
2008 FIXME("(%p)->(%p, %08x, %p): stub\n", iface
, pX509Cert
, cn
, ppszName
);
2012 static HRESULT WINAPI
MimeSecurity_GetMessageType(
2013 IMimeSecurity
* iface
,
2014 const HWND hwndParent
,
2018 FIXME("(%p)->(%p, %p, %p): stub\n", iface
, hwndParent
, pBody
, pdwSecType
);
2022 static HRESULT WINAPI
MimeSecurity_GetCertData(
2023 IMimeSecurity
* iface
,
2024 const PCX509CERT pX509Cert
,
2025 const CERTDATAID dataid
,
2026 LPPROPVARIANT pValue
)
2028 FIXME("(%p)->(%p, %x, %p): stub\n", iface
, pX509Cert
, dataid
, pValue
);
2033 static const IMimeSecurityVtbl MimeSecurityVtbl
=
2035 MimeSecurity_QueryInterface
,
2036 MimeSecurity_AddRef
,
2037 MimeSecurity_Release
,
2038 MimeSecurity_InitNew
,
2039 MimeSecurity_CheckInit
,
2040 MimeSecurity_EncodeMessage
,
2041 MimeSecurity_EncodeBody
,
2042 MimeSecurity_DecodeMessage
,
2043 MimeSecurity_DecodeBody
,
2044 MimeSecurity_EnumCertificates
,
2045 MimeSecurity_GetCertificateName
,
2046 MimeSecurity_GetMessageType
,
2047 MimeSecurity_GetCertData
2050 /***********************************************************************
2051 * MimeOleCreateSecurity (INETCOMM.@)
2053 HRESULT WINAPI
MimeOleCreateSecurity(IMimeSecurity
**ppSecurity
)
2057 TRACE("(%p)\n", ppSecurity
);
2061 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
2062 if (!This
) return E_OUTOFMEMORY
;
2064 This
->lpVtbl
= &MimeSecurityVtbl
;
2067 *ppSecurity
= (IMimeSecurity
*)&This
->lpVtbl
;
2074 IMimeAllocatorVtbl
*lpVtbl
;
2077 static HRESULT WINAPI
MimeAlloc_QueryInterface(
2078 IMimeAllocator
* iface
,
2082 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), obj
);
2084 if (IsEqualIID(riid
, &IID_IUnknown
) ||
2085 IsEqualIID(riid
, &IID_IMalloc
) ||
2086 IsEqualIID(riid
, &IID_IMimeAllocator
))
2089 IUnknown_AddRef(iface
);
2093 FIXME("no interface for %s\n", debugstr_guid(riid
));
2095 return E_NOINTERFACE
;
2098 static ULONG WINAPI
MimeAlloc_AddRef(
2099 IMimeAllocator
* iface
)
2104 static ULONG WINAPI
MimeAlloc_Release(
2105 IMimeAllocator
* iface
)
2110 static LPVOID WINAPI
MimeAlloc_Alloc(
2111 IMimeAllocator
* iface
,
2114 return CoTaskMemAlloc(cb
);
2117 static LPVOID WINAPI
MimeAlloc_Realloc(
2118 IMimeAllocator
* iface
,
2122 return CoTaskMemRealloc(pv
, cb
);
2125 static void WINAPI
MimeAlloc_Free(
2126 IMimeAllocator
* iface
,
2129 return CoTaskMemFree(pv
);
2132 static ULONG WINAPI
MimeAlloc_GetSize(
2133 IMimeAllocator
* iface
,
2140 static int WINAPI
MimeAlloc_DidAlloc(
2141 IMimeAllocator
* iface
,
2148 static void WINAPI
MimeAlloc_HeapMinimize(
2149 IMimeAllocator
* iface
)
2155 static HRESULT WINAPI
MimeAlloc_FreeParamInfoArray(
2156 IMimeAllocator
* iface
,
2158 LPMIMEPARAMINFO prgParam
,
2162 TRACE("(%p)->(%d, %p, %d)\n", iface
, cParams
, prgParam
, fFreeArray
);
2164 for(i
= 0; i
< cParams
; i
++)
2166 IMimeAllocator_Free(iface
, prgParam
[i
].pszName
);
2167 IMimeAllocator_Free(iface
, prgParam
[i
].pszData
);
2169 if(fFreeArray
) IMimeAllocator_Free(iface
, prgParam
);
2173 static HRESULT WINAPI
MimeAlloc_FreeAddressList(
2174 IMimeAllocator
* iface
,
2175 LPADDRESSLIST pList
)
2181 static HRESULT WINAPI
MimeAlloc_FreeAddressProps(
2182 IMimeAllocator
* iface
,
2183 LPADDRESSPROPS pAddress
)
2189 static HRESULT WINAPI
MimeAlloc_ReleaseObjects(
2190 IMimeAllocator
* iface
,
2192 IUnknown
**prgpUnknown
,
2200 static HRESULT WINAPI
MimeAlloc_FreeEnumHeaderRowArray(
2201 IMimeAllocator
* iface
,
2203 LPENUMHEADERROW prgRow
,
2210 static HRESULT WINAPI
MimeAlloc_FreeEnumPropertyArray(
2211 IMimeAllocator
* iface
,
2213 LPENUMPROPERTY prgProp
,
2220 static HRESULT WINAPI
MimeAlloc_FreeThumbprint(
2221 IMimeAllocator
* iface
,
2222 THUMBBLOB
*pthumbprint
)
2229 static HRESULT WINAPI
MimeAlloc_PropVariantClear(
2230 IMimeAllocator
* iface
,
2231 LPPROPVARIANT pProp
)
2237 static IMimeAllocatorVtbl mime_alloc_vtbl
=
2239 MimeAlloc_QueryInterface
,
2247 MimeAlloc_HeapMinimize
,
2248 MimeAlloc_FreeParamInfoArray
,
2249 MimeAlloc_FreeAddressList
,
2250 MimeAlloc_FreeAddressProps
,
2251 MimeAlloc_ReleaseObjects
,
2252 MimeAlloc_FreeEnumHeaderRowArray
,
2253 MimeAlloc_FreeEnumPropertyArray
,
2254 MimeAlloc_FreeThumbprint
,
2255 MimeAlloc_PropVariantClear
2258 static MimeAllocator mime_allocator
=
2263 HRESULT
MimeAllocator_create(IUnknown
*outer
, void **obj
)
2265 if(outer
) return CLASS_E_NOAGGREGATION
;
2267 *obj
= &mime_allocator
;
2271 HRESULT WINAPI
MimeOleGetAllocator(IMimeAllocator
**alloc
)
2273 return MimeAllocator_create(NULL
, (void**)alloc
);