4 * Copyright 2006 Robert Shearman for CodeWeavers
5 * Copyright 2007 Huw Davies for CodeWeavers
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "inetcomm_private.h"
25 #include <propvarutil.h>
31 DWORD flags
; /* MIMEPROPFLAGS */
39 } property_list_entry_t
;
41 static const property_t default_props
[] =
43 {"X-Newsgroup", PID_HDR_NEWSGROUP
, 0, VT_LPSTR
},
44 {"Newsgroups", PID_HDR_NEWSGROUPS
, 0, VT_LPSTR
},
45 {"References", PID_HDR_REFS
, 0, VT_LPSTR
},
46 {"Subject", PID_HDR_SUBJECT
, 0, VT_LPSTR
},
47 {"From", PID_HDR_FROM
, MPF_ADDRESS
, VT_LPSTR
},
48 {"Message-ID", PID_HDR_MESSAGEID
, 0, VT_LPSTR
},
49 {"Return-Path", PID_HDR_RETURNPATH
, MPF_ADDRESS
, VT_LPSTR
},
50 {"Rr", PID_HDR_RR
, 0, VT_LPSTR
},
51 {"Return-Receipt-To", PID_HDR_RETRCPTO
, MPF_ADDRESS
, VT_LPSTR
},
52 {"Apparently-To", PID_HDR_APPARTO
, MPF_ADDRESS
, VT_LPSTR
},
53 {"Date", PID_HDR_DATE
, 0, VT_LPSTR
},
54 {"Received", PID_HDR_RECEIVED
, 0, VT_LPSTR
},
55 {"Reply-To", PID_HDR_REPLYTO
, MPF_ADDRESS
, VT_LPSTR
},
56 {"X-Mailer", PID_HDR_XMAILER
, 0, VT_LPSTR
},
57 {"Bcc", PID_HDR_BCC
, MPF_ADDRESS
, VT_LPSTR
},
58 {"MIME-Version", PID_HDR_MIMEVER
, MPF_MIME
, VT_LPSTR
},
59 {"Content-Type", PID_HDR_CNTTYPE
, MPF_MIME
| MPF_HASPARAMS
, VT_LPSTR
},
60 {"Content-Transfer-Encoding", PID_HDR_CNTXFER
, MPF_MIME
, VT_LPSTR
},
61 {"Content-ID", PID_HDR_CNTID
, MPF_MIME
, VT_LPSTR
},
62 {"Content-Description", PID_HDR_CNTDESC
, MPF_MIME
, VT_LPSTR
},
63 {"Content-Disposition", PID_HDR_CNTDISP
, MPF_MIME
| MPF_HASPARAMS
, VT_LPSTR
},
64 {"Content-Base", PID_HDR_CNTBASE
, MPF_MIME
, VT_LPSTR
},
65 {"Content-Location", PID_HDR_CNTLOC
, MPF_MIME
, VT_LPSTR
},
66 {"To", PID_HDR_TO
, MPF_ADDRESS
, VT_LPSTR
},
67 {"Path", PID_HDR_PATH
, 0, VT_LPSTR
},
68 {"Followup-To", PID_HDR_FOLLOWUPTO
, 0, VT_LPSTR
},
69 {"Expires", PID_HDR_EXPIRES
, 0, VT_LPSTR
},
70 {"Cc", PID_HDR_CC
, MPF_ADDRESS
, VT_LPSTR
},
71 {"Control", PID_HDR_CONTROL
, 0, VT_LPSTR
},
72 {"Distribution", PID_HDR_DISTRIB
, 0, VT_LPSTR
},
73 {"Keywords", PID_HDR_KEYWORDS
, 0, VT_LPSTR
},
74 {"Summary", PID_HDR_SUMMARY
, 0, VT_LPSTR
},
75 {"Approved", PID_HDR_APPROVED
, 0, VT_LPSTR
},
76 {"Lines", PID_HDR_LINES
, 0, VT_LPSTR
},
77 {"Xref", PID_HDR_XREF
, 0, VT_LPSTR
},
78 {"Organization", PID_HDR_ORG
, 0, VT_LPSTR
},
79 {"X-Newsreader", PID_HDR_XNEWSRDR
, 0, VT_LPSTR
},
80 {"X-Priority", PID_HDR_XPRI
, 0, VT_LPSTR
},
81 {"X-MSMail-Priority", PID_HDR_XMSPRI
, 0, VT_LPSTR
},
82 {"par:content-disposition:filename", PID_PAR_FILENAME
, 0, VT_LPSTR
},
83 {"par:content-type:boundary", PID_PAR_BOUNDARY
, 0, VT_LPSTR
},
84 {"par:content-type:charset", PID_PAR_CHARSET
, 0, VT_LPSTR
},
85 {"par:content-type:name", PID_PAR_NAME
, 0, VT_LPSTR
},
86 {"att:filename", PID_ATT_FILENAME
, 0, VT_LPSTR
},
87 {"att:pri-content-type", PID_ATT_PRITYPE
, 0, VT_LPSTR
},
88 {"att:sub-content-type", PID_ATT_SUBTYPE
, 0, VT_LPSTR
},
89 {"att:illegal-lines", PID_ATT_ILLEGAL
, 0, VT_LPSTR
},
90 {"att:rendered", PID_ATT_RENDERED
, 0, VT_LPSTR
},
91 {"att:sent-time", PID_ATT_SENTTIME
, 0, VT_LPSTR
},
92 {"att:priority", PID_ATT_PRIORITY
, 0, VT_LPSTR
},
93 {"Comment", PID_HDR_COMMENT
, 0, VT_LPSTR
},
94 {"Encoding", PID_HDR_ENCODING
, 0, VT_LPSTR
},
95 {"Encrypted", PID_HDR_ENCRYPTED
, 0, VT_LPSTR
},
96 {"X-Offsets", PID_HDR_OFFSETS
, 0, VT_LPSTR
},
97 {"X-Unsent", PID_HDR_XUNSENT
, 0, VT_LPSTR
},
98 {"X-ArticleId", PID_HDR_ARTICLEID
, 0, VT_LPSTR
},
99 {"Sender", PID_HDR_SENDER
, MPF_ADDRESS
, VT_LPSTR
},
100 {"att:athena-server", PID_ATT_SERVER
, 0, VT_LPSTR
},
101 {"att:athena-account-id", PID_ATT_ACCOUNT
, 0, VT_LPSTR
},
102 {"att:athena-pop3-uidl", PID_ATT_UIDL
, 0, VT_LPSTR
},
103 {"att:athena-store-msgid", PID_ATT_STOREMSGID
, 0, VT_LPSTR
},
104 {"att:athena-user-name", PID_ATT_USERNAME
, 0, VT_LPSTR
},
105 {"att:athena-forward-to", PID_ATT_FORWARDTO
, 0, VT_LPSTR
},
106 {"att:athena-store-fdrid", PID_ATT_STOREFOLDERID
,0, VT_LPSTR
},
107 {"att:athena-ghosted", PID_ATT_GHOSTED
, 0, VT_LPSTR
},
108 {"att:athena-uncachedsize", PID_ATT_UNCACHEDSIZE
, 0, VT_LPSTR
},
109 {"att:athena-combined", PID_ATT_COMBINED
, 0, VT_LPSTR
},
110 {"att:auto-inlined", PID_ATT_AUTOINLINED
, 0, VT_LPSTR
},
111 {"Disposition-Notification-To", PID_HDR_DISP_NOTIFICATION_TO
, 0, VT_LPSTR
},
112 {"par:Content-Type:reply-type", PID_PAR_REPLYTYPE
, 0, VT_LPSTR
},
113 {"par:Content-Type:format", PID_PAR_FORMAT
, 0, VT_LPSTR
},
114 {"att:format", PID_ATT_FORMAT
, 0, VT_LPSTR
},
115 {"In-Reply-To", PID_HDR_INREPLYTO
, 0, VT_LPSTR
},
116 {"att:athena-account-name", PID_ATT_ACCOUNTNAME
, 0, VT_LPSTR
},
130 const property_t
*prop
;
135 typedef struct MimeBody
137 IMimeBody IMimeBody_iface
;
143 struct list new_props
; /* FIXME: This should be in a PropertySchema */
145 char *content_pri_type
;
146 char *content_sub_type
;
147 ENCODINGTYPE encoding
;
150 BODYOFFSETS body_offsets
;
155 IStream IStream_iface
;
158 ULARGE_INTEGER pos
, start
, length
;
161 static inline sub_stream_t
*impl_from_IStream(IStream
*iface
)
163 return CONTAINING_RECORD(iface
, sub_stream_t
, IStream_iface
);
166 static HRESULT WINAPI
sub_stream_QueryInterface(IStream
*iface
, REFIID riid
, void **ppv
)
168 sub_stream_t
*This
= impl_from_IStream(iface
);
170 TRACE("(%p)->(%s, %p)\n", This
, debugstr_guid(riid
), ppv
);
173 if(IsEqualIID(riid
, &IID_IUnknown
) ||
174 IsEqualIID(riid
, &IID_ISequentialStream
) ||
175 IsEqualIID(riid
, &IID_IStream
))
177 IStream_AddRef(iface
);
181 return E_NOINTERFACE
;
184 static ULONG WINAPI
sub_stream_AddRef(IStream
*iface
)
186 sub_stream_t
*This
= impl_from_IStream(iface
);
187 LONG ref
= InterlockedIncrement(&This
->ref
);
189 TRACE("(%p) ref=%d\n", This
, ref
);
194 static ULONG WINAPI
sub_stream_Release(IStream
*iface
)
196 sub_stream_t
*This
= impl_from_IStream(iface
);
197 LONG ref
= InterlockedDecrement(&This
->ref
);
199 TRACE("(%p) ref=%d\n", This
, ref
);
203 IStream_Release(This
->base
);
204 HeapFree(GetProcessHeap(), 0, This
);
209 static HRESULT WINAPI
sub_stream_Read(
215 sub_stream_t
*This
= impl_from_IStream(iface
);
217 LARGE_INTEGER tmp_pos
;
219 TRACE("(%p, %d, %p)\n", pv
, cb
, pcbRead
);
221 tmp_pos
.QuadPart
= This
->pos
.QuadPart
+ This
->start
.QuadPart
;
222 IStream_Seek(This
->base
, tmp_pos
, STREAM_SEEK_SET
, NULL
);
224 if(This
->pos
.QuadPart
+ cb
> This
->length
.QuadPart
)
225 cb
= This
->length
.QuadPart
- This
->pos
.QuadPart
;
227 hr
= IStream_Read(This
->base
, pv
, cb
, pcbRead
);
229 This
->pos
.QuadPart
+= *pcbRead
;
234 static HRESULT WINAPI
sub_stream_Write(
244 static HRESULT WINAPI
sub_stream_Seek(
246 LARGE_INTEGER dlibMove
,
248 ULARGE_INTEGER
*plibNewPosition
)
250 sub_stream_t
*This
= impl_from_IStream(iface
);
251 LARGE_INTEGER new_pos
;
253 TRACE("(%08x.%08x, %x, %p)\n", dlibMove
.u
.HighPart
, dlibMove
.u
.LowPart
, dwOrigin
, plibNewPosition
);
257 case STREAM_SEEK_SET
:
260 case STREAM_SEEK_CUR
:
261 new_pos
.QuadPart
= This
->pos
.QuadPart
+ dlibMove
.QuadPart
;
263 case STREAM_SEEK_END
:
264 new_pos
.QuadPart
= This
->length
.QuadPart
+ dlibMove
.QuadPart
;
267 return STG_E_INVALIDFUNCTION
;
270 if(new_pos
.QuadPart
< 0) new_pos
.QuadPart
= 0;
271 else if(new_pos
.QuadPart
> This
->length
.QuadPart
) new_pos
.QuadPart
= This
->length
.QuadPart
;
273 This
->pos
.QuadPart
= new_pos
.QuadPart
;
275 if(plibNewPosition
) *plibNewPosition
= This
->pos
;
279 static HRESULT WINAPI
sub_stream_SetSize(
281 ULARGE_INTEGER libNewSize
)
287 static HRESULT WINAPI
sub_stream_CopyTo(
291 ULARGE_INTEGER
*pcbRead
,
292 ULARGE_INTEGER
*pcbWritten
)
296 ULONG bytesRead
, bytesWritten
, copySize
;
297 ULARGE_INTEGER totalBytesRead
;
298 ULARGE_INTEGER totalBytesWritten
;
300 TRACE("(%p)->(%p, %d, %p, %p)\n", iface
, pstm
, cb
.u
.LowPart
, pcbRead
, pcbWritten
);
302 totalBytesRead
.QuadPart
= 0;
303 totalBytesWritten
.QuadPart
= 0;
305 while ( cb
.QuadPart
> 0 )
307 if ( cb
.QuadPart
>= sizeof(tmpBuffer
) )
308 copySize
= sizeof(tmpBuffer
);
310 copySize
= cb
.u
.LowPart
;
312 hr
= IStream_Read(iface
, tmpBuffer
, copySize
, &bytesRead
);
313 if (FAILED(hr
)) break;
315 totalBytesRead
.QuadPart
+= bytesRead
;
319 hr
= IStream_Write(pstm
, tmpBuffer
, bytesRead
, &bytesWritten
);
320 if (FAILED(hr
)) break;
321 totalBytesWritten
.QuadPart
+= bytesWritten
;
324 if (bytesRead
!= copySize
)
327 cb
.QuadPart
-= bytesRead
;
330 if (pcbRead
) pcbRead
->QuadPart
= totalBytesRead
.QuadPart
;
331 if (pcbWritten
) pcbWritten
->QuadPart
= totalBytesWritten
.QuadPart
;
336 static HRESULT WINAPI
sub_stream_Commit(
338 DWORD grfCommitFlags
)
344 static HRESULT WINAPI
sub_stream_Revert(
351 static HRESULT WINAPI
sub_stream_LockRegion(
353 ULARGE_INTEGER libOffset
,
361 static HRESULT WINAPI
sub_stream_UnlockRegion(
363 ULARGE_INTEGER libOffset
,
371 static HRESULT WINAPI
sub_stream_Stat(
376 sub_stream_t
*This
= impl_from_IStream(iface
);
377 FIXME("(%p)->(%p, %08x)\n", This
, pstatstg
, grfStatFlag
);
378 memset(pstatstg
, 0, sizeof(*pstatstg
));
379 pstatstg
->cbSize
= This
->length
;
383 static HRESULT WINAPI
sub_stream_Clone(
391 static struct IStreamVtbl sub_stream_vtbl
=
393 sub_stream_QueryInterface
,
403 sub_stream_LockRegion
,
404 sub_stream_UnlockRegion
,
409 static HRESULT
create_sub_stream(IStream
*stream
, ULARGE_INTEGER start
, ULARGE_INTEGER length
, IStream
**out
)
414 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
415 if(!This
) return E_OUTOFMEMORY
;
417 This
->IStream_iface
.lpVtbl
= &sub_stream_vtbl
;
420 This
->length
= length
;
421 This
->pos
.QuadPart
= 0;
422 IStream_AddRef(stream
);
425 *out
= &This
->IStream_iface
;
429 static HRESULT
get_stream_size(IStream
*stream
, ULARGE_INTEGER
*size
)
431 STATSTG statstg
= {NULL
};
435 hres
= IStream_Stat(stream
, &statstg
, STATFLAG_NONAME
);
436 if(SUCCEEDED(hres
)) {
437 *size
= statstg
.cbSize
;
442 return IStream_Seek(stream
, zero
, STREAM_SEEK_END
, size
);
445 static inline MimeBody
*impl_from_IMimeBody(IMimeBody
*iface
)
447 return CONTAINING_RECORD(iface
, MimeBody
, IMimeBody_iface
);
450 typedef struct propschema
452 IMimePropertySchema IMimePropertySchema_iface
;
456 static inline propschema
*impl_from_IMimePropertySchema(IMimePropertySchema
*iface
)
458 return CONTAINING_RECORD(iface
, propschema
, IMimePropertySchema_iface
);
461 static LPSTR
strdupA(LPCSTR str
)
464 int len
= strlen(str
);
465 ret
= HeapAlloc(GetProcessHeap(), 0, len
+ 1);
466 memcpy(ret
, str
, len
+ 1);
470 #define PARSER_BUF_SIZE 1024
472 /*****************************************************
473 * copy_headers_to_buf [internal]
475 * Copies the headers into a '\0' terminated memory block and leave
476 * the stream's current position set to after the blank line.
478 static HRESULT
copy_headers_to_buf(IStream
*stm
, char **ptr
)
481 DWORD size
= PARSER_BUF_SIZE
, offset
= 0, last_end
= 0;
493 buf
= HeapAlloc(GetProcessHeap(), 0, size
+ 1);
497 buf
= HeapReAlloc(GetProcessHeap(), 0, buf
, size
+ 1);
505 hr
= IStream_Read(stm
, buf
+ offset
, size
- offset
, &read
);
506 if(FAILED(hr
)) goto fail
;
511 if(read
== 0) done
= TRUE
;
513 while(!done
&& (end
= strstr(buf
+ last_end
, "\r\n")))
515 DWORD new_end
= end
- buf
+ 2;
516 if(new_end
- last_end
== 2)
519 off
.QuadPart
= (LONGLONG
)new_end
- offset
;
520 IStream_Seek(stm
, off
, STREAM_SEEK_CUR
, NULL
);
533 HeapFree(GetProcessHeap(), 0, buf
);
537 static header_t
*read_prop(MimeBody
*body
, char **ptr
)
539 char *colon
= strchr(*ptr
, ':');
540 const property_t
*prop
;
543 if(!colon
) return NULL
;
547 for(prop
= default_props
; prop
->name
; prop
++)
549 if(!lstrcmpiA(*ptr
, prop
->name
))
551 TRACE("%s: found match with default property id %d\n", *ptr
, prop
->id
);
558 property_list_entry_t
*prop_entry
;
559 LIST_FOR_EACH_ENTRY(prop_entry
, &body
->new_props
, property_list_entry_t
, entry
)
561 if(!lstrcmpiA(*ptr
, prop_entry
->prop
.name
))
563 TRACE("%s: found match with already added new property id %d\n", *ptr
, prop_entry
->prop
.id
);
564 prop
= &prop_entry
->prop
;
570 prop_entry
= HeapAlloc(GetProcessHeap(), 0, sizeof(*prop_entry
));
571 prop_entry
->prop
.name
= strdupA(*ptr
);
572 prop_entry
->prop
.id
= body
->next_prop_id
++;
573 prop_entry
->prop
.flags
= 0;
574 prop_entry
->prop
.default_vt
= VT_LPSTR
;
575 list_add_tail(&body
->new_props
, &prop_entry
->entry
);
576 prop
= &prop_entry
->prop
;
577 TRACE("%s: allocating new prop id %d\n", *ptr
, prop_entry
->prop
.id
);
581 ret
= HeapAlloc(GetProcessHeap(), 0, sizeof(*ret
));
583 PropVariantInit(&ret
->value
);
584 list_init(&ret
->params
);
590 static void unfold_header(char *header
, int len
)
592 char *start
= header
, *cp
= header
;
595 while(*cp
== ' ' || *cp
== '\t')
601 memmove(start
, cp
, len
+ 1);
603 cp
= strstr(start
, "\r\n");
610 } while(*cp
== ' ' || *cp
== '\t');
615 static char *unquote_string(const char *str
)
620 while(*str
== ' ' || *str
== '\t') str
++;
628 for(cp
= ret
; *cp
; cp
++)
631 memmove(cp
, cp
+ 1, strlen(cp
+ 1) + 1);
636 WARN("quote in unquoted string\n");
648 static void add_param(header_t
*header
, const char *p
)
650 const char *key
= p
, *value
, *cp
= p
;
654 TRACE("got param %s\n", p
);
656 while (*key
== ' ' || *key
== '\t' ) key
++;
658 cp
= strchr(key
, '=');
661 WARN("malformed parameter - skipping\n");
665 name
= HeapAlloc(GetProcessHeap(), 0, cp
- key
+ 1);
666 memcpy(name
, key
, cp
- key
);
667 name
[cp
- key
] = '\0';
671 param
= HeapAlloc(GetProcessHeap(), 0, sizeof(*param
));
673 param
->value
= unquote_string(value
);
674 list_add_tail(&header
->params
, ¶m
->entry
);
677 static void split_params(header_t
*header
, char *value
)
679 char *cp
= value
, *start
= value
;
680 BOOL in_quotes
= FALSE
, done_value
= FALSE
;
684 if(!in_quotes
&& *cp
== ';')
687 if(done_value
) add_param(header
, start
);
692 in_quotes
= !in_quotes
;
695 if(done_value
) add_param(header
, start
);
698 static void read_value(header_t
*header
, char **cur
)
700 char *end
= *cur
, *value
;
704 end
= strstr(end
, "\r\n");
706 } while(*end
== ' ' || *end
== '\t');
709 value
= HeapAlloc(GetProcessHeap(), 0, len
+ 1);
710 memcpy(value
, *cur
, len
);
713 unfold_header(value
, len
);
714 TRACE("value %s\n", debugstr_a(value
));
716 if(header
->prop
->flags
& MPF_HASPARAMS
)
718 split_params(header
, value
);
719 TRACE("value w/o params %s\n", debugstr_a(value
));
722 header
->value
.vt
= VT_LPSTR
;
723 header
->value
.u
.pszVal
= value
;
728 static void init_content_type(MimeBody
*body
, header_t
*header
)
733 slash
= strchr(header
->value
.u
.pszVal
, '/');
736 WARN("malformed context type value\n");
739 len
= slash
- header
->value
.u
.pszVal
;
740 body
->content_pri_type
= HeapAlloc(GetProcessHeap(), 0, len
+ 1);
741 memcpy(body
->content_pri_type
, header
->value
.u
.pszVal
, len
);
742 body
->content_pri_type
[len
] = '\0';
743 body
->content_sub_type
= strdupA(slash
+ 1);
746 static void init_content_encoding(MimeBody
*body
, header_t
*header
)
748 const char *encoding
= header
->value
.u
.pszVal
;
750 if(!strcasecmp(encoding
, "base64"))
751 body
->encoding
= IET_BASE64
;
752 else if(!strcasecmp(encoding
, "quoted-printable"))
753 body
->encoding
= IET_QP
;
754 else if(!strcasecmp(encoding
, "7bit"))
755 body
->encoding
= IET_7BIT
;
756 else if(!strcasecmp(encoding
, "8bit"))
757 body
->encoding
= IET_8BIT
;
759 FIXME("unknown encoding %s\n", debugstr_a(encoding
));
762 static HRESULT
parse_headers(MimeBody
*body
, IStream
*stm
)
764 char *header_buf
, *cur_header_ptr
;
768 hr
= copy_headers_to_buf(stm
, &header_buf
);
769 if(FAILED(hr
)) return hr
;
771 cur_header_ptr
= header_buf
;
772 while((header
= read_prop(body
, &cur_header_ptr
)))
774 read_value(header
, &cur_header_ptr
);
775 list_add_tail(&body
->headers
, &header
->entry
);
777 switch(header
->prop
->id
) {
778 case PID_HDR_CNTTYPE
:
779 init_content_type(body
, header
);
781 case PID_HDR_CNTXFER
:
782 init_content_encoding(body
, header
);
787 HeapFree(GetProcessHeap(), 0, header_buf
);
791 static void empty_param_list(struct list
*list
)
793 param_t
*param
, *cursor2
;
795 LIST_FOR_EACH_ENTRY_SAFE(param
, cursor2
, list
, param_t
, entry
)
797 list_remove(¶m
->entry
);
798 HeapFree(GetProcessHeap(), 0, param
->name
);
799 HeapFree(GetProcessHeap(), 0, param
->value
);
800 HeapFree(GetProcessHeap(), 0, param
);
804 static void empty_header_list(struct list
*list
)
806 header_t
*header
, *cursor2
;
808 LIST_FOR_EACH_ENTRY_SAFE(header
, cursor2
, list
, header_t
, entry
)
810 list_remove(&header
->entry
);
811 PropVariantClear(&header
->value
);
812 empty_param_list(&header
->params
);
813 HeapFree(GetProcessHeap(), 0, header
);
817 static void empty_new_prop_list(struct list
*list
)
819 property_list_entry_t
*prop
, *cursor2
;
821 LIST_FOR_EACH_ENTRY_SAFE(prop
, cursor2
, list
, property_list_entry_t
, entry
)
823 list_remove(&prop
->entry
);
824 HeapFree(GetProcessHeap(), 0, (char *)prop
->prop
.name
);
825 HeapFree(GetProcessHeap(), 0, prop
);
829 static void release_data(REFIID riid
, void *data
)
833 if(IsEqualIID(riid
, &IID_IStream
))
834 IStream_Release((IStream
*)data
);
836 FIXME("Unhandled data format %s\n", debugstr_guid(riid
));
839 static HRESULT
find_prop(MimeBody
*body
, const char *name
, header_t
**prop
)
845 LIST_FOR_EACH_ENTRY(header
, &body
->headers
, header_t
, entry
)
849 if(STRTOPID(name
) == header
->prop
->id
)
855 else if(!lstrcmpiA(name
, header
->prop
->name
))
862 return MIME_E_NOT_FOUND
;
865 static const property_t
*find_default_prop(const char *name
)
867 const property_t
*prop_def
= NULL
;
869 for(prop_def
= default_props
; prop_def
->name
; prop_def
++)
873 if(STRTOPID(name
) == prop_def
->id
)
878 else if(!lstrcmpiA(name
, prop_def
->name
))
885 TRACE("%s: found match with default property id %d\n", prop_def
->name
, prop_def
->id
);
892 static HRESULT WINAPI
MimeBody_QueryInterface(IMimeBody
* iface
,
896 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ppvObject
);
900 if (IsEqualIID(riid
, &IID_IUnknown
) ||
901 IsEqualIID(riid
, &IID_IPersist
) ||
902 IsEqualIID(riid
, &IID_IPersistStreamInit
) ||
903 IsEqualIID(riid
, &IID_IMimePropertySet
) ||
904 IsEqualIID(riid
, &IID_IMimeBody
))
911 IUnknown_AddRef((IUnknown
*)*ppvObject
);
915 FIXME("no interface for %s\n", debugstr_guid(riid
));
916 return E_NOINTERFACE
;
919 static ULONG WINAPI
MimeBody_AddRef(IMimeBody
*iface
)
921 MimeBody
*This
= impl_from_IMimeBody(iface
);
922 LONG ref
= InterlockedIncrement(&This
->ref
);
924 TRACE("(%p) ref=%d\n", This
, ref
);
929 static ULONG WINAPI
MimeBody_Release(IMimeBody
*iface
)
931 MimeBody
*This
= impl_from_IMimeBody(iface
);
932 LONG ref
= InterlockedDecrement(&This
->ref
);
934 TRACE("(%p) ref=%d\n", This
, ref
);
938 empty_header_list(&This
->headers
);
939 empty_new_prop_list(&This
->new_props
);
941 HeapFree(GetProcessHeap(), 0, This
->content_pri_type
);
942 HeapFree(GetProcessHeap(), 0, This
->content_sub_type
);
944 release_data(&This
->data_iid
, This
->data
);
946 HeapFree(GetProcessHeap(), 0, This
);
952 static HRESULT WINAPI
MimeBody_GetClassID(
956 MimeBody
*This
= impl_from_IMimeBody(iface
);
958 TRACE("(%p)->(%p)\n", This
, pClassID
);
963 *pClassID
= IID_IMimeBody
;
967 static HRESULT WINAPI
MimeBody_IsDirty(
970 MimeBody
*This
= impl_from_IMimeBody(iface
);
971 FIXME("(%p)->() stub\n", This
);
975 static HRESULT WINAPI
MimeBody_Load(IMimeBody
*iface
, IStream
*pStm
)
977 MimeBody
*This
= impl_from_IMimeBody(iface
);
978 TRACE("(%p)->(%p)\n", This
, pStm
);
979 return parse_headers(This
, pStm
);
982 static HRESULT WINAPI
MimeBody_Save(IMimeBody
*iface
, IStream
*pStm
, BOOL fClearDirty
)
984 MimeBody
*This
= impl_from_IMimeBody(iface
);
985 FIXME("(%p)->(%p, %d)\n", This
, pStm
, fClearDirty
);
989 static HRESULT WINAPI
MimeBody_GetSizeMax(
991 ULARGE_INTEGER
* pcbSize
)
993 MimeBody
*This
= impl_from_IMimeBody(iface
);
994 FIXME("(%p)->(%p) stub\n", This
, pcbSize
);
998 static HRESULT WINAPI
MimeBody_InitNew(
1001 MimeBody
*This
= impl_from_IMimeBody(iface
);
1002 TRACE("(%p)->()\n", This
);
1006 static HRESULT WINAPI
MimeBody_GetPropInfo(
1009 LPMIMEPROPINFO pInfo
)
1011 MimeBody
*This
= impl_from_IMimeBody(iface
);
1014 DWORD supported
= PIM_PROPID
| PIM_VTDEFAULT
;
1016 TRACE("(%p)->(%s, %p) semi-stub\n", This
, debugstr_a(pszName
), pInfo
);
1018 if(!pszName
|| !pInfo
)
1019 return E_INVALIDARG
;
1021 TRACE("mask 0x%04x\n", pInfo
->dwMask
);
1023 if(pInfo
->dwMask
& ~supported
)
1024 FIXME("Unsupported mask flags 0x%04x\n", pInfo
->dwMask
& ~supported
);
1026 hr
= find_prop(This
, pszName
, &header
);
1029 if(pInfo
->dwMask
& PIM_CHARSET
)
1030 pInfo
->hCharset
= 0;
1031 if(pInfo
->dwMask
& PIM_FLAGS
)
1032 pInfo
->dwFlags
= 0x00000000;
1033 if(pInfo
->dwMask
& PIM_ROWNUMBER
)
1034 pInfo
->dwRowNumber
= 0;
1035 if(pInfo
->dwMask
& PIM_ENCODINGTYPE
)
1036 pInfo
->ietEncoding
= 0;
1037 if(pInfo
->dwMask
& PIM_VALUES
)
1039 if(pInfo
->dwMask
& PIM_PROPID
)
1040 pInfo
->dwPropId
= header
->prop
->id
;
1041 if(pInfo
->dwMask
& PIM_VTDEFAULT
)
1042 pInfo
->vtDefault
= header
->prop
->default_vt
;
1043 if(pInfo
->dwMask
& PIM_VTCURRENT
)
1044 pInfo
->vtCurrent
= 0;
1050 static HRESULT WINAPI
MimeBody_SetPropInfo(
1053 LPCMIMEPROPINFO pInfo
)
1055 MimeBody
*This
= impl_from_IMimeBody(iface
);
1056 FIXME("(%p)->(%s, %p) stub\n", This
, debugstr_a(pszName
), pInfo
);
1060 static HRESULT WINAPI
MimeBody_GetProp(
1064 LPPROPVARIANT pValue
)
1066 MimeBody
*This
= impl_from_IMimeBody(iface
);
1070 TRACE("(%p)->(%s, 0x%x, %p)\n", This
, debugstr_a(pszName
), dwFlags
, pValue
);
1072 if(!pszName
|| !pValue
)
1073 return E_INVALIDARG
;
1075 if(!ISPIDSTR(pszName
) && !lstrcmpiA(pszName
, "att:pri-content-type"))
1077 PropVariantClear(pValue
);
1078 pValue
->vt
= VT_LPSTR
;
1079 pValue
->u
.pszVal
= strdupA(This
->content_pri_type
);
1083 hr
= find_prop(This
, pszName
, &header
);
1086 TRACE("type %d->%d\n", header
->value
.vt
, pValue
->vt
);
1088 hr
= PropVariantChangeType(pValue
, &header
->value
, 0, pValue
->vt
);
1090 FIXME("Conversion not currently supported (%d->%d)\n", header
->value
.vt
, pValue
->vt
);
1096 static HRESULT WINAPI
MimeBody_SetProp(
1100 LPCPROPVARIANT pValue
)
1102 MimeBody
*This
= impl_from_IMimeBody(iface
);
1106 TRACE("(%p)->(%s, 0x%x, %p)\n", This
, debugstr_a(pszName
), dwFlags
, pValue
);
1108 if(!pszName
|| !pValue
)
1109 return E_INVALIDARG
;
1111 hr
= find_prop(This
, pszName
, &header
);
1114 property_list_entry_t
*prop_entry
;
1115 const property_t
*prop
= NULL
;
1117 LIST_FOR_EACH_ENTRY(prop_entry
, &This
->new_props
, property_list_entry_t
, entry
)
1119 if(ISPIDSTR(pszName
))
1121 if(STRTOPID(pszName
) == prop_entry
->prop
.id
)
1123 TRACE("Found match with already added new property id %d\n", prop_entry
->prop
.id
);
1124 prop
= &prop_entry
->prop
;
1128 else if(!lstrcmpiA(pszName
, prop_entry
->prop
.name
))
1130 TRACE("Found match with already added new property id %d\n", prop_entry
->prop
.id
);
1131 prop
= &prop_entry
->prop
;
1136 header
= HeapAlloc(GetProcessHeap(), 0, sizeof(*header
));
1138 return E_OUTOFMEMORY
;
1142 const property_t
*prop_def
= NULL
;
1143 prop_entry
= HeapAlloc(GetProcessHeap(), 0, sizeof(*prop_entry
));
1146 HeapFree(GetProcessHeap(), 0, header
);
1147 return E_OUTOFMEMORY
;
1150 prop_def
= find_default_prop(pszName
);
1153 prop_entry
->prop
.name
= strdupA(prop_def
->name
);
1154 prop_entry
->prop
.id
= prop_def
->id
;
1158 if(ISPIDSTR(pszName
))
1160 HeapFree(GetProcessHeap(), 0, prop_entry
);
1161 HeapFree(GetProcessHeap(), 0, header
);
1162 return MIME_E_NOT_FOUND
;
1165 prop_entry
->prop
.name
= strdupA(pszName
);
1166 prop_entry
->prop
.id
= This
->next_prop_id
++;
1169 prop_entry
->prop
.flags
= 0;
1170 prop_entry
->prop
.default_vt
= pValue
->vt
;
1171 list_add_tail(&This
->new_props
, &prop_entry
->entry
);
1172 prop
= &prop_entry
->prop
;
1173 TRACE("Allocating new prop id %d\n", prop_entry
->prop
.id
);
1176 header
->prop
= prop
;
1177 PropVariantInit(&header
->value
);
1178 list_init(&header
->params
);
1179 list_add_tail(&This
->headers
, &header
->entry
);
1182 PropVariantCopy(&header
->value
, pValue
);
1187 static HRESULT WINAPI
MimeBody_AppendProp(
1191 LPPROPVARIANT pValue
)
1193 MimeBody
*This
= impl_from_IMimeBody(iface
);
1194 FIXME("(%p)->(%s, 0x%x, %p) stub\n", This
, debugstr_a(pszName
), dwFlags
, pValue
);
1198 static HRESULT WINAPI
MimeBody_DeleteProp(
1202 MimeBody
*This
= impl_from_IMimeBody(iface
);
1206 TRACE("(%p)->(%s) stub\n", This
, debugstr_a(pszName
));
1208 LIST_FOR_EACH_ENTRY(cursor
, &This
->headers
, header_t
, entry
)
1210 if(ISPIDSTR(pszName
))
1211 found
= STRTOPID(pszName
) == cursor
->prop
->id
;
1213 found
= !lstrcmpiA(pszName
, cursor
->prop
->name
);
1217 list_remove(&cursor
->entry
);
1218 HeapFree(GetProcessHeap(), 0, cursor
);
1223 return MIME_E_NOT_FOUND
;
1226 static HRESULT WINAPI
MimeBody_CopyProps(
1230 IMimePropertySet
* pPropertySet
)
1232 MimeBody
*This
= impl_from_IMimeBody(iface
);
1233 FIXME("(%p)->(%d, %p, %p) stub\n", This
, cNames
, prgszName
, pPropertySet
);
1237 static HRESULT WINAPI
MimeBody_MoveProps(
1241 IMimePropertySet
* pPropertySet
)
1243 MimeBody
*This
= impl_from_IMimeBody(iface
);
1244 FIXME("(%p)->(%d, %p, %p) stub\n", This
, cNames
, prgszName
, pPropertySet
);
1248 static HRESULT WINAPI
MimeBody_DeleteExcept(
1253 MimeBody
*This
= impl_from_IMimeBody(iface
);
1254 FIXME("(%p)->(%d, %p) stub\n", This
, cNames
, prgszName
);
1258 static HRESULT WINAPI
MimeBody_QueryProp(
1263 boolean fCaseSensitive
)
1265 MimeBody
*This
= impl_from_IMimeBody(iface
);
1266 FIXME("(%p)->(%s, %s, %d, %d) stub\n", This
, debugstr_a(pszName
), debugstr_a(pszCriteria
), fSubString
, fCaseSensitive
);
1270 static HRESULT WINAPI
MimeBody_GetCharset(
1272 LPHCHARSET phCharset
)
1274 MimeBody
*This
= impl_from_IMimeBody(iface
);
1275 FIXME("(%p)->(%p) stub\n", This
, phCharset
);
1280 static HRESULT WINAPI
MimeBody_SetCharset(
1283 CSETAPPLYTYPE applytype
)
1285 MimeBody
*This
= impl_from_IMimeBody(iface
);
1286 FIXME("(%p)->(%p, %d) stub\n", This
, hCharset
, applytype
);
1290 static HRESULT WINAPI
MimeBody_GetParameters(
1294 LPMIMEPARAMINFO
* pprgParam
)
1296 MimeBody
*This
= impl_from_IMimeBody(iface
);
1300 TRACE("(%p)->(%s, %p, %p)\n", iface
, debugstr_a(pszName
), pcParams
, pprgParam
);
1305 hr
= find_prop(This
, pszName
, &header
);
1306 if(hr
!= S_OK
) return hr
;
1308 *pcParams
= list_count(&header
->params
);
1311 IMimeAllocator
*alloc
;
1313 MIMEPARAMINFO
*info
;
1315 MimeOleGetAllocator(&alloc
);
1317 *pprgParam
= info
= IMimeAllocator_Alloc(alloc
, *pcParams
* sizeof(**pprgParam
));
1318 LIST_FOR_EACH_ENTRY(param
, &header
->params
, param_t
, entry
)
1322 len
= strlen(param
->name
) + 1;
1323 info
->pszName
= IMimeAllocator_Alloc(alloc
, len
);
1324 memcpy(info
->pszName
, param
->name
, len
);
1325 len
= strlen(param
->value
) + 1;
1326 info
->pszData
= IMimeAllocator_Alloc(alloc
, len
);
1327 memcpy(info
->pszData
, param
->value
, len
);
1330 IMimeAllocator_Release(alloc
);
1335 static HRESULT WINAPI
MimeBody_IsContentType(
1340 MimeBody
*This
= impl_from_IMimeBody(iface
);
1342 TRACE("(%p)->(%s, %s)\n", This
, debugstr_a(pszPriType
), debugstr_a(pszSubType
));
1345 const char *pri
= This
->content_pri_type
;
1346 if(!pri
) pri
= "text";
1347 if(lstrcmpiA(pri
, pszPriType
)) return S_FALSE
;
1352 const char *sub
= This
->content_sub_type
;
1353 if(!sub
) sub
= "plain";
1354 if(lstrcmpiA(sub
, pszSubType
)) return S_FALSE
;
1360 static HRESULT WINAPI
MimeBody_BindToObject(
1365 MimeBody
*This
= impl_from_IMimeBody(iface
);
1366 FIXME("(%p)->(%s, %p) stub\n", This
, debugstr_guid(riid
), ppvObject
);
1370 static HRESULT WINAPI
MimeBody_Clone(
1372 IMimePropertySet
** ppPropertySet
)
1374 MimeBody
*This
= impl_from_IMimeBody(iface
);
1375 FIXME("(%p)->(%p) stub\n", This
, ppPropertySet
);
1379 static HRESULT WINAPI
MimeBody_SetOption(
1382 LPCPROPVARIANT pValue
)
1384 MimeBody
*This
= impl_from_IMimeBody(iface
);
1385 HRESULT hr
= E_NOTIMPL
;
1386 TRACE("(%p)->(%08x, %p)\n", This
, oid
, pValue
);
1388 if(pValue
->vt
!= TYPEDID_TYPE(oid
))
1390 WARN("Called with vartype %04x and oid %08x\n", pValue
->vt
, oid
);
1391 return E_INVALIDARG
;
1396 case OID_SECURITY_HWND_OWNER
:
1397 FIXME("OID_SECURITY_HWND_OWNER (value %08x): ignoring\n", pValue
->u
.ulVal
);
1400 case OID_TRANSMIT_BODY_ENCODING
:
1401 FIXME("OID_TRANSMIT_BODY_ENCODING (value %08x): ignoring\n", pValue
->u
.ulVal
);
1405 FIXME("Unhandled oid %08x\n", oid
);
1411 static HRESULT WINAPI
MimeBody_GetOption(
1414 LPPROPVARIANT pValue
)
1416 MimeBody
*This
= impl_from_IMimeBody(iface
);
1417 FIXME("(%p)->(%08x, %p): stub\n", This
, oid
, pValue
);
1421 static HRESULT WINAPI
MimeBody_EnumProps(
1424 IMimeEnumProperties
** ppEnum
)
1426 MimeBody
*This
= impl_from_IMimeBody(iface
);
1427 FIXME("(%p)->(0x%x, %p) stub\n", This
, dwFlags
, ppEnum
);
1431 static HRESULT WINAPI
MimeBody_IsType(
1433 IMSGBODYTYPE bodytype
)
1435 MimeBody
*This
= impl_from_IMimeBody(iface
);
1437 TRACE("(%p)->(%d)\n", This
, bodytype
);
1441 return This
->data
? S_FALSE
: S_OK
;
1443 FIXME("Unimplemented bodytype %d - returning S_OK\n", bodytype
);
1448 static HRESULT WINAPI
MimeBody_SetDisplayName(
1452 MimeBody
*This
= impl_from_IMimeBody(iface
);
1453 FIXME("(%p)->(%s) stub\n", This
, debugstr_a(pszDisplay
));
1457 static HRESULT WINAPI
MimeBody_GetDisplayName(
1461 MimeBody
*This
= impl_from_IMimeBody(iface
);
1462 FIXME("(%p)->(%p) stub\n", This
, ppszDisplay
);
1466 static HRESULT WINAPI
MimeBody_GetOffsets(
1468 LPBODYOFFSETS pOffsets
)
1470 MimeBody
*This
= impl_from_IMimeBody(iface
);
1471 TRACE("(%p)->(%p)\n", This
, pOffsets
);
1473 *pOffsets
= This
->body_offsets
;
1475 if(This
->body_offsets
.cbBodyEnd
== 0) return MIME_E_NO_DATA
;
1479 static HRESULT WINAPI
MimeBody_GetCurrentEncoding(
1481 ENCODINGTYPE
* pietEncoding
)
1483 MimeBody
*This
= impl_from_IMimeBody(iface
);
1485 TRACE("(%p)->(%p)\n", This
, pietEncoding
);
1487 *pietEncoding
= This
->encoding
;
1491 static HRESULT WINAPI
MimeBody_SetCurrentEncoding(
1493 ENCODINGTYPE ietEncoding
)
1495 MimeBody
*This
= impl_from_IMimeBody(iface
);
1497 TRACE("(%p)->(%d)\n", This
, ietEncoding
);
1499 This
->encoding
= ietEncoding
;
1503 static HRESULT WINAPI
MimeBody_GetEstimatedSize(
1505 ENCODINGTYPE ietEncoding
,
1508 MimeBody
*This
= impl_from_IMimeBody(iface
);
1509 FIXME("(%p)->(%d, %p) stub\n", This
, ietEncoding
, pcbSize
);
1513 static HRESULT WINAPI
MimeBody_GetDataHere(
1515 ENCODINGTYPE ietEncoding
,
1518 MimeBody
*This
= impl_from_IMimeBody(iface
);
1519 FIXME("(%p)->(%d, %p) stub\n", This
, ietEncoding
, pStream
);
1523 static const signed char base64_decode_table
[] =
1525 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x00 */
1526 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x10 */
1527 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, /* 0x20 */
1528 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, /* 0x30 */
1529 -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 0x40 */
1530 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, /* 0x50 */
1531 -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, /* 0x60 */
1532 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1 /* 0x70 */
1535 static HRESULT
decode_base64(IStream
*input
, IStream
**ret_stream
)
1537 const unsigned char *ptr
, *end
;
1538 unsigned char buf
[1024];
1541 unsigned char in
[4];
1548 hres
= IStream_Seek(input
, pos
, STREAM_SEEK_SET
, NULL
);
1552 hres
= CreateStreamOnHGlobal(NULL
, TRUE
, &output
);
1557 hres
= IStream_Read(input
, buf
, sizeof(buf
), &size
);
1558 if(FAILED(hres
) || !size
)
1565 /* skip invalid chars */
1567 (*ptr
>= sizeof(base64_decode_table
)/sizeof(*base64_decode_table
)
1568 || base64_decode_table
[*ptr
] == -1))
1573 in
[n
++] = base64_decode_table
[*ptr
++];
1576 *ret
++ = in
[0] << 2 | in
[1] >> 4;
1579 *ret
++ = in
[1] << 4 | in
[2] >> 2;
1582 *ret
++ = ((in
[2] << 6) & 0xc0) | in
[3];
1588 hres
= IStream_Write(output
, buf
, ret
- buf
, NULL
);
1595 hres
= IStream_Seek(output
, pos
, STREAM_SEEK_SET
, NULL
);
1597 IStream_Release(output
);
1601 *ret_stream
= output
;
1605 static int hex_digit(char c
)
1607 if('0' <= c
&& c
<= '9')
1609 if('A' <= c
&& c
<= 'F')
1610 return c
- 'A' + 10;
1611 if('a' <= c
&& c
<= 'f')
1612 return c
- 'a' + 10;
1616 static HRESULT
decode_qp(IStream
*input
, IStream
**ret_stream
)
1618 const unsigned char *ptr
, *end
;
1619 unsigned char *ret
, prev
= 0;
1620 unsigned char buf
[1024];
1628 hres
= IStream_Seek(input
, pos
, STREAM_SEEK_SET
, NULL
);
1632 hres
= CreateStreamOnHGlobal(NULL
, TRUE
, &output
);
1637 hres
= IStream_Read(input
, buf
, sizeof(buf
), &size
);
1638 if(FAILED(hres
) || !size
)
1645 unsigned char byte
= *ptr
++;
1659 if(prev
!= '\r' || byte
!= '\n') {
1660 int h1
= hex_digit(prev
), h2
= hex_digit(byte
);
1661 if(h1
!= -1 && h2
!= -1)
1662 *ret
++ = (h1
<< 4) | h2
;
1672 hres
= IStream_Write(output
, buf
, ret
- buf
, NULL
);
1679 hres
= IStream_Seek(output
, pos
, STREAM_SEEK_SET
, NULL
);
1681 IStream_Release(output
);
1685 *ret_stream
= output
;
1689 static HRESULT WINAPI
MimeBody_GetData(
1691 ENCODINGTYPE ietEncoding
,
1694 MimeBody
*This
= impl_from_IMimeBody(iface
);
1695 ULARGE_INTEGER start
, size
;
1698 TRACE("(%p)->(%d %p)\n", This
, ietEncoding
, ppStream
);
1700 if(This
->encoding
!= ietEncoding
) {
1701 switch(This
->encoding
) {
1703 hres
= decode_base64(This
->data
, ppStream
);
1706 hres
= decode_qp(This
->data
, ppStream
);
1709 FIXME("Decoding %d is not supported.\n", This
->encoding
);
1712 if(ietEncoding
!= IET_BINARY
)
1713 FIXME("Encoding %d is not supported.\n", ietEncoding
);
1719 hres
= get_stream_size(This
->data
, &size
);
1721 hres
= create_sub_stream(This
->data
, start
, size
, ppStream
);
1725 static HRESULT WINAPI
MimeBody_SetData(
1727 ENCODINGTYPE ietEncoding
,
1733 MimeBody
*This
= impl_from_IMimeBody(iface
);
1734 TRACE("(%p)->(%d, %s, %s, %s %p)\n", This
, ietEncoding
, debugstr_a(pszPriType
), debugstr_a(pszSubType
),
1735 debugstr_guid(riid
), pvObject
);
1737 if(IsEqualIID(riid
, &IID_IStream
))
1738 IStream_AddRef((IStream
*)pvObject
);
1741 FIXME("Unhandled object type %s\n", debugstr_guid(riid
));
1742 return E_INVALIDARG
;
1746 release_data(&This
->data_iid
, This
->data
);
1748 This
->data_iid
= *riid
;
1749 This
->data
= pvObject
;
1751 IMimeBody_SetCurrentEncoding(iface
, ietEncoding
);
1753 /* FIXME: Update the content type.
1754 If pszPriType == NULL use 'application'
1755 If pszSubType == NULL use 'octet-stream' */
1760 static HRESULT WINAPI
MimeBody_EmptyData(
1763 MimeBody
*This
= impl_from_IMimeBody(iface
);
1764 FIXME("(%p)->() stub\n", This
);
1768 static HRESULT WINAPI
MimeBody_CopyTo(
1772 MimeBody
*This
= impl_from_IMimeBody(iface
);
1773 FIXME("(%p)->(%p) stub\n", This
, pBody
);
1777 static HRESULT WINAPI
MimeBody_GetTransmitInfo(
1779 LPTRANSMITINFO pTransmitInfo
)
1781 MimeBody
*This
= impl_from_IMimeBody(iface
);
1782 FIXME("(%p)->(%p) stub\n", This
, pTransmitInfo
);
1786 static HRESULT WINAPI
MimeBody_SaveToFile(
1788 ENCODINGTYPE ietEncoding
,
1791 MimeBody
*This
= impl_from_IMimeBody(iface
);
1792 FIXME("(%p)->(%d, %s) stub\n", This
, ietEncoding
, debugstr_a(pszFilePath
));
1796 static HRESULT WINAPI
MimeBody_GetHandle(
1800 MimeBody
*This
= impl_from_IMimeBody(iface
);
1801 TRACE("(%p)->(%p)\n", iface
, phBody
);
1804 return E_INVALIDARG
;
1806 *phBody
= This
->handle
;
1807 return This
->handle
? S_OK
: MIME_E_NO_DATA
;
1810 static IMimeBodyVtbl body_vtbl
=
1812 MimeBody_QueryInterface
,
1815 MimeBody_GetClassID
,
1819 MimeBody_GetSizeMax
,
1821 MimeBody_GetPropInfo
,
1822 MimeBody_SetPropInfo
,
1825 MimeBody_AppendProp
,
1826 MimeBody_DeleteProp
,
1829 MimeBody_DeleteExcept
,
1831 MimeBody_GetCharset
,
1832 MimeBody_SetCharset
,
1833 MimeBody_GetParameters
,
1834 MimeBody_IsContentType
,
1835 MimeBody_BindToObject
,
1841 MimeBody_SetDisplayName
,
1842 MimeBody_GetDisplayName
,
1843 MimeBody_GetOffsets
,
1844 MimeBody_GetCurrentEncoding
,
1845 MimeBody_SetCurrentEncoding
,
1846 MimeBody_GetEstimatedSize
,
1847 MimeBody_GetDataHere
,
1852 MimeBody_GetTransmitInfo
,
1853 MimeBody_SaveToFile
,
1857 static HRESULT
MimeBody_set_offsets(MimeBody
*body
, const BODYOFFSETS
*offsets
)
1859 TRACE("setting offsets to %d, %d, %d, %d\n", offsets
->cbBoundaryStart
,
1860 offsets
->cbHeaderStart
, offsets
->cbBodyStart
, offsets
->cbBodyEnd
);
1862 body
->body_offsets
= *offsets
;
1866 #define FIRST_CUSTOM_PROP_ID 0x100
1868 static MimeBody
*mimebody_create(void)
1871 BODYOFFSETS body_offsets
;
1873 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
1877 This
->IMimeBody_iface
.lpVtbl
= &body_vtbl
;
1879 This
->handle
= NULL
;
1880 list_init(&This
->headers
);
1881 list_init(&This
->new_props
);
1882 This
->next_prop_id
= FIRST_CUSTOM_PROP_ID
;
1883 This
->content_pri_type
= NULL
;
1884 This
->content_sub_type
= NULL
;
1885 This
->encoding
= IET_7BIT
;
1887 This
->data_iid
= IID_NULL
;
1889 body_offsets
.cbBoundaryStart
= body_offsets
.cbHeaderStart
= 0;
1890 body_offsets
.cbBodyStart
= body_offsets
.cbBodyEnd
= 0;
1891 MimeBody_set_offsets(This
, &body_offsets
);
1896 HRESULT
MimeBody_create(IUnknown
*outer
, void **ppv
)
1901 return CLASS_E_NOAGGREGATION
;
1903 if ((mb
= mimebody_create()))
1905 *ppv
= &mb
->IMimeBody_iface
;
1911 return E_OUTOFMEMORY
;
1915 typedef struct body_t
1919 MimeBody
*mime_body
;
1921 struct body_t
*parent
;
1922 struct list children
;
1925 typedef struct MimeMessage
1927 IMimeMessage IMimeMessage_iface
;
1931 struct list body_tree
;
1935 static inline MimeMessage
*impl_from_IMimeMessage(IMimeMessage
*iface
)
1937 return CONTAINING_RECORD(iface
, MimeMessage
, IMimeMessage_iface
);
1940 static HRESULT WINAPI
MimeMessage_QueryInterface(IMimeMessage
*iface
, REFIID riid
, void **ppv
)
1942 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ppv
);
1944 if (IsEqualIID(riid
, &IID_IUnknown
) ||
1945 IsEqualIID(riid
, &IID_IPersist
) ||
1946 IsEqualIID(riid
, &IID_IPersistStreamInit
) ||
1947 IsEqualIID(riid
, &IID_IMimeMessageTree
) ||
1948 IsEqualIID(riid
, &IID_IMimeMessage
))
1951 IMimeMessage_AddRef(iface
);
1955 FIXME("no interface for %s\n", debugstr_guid(riid
));
1957 return E_NOINTERFACE
;
1960 static ULONG WINAPI
MimeMessage_AddRef(IMimeMessage
*iface
)
1962 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
1963 ULONG ref
= InterlockedIncrement(&This
->ref
);
1965 TRACE("(%p) ref=%d\n", This
, ref
);
1970 static void empty_body_list(struct list
*list
)
1972 body_t
*body
, *cursor2
;
1973 LIST_FOR_EACH_ENTRY_SAFE(body
, cursor2
, list
, body_t
, entry
)
1975 empty_body_list(&body
->children
);
1976 list_remove(&body
->entry
);
1977 IMimeBody_Release(&body
->mime_body
->IMimeBody_iface
);
1978 HeapFree(GetProcessHeap(), 0, body
);
1982 static ULONG WINAPI
MimeMessage_Release(IMimeMessage
*iface
)
1984 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
1985 ULONG ref
= InterlockedDecrement(&This
->ref
);
1987 TRACE("(%p) ref=%d\n", This
, ref
);
1991 empty_body_list(&This
->body_tree
);
1993 if(This
->stream
) IStream_Release(This
->stream
);
1994 HeapFree(GetProcessHeap(), 0, This
);
2000 /*** IPersist methods ***/
2001 static HRESULT WINAPI
MimeMessage_GetClassID(
2002 IMimeMessage
*iface
,
2005 FIXME("(%p)->(%p)\n", iface
, pClassID
);
2009 /*** IPersistStreamInit methods ***/
2010 static HRESULT WINAPI
MimeMessage_IsDirty(
2011 IMimeMessage
*iface
)
2013 FIXME("(%p)->()\n", iface
);
2017 static body_t
*new_body_entry(MimeBody
*mime_body
, DWORD index
, body_t
*parent
)
2019 body_t
*body
= HeapAlloc(GetProcessHeap(), 0, sizeof(*body
));
2022 body
->mime_body
= mime_body
;
2023 body
->index
= index
;
2024 list_init(&body
->children
);
2025 body
->parent
= parent
;
2027 mime_body
->handle
= UlongToHandle(body
->index
);
2035 BODYOFFSETS offsets
;
2038 static HRESULT
create_body_offset_list(IStream
*stm
, const char *boundary
, struct list
*body_offsets
)
2041 DWORD read
, boundary_start
;
2042 int boundary_len
= strlen(boundary
);
2043 char *buf
, *ptr
, *overlap
;
2044 DWORD start
= 0, overlap_no
;
2045 offset_entry_t
*cur_body
= NULL
;
2046 BOOL is_first_line
= TRUE
;
2050 list_init(body_offsets
);
2052 overlap_no
= boundary_len
+ 5;
2054 overlap
= buf
= HeapAlloc(GetProcessHeap(), 0, overlap_no
+ PARSER_BUF_SIZE
+ 1);
2057 hr
= IStream_Seek(stm
, zero
, STREAM_SEEK_CUR
, &cur
);
2058 start
= cur
.u
.LowPart
;
2061 hr
= IStream_Read(stm
, overlap
, PARSER_BUF_SIZE
, &read
);
2062 if(FAILED(hr
)) goto end
;
2063 if(read
== 0) break;
2064 overlap
[read
] = '\0';
2069 is_first_line
= FALSE
;
2071 ptr
= strstr(ptr
, "\r\n");
2077 boundary_start
= start
+ ptr
- buf
;
2079 if(*ptr
== '-' && *(ptr
+ 1) == '-' && !memcmp(ptr
+ 2, boundary
, boundary_len
)) {
2080 ptr
+= boundary_len
+ 2;
2082 if(*ptr
== '\r' && *(ptr
+ 1) == '\n')
2087 cur_body
->offsets
.cbBodyEnd
= boundary_start
- 2;
2088 list_add_tail(body_offsets
, &cur_body
->entry
);
2090 cur_body
= HeapAlloc(GetProcessHeap(), 0, sizeof(*cur_body
));
2091 cur_body
->offsets
.cbBoundaryStart
= boundary_start
;
2092 cur_body
->offsets
.cbHeaderStart
= start
+ ptr
- buf
;
2094 else if(*ptr
== '-' && *(ptr
+ 1) == '-')
2098 cur_body
->offsets
.cbBodyEnd
= boundary_start
- 2;
2099 list_add_tail(body_offsets
, &cur_body
->entry
);
2106 if(overlap
== buf
) /* 1st iteration */
2108 memmove(buf
, buf
+ PARSER_BUF_SIZE
- overlap_no
, overlap_no
);
2109 overlap
= buf
+ overlap_no
;
2110 start
+= read
- overlap_no
;
2114 memmove(buf
, buf
+ PARSER_BUF_SIZE
, overlap_no
);
2120 HeapFree(GetProcessHeap(), 0, buf
);
2124 static body_t
*create_sub_body(MimeMessage
*msg
, IStream
*pStm
, BODYOFFSETS
*offset
, body_t
*parent
)
2126 ULARGE_INTEGER start
, length
;
2127 MimeBody
*mime_body
;
2132 pos
.QuadPart
= offset
->cbHeaderStart
;
2133 IStream_Seek(pStm
, pos
, STREAM_SEEK_SET
, NULL
);
2135 mime_body
= mimebody_create();
2136 IMimeBody_Load(&mime_body
->IMimeBody_iface
, pStm
);
2139 hr
= IStream_Seek(pStm
, pos
, STREAM_SEEK_CUR
, &start
);
2140 offset
->cbBodyStart
= start
.QuadPart
;
2141 if (parent
) MimeBody_set_offsets(mime_body
, offset
);
2143 length
.QuadPart
= offset
->cbBodyEnd
- offset
->cbBodyStart
;
2144 create_sub_stream(pStm
, start
, length
, (IStream
**)&mime_body
->data
);
2145 mime_body
->data_iid
= IID_IStream
;
2147 body
= new_body_entry(mime_body
, msg
->next_index
++, parent
);
2149 if(IMimeBody_IsContentType(&mime_body
->IMimeBody_iface
, "multipart", NULL
) == S_OK
)
2151 MIMEPARAMINFO
*param_info
;
2153 IMimeAllocator
*alloc
;
2155 hr
= IMimeBody_GetParameters(&mime_body
->IMimeBody_iface
, "Content-Type", &count
,
2157 if(hr
!= S_OK
|| count
== 0) return body
;
2159 MimeOleGetAllocator(&alloc
);
2161 for(i
= 0; i
< count
; i
++)
2163 if(!lstrcmpiA(param_info
[i
].pszName
, "boundary"))
2165 struct list offset_list
;
2166 offset_entry_t
*cur
, *cursor2
;
2167 hr
= create_body_offset_list(pStm
, param_info
[i
].pszData
, &offset_list
);
2168 LIST_FOR_EACH_ENTRY_SAFE(cur
, cursor2
, &offset_list
, offset_entry_t
, entry
)
2172 sub_body
= create_sub_body(msg
, pStm
, &cur
->offsets
, body
);
2173 list_add_tail(&body
->children
, &sub_body
->entry
);
2174 list_remove(&cur
->entry
);
2175 HeapFree(GetProcessHeap(), 0, cur
);
2180 IMimeAllocator_FreeParamInfoArray(alloc
, count
, param_info
, TRUE
);
2181 IMimeAllocator_Release(alloc
);
2186 static HRESULT WINAPI
MimeMessage_Load(IMimeMessage
*iface
, IStream
*pStm
)
2188 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2190 BODYOFFSETS offsets
;
2194 TRACE("(%p)->(%p)\n", iface
, pStm
);
2198 FIXME("already loaded a message\n");
2202 empty_body_list(&This
->body_tree
);
2204 IStream_AddRef(pStm
);
2205 This
->stream
= pStm
;
2206 offsets
.cbBoundaryStart
= offsets
.cbHeaderStart
= 0;
2207 offsets
.cbBodyStart
= offsets
.cbBodyEnd
= 0;
2209 root_body
= create_sub_body(This
, pStm
, &offsets
, NULL
);
2212 IStream_Seek(pStm
, zero
, STREAM_SEEK_END
, &cur
);
2213 offsets
.cbBodyEnd
= cur
.u
.LowPart
;
2214 MimeBody_set_offsets(root_body
->mime_body
, &offsets
);
2216 list_add_head(&This
->body_tree
, &root_body
->entry
);
2221 static HRESULT WINAPI
MimeMessage_Save(IMimeMessage
*iface
, IStream
*pStm
, BOOL fClearDirty
)
2223 FIXME("(%p)->(%p, %s)\n", iface
, pStm
, fClearDirty
? "TRUE" : "FALSE");
2227 static HRESULT WINAPI
MimeMessage_GetSizeMax(
2228 IMimeMessage
*iface
,
2229 ULARGE_INTEGER
*pcbSize
)
2231 FIXME("(%p)->(%p)\n", iface
, pcbSize
);
2235 static HRESULT WINAPI
MimeMessage_InitNew(
2236 IMimeMessage
*iface
)
2238 FIXME("(%p)->()\n", iface
);
2242 /*** IMimeMessageTree methods ***/
2243 static HRESULT WINAPI
MimeMessage_GetMessageSource(IMimeMessage
*iface
, IStream
**ppStream
,
2246 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2248 FIXME("(%p)->(%p, 0x%x)\n", iface
, ppStream
, dwFlags
);
2250 IStream_AddRef(This
->stream
);
2251 *ppStream
= This
->stream
;
2255 static HRESULT WINAPI
MimeMessage_GetMessageSize(
2256 IMimeMessage
*iface
,
2260 FIXME("(%p)->(%p, 0x%x)\n", iface
, pcbSize
, dwFlags
);
2264 static HRESULT WINAPI
MimeMessage_LoadOffsetTable(
2265 IMimeMessage
*iface
,
2268 FIXME("(%p)->(%p)\n", iface
, pStream
);
2272 static HRESULT WINAPI
MimeMessage_SaveOffsetTable(
2273 IMimeMessage
*iface
,
2277 FIXME("(%p)->(%p, 0x%x)\n", iface
, pStream
, dwFlags
);
2282 static HRESULT WINAPI
MimeMessage_GetFlags(
2283 IMimeMessage
*iface
,
2286 FIXME("(%p)->(%p)\n", iface
, pdwFlags
);
2290 static HRESULT WINAPI
MimeMessage_Commit(
2291 IMimeMessage
*iface
,
2294 FIXME("(%p)->(0x%x)\n", iface
, dwFlags
);
2299 static HRESULT WINAPI
MimeMessage_HandsOffStorage(
2300 IMimeMessage
*iface
)
2302 FIXME("(%p)->()\n", iface
);
2306 static HRESULT
find_body(struct list
*list
, HBODY hbody
, body_t
**body
)
2311 if(hbody
== HBODY_ROOT
)
2313 *body
= LIST_ENTRY(list_head(list
), body_t
, entry
);
2317 LIST_FOR_EACH_ENTRY(cur
, list
, body_t
, entry
)
2319 if(cur
->index
== HandleToUlong(hbody
))
2324 hr
= find_body(&cur
->children
, hbody
, body
);
2325 if(hr
== S_OK
) return S_OK
;
2330 static HRESULT WINAPI
MimeMessage_BindToObject(IMimeMessage
*iface
, const HBODY hBody
, REFIID riid
,
2333 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2337 TRACE("(%p)->(%p, %s, %p)\n", iface
, hBody
, debugstr_guid(riid
), ppvObject
);
2339 hr
= find_body(&This
->body_tree
, hBody
, &body
);
2341 if(hr
!= S_OK
) return hr
;
2343 if(IsEqualIID(riid
, &IID_IMimeBody
))
2345 IMimeBody_AddRef(&body
->mime_body
->IMimeBody_iface
);
2346 *ppvObject
= &body
->mime_body
->IMimeBody_iface
;
2350 return E_NOINTERFACE
;
2353 static HRESULT WINAPI
MimeMessage_SaveBody(
2354 IMimeMessage
*iface
,
2359 FIXME("(%p)->(%p, 0x%x, %p)\n", iface
, hBody
, dwFlags
, pStream
);
2363 static HRESULT
get_body(MimeMessage
*msg
, BODYLOCATION location
, HBODY pivot
, body_t
**out
)
2365 body_t
*root
= LIST_ENTRY(list_head(&msg
->body_tree
), body_t
, entry
);
2370 if(location
== IBL_ROOT
)
2376 hr
= find_body(&msg
->body_tree
, pivot
, &body
);
2384 *out
= body
->parent
;
2386 hr
= MIME_E_NOT_FOUND
;
2390 list
= list_head(&body
->children
);
2392 *out
= LIST_ENTRY(list
, body_t
, entry
);
2394 hr
= MIME_E_NOT_FOUND
;
2398 list
= list_tail(&body
->children
);
2400 *out
= LIST_ENTRY(list
, body_t
, entry
);
2402 hr
= MIME_E_NOT_FOUND
;
2406 list
= list_next(&body
->parent
->children
, &body
->entry
);
2408 *out
= LIST_ENTRY(list
, body_t
, entry
);
2410 hr
= MIME_E_NOT_FOUND
;
2414 list
= list_prev(&body
->parent
->children
, &body
->entry
);
2416 *out
= LIST_ENTRY(list
, body_t
, entry
);
2418 hr
= MIME_E_NOT_FOUND
;
2431 static HRESULT WINAPI
MimeMessage_InsertBody(
2432 IMimeMessage
*iface
,
2433 BODYLOCATION location
,
2437 FIXME("(%p)->(%d, %p, %p)\n", iface
, location
, hPivot
, phBody
);
2441 static HRESULT WINAPI
MimeMessage_GetBody(IMimeMessage
*iface
, BODYLOCATION location
, HBODY hPivot
,
2444 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2448 TRACE("(%p)->(%d, %p, %p)\n", iface
, location
, hPivot
, phBody
);
2451 return E_INVALIDARG
;
2455 hr
= get_body(This
, location
, hPivot
, &body
);
2457 if(hr
== S_OK
) *phBody
= UlongToHandle(body
->index
);
2462 static HRESULT WINAPI
MimeMessage_DeleteBody(
2463 IMimeMessage
*iface
,
2467 FIXME("(%p)->(%p, %08x)\n", iface
, hBody
, dwFlags
);
2471 static HRESULT WINAPI
MimeMessage_MoveBody(
2472 IMimeMessage
*iface
,
2474 BODYLOCATION location
)
2476 FIXME("(%p)->(%d)\n", iface
, location
);
2480 static void count_children(body_t
*body
, boolean recurse
, ULONG
*count
)
2484 LIST_FOR_EACH_ENTRY(child
, &body
->children
, body_t
, entry
)
2487 if(recurse
) count_children(child
, recurse
, count
);
2491 static HRESULT WINAPI
MimeMessage_CountBodies(IMimeMessage
*iface
, HBODY hParent
, boolean fRecurse
,
2495 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2498 TRACE("(%p)->(%p, %s, %p)\n", iface
, hParent
, fRecurse
? "TRUE" : "FALSE", pcBodies
);
2500 hr
= find_body(&This
->body_tree
, hParent
, &body
);
2501 if(hr
!= S_OK
) return hr
;
2504 count_children(body
, fRecurse
, pcBodies
);
2509 static HRESULT
find_next(MimeMessage
*This
, body_t
*body
, FINDBODY
*find
, HBODY
*out
)
2516 if (!body
) ptr
= list_head( &This
->body_tree
);
2519 ptr
= list_head( &body
->children
);
2522 if (!body
->parent
) return MIME_E_NOT_FOUND
;
2523 if (!(ptr
= list_next( &body
->parent
->children
, &body
->entry
))) body
= body
->parent
;
2527 body
= LIST_ENTRY( ptr
, body_t
, entry
);
2528 next
= UlongToHandle( body
->index
);
2529 find
->dwReserved
= body
->index
;
2530 if (IMimeBody_IsContentType(&body
->mime_body
->IMimeBody_iface
, find
->pszPriType
,
2531 find
->pszSubType
) == S_OK
)
2537 return MIME_E_NOT_FOUND
;
2540 static HRESULT WINAPI
MimeMessage_FindFirst(IMimeMessage
*iface
, FINDBODY
*pFindBody
, HBODY
*phBody
)
2542 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2544 TRACE("(%p)->(%p, %p)\n", iface
, pFindBody
, phBody
);
2546 pFindBody
->dwReserved
= 0;
2547 return find_next(This
, NULL
, pFindBody
, phBody
);
2550 static HRESULT WINAPI
MimeMessage_FindNext(IMimeMessage
*iface
, FINDBODY
*pFindBody
, HBODY
*phBody
)
2552 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2556 TRACE("(%p)->(%p, %p)\n", iface
, pFindBody
, phBody
);
2558 hr
= find_body( &This
->body_tree
, UlongToHandle( pFindBody
->dwReserved
), &body
);
2559 if (hr
!= S_OK
) return MIME_E_NOT_FOUND
;
2560 return find_next(This
, body
, pFindBody
, phBody
);
2563 static HRESULT WINAPI
MimeMessage_ResolveURL(
2564 IMimeMessage
*iface
,
2571 FIXME("(%p)->(%p, %s, %s, 0x%x, %p)\n", iface
, hRelated
, pszBase
, pszURL
, dwFlags
, phBody
);
2575 static HRESULT WINAPI
MimeMessage_ToMultipart(
2576 IMimeMessage
*iface
,
2579 LPHBODY phMultipart
)
2581 FIXME("(%p)->(%p, %s, %p)\n", iface
, hBody
, pszSubType
, phMultipart
);
2585 static HRESULT WINAPI
MimeMessage_GetBodyOffsets(
2586 IMimeMessage
*iface
,
2588 LPBODYOFFSETS pOffsets
)
2590 FIXME("(%p)->(%p, %p)\n", iface
, hBody
, pOffsets
);
2594 static HRESULT WINAPI
MimeMessage_GetCharset(
2595 IMimeMessage
*iface
,
2596 LPHCHARSET phCharset
)
2598 FIXME("(%p)->(%p)\n", iface
, phCharset
);
2603 static HRESULT WINAPI
MimeMessage_SetCharset(
2604 IMimeMessage
*iface
,
2606 CSETAPPLYTYPE applytype
)
2608 FIXME("(%p)->(%p, %d)\n", iface
, hCharset
, applytype
);
2612 static HRESULT WINAPI
MimeMessage_IsBodyType(
2613 IMimeMessage
*iface
,
2615 IMSGBODYTYPE bodytype
)
2618 IMimeBody
*mime_body
;
2619 TRACE("(%p)->(%p, %d)\n", iface
, hBody
, bodytype
);
2621 hr
= IMimeMessage_BindToObject(iface
, hBody
, &IID_IMimeBody
, (void**)&mime_body
);
2622 if(hr
!= S_OK
) return hr
;
2624 hr
= IMimeBody_IsType(mime_body
, bodytype
);
2625 MimeBody_Release(mime_body
);
2629 static HRESULT WINAPI
MimeMessage_IsContentType(
2630 IMimeMessage
*iface
,
2636 IMimeBody
*mime_body
;
2637 TRACE("(%p)->(%p, %s, %s)\n", iface
, hBody
, debugstr_a(pszPriType
),
2638 debugstr_a(pszSubType
));
2640 hr
= IMimeMessage_BindToObject(iface
, hBody
, &IID_IMimeBody
, (void**)&mime_body
);
2641 if(FAILED(hr
)) return hr
;
2643 hr
= IMimeBody_IsContentType(mime_body
, pszPriType
, pszSubType
);
2644 IMimeBody_Release(mime_body
);
2648 static HRESULT WINAPI
MimeMessage_QueryBodyProp(
2649 IMimeMessage
*iface
,
2654 boolean fCaseSensitive
)
2656 FIXME("(%p)->(%p, %s, %s, %s, %s)\n", iface
, hBody
, pszName
, pszCriteria
, fSubString
? "TRUE" : "FALSE", fCaseSensitive
? "TRUE" : "FALSE");
2660 static HRESULT WINAPI
MimeMessage_GetBodyProp(
2661 IMimeMessage
*iface
,
2665 LPPROPVARIANT pValue
)
2668 IMimeBody
*mime_body
;
2670 TRACE("(%p)->(%p, %s, 0x%x, %p)\n", iface
, hBody
, pszName
, dwFlags
, pValue
);
2672 hr
= IMimeMessage_BindToObject(iface
, hBody
, &IID_IMimeBody
, (void**)&mime_body
);
2673 if(hr
!= S_OK
) return hr
;
2675 hr
= IMimeBody_GetProp(mime_body
, pszName
, dwFlags
, pValue
);
2676 IMimeBody_Release(mime_body
);
2681 static HRESULT WINAPI
MimeMessage_SetBodyProp(
2682 IMimeMessage
*iface
,
2686 LPCPROPVARIANT pValue
)
2688 FIXME("(%p)->(%p, %s, 0x%x, %p)\n", iface
, hBody
, pszName
, dwFlags
, pValue
);
2692 static HRESULT WINAPI
MimeMessage_DeleteBodyProp(
2693 IMimeMessage
*iface
,
2697 FIXME("(%p)->(%p, %s)\n", iface
, hBody
, pszName
);
2701 static HRESULT WINAPI
MimeMessage_SetOption(
2702 IMimeMessage
*iface
,
2704 LPCPROPVARIANT pValue
)
2707 TRACE("(%p)->(%08x, %p)\n", iface
, oid
, pValue
);
2709 /* Message ID is checked before type.
2710 * OID 0x4D -> 0x56 and 0x58 aren't defined but will filtered out later.
2712 if(TYPEDID_ID(oid
) < TYPEDID_ID(OID_ALLOW_8BIT_HEADER
) || TYPEDID_ID(oid
) > TYPEDID_ID(OID_SECURITY_2KEY_CERT_BAG_64
))
2714 WARN("oid (%08x) out of range\n", oid
);
2715 return MIME_E_INVALID_OPTION_ID
;
2718 if(pValue
->vt
!= TYPEDID_TYPE(oid
))
2720 WARN("Called with vartype %04x and oid %08x\n", pValue
->vt
, oid
);
2726 case OID_HIDE_TNEF_ATTACHMENTS
:
2727 FIXME("OID_HIDE_TNEF_ATTACHMENTS (value %d): ignoring\n", pValue
->u
.boolVal
);
2729 case OID_SHOW_MACBINARY
:
2730 FIXME("OID_SHOW_MACBINARY (value %d): ignoring\n", pValue
->u
.boolVal
);
2732 case OID_SAVEBODY_KEEPBOUNDARY
:
2733 FIXME("OID_SAVEBODY_KEEPBOUNDARY (value %d): ignoring\n", pValue
->u
.boolVal
);
2735 case OID_CLEANUP_TREE_ON_SAVE
:
2736 FIXME("OID_CLEANUP_TREE_ON_SAVE (value %d): ignoring\n", pValue
->u
.boolVal
);
2739 FIXME("Unhandled oid %08x\n", oid
);
2740 hr
= MIME_E_INVALID_OPTION_ID
;
2746 static HRESULT WINAPI
MimeMessage_GetOption(
2747 IMimeMessage
*iface
,
2749 LPPROPVARIANT pValue
)
2751 FIXME("(%p)->(%08x, %p)\n", iface
, oid
, pValue
);
2755 /*** IMimeMessage methods ***/
2756 static HRESULT WINAPI
MimeMessage_CreateWebPage(
2757 IMimeMessage
*iface
,
2759 LPWEBPAGEOPTIONS pOptions
,
2760 IMimeMessageCallback
*pCallback
,
2761 IMoniker
**ppMoniker
)
2763 FIXME("(%p)->(%p, %p, %p, %p)\n", iface
, pRootStm
, pOptions
, pCallback
, ppMoniker
);
2768 static HRESULT WINAPI
MimeMessage_GetProp(
2769 IMimeMessage
*iface
,
2772 LPPROPVARIANT pValue
)
2774 FIXME("(%p)->(%s, 0x%x, %p)\n", iface
, pszName
, dwFlags
, pValue
);
2778 static HRESULT WINAPI
MimeMessage_SetProp(
2779 IMimeMessage
*iface
,
2782 LPCPROPVARIANT pValue
)
2784 FIXME("(%p)->(%s, 0x%x, %p)\n", iface
, pszName
, dwFlags
, pValue
);
2788 static HRESULT WINAPI
MimeMessage_DeleteProp(
2789 IMimeMessage
*iface
,
2792 FIXME("(%p)->(%s)\n", iface
, pszName
);
2796 static HRESULT WINAPI
MimeMessage_QueryProp(
2797 IMimeMessage
*iface
,
2801 boolean fCaseSensitive
)
2803 FIXME("(%p)->(%s, %s, %s, %s)\n", iface
, pszName
, pszCriteria
, fSubString
? "TRUE" : "FALSE", fCaseSensitive
? "TRUE" : "FALSE");
2807 static HRESULT WINAPI
MimeMessage_GetTextBody(
2808 IMimeMessage
*iface
,
2810 ENCODINGTYPE ietEncoding
,
2816 FINDBODY find_struct
;
2817 IMimeBody
*mime_body
;
2818 static char text
[] = "text";
2819 static char plain
[] = "plain";
2820 static char html
[] = "html";
2822 TRACE("(%p)->(%d, %d, %p, %p)\n", iface
, dwTxtType
, ietEncoding
, pStream
, phBody
);
2824 find_struct
.pszPriType
= text
;
2829 find_struct
.pszSubType
= plain
;
2832 find_struct
.pszSubType
= html
;
2835 return MIME_E_INVALID_TEXT_TYPE
;
2838 hr
= IMimeMessage_FindFirst(iface
, &find_struct
, &hbody
);
2841 TRACE("not found hr %08x\n", hr
);
2846 IMimeMessage_BindToObject(iface
, hbody
, &IID_IMimeBody
, (void**)&mime_body
);
2848 IMimeBody_GetData(mime_body
, ietEncoding
, pStream
);
2850 IMimeBody_Release(mime_body
);
2854 static HRESULT WINAPI
MimeMessage_SetTextBody(
2855 IMimeMessage
*iface
,
2857 ENCODINGTYPE ietEncoding
,
2862 FIXME("(%p)->(%d, %d, %p, %p, %p)\n", iface
, dwTxtType
, ietEncoding
, hAlternative
, pStream
, phBody
);
2866 static HRESULT WINAPI
MimeMessage_AttachObject(
2867 IMimeMessage
*iface
,
2872 FIXME("(%p)->(%s, %p, %p)\n", iface
, debugstr_guid(riid
), pvObject
, phBody
);
2876 static HRESULT WINAPI
MimeMessage_AttachFile(
2877 IMimeMessage
*iface
,
2882 FIXME("(%p)->(%s, %p, %p)\n", iface
, pszFilePath
, pstmFile
, phBody
);
2886 static HRESULT WINAPI
MimeMessage_AttachURL(
2887 IMimeMessage
*iface
,
2895 FIXME("(%p)->(%s, %s, 0x%x, %p, %p, %p)\n", iface
, pszBase
, pszURL
, dwFlags
, pstmURL
, ppszCIDURL
, phBody
);
2899 static HRESULT WINAPI
MimeMessage_GetAttachments(
2900 IMimeMessage
*iface
,
2902 LPHBODY
*pprghAttach
)
2905 FINDBODY find_struct
;
2910 TRACE("(%p)->(%p, %p)\n", iface
, pcAttach
, pprghAttach
);
2913 array
= CoTaskMemAlloc(size
* sizeof(HBODY
));
2915 find_struct
.pszPriType
= find_struct
.pszSubType
= NULL
;
2916 hr
= IMimeMessage_FindFirst(iface
, &find_struct
, &hbody
);
2919 hr
= IMimeMessage_IsContentType(iface
, hbody
, "multipart", NULL
);
2920 TRACE("IsCT rets %08x %d\n", hr
, *pcAttach
);
2923 if(*pcAttach
+ 1 > size
)
2926 array
= CoTaskMemRealloc(array
, size
* sizeof(HBODY
));
2928 array
[*pcAttach
] = hbody
;
2931 hr
= IMimeMessage_FindNext(iface
, &find_struct
, &hbody
);
2934 *pprghAttach
= array
;
2938 static HRESULT WINAPI
MimeMessage_GetAddressTable(
2939 IMimeMessage
*iface
,
2940 IMimeAddressTable
**ppTable
)
2942 FIXME("(%p)->(%p)\n", iface
, ppTable
);
2946 static HRESULT WINAPI
MimeMessage_GetSender(
2947 IMimeMessage
*iface
,
2948 LPADDRESSPROPS pAddress
)
2950 FIXME("(%p)->(%p)\n", iface
, pAddress
);
2954 static HRESULT WINAPI
MimeMessage_GetAddressTypes(
2955 IMimeMessage
*iface
,
2958 LPADDRESSLIST pList
)
2960 FIXME("(%p)->(%d, %d, %p)\n", iface
, dwAdrTypes
, dwProps
, pList
);
2964 static HRESULT WINAPI
MimeMessage_GetAddressFormat(
2965 IMimeMessage
*iface
,
2967 ADDRESSFORMAT format
,
2970 FIXME("(%p)->(%d, %d, %p)\n", iface
, dwAdrTypes
, format
, ppszFormat
);
2974 static HRESULT WINAPI
MimeMessage_EnumAddressTypes(
2975 IMimeMessage
*iface
,
2978 IMimeEnumAddressTypes
**ppEnum
)
2980 FIXME("(%p)->(%d, %d, %p)\n", iface
, dwAdrTypes
, dwProps
, ppEnum
);
2984 static HRESULT WINAPI
MimeMessage_SplitMessage(
2985 IMimeMessage
*iface
,
2987 IMimeMessageParts
**ppParts
)
2989 FIXME("(%p)->(%d, %p)\n", iface
, cbMaxPart
, ppParts
);
2993 static HRESULT WINAPI
MimeMessage_GetRootMoniker(
2994 IMimeMessage
*iface
,
2995 IMoniker
**ppMoniker
)
2997 FIXME("(%p)->(%p)\n", iface
, ppMoniker
);
3001 static const IMimeMessageVtbl MimeMessageVtbl
=
3003 MimeMessage_QueryInterface
,
3005 MimeMessage_Release
,
3006 MimeMessage_GetClassID
,
3007 MimeMessage_IsDirty
,
3010 MimeMessage_GetSizeMax
,
3011 MimeMessage_InitNew
,
3012 MimeMessage_GetMessageSource
,
3013 MimeMessage_GetMessageSize
,
3014 MimeMessage_LoadOffsetTable
,
3015 MimeMessage_SaveOffsetTable
,
3016 MimeMessage_GetFlags
,
3018 MimeMessage_HandsOffStorage
,
3019 MimeMessage_BindToObject
,
3020 MimeMessage_SaveBody
,
3021 MimeMessage_InsertBody
,
3022 MimeMessage_GetBody
,
3023 MimeMessage_DeleteBody
,
3024 MimeMessage_MoveBody
,
3025 MimeMessage_CountBodies
,
3026 MimeMessage_FindFirst
,
3027 MimeMessage_FindNext
,
3028 MimeMessage_ResolveURL
,
3029 MimeMessage_ToMultipart
,
3030 MimeMessage_GetBodyOffsets
,
3031 MimeMessage_GetCharset
,
3032 MimeMessage_SetCharset
,
3033 MimeMessage_IsBodyType
,
3034 MimeMessage_IsContentType
,
3035 MimeMessage_QueryBodyProp
,
3036 MimeMessage_GetBodyProp
,
3037 MimeMessage_SetBodyProp
,
3038 MimeMessage_DeleteBodyProp
,
3039 MimeMessage_SetOption
,
3040 MimeMessage_GetOption
,
3041 MimeMessage_CreateWebPage
,
3042 MimeMessage_GetProp
,
3043 MimeMessage_SetProp
,
3044 MimeMessage_DeleteProp
,
3045 MimeMessage_QueryProp
,
3046 MimeMessage_GetTextBody
,
3047 MimeMessage_SetTextBody
,
3048 MimeMessage_AttachObject
,
3049 MimeMessage_AttachFile
,
3050 MimeMessage_AttachURL
,
3051 MimeMessage_GetAttachments
,
3052 MimeMessage_GetAddressTable
,
3053 MimeMessage_GetSender
,
3054 MimeMessage_GetAddressTypes
,
3055 MimeMessage_GetAddressFormat
,
3056 MimeMessage_EnumAddressTypes
,
3057 MimeMessage_SplitMessage
,
3058 MimeMessage_GetRootMoniker
,
3061 HRESULT
MimeMessage_create(IUnknown
*outer
, void **obj
)
3064 MimeBody
*mime_body
;
3067 TRACE("(%p, %p)\n", outer
, obj
);
3071 FIXME("outer unknown not supported yet\n");
3077 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
3078 if (!This
) return E_OUTOFMEMORY
;
3080 This
->IMimeMessage_iface
.lpVtbl
= &MimeMessageVtbl
;
3082 This
->stream
= NULL
;
3083 list_init(&This
->body_tree
);
3084 This
->next_index
= 1;
3086 mime_body
= mimebody_create();
3087 root_body
= new_body_entry(mime_body
, This
->next_index
++, NULL
);
3088 list_add_head(&This
->body_tree
, &root_body
->entry
);
3090 *obj
= &This
->IMimeMessage_iface
;
3094 /***********************************************************************
3095 * MimeOleCreateMessage (INETCOMM.@)
3097 HRESULT WINAPI
MimeOleCreateMessage(IUnknown
*pUnkOuter
, IMimeMessage
**ppMessage
)
3099 TRACE("(%p, %p)\n", pUnkOuter
, ppMessage
);
3100 return MimeMessage_create(NULL
, (void **)ppMessage
);
3103 /***********************************************************************
3104 * MimeOleSetCompatMode (INETCOMM.@)
3106 HRESULT WINAPI
MimeOleSetCompatMode(DWORD dwMode
)
3108 FIXME("(0x%x)\n", dwMode
);
3112 /***********************************************************************
3113 * MimeOleCreateVirtualStream (INETCOMM.@)
3115 HRESULT WINAPI
MimeOleCreateVirtualStream(IStream
**ppStream
)
3118 FIXME("(%p)\n", ppStream
);
3120 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, ppStream
);
3124 typedef struct MimeSecurity
3126 IMimeSecurity IMimeSecurity_iface
;
3130 static inline MimeSecurity
*impl_from_IMimeSecurity(IMimeSecurity
*iface
)
3132 return CONTAINING_RECORD(iface
, MimeSecurity
, IMimeSecurity_iface
);
3135 static HRESULT WINAPI
MimeSecurity_QueryInterface(IMimeSecurity
*iface
, REFIID riid
, void **ppv
)
3137 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ppv
);
3139 if (IsEqualIID(riid
, &IID_IUnknown
) ||
3140 IsEqualIID(riid
, &IID_IMimeSecurity
))
3143 IMimeSecurity_AddRef(iface
);
3147 FIXME("no interface for %s\n", debugstr_guid(riid
));
3149 return E_NOINTERFACE
;
3152 static ULONG WINAPI
MimeSecurity_AddRef(IMimeSecurity
*iface
)
3154 MimeSecurity
*This
= impl_from_IMimeSecurity(iface
);
3155 LONG ref
= InterlockedIncrement(&This
->ref
);
3157 TRACE("(%p) ref=%d\n", This
, ref
);
3162 static ULONG WINAPI
MimeSecurity_Release(IMimeSecurity
*iface
)
3164 MimeSecurity
*This
= impl_from_IMimeSecurity(iface
);
3165 LONG ref
= InterlockedDecrement(&This
->ref
);
3167 TRACE("(%p) ref=%d\n", This
, ref
);
3170 HeapFree(GetProcessHeap(), 0, This
);
3175 static HRESULT WINAPI
MimeSecurity_InitNew(
3176 IMimeSecurity
* iface
)
3178 FIXME("(%p)->(): stub\n", iface
);
3182 static HRESULT WINAPI
MimeSecurity_CheckInit(
3183 IMimeSecurity
* iface
)
3185 FIXME("(%p)->(): stub\n", iface
);
3189 static HRESULT WINAPI
MimeSecurity_EncodeMessage(
3190 IMimeSecurity
* iface
,
3191 IMimeMessageTree
* pTree
,
3194 FIXME("(%p)->(%p, %08x): stub\n", iface
, pTree
, dwFlags
);
3198 static HRESULT WINAPI
MimeSecurity_EncodeBody(
3199 IMimeSecurity
* iface
,
3200 IMimeMessageTree
* pTree
,
3204 FIXME("(%p)->(%p, %p, %08x): stub\n", iface
, pTree
, hEncodeRoot
, dwFlags
);
3208 static HRESULT WINAPI
MimeSecurity_DecodeMessage(
3209 IMimeSecurity
* iface
,
3210 IMimeMessageTree
* pTree
,
3213 FIXME("(%p)->(%p, %08x): stub\n", iface
, pTree
, dwFlags
);
3217 static HRESULT WINAPI
MimeSecurity_DecodeBody(
3218 IMimeSecurity
* iface
,
3219 IMimeMessageTree
* pTree
,
3223 FIXME("(%p)->(%p, %p, %08x): stub\n", iface
, pTree
, hDecodeRoot
, dwFlags
);
3227 static HRESULT WINAPI
MimeSecurity_EnumCertificates(
3228 IMimeSecurity
* iface
,
3234 FIXME("(%p)->(%p, %08x, %p, %p): stub\n", iface
, hc
, dwUsage
, pPrev
, ppCert
);
3238 static HRESULT WINAPI
MimeSecurity_GetCertificateName(
3239 IMimeSecurity
* iface
,
3240 const PCX509CERT pX509Cert
,
3241 const CERTNAMETYPE cn
,
3244 FIXME("(%p)->(%p, %08x, %p): stub\n", iface
, pX509Cert
, cn
, ppszName
);
3248 static HRESULT WINAPI
MimeSecurity_GetMessageType(
3249 IMimeSecurity
* iface
,
3250 const HWND hwndParent
,
3254 FIXME("(%p)->(%p, %p, %p): stub\n", iface
, hwndParent
, pBody
, pdwSecType
);
3258 static HRESULT WINAPI
MimeSecurity_GetCertData(
3259 IMimeSecurity
* iface
,
3260 const PCX509CERT pX509Cert
,
3261 const CERTDATAID dataid
,
3262 LPPROPVARIANT pValue
)
3264 FIXME("(%p)->(%p, %x, %p): stub\n", iface
, pX509Cert
, dataid
, pValue
);
3269 static const IMimeSecurityVtbl MimeSecurityVtbl
=
3271 MimeSecurity_QueryInterface
,
3272 MimeSecurity_AddRef
,
3273 MimeSecurity_Release
,
3274 MimeSecurity_InitNew
,
3275 MimeSecurity_CheckInit
,
3276 MimeSecurity_EncodeMessage
,
3277 MimeSecurity_EncodeBody
,
3278 MimeSecurity_DecodeMessage
,
3279 MimeSecurity_DecodeBody
,
3280 MimeSecurity_EnumCertificates
,
3281 MimeSecurity_GetCertificateName
,
3282 MimeSecurity_GetMessageType
,
3283 MimeSecurity_GetCertData
3286 HRESULT
MimeSecurity_create(IUnknown
*outer
, void **obj
)
3292 if (outer
) return CLASS_E_NOAGGREGATION
;
3294 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
3295 if (!This
) return E_OUTOFMEMORY
;
3297 This
->IMimeSecurity_iface
.lpVtbl
= &MimeSecurityVtbl
;
3300 *obj
= &This
->IMimeSecurity_iface
;
3304 /***********************************************************************
3305 * MimeOleCreateSecurity (INETCOMM.@)
3307 HRESULT WINAPI
MimeOleCreateSecurity(IMimeSecurity
**ppSecurity
)
3309 return MimeSecurity_create(NULL
, (void **)ppSecurity
);
3312 static HRESULT WINAPI
MimeAlloc_QueryInterface(
3313 IMimeAllocator
* iface
,
3317 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), obj
);
3319 if (IsEqualIID(riid
, &IID_IUnknown
) ||
3320 IsEqualIID(riid
, &IID_IMalloc
) ||
3321 IsEqualIID(riid
, &IID_IMimeAllocator
))
3324 IMimeAllocator_AddRef(iface
);
3328 FIXME("no interface for %s\n", debugstr_guid(riid
));
3330 return E_NOINTERFACE
;
3333 static ULONG WINAPI
MimeAlloc_AddRef(
3334 IMimeAllocator
* iface
)
3339 static ULONG WINAPI
MimeAlloc_Release(
3340 IMimeAllocator
* iface
)
3345 static LPVOID WINAPI
MimeAlloc_Alloc(
3346 IMimeAllocator
* iface
,
3349 return CoTaskMemAlloc(cb
);
3352 static LPVOID WINAPI
MimeAlloc_Realloc(
3353 IMimeAllocator
* iface
,
3357 return CoTaskMemRealloc(pv
, cb
);
3360 static void WINAPI
MimeAlloc_Free(
3361 IMimeAllocator
* iface
,
3367 static SIZE_T WINAPI
MimeAlloc_GetSize(
3368 IMimeAllocator
* iface
,
3375 static int WINAPI
MimeAlloc_DidAlloc(
3376 IMimeAllocator
* iface
,
3383 static void WINAPI
MimeAlloc_HeapMinimize(
3384 IMimeAllocator
* iface
)
3390 static HRESULT WINAPI
MimeAlloc_FreeParamInfoArray(
3391 IMimeAllocator
* iface
,
3393 LPMIMEPARAMINFO prgParam
,
3397 TRACE("(%p)->(%d, %p, %d)\n", iface
, cParams
, prgParam
, fFreeArray
);
3399 for(i
= 0; i
< cParams
; i
++)
3401 IMimeAllocator_Free(iface
, prgParam
[i
].pszName
);
3402 IMimeAllocator_Free(iface
, prgParam
[i
].pszData
);
3404 if(fFreeArray
) IMimeAllocator_Free(iface
, prgParam
);
3408 static HRESULT WINAPI
MimeAlloc_FreeAddressList(
3409 IMimeAllocator
* iface
,
3410 LPADDRESSLIST pList
)
3416 static HRESULT WINAPI
MimeAlloc_FreeAddressProps(
3417 IMimeAllocator
* iface
,
3418 LPADDRESSPROPS pAddress
)
3424 static HRESULT WINAPI
MimeAlloc_ReleaseObjects(
3425 IMimeAllocator
* iface
,
3427 IUnknown
**prgpUnknown
,
3435 static HRESULT WINAPI
MimeAlloc_FreeEnumHeaderRowArray(
3436 IMimeAllocator
* iface
,
3438 LPENUMHEADERROW prgRow
,
3445 static HRESULT WINAPI
MimeAlloc_FreeEnumPropertyArray(
3446 IMimeAllocator
* iface
,
3448 LPENUMPROPERTY prgProp
,
3455 static HRESULT WINAPI
MimeAlloc_FreeThumbprint(
3456 IMimeAllocator
* iface
,
3457 THUMBBLOB
*pthumbprint
)
3464 static HRESULT WINAPI
MimeAlloc_PropVariantClear(
3465 IMimeAllocator
* iface
,
3466 LPPROPVARIANT pProp
)
3472 static IMimeAllocatorVtbl mime_alloc_vtbl
=
3474 MimeAlloc_QueryInterface
,
3482 MimeAlloc_HeapMinimize
,
3483 MimeAlloc_FreeParamInfoArray
,
3484 MimeAlloc_FreeAddressList
,
3485 MimeAlloc_FreeAddressProps
,
3486 MimeAlloc_ReleaseObjects
,
3487 MimeAlloc_FreeEnumHeaderRowArray
,
3488 MimeAlloc_FreeEnumPropertyArray
,
3489 MimeAlloc_FreeThumbprint
,
3490 MimeAlloc_PropVariantClear
3493 static IMimeAllocator mime_allocator
=
3498 HRESULT
MimeAllocator_create(IUnknown
*outer
, void **obj
)
3500 if(outer
) return CLASS_E_NOAGGREGATION
;
3502 *obj
= &mime_allocator
;
3506 HRESULT WINAPI
MimeOleGetAllocator(IMimeAllocator
**alloc
)
3508 return MimeAllocator_create(NULL
, (void**)alloc
);
3511 HRESULT
VirtualStream_create(IUnknown
*outer
, void **obj
)
3513 FIXME("(%p, %p)\n", outer
, obj
);
3516 if (outer
) return CLASS_E_NOAGGREGATION
;
3518 return MimeOleCreateVirtualStream((IStream
**)obj
);
3521 /* IMimePropertySchema Interface */
3522 static HRESULT WINAPI
propschema_QueryInterface(IMimePropertySchema
*iface
, REFIID riid
, void **out
)
3524 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3525 TRACE("(%p)->(%s, %p)\n", This
, debugstr_guid(riid
), out
);
3529 if (IsEqualIID(riid
, &IID_IUnknown
) ||
3530 IsEqualIID(riid
, &IID_IMimePropertySchema
))
3536 FIXME("no interface for %s\n", debugstr_guid(riid
));
3537 return E_NOINTERFACE
;
3540 IMimePropertySchema_AddRef(iface
);
3544 static ULONG WINAPI
propschema_AddRef(IMimePropertySchema
*iface
)
3546 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3547 LONG ref
= InterlockedIncrement(&This
->ref
);
3549 TRACE("(%p) ref=%d\n", This
, ref
);
3554 static ULONG WINAPI
propschema_Release(IMimePropertySchema
*iface
)
3556 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3557 LONG ref
= InterlockedDecrement(&This
->ref
);
3559 TRACE("(%p) ref=%d\n", This
, ref
);
3563 HeapFree(GetProcessHeap(), 0, This
);
3569 static HRESULT WINAPI
propschema_RegisterProperty(IMimePropertySchema
*iface
, const char *name
, DWORD flags
,
3570 DWORD rownumber
, VARTYPE vtdefault
, DWORD
*propid
)
3572 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3573 FIXME("(%p)->(%s, %x, %d, %d, %p) stub\n", This
, debugstr_a(name
), flags
, rownumber
, vtdefault
, propid
);
3577 static HRESULT WINAPI
propschema_ModifyProperty(IMimePropertySchema
*iface
, const char *name
, DWORD flags
,
3578 DWORD rownumber
, VARTYPE vtdefault
)
3580 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3581 FIXME("(%p)->(%s, %x, %d, %d) stub\n", This
, debugstr_a(name
), flags
, rownumber
, vtdefault
);
3585 static HRESULT WINAPI
propschema_GetPropertyId(IMimePropertySchema
*iface
, const char *name
, DWORD
*propid
)
3587 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3588 FIXME("(%p)->(%s, %p) stub\n", This
, debugstr_a(name
), propid
);
3592 static HRESULT WINAPI
propschema_GetPropertyName(IMimePropertySchema
*iface
, DWORD propid
, char **name
)
3594 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3595 FIXME("(%p)->(%d, %p) stub\n", This
, propid
, name
);
3599 static HRESULT WINAPI
propschema_RegisterAddressType(IMimePropertySchema
*iface
, const char *name
, DWORD
*adrtype
)
3601 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3602 FIXME("(%p)->(%s, %p) stub\n", This
, debugstr_a(name
), adrtype
);
3606 static IMimePropertySchemaVtbl prop_schema_vtbl
=
3608 propschema_QueryInterface
,
3611 propschema_RegisterProperty
,
3612 propschema_ModifyProperty
,
3613 propschema_GetPropertyId
,
3614 propschema_GetPropertyName
,
3615 propschema_RegisterAddressType
3619 HRESULT WINAPI
MimeOleGetPropertySchema(IMimePropertySchema
**schema
)
3623 TRACE("(%p) stub\n", schema
);
3625 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
3627 return E_OUTOFMEMORY
;
3629 This
->IMimePropertySchema_iface
.lpVtbl
= &prop_schema_vtbl
;
3632 *schema
= &This
->IMimePropertySchema_iface
;
3637 HRESULT WINAPI
MimeGetAddressFormatW(REFIID riid
, void *object
, DWORD addr_type
,
3638 ADDRESSFORMAT addr_format
, WCHAR
**address
)
3640 FIXME("(%s, %p, %d, %d, %p) stub\n", debugstr_guid(riid
), object
, addr_type
, addr_format
, address
);
3645 static HRESULT WINAPI
mime_obj_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppv
)
3647 FIXME("(%s %p)\n", debugstr_guid(riid
), ppv
);
3649 return E_NOINTERFACE
;
3652 static ULONG WINAPI
mime_obj_AddRef(IUnknown
*iface
)
3658 static ULONG WINAPI
mime_obj_Release(IUnknown
*iface
)
3664 static const IUnknownVtbl mime_obj_vtbl
= {
3665 mime_obj_QueryInterface
,
3670 static IUnknown mime_obj
= { &mime_obj_vtbl
};
3672 HRESULT WINAPI
MimeOleObjectFromMoniker(BINDF bindf
, IMoniker
*moniker
, IBindCtx
*binding
,
3673 REFIID riid
, void **out
, IMoniker
**moniker_new
)
3675 WCHAR
*display_name
, *mhtml_url
;
3679 static const WCHAR mhtml_prefixW
[] = {'m','h','t','m','l',':'};
3681 WARN("(0x%08x, %p, %p, %s, %p, %p) semi-stub\n", bindf
, moniker
, binding
, debugstr_guid(riid
), out
, moniker_new
);
3683 if(!IsEqualGUID(&IID_IUnknown
, riid
)) {
3684 FIXME("Unsupported riid %s\n", debugstr_guid(riid
));
3685 return E_NOINTERFACE
;
3688 hres
= IMoniker_GetDisplayName(moniker
, NULL
, NULL
, &display_name
);
3692 TRACE("display name %s\n", debugstr_w(display_name
));
3694 len
= strlenW(display_name
);
3695 mhtml_url
= heap_alloc((len
+1)*sizeof(WCHAR
) + sizeof(mhtml_prefixW
));
3697 return E_OUTOFMEMORY
;
3699 memcpy(mhtml_url
, mhtml_prefixW
, sizeof(mhtml_prefixW
));
3700 strcpyW(mhtml_url
+ sizeof(mhtml_prefixW
)/sizeof(WCHAR
), display_name
);
3701 HeapFree(GetProcessHeap(), 0, display_name
);
3703 hres
= CreateURLMoniker(NULL
, mhtml_url
, moniker_new
);
3704 heap_free(mhtml_url
);
3708 /* FIXME: We most likely should start binding here and return something more meaningful as mime object. */