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
);
957 FIXME("(%p)->(%p) stub\n", This
, pClassID
);
962 static HRESULT WINAPI
MimeBody_IsDirty(
965 MimeBody
*This
= impl_from_IMimeBody(iface
);
966 FIXME("(%p)->() stub\n", This
);
970 static HRESULT WINAPI
MimeBody_Load(IMimeBody
*iface
, IStream
*pStm
)
972 MimeBody
*This
= impl_from_IMimeBody(iface
);
973 TRACE("(%p)->(%p)\n", This
, pStm
);
974 return parse_headers(This
, pStm
);
977 static HRESULT WINAPI
MimeBody_Save(IMimeBody
*iface
, IStream
*pStm
, BOOL fClearDirty
)
979 MimeBody
*This
= impl_from_IMimeBody(iface
);
980 FIXME("(%p)->(%p, %d)\n", This
, pStm
, fClearDirty
);
984 static HRESULT WINAPI
MimeBody_GetSizeMax(
986 ULARGE_INTEGER
* pcbSize
)
988 MimeBody
*This
= impl_from_IMimeBody(iface
);
989 FIXME("(%p)->(%p) stub\n", This
, pcbSize
);
993 static HRESULT WINAPI
MimeBody_InitNew(
996 MimeBody
*This
= impl_from_IMimeBody(iface
);
997 TRACE("(%p)->()\n", This
);
1001 static HRESULT WINAPI
MimeBody_GetPropInfo(
1004 LPMIMEPROPINFO pInfo
)
1006 MimeBody
*This
= impl_from_IMimeBody(iface
);
1009 DWORD supported
= PIM_PROPID
| PIM_VTDEFAULT
;
1011 TRACE("(%p)->(%s, %p) semi-stub\n", This
, debugstr_a(pszName
), pInfo
);
1013 if(!pszName
|| !pInfo
)
1014 return E_INVALIDARG
;
1016 TRACE("mask 0x%04x\n", pInfo
->dwMask
);
1018 if(pInfo
->dwMask
& ~supported
)
1019 FIXME("Unsupported mask flags 0x%04x\n", pInfo
->dwMask
& ~supported
);
1021 hr
= find_prop(This
, pszName
, &header
);
1024 if(pInfo
->dwMask
& PIM_CHARSET
)
1025 pInfo
->hCharset
= 0;
1026 if(pInfo
->dwMask
& PIM_FLAGS
)
1027 pInfo
->dwFlags
= 0x00000000;
1028 if(pInfo
->dwMask
& PIM_ROWNUMBER
)
1029 pInfo
->dwRowNumber
= 0;
1030 if(pInfo
->dwMask
& PIM_ENCODINGTYPE
)
1031 pInfo
->ietEncoding
= 0;
1032 if(pInfo
->dwMask
& PIM_VALUES
)
1034 if(pInfo
->dwMask
& PIM_PROPID
)
1035 pInfo
->dwPropId
= header
->prop
->id
;
1036 if(pInfo
->dwMask
& PIM_VTDEFAULT
)
1037 pInfo
->vtDefault
= header
->prop
->default_vt
;
1038 if(pInfo
->dwMask
& PIM_VTCURRENT
)
1039 pInfo
->vtCurrent
= 0;
1045 static HRESULT WINAPI
MimeBody_SetPropInfo(
1048 LPCMIMEPROPINFO pInfo
)
1050 MimeBody
*This
= impl_from_IMimeBody(iface
);
1051 FIXME("(%p)->(%s, %p) stub\n", This
, debugstr_a(pszName
), pInfo
);
1055 static HRESULT WINAPI
MimeBody_GetProp(
1059 LPPROPVARIANT pValue
)
1061 MimeBody
*This
= impl_from_IMimeBody(iface
);
1065 TRACE("(%p)->(%s, 0x%x, %p)\n", This
, debugstr_a(pszName
), dwFlags
, pValue
);
1067 if(!pszName
|| !pValue
)
1068 return E_INVALIDARG
;
1070 if(!ISPIDSTR(pszName
) && !lstrcmpiA(pszName
, "att:pri-content-type"))
1072 PropVariantClear(pValue
);
1073 pValue
->vt
= VT_LPSTR
;
1074 pValue
->u
.pszVal
= strdupA(This
->content_pri_type
);
1078 hr
= find_prop(This
, pszName
, &header
);
1081 TRACE("type %d->%d\n", header
->value
.vt
, pValue
->vt
);
1083 hr
= PropVariantChangeType(pValue
, &header
->value
, 0, pValue
->vt
);
1085 FIXME("Conversion not currently supported (%d->%d)\n", header
->value
.vt
, pValue
->vt
);
1091 static HRESULT WINAPI
MimeBody_SetProp(
1095 LPCPROPVARIANT pValue
)
1097 MimeBody
*This
= impl_from_IMimeBody(iface
);
1101 TRACE("(%p)->(%s, 0x%x, %p)\n", This
, debugstr_a(pszName
), dwFlags
, pValue
);
1103 if(!pszName
|| !pValue
)
1104 return E_INVALIDARG
;
1106 hr
= find_prop(This
, pszName
, &header
);
1109 property_list_entry_t
*prop_entry
;
1110 const property_t
*prop
= NULL
;
1112 LIST_FOR_EACH_ENTRY(prop_entry
, &This
->new_props
, property_list_entry_t
, entry
)
1114 if(ISPIDSTR(pszName
))
1116 if(STRTOPID(pszName
) == prop_entry
->prop
.id
)
1118 TRACE("Found match with already added new property id %d\n", prop_entry
->prop
.id
);
1119 prop
= &prop_entry
->prop
;
1123 else if(!lstrcmpiA(pszName
, prop_entry
->prop
.name
))
1125 TRACE("Found match with already added new property id %d\n", prop_entry
->prop
.id
);
1126 prop
= &prop_entry
->prop
;
1131 header
= HeapAlloc(GetProcessHeap(), 0, sizeof(*header
));
1133 return E_OUTOFMEMORY
;
1137 const property_t
*prop_def
= NULL
;
1138 prop_entry
= HeapAlloc(GetProcessHeap(), 0, sizeof(*prop_entry
));
1141 HeapFree(GetProcessHeap(), 0, header
);
1142 return E_OUTOFMEMORY
;
1145 prop_def
= find_default_prop(pszName
);
1148 prop_entry
->prop
.name
= strdupA(prop_def
->name
);
1149 prop_entry
->prop
.id
= prop_def
->id
;
1153 if(ISPIDSTR(pszName
))
1155 HeapFree(GetProcessHeap(), 0, prop_entry
);
1156 HeapFree(GetProcessHeap(), 0, header
);
1157 return MIME_E_NOT_FOUND
;
1160 prop_entry
->prop
.name
= strdupA(pszName
);
1161 prop_entry
->prop
.id
= This
->next_prop_id
++;
1164 prop_entry
->prop
.flags
= 0;
1165 prop_entry
->prop
.default_vt
= pValue
->vt
;
1166 list_add_tail(&This
->new_props
, &prop_entry
->entry
);
1167 prop
= &prop_entry
->prop
;
1168 TRACE("Allocating new prop id %d\n", prop_entry
->prop
.id
);
1171 header
->prop
= prop
;
1172 PropVariantInit(&header
->value
);
1173 list_init(&header
->params
);
1174 list_add_tail(&This
->headers
, &header
->entry
);
1177 PropVariantCopy(&header
->value
, pValue
);
1182 static HRESULT WINAPI
MimeBody_AppendProp(
1186 LPPROPVARIANT pValue
)
1188 MimeBody
*This
= impl_from_IMimeBody(iface
);
1189 FIXME("(%p)->(%s, 0x%x, %p) stub\n", This
, debugstr_a(pszName
), dwFlags
, pValue
);
1193 static HRESULT WINAPI
MimeBody_DeleteProp(
1197 MimeBody
*This
= impl_from_IMimeBody(iface
);
1201 TRACE("(%p)->(%s) stub\n", This
, debugstr_a(pszName
));
1203 LIST_FOR_EACH_ENTRY(cursor
, &This
->headers
, header_t
, entry
)
1205 if(ISPIDSTR(pszName
))
1206 found
= STRTOPID(pszName
) == cursor
->prop
->id
;
1208 found
= !lstrcmpiA(pszName
, cursor
->prop
->name
);
1212 list_remove(&cursor
->entry
);
1213 HeapFree(GetProcessHeap(), 0, cursor
);
1218 return MIME_E_NOT_FOUND
;
1221 static HRESULT WINAPI
MimeBody_CopyProps(
1225 IMimePropertySet
* pPropertySet
)
1227 MimeBody
*This
= impl_from_IMimeBody(iface
);
1228 FIXME("(%p)->(%d, %p, %p) stub\n", This
, cNames
, prgszName
, pPropertySet
);
1232 static HRESULT WINAPI
MimeBody_MoveProps(
1236 IMimePropertySet
* pPropertySet
)
1238 MimeBody
*This
= impl_from_IMimeBody(iface
);
1239 FIXME("(%p)->(%d, %p, %p) stub\n", This
, cNames
, prgszName
, pPropertySet
);
1243 static HRESULT WINAPI
MimeBody_DeleteExcept(
1248 MimeBody
*This
= impl_from_IMimeBody(iface
);
1249 FIXME("(%p)->(%d, %p) stub\n", This
, cNames
, prgszName
);
1253 static HRESULT WINAPI
MimeBody_QueryProp(
1258 boolean fCaseSensitive
)
1260 MimeBody
*This
= impl_from_IMimeBody(iface
);
1261 FIXME("(%p)->(%s, %s, %d, %d) stub\n", This
, debugstr_a(pszName
), debugstr_a(pszCriteria
), fSubString
, fCaseSensitive
);
1265 static HRESULT WINAPI
MimeBody_GetCharset(
1267 LPHCHARSET phCharset
)
1269 MimeBody
*This
= impl_from_IMimeBody(iface
);
1270 FIXME("(%p)->(%p) stub\n", This
, phCharset
);
1275 static HRESULT WINAPI
MimeBody_SetCharset(
1278 CSETAPPLYTYPE applytype
)
1280 MimeBody
*This
= impl_from_IMimeBody(iface
);
1281 FIXME("(%p)->(%p, %d) stub\n", This
, hCharset
, applytype
);
1285 static HRESULT WINAPI
MimeBody_GetParameters(
1289 LPMIMEPARAMINFO
* pprgParam
)
1291 MimeBody
*This
= impl_from_IMimeBody(iface
);
1295 TRACE("(%p)->(%s, %p, %p)\n", iface
, debugstr_a(pszName
), pcParams
, pprgParam
);
1300 hr
= find_prop(This
, pszName
, &header
);
1301 if(hr
!= S_OK
) return hr
;
1303 *pcParams
= list_count(&header
->params
);
1306 IMimeAllocator
*alloc
;
1308 MIMEPARAMINFO
*info
;
1310 MimeOleGetAllocator(&alloc
);
1312 *pprgParam
= info
= IMimeAllocator_Alloc(alloc
, *pcParams
* sizeof(**pprgParam
));
1313 LIST_FOR_EACH_ENTRY(param
, &header
->params
, param_t
, entry
)
1317 len
= strlen(param
->name
) + 1;
1318 info
->pszName
= IMimeAllocator_Alloc(alloc
, len
);
1319 memcpy(info
->pszName
, param
->name
, len
);
1320 len
= strlen(param
->value
) + 1;
1321 info
->pszData
= IMimeAllocator_Alloc(alloc
, len
);
1322 memcpy(info
->pszData
, param
->value
, len
);
1325 IMimeAllocator_Release(alloc
);
1330 static HRESULT WINAPI
MimeBody_IsContentType(
1335 MimeBody
*This
= impl_from_IMimeBody(iface
);
1337 TRACE("(%p)->(%s, %s)\n", This
, debugstr_a(pszPriType
), debugstr_a(pszSubType
));
1340 const char *pri
= This
->content_pri_type
;
1341 if(!pri
) pri
= "text";
1342 if(lstrcmpiA(pri
, pszPriType
)) return S_FALSE
;
1347 const char *sub
= This
->content_sub_type
;
1348 if(!sub
) sub
= "plain";
1349 if(lstrcmpiA(sub
, pszSubType
)) return S_FALSE
;
1355 static HRESULT WINAPI
MimeBody_BindToObject(
1360 MimeBody
*This
= impl_from_IMimeBody(iface
);
1361 FIXME("(%p)->(%s, %p) stub\n", This
, debugstr_guid(riid
), ppvObject
);
1365 static HRESULT WINAPI
MimeBody_Clone(
1367 IMimePropertySet
** ppPropertySet
)
1369 MimeBody
*This
= impl_from_IMimeBody(iface
);
1370 FIXME("(%p)->(%p) stub\n", This
, ppPropertySet
);
1374 static HRESULT WINAPI
MimeBody_SetOption(
1377 LPCPROPVARIANT pValue
)
1379 MimeBody
*This
= impl_from_IMimeBody(iface
);
1380 HRESULT hr
= E_NOTIMPL
;
1381 TRACE("(%p)->(%08x, %p)\n", This
, oid
, pValue
);
1383 if(pValue
->vt
!= TYPEDID_TYPE(oid
))
1385 WARN("Called with vartype %04x and oid %08x\n", pValue
->vt
, oid
);
1386 return E_INVALIDARG
;
1391 case OID_SECURITY_HWND_OWNER
:
1392 FIXME("OID_SECURITY_HWND_OWNER (value %08x): ignoring\n", pValue
->u
.ulVal
);
1395 case OID_TRANSMIT_BODY_ENCODING
:
1396 FIXME("OID_TRANSMIT_BODY_ENCODING (value %08x): ignoring\n", pValue
->u
.ulVal
);
1400 FIXME("Unhandled oid %08x\n", oid
);
1406 static HRESULT WINAPI
MimeBody_GetOption(
1409 LPPROPVARIANT pValue
)
1411 MimeBody
*This
= impl_from_IMimeBody(iface
);
1412 FIXME("(%p)->(%08x, %p): stub\n", This
, oid
, pValue
);
1416 static HRESULT WINAPI
MimeBody_EnumProps(
1419 IMimeEnumProperties
** ppEnum
)
1421 MimeBody
*This
= impl_from_IMimeBody(iface
);
1422 FIXME("(%p)->(0x%x, %p) stub\n", This
, dwFlags
, ppEnum
);
1426 static HRESULT WINAPI
MimeBody_IsType(
1428 IMSGBODYTYPE bodytype
)
1430 MimeBody
*This
= impl_from_IMimeBody(iface
);
1432 TRACE("(%p)->(%d)\n", This
, bodytype
);
1436 return This
->data
? S_FALSE
: S_OK
;
1438 FIXME("Unimplemented bodytype %d - returning S_OK\n", bodytype
);
1443 static HRESULT WINAPI
MimeBody_SetDisplayName(
1447 MimeBody
*This
= impl_from_IMimeBody(iface
);
1448 FIXME("(%p)->(%s) stub\n", This
, debugstr_a(pszDisplay
));
1452 static HRESULT WINAPI
MimeBody_GetDisplayName(
1456 MimeBody
*This
= impl_from_IMimeBody(iface
);
1457 FIXME("(%p)->(%p) stub\n", This
, ppszDisplay
);
1461 static HRESULT WINAPI
MimeBody_GetOffsets(
1463 LPBODYOFFSETS pOffsets
)
1465 MimeBody
*This
= impl_from_IMimeBody(iface
);
1466 TRACE("(%p)->(%p)\n", This
, pOffsets
);
1468 *pOffsets
= This
->body_offsets
;
1470 if(This
->body_offsets
.cbBodyEnd
== 0) return MIME_E_NO_DATA
;
1474 static HRESULT WINAPI
MimeBody_GetCurrentEncoding(
1476 ENCODINGTYPE
* pietEncoding
)
1478 MimeBody
*This
= impl_from_IMimeBody(iface
);
1480 TRACE("(%p)->(%p)\n", This
, pietEncoding
);
1482 *pietEncoding
= This
->encoding
;
1486 static HRESULT WINAPI
MimeBody_SetCurrentEncoding(
1488 ENCODINGTYPE ietEncoding
)
1490 MimeBody
*This
= impl_from_IMimeBody(iface
);
1492 TRACE("(%p)->(%d)\n", This
, ietEncoding
);
1494 This
->encoding
= ietEncoding
;
1498 static HRESULT WINAPI
MimeBody_GetEstimatedSize(
1500 ENCODINGTYPE ietEncoding
,
1503 MimeBody
*This
= impl_from_IMimeBody(iface
);
1504 FIXME("(%p)->(%d, %p) stub\n", This
, ietEncoding
, pcbSize
);
1508 static HRESULT WINAPI
MimeBody_GetDataHere(
1510 ENCODINGTYPE ietEncoding
,
1513 MimeBody
*This
= impl_from_IMimeBody(iface
);
1514 FIXME("(%p)->(%d, %p) stub\n", This
, ietEncoding
, pStream
);
1518 static const signed char base64_decode_table
[] =
1520 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x00 */
1521 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x10 */
1522 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, /* 0x20 */
1523 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, /* 0x30 */
1524 -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 0x40 */
1525 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, /* 0x50 */
1526 -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, /* 0x60 */
1527 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1 /* 0x70 */
1530 static HRESULT
decode_base64(IStream
*input
, IStream
**ret_stream
)
1532 const unsigned char *ptr
, *end
;
1533 unsigned char buf
[1024];
1536 unsigned char in
[4];
1543 hres
= IStream_Seek(input
, pos
, STREAM_SEEK_SET
, NULL
);
1547 hres
= CreateStreamOnHGlobal(NULL
, TRUE
, &output
);
1552 hres
= IStream_Read(input
, buf
, sizeof(buf
), &size
);
1553 if(FAILED(hres
) || !size
)
1560 /* skip invalid chars */
1562 (*ptr
>= sizeof(base64_decode_table
)/sizeof(*base64_decode_table
)
1563 || base64_decode_table
[*ptr
] == -1))
1568 in
[n
++] = base64_decode_table
[*ptr
++];
1571 *ret
++ = in
[0] << 2 | in
[1] >> 4;
1574 *ret
++ = in
[1] << 4 | in
[2] >> 2;
1577 *ret
++ = ((in
[2] << 6) & 0xc0) | in
[3];
1583 hres
= IStream_Write(output
, buf
, ret
- buf
, NULL
);
1590 hres
= IStream_Seek(output
, pos
, STREAM_SEEK_SET
, NULL
);
1592 IStream_Release(output
);
1596 *ret_stream
= output
;
1600 static int hex_digit(char c
)
1602 if('0' <= c
&& c
<= '9')
1604 if('A' <= c
&& c
<= 'F')
1605 return c
- 'A' + 10;
1606 if('a' <= c
&& c
<= 'f')
1607 return c
- 'a' + 10;
1611 static HRESULT
decode_qp(IStream
*input
, IStream
**ret_stream
)
1613 const unsigned char *ptr
, *end
;
1614 unsigned char *ret
, prev
= 0;
1615 unsigned char buf
[1024];
1623 hres
= IStream_Seek(input
, pos
, STREAM_SEEK_SET
, NULL
);
1627 hres
= CreateStreamOnHGlobal(NULL
, TRUE
, &output
);
1632 hres
= IStream_Read(input
, buf
, sizeof(buf
), &size
);
1633 if(FAILED(hres
) || !size
)
1640 unsigned char byte
= *ptr
++;
1654 if(prev
!= '\r' || byte
!= '\n') {
1655 int h1
= hex_digit(prev
), h2
= hex_digit(byte
);
1656 if(h1
!= -1 && h2
!= -1)
1657 *ret
++ = (h1
<< 4) | h2
;
1667 hres
= IStream_Write(output
, buf
, ret
- buf
, NULL
);
1674 hres
= IStream_Seek(output
, pos
, STREAM_SEEK_SET
, NULL
);
1676 IStream_Release(output
);
1680 *ret_stream
= output
;
1684 static HRESULT WINAPI
MimeBody_GetData(
1686 ENCODINGTYPE ietEncoding
,
1689 MimeBody
*This
= impl_from_IMimeBody(iface
);
1690 ULARGE_INTEGER start
, size
;
1693 TRACE("(%p)->(%d %p)\n", This
, ietEncoding
, ppStream
);
1695 if(This
->encoding
!= ietEncoding
) {
1696 switch(This
->encoding
) {
1698 hres
= decode_base64(This
->data
, ppStream
);
1701 hres
= decode_qp(This
->data
, ppStream
);
1704 FIXME("Decoding %d is not supported.\n", This
->encoding
);
1707 if(ietEncoding
!= IET_BINARY
)
1708 FIXME("Encoding %d is not supported.\n", ietEncoding
);
1714 hres
= get_stream_size(This
->data
, &size
);
1716 hres
= create_sub_stream(This
->data
, start
, size
, ppStream
);
1720 static HRESULT WINAPI
MimeBody_SetData(
1722 ENCODINGTYPE ietEncoding
,
1728 MimeBody
*This
= impl_from_IMimeBody(iface
);
1729 TRACE("(%p)->(%d, %s, %s, %s %p)\n", This
, ietEncoding
, debugstr_a(pszPriType
), debugstr_a(pszSubType
),
1730 debugstr_guid(riid
), pvObject
);
1732 if(IsEqualIID(riid
, &IID_IStream
))
1733 IStream_AddRef((IStream
*)pvObject
);
1736 FIXME("Unhandled object type %s\n", debugstr_guid(riid
));
1737 return E_INVALIDARG
;
1741 FIXME("release old data\n");
1743 This
->data_iid
= *riid
;
1744 This
->data
= pvObject
;
1746 IMimeBody_SetCurrentEncoding(iface
, ietEncoding
);
1748 /* FIXME: Update the content type.
1749 If pszPriType == NULL use 'application'
1750 If pszSubType == NULL use 'octet-stream' */
1755 static HRESULT WINAPI
MimeBody_EmptyData(
1758 MimeBody
*This
= impl_from_IMimeBody(iface
);
1759 FIXME("(%p)->() stub\n", This
);
1763 static HRESULT WINAPI
MimeBody_CopyTo(
1767 MimeBody
*This
= impl_from_IMimeBody(iface
);
1768 FIXME("(%p)->(%p) stub\n", This
, pBody
);
1772 static HRESULT WINAPI
MimeBody_GetTransmitInfo(
1774 LPTRANSMITINFO pTransmitInfo
)
1776 MimeBody
*This
= impl_from_IMimeBody(iface
);
1777 FIXME("(%p)->(%p) stub\n", This
, pTransmitInfo
);
1781 static HRESULT WINAPI
MimeBody_SaveToFile(
1783 ENCODINGTYPE ietEncoding
,
1786 MimeBody
*This
= impl_from_IMimeBody(iface
);
1787 FIXME("(%p)->(%d, %s) stub\n", This
, ietEncoding
, debugstr_a(pszFilePath
));
1791 static HRESULT WINAPI
MimeBody_GetHandle(
1795 MimeBody
*This
= impl_from_IMimeBody(iface
);
1796 TRACE("(%p)->(%p)\n", iface
, phBody
);
1799 return E_INVALIDARG
;
1801 *phBody
= This
->handle
;
1802 return This
->handle
? S_OK
: MIME_E_NO_DATA
;
1805 static IMimeBodyVtbl body_vtbl
=
1807 MimeBody_QueryInterface
,
1810 MimeBody_GetClassID
,
1814 MimeBody_GetSizeMax
,
1816 MimeBody_GetPropInfo
,
1817 MimeBody_SetPropInfo
,
1820 MimeBody_AppendProp
,
1821 MimeBody_DeleteProp
,
1824 MimeBody_DeleteExcept
,
1826 MimeBody_GetCharset
,
1827 MimeBody_SetCharset
,
1828 MimeBody_GetParameters
,
1829 MimeBody_IsContentType
,
1830 MimeBody_BindToObject
,
1836 MimeBody_SetDisplayName
,
1837 MimeBody_GetDisplayName
,
1838 MimeBody_GetOffsets
,
1839 MimeBody_GetCurrentEncoding
,
1840 MimeBody_SetCurrentEncoding
,
1841 MimeBody_GetEstimatedSize
,
1842 MimeBody_GetDataHere
,
1847 MimeBody_GetTransmitInfo
,
1848 MimeBody_SaveToFile
,
1852 static HRESULT
MimeBody_set_offsets(MimeBody
*body
, const BODYOFFSETS
*offsets
)
1854 TRACE("setting offsets to %d, %d, %d, %d\n", offsets
->cbBoundaryStart
,
1855 offsets
->cbHeaderStart
, offsets
->cbBodyStart
, offsets
->cbBodyEnd
);
1857 body
->body_offsets
= *offsets
;
1861 #define FIRST_CUSTOM_PROP_ID 0x100
1863 static MimeBody
*mimebody_create(void)
1866 BODYOFFSETS body_offsets
;
1868 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
1872 This
->IMimeBody_iface
.lpVtbl
= &body_vtbl
;
1874 This
->handle
= NULL
;
1875 list_init(&This
->headers
);
1876 list_init(&This
->new_props
);
1877 This
->next_prop_id
= FIRST_CUSTOM_PROP_ID
;
1878 This
->content_pri_type
= NULL
;
1879 This
->content_sub_type
= NULL
;
1880 This
->encoding
= IET_7BIT
;
1882 This
->data_iid
= IID_NULL
;
1884 body_offsets
.cbBoundaryStart
= body_offsets
.cbHeaderStart
= 0;
1885 body_offsets
.cbBodyStart
= body_offsets
.cbBodyEnd
= 0;
1886 MimeBody_set_offsets(This
, &body_offsets
);
1891 HRESULT
MimeBody_create(IUnknown
*outer
, void **ppv
)
1896 return CLASS_E_NOAGGREGATION
;
1898 if ((mb
= mimebody_create()))
1900 *ppv
= &mb
->IMimeBody_iface
;
1906 return E_OUTOFMEMORY
;
1910 typedef struct body_t
1914 MimeBody
*mime_body
;
1916 struct body_t
*parent
;
1917 struct list children
;
1920 typedef struct MimeMessage
1922 IMimeMessage IMimeMessage_iface
;
1926 struct list body_tree
;
1930 static inline MimeMessage
*impl_from_IMimeMessage(IMimeMessage
*iface
)
1932 return CONTAINING_RECORD(iface
, MimeMessage
, IMimeMessage_iface
);
1935 static HRESULT WINAPI
MimeMessage_QueryInterface(IMimeMessage
*iface
, REFIID riid
, void **ppv
)
1937 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ppv
);
1939 if (IsEqualIID(riid
, &IID_IUnknown
) ||
1940 IsEqualIID(riid
, &IID_IPersist
) ||
1941 IsEqualIID(riid
, &IID_IPersistStreamInit
) ||
1942 IsEqualIID(riid
, &IID_IMimeMessageTree
) ||
1943 IsEqualIID(riid
, &IID_IMimeMessage
))
1946 IMimeMessage_AddRef(iface
);
1950 FIXME("no interface for %s\n", debugstr_guid(riid
));
1952 return E_NOINTERFACE
;
1955 static ULONG WINAPI
MimeMessage_AddRef(IMimeMessage
*iface
)
1957 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
1958 ULONG ref
= InterlockedIncrement(&This
->ref
);
1960 TRACE("(%p) ref=%d\n", This
, ref
);
1965 static void empty_body_list(struct list
*list
)
1967 body_t
*body
, *cursor2
;
1968 LIST_FOR_EACH_ENTRY_SAFE(body
, cursor2
, list
, body_t
, entry
)
1970 empty_body_list(&body
->children
);
1971 list_remove(&body
->entry
);
1972 IMimeBody_Release(&body
->mime_body
->IMimeBody_iface
);
1973 HeapFree(GetProcessHeap(), 0, body
);
1977 static ULONG WINAPI
MimeMessage_Release(IMimeMessage
*iface
)
1979 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
1980 ULONG ref
= InterlockedDecrement(&This
->ref
);
1982 TRACE("(%p) ref=%d\n", This
, ref
);
1986 empty_body_list(&This
->body_tree
);
1988 if(This
->stream
) IStream_Release(This
->stream
);
1989 HeapFree(GetProcessHeap(), 0, This
);
1995 /*** IPersist methods ***/
1996 static HRESULT WINAPI
MimeMessage_GetClassID(
1997 IMimeMessage
*iface
,
2000 FIXME("(%p)->(%p)\n", iface
, pClassID
);
2004 /*** IPersistStreamInit methods ***/
2005 static HRESULT WINAPI
MimeMessage_IsDirty(
2006 IMimeMessage
*iface
)
2008 FIXME("(%p)->()\n", iface
);
2012 static body_t
*new_body_entry(MimeBody
*mime_body
, DWORD index
, body_t
*parent
)
2014 body_t
*body
= HeapAlloc(GetProcessHeap(), 0, sizeof(*body
));
2017 body
->mime_body
= mime_body
;
2018 body
->index
= index
;
2019 list_init(&body
->children
);
2020 body
->parent
= parent
;
2022 mime_body
->handle
= UlongToHandle(body
->index
);
2030 BODYOFFSETS offsets
;
2033 static HRESULT
create_body_offset_list(IStream
*stm
, const char *boundary
, struct list
*body_offsets
)
2036 DWORD read
, boundary_start
;
2037 int boundary_len
= strlen(boundary
);
2038 char *buf
, *ptr
, *overlap
;
2039 DWORD start
= 0, overlap_no
;
2040 offset_entry_t
*cur_body
= NULL
;
2041 BOOL is_first_line
= TRUE
;
2045 list_init(body_offsets
);
2047 overlap_no
= boundary_len
+ 5;
2049 overlap
= buf
= HeapAlloc(GetProcessHeap(), 0, overlap_no
+ PARSER_BUF_SIZE
+ 1);
2052 hr
= IStream_Seek(stm
, zero
, STREAM_SEEK_CUR
, &cur
);
2053 start
= cur
.u
.LowPart
;
2056 hr
= IStream_Read(stm
, overlap
, PARSER_BUF_SIZE
, &read
);
2057 if(FAILED(hr
)) goto end
;
2058 if(read
== 0) break;
2059 overlap
[read
] = '\0';
2064 is_first_line
= FALSE
;
2066 ptr
= strstr(ptr
, "\r\n");
2072 boundary_start
= start
+ ptr
- buf
;
2074 if(*ptr
== '-' && *(ptr
+ 1) == '-' && !memcmp(ptr
+ 2, boundary
, boundary_len
)) {
2075 ptr
+= boundary_len
+ 2;
2077 if(*ptr
== '\r' && *(ptr
+ 1) == '\n')
2082 cur_body
->offsets
.cbBodyEnd
= boundary_start
- 2;
2083 list_add_tail(body_offsets
, &cur_body
->entry
);
2085 cur_body
= HeapAlloc(GetProcessHeap(), 0, sizeof(*cur_body
));
2086 cur_body
->offsets
.cbBoundaryStart
= boundary_start
;
2087 cur_body
->offsets
.cbHeaderStart
= start
+ ptr
- buf
;
2089 else if(*ptr
== '-' && *(ptr
+ 1) == '-')
2093 cur_body
->offsets
.cbBodyEnd
= boundary_start
- 2;
2094 list_add_tail(body_offsets
, &cur_body
->entry
);
2101 if(overlap
== buf
) /* 1st iteration */
2103 memmove(buf
, buf
+ PARSER_BUF_SIZE
- overlap_no
, overlap_no
);
2104 overlap
= buf
+ overlap_no
;
2105 start
+= read
- overlap_no
;
2109 memmove(buf
, buf
+ PARSER_BUF_SIZE
, overlap_no
);
2115 HeapFree(GetProcessHeap(), 0, buf
);
2119 static body_t
*create_sub_body(MimeMessage
*msg
, IStream
*pStm
, BODYOFFSETS
*offset
, body_t
*parent
)
2121 ULARGE_INTEGER start
, length
;
2122 MimeBody
*mime_body
;
2127 pos
.QuadPart
= offset
->cbHeaderStart
;
2128 IStream_Seek(pStm
, pos
, STREAM_SEEK_SET
, NULL
);
2130 mime_body
= mimebody_create();
2131 IMimeBody_Load(&mime_body
->IMimeBody_iface
, pStm
);
2134 hr
= IStream_Seek(pStm
, pos
, STREAM_SEEK_CUR
, &start
);
2135 offset
->cbBodyStart
= start
.QuadPart
;
2136 if (parent
) MimeBody_set_offsets(mime_body
, offset
);
2138 length
.QuadPart
= offset
->cbBodyEnd
- offset
->cbBodyStart
;
2139 create_sub_stream(pStm
, start
, length
, (IStream
**)&mime_body
->data
);
2140 mime_body
->data_iid
= IID_IStream
;
2142 body
= new_body_entry(mime_body
, msg
->next_index
++, parent
);
2144 if(IMimeBody_IsContentType(&mime_body
->IMimeBody_iface
, "multipart", NULL
) == S_OK
)
2146 MIMEPARAMINFO
*param_info
;
2148 IMimeAllocator
*alloc
;
2150 hr
= IMimeBody_GetParameters(&mime_body
->IMimeBody_iface
, "Content-Type", &count
,
2152 if(hr
!= S_OK
|| count
== 0) return body
;
2154 MimeOleGetAllocator(&alloc
);
2156 for(i
= 0; i
< count
; i
++)
2158 if(!lstrcmpiA(param_info
[i
].pszName
, "boundary"))
2160 struct list offset_list
;
2161 offset_entry_t
*cur
, *cursor2
;
2162 hr
= create_body_offset_list(pStm
, param_info
[i
].pszData
, &offset_list
);
2163 LIST_FOR_EACH_ENTRY_SAFE(cur
, cursor2
, &offset_list
, offset_entry_t
, entry
)
2167 sub_body
= create_sub_body(msg
, pStm
, &cur
->offsets
, body
);
2168 list_add_tail(&body
->children
, &sub_body
->entry
);
2169 list_remove(&cur
->entry
);
2170 HeapFree(GetProcessHeap(), 0, cur
);
2175 IMimeAllocator_FreeParamInfoArray(alloc
, count
, param_info
, TRUE
);
2176 IMimeAllocator_Release(alloc
);
2181 static HRESULT WINAPI
MimeMessage_Load(IMimeMessage
*iface
, IStream
*pStm
)
2183 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2185 BODYOFFSETS offsets
;
2189 TRACE("(%p)->(%p)\n", iface
, pStm
);
2193 FIXME("already loaded a message\n");
2197 empty_body_list(&This
->body_tree
);
2199 IStream_AddRef(pStm
);
2200 This
->stream
= pStm
;
2201 offsets
.cbBoundaryStart
= offsets
.cbHeaderStart
= 0;
2202 offsets
.cbBodyStart
= offsets
.cbBodyEnd
= 0;
2204 root_body
= create_sub_body(This
, pStm
, &offsets
, NULL
);
2207 IStream_Seek(pStm
, zero
, STREAM_SEEK_END
, &cur
);
2208 offsets
.cbBodyEnd
= cur
.u
.LowPart
;
2209 MimeBody_set_offsets(root_body
->mime_body
, &offsets
);
2211 list_add_head(&This
->body_tree
, &root_body
->entry
);
2216 static HRESULT WINAPI
MimeMessage_Save(IMimeMessage
*iface
, IStream
*pStm
, BOOL fClearDirty
)
2218 FIXME("(%p)->(%p, %s)\n", iface
, pStm
, fClearDirty
? "TRUE" : "FALSE");
2222 static HRESULT WINAPI
MimeMessage_GetSizeMax(
2223 IMimeMessage
*iface
,
2224 ULARGE_INTEGER
*pcbSize
)
2226 FIXME("(%p)->(%p)\n", iface
, pcbSize
);
2230 static HRESULT WINAPI
MimeMessage_InitNew(
2231 IMimeMessage
*iface
)
2233 FIXME("(%p)->()\n", iface
);
2237 /*** IMimeMessageTree methods ***/
2238 static HRESULT WINAPI
MimeMessage_GetMessageSource(IMimeMessage
*iface
, IStream
**ppStream
,
2241 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2243 FIXME("(%p)->(%p, 0x%x)\n", iface
, ppStream
, dwFlags
);
2245 IStream_AddRef(This
->stream
);
2246 *ppStream
= This
->stream
;
2250 static HRESULT WINAPI
MimeMessage_GetMessageSize(
2251 IMimeMessage
*iface
,
2255 FIXME("(%p)->(%p, 0x%x)\n", iface
, pcbSize
, dwFlags
);
2259 static HRESULT WINAPI
MimeMessage_LoadOffsetTable(
2260 IMimeMessage
*iface
,
2263 FIXME("(%p)->(%p)\n", iface
, pStream
);
2267 static HRESULT WINAPI
MimeMessage_SaveOffsetTable(
2268 IMimeMessage
*iface
,
2272 FIXME("(%p)->(%p, 0x%x)\n", iface
, pStream
, dwFlags
);
2277 static HRESULT WINAPI
MimeMessage_GetFlags(
2278 IMimeMessage
*iface
,
2281 FIXME("(%p)->(%p)\n", iface
, pdwFlags
);
2285 static HRESULT WINAPI
MimeMessage_Commit(
2286 IMimeMessage
*iface
,
2289 FIXME("(%p)->(0x%x)\n", iface
, dwFlags
);
2294 static HRESULT WINAPI
MimeMessage_HandsOffStorage(
2295 IMimeMessage
*iface
)
2297 FIXME("(%p)->()\n", iface
);
2301 static HRESULT
find_body(struct list
*list
, HBODY hbody
, body_t
**body
)
2306 if(hbody
== HBODY_ROOT
)
2308 *body
= LIST_ENTRY(list_head(list
), body_t
, entry
);
2312 LIST_FOR_EACH_ENTRY(cur
, list
, body_t
, entry
)
2314 if(cur
->index
== HandleToUlong(hbody
))
2319 hr
= find_body(&cur
->children
, hbody
, body
);
2320 if(hr
== S_OK
) return S_OK
;
2325 static HRESULT WINAPI
MimeMessage_BindToObject(IMimeMessage
*iface
, const HBODY hBody
, REFIID riid
,
2328 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2332 TRACE("(%p)->(%p, %s, %p)\n", iface
, hBody
, debugstr_guid(riid
), ppvObject
);
2334 hr
= find_body(&This
->body_tree
, hBody
, &body
);
2336 if(hr
!= S_OK
) return hr
;
2338 if(IsEqualIID(riid
, &IID_IMimeBody
))
2340 IMimeBody_AddRef(&body
->mime_body
->IMimeBody_iface
);
2341 *ppvObject
= &body
->mime_body
->IMimeBody_iface
;
2345 return E_NOINTERFACE
;
2348 static HRESULT WINAPI
MimeMessage_SaveBody(
2349 IMimeMessage
*iface
,
2354 FIXME("(%p)->(%p, 0x%x, %p)\n", iface
, hBody
, dwFlags
, pStream
);
2358 static HRESULT
get_body(MimeMessage
*msg
, BODYLOCATION location
, HBODY pivot
, body_t
**out
)
2360 body_t
*root
= LIST_ENTRY(list_head(&msg
->body_tree
), body_t
, entry
);
2365 if(location
== IBL_ROOT
)
2371 hr
= find_body(&msg
->body_tree
, pivot
, &body
);
2379 *out
= body
->parent
;
2381 hr
= MIME_E_NOT_FOUND
;
2385 list
= list_head(&body
->children
);
2387 *out
= LIST_ENTRY(list
, body_t
, entry
);
2389 hr
= MIME_E_NOT_FOUND
;
2393 list
= list_tail(&body
->children
);
2395 *out
= LIST_ENTRY(list
, body_t
, entry
);
2397 hr
= MIME_E_NOT_FOUND
;
2401 list
= list_next(&body
->parent
->children
, &body
->entry
);
2403 *out
= LIST_ENTRY(list
, body_t
, entry
);
2405 hr
= MIME_E_NOT_FOUND
;
2409 list
= list_prev(&body
->parent
->children
, &body
->entry
);
2411 *out
= LIST_ENTRY(list
, body_t
, entry
);
2413 hr
= MIME_E_NOT_FOUND
;
2426 static HRESULT WINAPI
MimeMessage_InsertBody(
2427 IMimeMessage
*iface
,
2428 BODYLOCATION location
,
2432 FIXME("(%p)->(%d, %p, %p)\n", iface
, location
, hPivot
, phBody
);
2436 static HRESULT WINAPI
MimeMessage_GetBody(IMimeMessage
*iface
, BODYLOCATION location
, HBODY hPivot
,
2439 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2443 TRACE("(%p)->(%d, %p, %p)\n", iface
, location
, hPivot
, phBody
);
2446 return E_INVALIDARG
;
2450 hr
= get_body(This
, location
, hPivot
, &body
);
2452 if(hr
== S_OK
) *phBody
= UlongToHandle(body
->index
);
2457 static HRESULT WINAPI
MimeMessage_DeleteBody(
2458 IMimeMessage
*iface
,
2462 FIXME("(%p)->(%p, %08x)\n", iface
, hBody
, dwFlags
);
2466 static HRESULT WINAPI
MimeMessage_MoveBody(
2467 IMimeMessage
*iface
,
2469 BODYLOCATION location
)
2471 FIXME("(%p)->(%d)\n", iface
, location
);
2475 static void count_children(body_t
*body
, boolean recurse
, ULONG
*count
)
2479 LIST_FOR_EACH_ENTRY(child
, &body
->children
, body_t
, entry
)
2482 if(recurse
) count_children(child
, recurse
, count
);
2486 static HRESULT WINAPI
MimeMessage_CountBodies(IMimeMessage
*iface
, HBODY hParent
, boolean fRecurse
,
2490 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2493 TRACE("(%p)->(%p, %s, %p)\n", iface
, hParent
, fRecurse
? "TRUE" : "FALSE", pcBodies
);
2495 hr
= find_body(&This
->body_tree
, hParent
, &body
);
2496 if(hr
!= S_OK
) return hr
;
2499 count_children(body
, fRecurse
, pcBodies
);
2504 static HRESULT
find_next(MimeMessage
*This
, body_t
*body
, FINDBODY
*find
, HBODY
*out
)
2511 if (!body
) ptr
= list_head( &This
->body_tree
);
2514 ptr
= list_head( &body
->children
);
2517 if (!body
->parent
) return MIME_E_NOT_FOUND
;
2518 if (!(ptr
= list_next( &body
->parent
->children
, &body
->entry
))) body
= body
->parent
;
2522 body
= LIST_ENTRY( ptr
, body_t
, entry
);
2523 next
= UlongToHandle( body
->index
);
2524 find
->dwReserved
= body
->index
;
2525 if (IMimeBody_IsContentType(&body
->mime_body
->IMimeBody_iface
, find
->pszPriType
,
2526 find
->pszSubType
) == S_OK
)
2532 return MIME_E_NOT_FOUND
;
2535 static HRESULT WINAPI
MimeMessage_FindFirst(IMimeMessage
*iface
, FINDBODY
*pFindBody
, HBODY
*phBody
)
2537 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2539 TRACE("(%p)->(%p, %p)\n", iface
, pFindBody
, phBody
);
2541 pFindBody
->dwReserved
= 0;
2542 return find_next(This
, NULL
, pFindBody
, phBody
);
2545 static HRESULT WINAPI
MimeMessage_FindNext(IMimeMessage
*iface
, FINDBODY
*pFindBody
, HBODY
*phBody
)
2547 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2551 TRACE("(%p)->(%p, %p)\n", iface
, pFindBody
, phBody
);
2553 hr
= find_body( &This
->body_tree
, UlongToHandle( pFindBody
->dwReserved
), &body
);
2554 if (hr
!= S_OK
) return MIME_E_NOT_FOUND
;
2555 return find_next(This
, body
, pFindBody
, phBody
);
2558 static HRESULT WINAPI
MimeMessage_ResolveURL(
2559 IMimeMessage
*iface
,
2566 FIXME("(%p)->(%p, %s, %s, 0x%x, %p)\n", iface
, hRelated
, pszBase
, pszURL
, dwFlags
, phBody
);
2570 static HRESULT WINAPI
MimeMessage_ToMultipart(
2571 IMimeMessage
*iface
,
2574 LPHBODY phMultipart
)
2576 FIXME("(%p)->(%p, %s, %p)\n", iface
, hBody
, pszSubType
, phMultipart
);
2580 static HRESULT WINAPI
MimeMessage_GetBodyOffsets(
2581 IMimeMessage
*iface
,
2583 LPBODYOFFSETS pOffsets
)
2585 FIXME("(%p)->(%p, %p)\n", iface
, hBody
, pOffsets
);
2589 static HRESULT WINAPI
MimeMessage_GetCharset(
2590 IMimeMessage
*iface
,
2591 LPHCHARSET phCharset
)
2593 FIXME("(%p)->(%p)\n", iface
, phCharset
);
2598 static HRESULT WINAPI
MimeMessage_SetCharset(
2599 IMimeMessage
*iface
,
2601 CSETAPPLYTYPE applytype
)
2603 FIXME("(%p)->(%p, %d)\n", iface
, hCharset
, applytype
);
2607 static HRESULT WINAPI
MimeMessage_IsBodyType(
2608 IMimeMessage
*iface
,
2610 IMSGBODYTYPE bodytype
)
2613 IMimeBody
*mime_body
;
2614 TRACE("(%p)->(%p, %d)\n", iface
, hBody
, bodytype
);
2616 hr
= IMimeMessage_BindToObject(iface
, hBody
, &IID_IMimeBody
, (void**)&mime_body
);
2617 if(hr
!= S_OK
) return hr
;
2619 hr
= IMimeBody_IsType(mime_body
, bodytype
);
2620 MimeBody_Release(mime_body
);
2624 static HRESULT WINAPI
MimeMessage_IsContentType(
2625 IMimeMessage
*iface
,
2631 IMimeBody
*mime_body
;
2632 TRACE("(%p)->(%p, %s, %s)\n", iface
, hBody
, debugstr_a(pszPriType
),
2633 debugstr_a(pszSubType
));
2635 hr
= IMimeMessage_BindToObject(iface
, hBody
, &IID_IMimeBody
, (void**)&mime_body
);
2636 if(FAILED(hr
)) return hr
;
2638 hr
= IMimeBody_IsContentType(mime_body
, pszPriType
, pszSubType
);
2639 IMimeBody_Release(mime_body
);
2643 static HRESULT WINAPI
MimeMessage_QueryBodyProp(
2644 IMimeMessage
*iface
,
2649 boolean fCaseSensitive
)
2651 FIXME("(%p)->(%p, %s, %s, %s, %s)\n", iface
, hBody
, pszName
, pszCriteria
, fSubString
? "TRUE" : "FALSE", fCaseSensitive
? "TRUE" : "FALSE");
2655 static HRESULT WINAPI
MimeMessage_GetBodyProp(
2656 IMimeMessage
*iface
,
2660 LPPROPVARIANT pValue
)
2663 IMimeBody
*mime_body
;
2665 TRACE("(%p)->(%p, %s, 0x%x, %p)\n", iface
, hBody
, pszName
, dwFlags
, pValue
);
2667 hr
= IMimeMessage_BindToObject(iface
, hBody
, &IID_IMimeBody
, (void**)&mime_body
);
2668 if(hr
!= S_OK
) return hr
;
2670 hr
= IMimeBody_GetProp(mime_body
, pszName
, dwFlags
, pValue
);
2671 IMimeBody_Release(mime_body
);
2676 static HRESULT WINAPI
MimeMessage_SetBodyProp(
2677 IMimeMessage
*iface
,
2681 LPCPROPVARIANT pValue
)
2683 FIXME("(%p)->(%p, %s, 0x%x, %p)\n", iface
, hBody
, pszName
, dwFlags
, pValue
);
2687 static HRESULT WINAPI
MimeMessage_DeleteBodyProp(
2688 IMimeMessage
*iface
,
2692 FIXME("(%p)->(%p, %s)\n", iface
, hBody
, pszName
);
2696 static HRESULT WINAPI
MimeMessage_SetOption(
2697 IMimeMessage
*iface
,
2699 LPCPROPVARIANT pValue
)
2702 TRACE("(%p)->(%08x, %p)\n", iface
, oid
, pValue
);
2704 /* Message ID is checked before type.
2705 * OID 0x4D -> 0x56 and 0x58 aren't defined but will filtered out later.
2707 if(TYPEDID_ID(oid
) < TYPEDID_ID(OID_ALLOW_8BIT_HEADER
) || TYPEDID_ID(oid
) > TYPEDID_ID(OID_SECURITY_2KEY_CERT_BAG_64
))
2709 WARN("oid (%08x) out of range\n", oid
);
2710 return MIME_E_INVALID_OPTION_ID
;
2713 if(pValue
->vt
!= TYPEDID_TYPE(oid
))
2715 WARN("Called with vartype %04x and oid %08x\n", pValue
->vt
, oid
);
2721 case OID_HIDE_TNEF_ATTACHMENTS
:
2722 FIXME("OID_HIDE_TNEF_ATTACHMENTS (value %d): ignoring\n", pValue
->u
.boolVal
);
2724 case OID_SHOW_MACBINARY
:
2725 FIXME("OID_SHOW_MACBINARY (value %d): ignoring\n", pValue
->u
.boolVal
);
2727 case OID_SAVEBODY_KEEPBOUNDARY
:
2728 FIXME("OID_SAVEBODY_KEEPBOUNDARY (value %d): ignoring\n", pValue
->u
.boolVal
);
2730 case OID_CLEANUP_TREE_ON_SAVE
:
2731 FIXME("OID_CLEANUP_TREE_ON_SAVE (value %d): ignoring\n", pValue
->u
.boolVal
);
2734 FIXME("Unhandled oid %08x\n", oid
);
2735 hr
= MIME_E_INVALID_OPTION_ID
;
2741 static HRESULT WINAPI
MimeMessage_GetOption(
2742 IMimeMessage
*iface
,
2744 LPPROPVARIANT pValue
)
2746 FIXME("(%p)->(%08x, %p)\n", iface
, oid
, pValue
);
2750 /*** IMimeMessage methods ***/
2751 static HRESULT WINAPI
MimeMessage_CreateWebPage(
2752 IMimeMessage
*iface
,
2754 LPWEBPAGEOPTIONS pOptions
,
2755 IMimeMessageCallback
*pCallback
,
2756 IMoniker
**ppMoniker
)
2758 FIXME("(%p)->(%p, %p, %p, %p)\n", iface
, pRootStm
, pOptions
, pCallback
, ppMoniker
);
2763 static HRESULT WINAPI
MimeMessage_GetProp(
2764 IMimeMessage
*iface
,
2767 LPPROPVARIANT pValue
)
2769 FIXME("(%p)->(%s, 0x%x, %p)\n", iface
, pszName
, dwFlags
, pValue
);
2773 static HRESULT WINAPI
MimeMessage_SetProp(
2774 IMimeMessage
*iface
,
2777 LPCPROPVARIANT pValue
)
2779 FIXME("(%p)->(%s, 0x%x, %p)\n", iface
, pszName
, dwFlags
, pValue
);
2783 static HRESULT WINAPI
MimeMessage_DeleteProp(
2784 IMimeMessage
*iface
,
2787 FIXME("(%p)->(%s)\n", iface
, pszName
);
2791 static HRESULT WINAPI
MimeMessage_QueryProp(
2792 IMimeMessage
*iface
,
2796 boolean fCaseSensitive
)
2798 FIXME("(%p)->(%s, %s, %s, %s)\n", iface
, pszName
, pszCriteria
, fSubString
? "TRUE" : "FALSE", fCaseSensitive
? "TRUE" : "FALSE");
2802 static HRESULT WINAPI
MimeMessage_GetTextBody(
2803 IMimeMessage
*iface
,
2805 ENCODINGTYPE ietEncoding
,
2811 FINDBODY find_struct
;
2812 IMimeBody
*mime_body
;
2813 static char text
[] = "text";
2814 static char plain
[] = "plain";
2815 static char html
[] = "html";
2817 TRACE("(%p)->(%d, %d, %p, %p)\n", iface
, dwTxtType
, ietEncoding
, pStream
, phBody
);
2819 find_struct
.pszPriType
= text
;
2824 find_struct
.pszSubType
= plain
;
2827 find_struct
.pszSubType
= html
;
2830 return MIME_E_INVALID_TEXT_TYPE
;
2833 hr
= IMimeMessage_FindFirst(iface
, &find_struct
, &hbody
);
2836 TRACE("not found hr %08x\n", hr
);
2841 IMimeMessage_BindToObject(iface
, hbody
, &IID_IMimeBody
, (void**)&mime_body
);
2843 IMimeBody_GetData(mime_body
, ietEncoding
, pStream
);
2845 IMimeBody_Release(mime_body
);
2849 static HRESULT WINAPI
MimeMessage_SetTextBody(
2850 IMimeMessage
*iface
,
2852 ENCODINGTYPE ietEncoding
,
2857 FIXME("(%p)->(%d, %d, %p, %p, %p)\n", iface
, dwTxtType
, ietEncoding
, hAlternative
, pStream
, phBody
);
2861 static HRESULT WINAPI
MimeMessage_AttachObject(
2862 IMimeMessage
*iface
,
2867 FIXME("(%p)->(%s, %p, %p)\n", iface
, debugstr_guid(riid
), pvObject
, phBody
);
2871 static HRESULT WINAPI
MimeMessage_AttachFile(
2872 IMimeMessage
*iface
,
2877 FIXME("(%p)->(%s, %p, %p)\n", iface
, pszFilePath
, pstmFile
, phBody
);
2881 static HRESULT WINAPI
MimeMessage_AttachURL(
2882 IMimeMessage
*iface
,
2890 FIXME("(%p)->(%s, %s, 0x%x, %p, %p, %p)\n", iface
, pszBase
, pszURL
, dwFlags
, pstmURL
, ppszCIDURL
, phBody
);
2894 static HRESULT WINAPI
MimeMessage_GetAttachments(
2895 IMimeMessage
*iface
,
2897 LPHBODY
*pprghAttach
)
2900 FINDBODY find_struct
;
2905 TRACE("(%p)->(%p, %p)\n", iface
, pcAttach
, pprghAttach
);
2908 array
= CoTaskMemAlloc(size
* sizeof(HBODY
));
2910 find_struct
.pszPriType
= find_struct
.pszSubType
= NULL
;
2911 hr
= IMimeMessage_FindFirst(iface
, &find_struct
, &hbody
);
2914 hr
= IMimeMessage_IsContentType(iface
, hbody
, "multipart", NULL
);
2915 TRACE("IsCT rets %08x %d\n", hr
, *pcAttach
);
2918 if(*pcAttach
+ 1 > size
)
2921 array
= CoTaskMemRealloc(array
, size
* sizeof(HBODY
));
2923 array
[*pcAttach
] = hbody
;
2926 hr
= IMimeMessage_FindNext(iface
, &find_struct
, &hbody
);
2929 *pprghAttach
= array
;
2933 static HRESULT WINAPI
MimeMessage_GetAddressTable(
2934 IMimeMessage
*iface
,
2935 IMimeAddressTable
**ppTable
)
2937 FIXME("(%p)->(%p)\n", iface
, ppTable
);
2941 static HRESULT WINAPI
MimeMessage_GetSender(
2942 IMimeMessage
*iface
,
2943 LPADDRESSPROPS pAddress
)
2945 FIXME("(%p)->(%p)\n", iface
, pAddress
);
2949 static HRESULT WINAPI
MimeMessage_GetAddressTypes(
2950 IMimeMessage
*iface
,
2953 LPADDRESSLIST pList
)
2955 FIXME("(%p)->(%d, %d, %p)\n", iface
, dwAdrTypes
, dwProps
, pList
);
2959 static HRESULT WINAPI
MimeMessage_GetAddressFormat(
2960 IMimeMessage
*iface
,
2962 ADDRESSFORMAT format
,
2965 FIXME("(%p)->(%d, %d, %p)\n", iface
, dwAdrTypes
, format
, ppszFormat
);
2969 static HRESULT WINAPI
MimeMessage_EnumAddressTypes(
2970 IMimeMessage
*iface
,
2973 IMimeEnumAddressTypes
**ppEnum
)
2975 FIXME("(%p)->(%d, %d, %p)\n", iface
, dwAdrTypes
, dwProps
, ppEnum
);
2979 static HRESULT WINAPI
MimeMessage_SplitMessage(
2980 IMimeMessage
*iface
,
2982 IMimeMessageParts
**ppParts
)
2984 FIXME("(%p)->(%d, %p)\n", iface
, cbMaxPart
, ppParts
);
2988 static HRESULT WINAPI
MimeMessage_GetRootMoniker(
2989 IMimeMessage
*iface
,
2990 IMoniker
**ppMoniker
)
2992 FIXME("(%p)->(%p)\n", iface
, ppMoniker
);
2996 static const IMimeMessageVtbl MimeMessageVtbl
=
2998 MimeMessage_QueryInterface
,
3000 MimeMessage_Release
,
3001 MimeMessage_GetClassID
,
3002 MimeMessage_IsDirty
,
3005 MimeMessage_GetSizeMax
,
3006 MimeMessage_InitNew
,
3007 MimeMessage_GetMessageSource
,
3008 MimeMessage_GetMessageSize
,
3009 MimeMessage_LoadOffsetTable
,
3010 MimeMessage_SaveOffsetTable
,
3011 MimeMessage_GetFlags
,
3013 MimeMessage_HandsOffStorage
,
3014 MimeMessage_BindToObject
,
3015 MimeMessage_SaveBody
,
3016 MimeMessage_InsertBody
,
3017 MimeMessage_GetBody
,
3018 MimeMessage_DeleteBody
,
3019 MimeMessage_MoveBody
,
3020 MimeMessage_CountBodies
,
3021 MimeMessage_FindFirst
,
3022 MimeMessage_FindNext
,
3023 MimeMessage_ResolveURL
,
3024 MimeMessage_ToMultipart
,
3025 MimeMessage_GetBodyOffsets
,
3026 MimeMessage_GetCharset
,
3027 MimeMessage_SetCharset
,
3028 MimeMessage_IsBodyType
,
3029 MimeMessage_IsContentType
,
3030 MimeMessage_QueryBodyProp
,
3031 MimeMessage_GetBodyProp
,
3032 MimeMessage_SetBodyProp
,
3033 MimeMessage_DeleteBodyProp
,
3034 MimeMessage_SetOption
,
3035 MimeMessage_GetOption
,
3036 MimeMessage_CreateWebPage
,
3037 MimeMessage_GetProp
,
3038 MimeMessage_SetProp
,
3039 MimeMessage_DeleteProp
,
3040 MimeMessage_QueryProp
,
3041 MimeMessage_GetTextBody
,
3042 MimeMessage_SetTextBody
,
3043 MimeMessage_AttachObject
,
3044 MimeMessage_AttachFile
,
3045 MimeMessage_AttachURL
,
3046 MimeMessage_GetAttachments
,
3047 MimeMessage_GetAddressTable
,
3048 MimeMessage_GetSender
,
3049 MimeMessage_GetAddressTypes
,
3050 MimeMessage_GetAddressFormat
,
3051 MimeMessage_EnumAddressTypes
,
3052 MimeMessage_SplitMessage
,
3053 MimeMessage_GetRootMoniker
,
3056 HRESULT
MimeMessage_create(IUnknown
*outer
, void **obj
)
3059 MimeBody
*mime_body
;
3062 TRACE("(%p, %p)\n", outer
, obj
);
3066 FIXME("outer unknown not supported yet\n");
3072 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
3073 if (!This
) return E_OUTOFMEMORY
;
3075 This
->IMimeMessage_iface
.lpVtbl
= &MimeMessageVtbl
;
3077 This
->stream
= NULL
;
3078 list_init(&This
->body_tree
);
3079 This
->next_index
= 1;
3081 mime_body
= mimebody_create();
3082 root_body
= new_body_entry(mime_body
, This
->next_index
++, NULL
);
3083 list_add_head(&This
->body_tree
, &root_body
->entry
);
3085 *obj
= &This
->IMimeMessage_iface
;
3089 /***********************************************************************
3090 * MimeOleCreateMessage (INETCOMM.@)
3092 HRESULT WINAPI
MimeOleCreateMessage(IUnknown
*pUnkOuter
, IMimeMessage
**ppMessage
)
3094 TRACE("(%p, %p)\n", pUnkOuter
, ppMessage
);
3095 return MimeMessage_create(NULL
, (void **)ppMessage
);
3098 /***********************************************************************
3099 * MimeOleSetCompatMode (INETCOMM.@)
3101 HRESULT WINAPI
MimeOleSetCompatMode(DWORD dwMode
)
3103 FIXME("(0x%x)\n", dwMode
);
3107 /***********************************************************************
3108 * MimeOleCreateVirtualStream (INETCOMM.@)
3110 HRESULT WINAPI
MimeOleCreateVirtualStream(IStream
**ppStream
)
3113 FIXME("(%p)\n", ppStream
);
3115 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, ppStream
);
3119 typedef struct MimeSecurity
3121 IMimeSecurity IMimeSecurity_iface
;
3125 static inline MimeSecurity
*impl_from_IMimeSecurity(IMimeSecurity
*iface
)
3127 return CONTAINING_RECORD(iface
, MimeSecurity
, IMimeSecurity_iface
);
3130 static HRESULT WINAPI
MimeSecurity_QueryInterface(IMimeSecurity
*iface
, REFIID riid
, void **ppv
)
3132 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ppv
);
3134 if (IsEqualIID(riid
, &IID_IUnknown
) ||
3135 IsEqualIID(riid
, &IID_IMimeSecurity
))
3138 IMimeSecurity_AddRef(iface
);
3142 FIXME("no interface for %s\n", debugstr_guid(riid
));
3144 return E_NOINTERFACE
;
3147 static ULONG WINAPI
MimeSecurity_AddRef(IMimeSecurity
*iface
)
3149 MimeSecurity
*This
= impl_from_IMimeSecurity(iface
);
3150 LONG ref
= InterlockedIncrement(&This
->ref
);
3152 TRACE("(%p) ref=%d\n", This
, ref
);
3157 static ULONG WINAPI
MimeSecurity_Release(IMimeSecurity
*iface
)
3159 MimeSecurity
*This
= impl_from_IMimeSecurity(iface
);
3160 LONG ref
= InterlockedDecrement(&This
->ref
);
3162 TRACE("(%p) ref=%d\n", This
, ref
);
3165 HeapFree(GetProcessHeap(), 0, This
);
3170 static HRESULT WINAPI
MimeSecurity_InitNew(
3171 IMimeSecurity
* iface
)
3173 FIXME("(%p)->(): stub\n", iface
);
3177 static HRESULT WINAPI
MimeSecurity_CheckInit(
3178 IMimeSecurity
* iface
)
3180 FIXME("(%p)->(): stub\n", iface
);
3184 static HRESULT WINAPI
MimeSecurity_EncodeMessage(
3185 IMimeSecurity
* iface
,
3186 IMimeMessageTree
* pTree
,
3189 FIXME("(%p)->(%p, %08x): stub\n", iface
, pTree
, dwFlags
);
3193 static HRESULT WINAPI
MimeSecurity_EncodeBody(
3194 IMimeSecurity
* iface
,
3195 IMimeMessageTree
* pTree
,
3199 FIXME("(%p)->(%p, %p, %08x): stub\n", iface
, pTree
, hEncodeRoot
, dwFlags
);
3203 static HRESULT WINAPI
MimeSecurity_DecodeMessage(
3204 IMimeSecurity
* iface
,
3205 IMimeMessageTree
* pTree
,
3208 FIXME("(%p)->(%p, %08x): stub\n", iface
, pTree
, dwFlags
);
3212 static HRESULT WINAPI
MimeSecurity_DecodeBody(
3213 IMimeSecurity
* iface
,
3214 IMimeMessageTree
* pTree
,
3218 FIXME("(%p)->(%p, %p, %08x): stub\n", iface
, pTree
, hDecodeRoot
, dwFlags
);
3222 static HRESULT WINAPI
MimeSecurity_EnumCertificates(
3223 IMimeSecurity
* iface
,
3229 FIXME("(%p)->(%p, %08x, %p, %p): stub\n", iface
, hc
, dwUsage
, pPrev
, ppCert
);
3233 static HRESULT WINAPI
MimeSecurity_GetCertificateName(
3234 IMimeSecurity
* iface
,
3235 const PCX509CERT pX509Cert
,
3236 const CERTNAMETYPE cn
,
3239 FIXME("(%p)->(%p, %08x, %p): stub\n", iface
, pX509Cert
, cn
, ppszName
);
3243 static HRESULT WINAPI
MimeSecurity_GetMessageType(
3244 IMimeSecurity
* iface
,
3245 const HWND hwndParent
,
3249 FIXME("(%p)->(%p, %p, %p): stub\n", iface
, hwndParent
, pBody
, pdwSecType
);
3253 static HRESULT WINAPI
MimeSecurity_GetCertData(
3254 IMimeSecurity
* iface
,
3255 const PCX509CERT pX509Cert
,
3256 const CERTDATAID dataid
,
3257 LPPROPVARIANT pValue
)
3259 FIXME("(%p)->(%p, %x, %p): stub\n", iface
, pX509Cert
, dataid
, pValue
);
3264 static const IMimeSecurityVtbl MimeSecurityVtbl
=
3266 MimeSecurity_QueryInterface
,
3267 MimeSecurity_AddRef
,
3268 MimeSecurity_Release
,
3269 MimeSecurity_InitNew
,
3270 MimeSecurity_CheckInit
,
3271 MimeSecurity_EncodeMessage
,
3272 MimeSecurity_EncodeBody
,
3273 MimeSecurity_DecodeMessage
,
3274 MimeSecurity_DecodeBody
,
3275 MimeSecurity_EnumCertificates
,
3276 MimeSecurity_GetCertificateName
,
3277 MimeSecurity_GetMessageType
,
3278 MimeSecurity_GetCertData
3281 HRESULT
MimeSecurity_create(IUnknown
*outer
, void **obj
)
3287 if (outer
) return CLASS_E_NOAGGREGATION
;
3289 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
3290 if (!This
) return E_OUTOFMEMORY
;
3292 This
->IMimeSecurity_iface
.lpVtbl
= &MimeSecurityVtbl
;
3295 *obj
= &This
->IMimeSecurity_iface
;
3299 /***********************************************************************
3300 * MimeOleCreateSecurity (INETCOMM.@)
3302 HRESULT WINAPI
MimeOleCreateSecurity(IMimeSecurity
**ppSecurity
)
3304 return MimeSecurity_create(NULL
, (void **)ppSecurity
);
3307 static HRESULT WINAPI
MimeAlloc_QueryInterface(
3308 IMimeAllocator
* iface
,
3312 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), obj
);
3314 if (IsEqualIID(riid
, &IID_IUnknown
) ||
3315 IsEqualIID(riid
, &IID_IMalloc
) ||
3316 IsEqualIID(riid
, &IID_IMimeAllocator
))
3319 IMimeAllocator_AddRef(iface
);
3323 FIXME("no interface for %s\n", debugstr_guid(riid
));
3325 return E_NOINTERFACE
;
3328 static ULONG WINAPI
MimeAlloc_AddRef(
3329 IMimeAllocator
* iface
)
3334 static ULONG WINAPI
MimeAlloc_Release(
3335 IMimeAllocator
* iface
)
3340 static LPVOID WINAPI
MimeAlloc_Alloc(
3341 IMimeAllocator
* iface
,
3344 return CoTaskMemAlloc(cb
);
3347 static LPVOID WINAPI
MimeAlloc_Realloc(
3348 IMimeAllocator
* iface
,
3352 return CoTaskMemRealloc(pv
, cb
);
3355 static void WINAPI
MimeAlloc_Free(
3356 IMimeAllocator
* iface
,
3362 static SIZE_T WINAPI
MimeAlloc_GetSize(
3363 IMimeAllocator
* iface
,
3370 static int WINAPI
MimeAlloc_DidAlloc(
3371 IMimeAllocator
* iface
,
3378 static void WINAPI
MimeAlloc_HeapMinimize(
3379 IMimeAllocator
* iface
)
3385 static HRESULT WINAPI
MimeAlloc_FreeParamInfoArray(
3386 IMimeAllocator
* iface
,
3388 LPMIMEPARAMINFO prgParam
,
3392 TRACE("(%p)->(%d, %p, %d)\n", iface
, cParams
, prgParam
, fFreeArray
);
3394 for(i
= 0; i
< cParams
; i
++)
3396 IMimeAllocator_Free(iface
, prgParam
[i
].pszName
);
3397 IMimeAllocator_Free(iface
, prgParam
[i
].pszData
);
3399 if(fFreeArray
) IMimeAllocator_Free(iface
, prgParam
);
3403 static HRESULT WINAPI
MimeAlloc_FreeAddressList(
3404 IMimeAllocator
* iface
,
3405 LPADDRESSLIST pList
)
3411 static HRESULT WINAPI
MimeAlloc_FreeAddressProps(
3412 IMimeAllocator
* iface
,
3413 LPADDRESSPROPS pAddress
)
3419 static HRESULT WINAPI
MimeAlloc_ReleaseObjects(
3420 IMimeAllocator
* iface
,
3422 IUnknown
**prgpUnknown
,
3430 static HRESULT WINAPI
MimeAlloc_FreeEnumHeaderRowArray(
3431 IMimeAllocator
* iface
,
3433 LPENUMHEADERROW prgRow
,
3440 static HRESULT WINAPI
MimeAlloc_FreeEnumPropertyArray(
3441 IMimeAllocator
* iface
,
3443 LPENUMPROPERTY prgProp
,
3450 static HRESULT WINAPI
MimeAlloc_FreeThumbprint(
3451 IMimeAllocator
* iface
,
3452 THUMBBLOB
*pthumbprint
)
3459 static HRESULT WINAPI
MimeAlloc_PropVariantClear(
3460 IMimeAllocator
* iface
,
3461 LPPROPVARIANT pProp
)
3467 static IMimeAllocatorVtbl mime_alloc_vtbl
=
3469 MimeAlloc_QueryInterface
,
3477 MimeAlloc_HeapMinimize
,
3478 MimeAlloc_FreeParamInfoArray
,
3479 MimeAlloc_FreeAddressList
,
3480 MimeAlloc_FreeAddressProps
,
3481 MimeAlloc_ReleaseObjects
,
3482 MimeAlloc_FreeEnumHeaderRowArray
,
3483 MimeAlloc_FreeEnumPropertyArray
,
3484 MimeAlloc_FreeThumbprint
,
3485 MimeAlloc_PropVariantClear
3488 static IMimeAllocator mime_allocator
=
3493 HRESULT
MimeAllocator_create(IUnknown
*outer
, void **obj
)
3495 if(outer
) return CLASS_E_NOAGGREGATION
;
3497 *obj
= &mime_allocator
;
3501 HRESULT WINAPI
MimeOleGetAllocator(IMimeAllocator
**alloc
)
3503 return MimeAllocator_create(NULL
, (void**)alloc
);
3506 HRESULT
VirtualStream_create(IUnknown
*outer
, void **obj
)
3508 FIXME("(%p, %p)\n", outer
, obj
);
3511 if (outer
) return CLASS_E_NOAGGREGATION
;
3513 return MimeOleCreateVirtualStream((IStream
**)obj
);
3516 /* IMimePropertySchema Interface */
3517 static HRESULT WINAPI
propschema_QueryInterface(IMimePropertySchema
*iface
, REFIID riid
, void **out
)
3519 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3520 TRACE("(%p)->(%s, %p)\n", This
, debugstr_guid(riid
), out
);
3524 if (IsEqualIID(riid
, &IID_IUnknown
) ||
3525 IsEqualIID(riid
, &IID_IMimePropertySchema
))
3531 FIXME("no interface for %s\n", debugstr_guid(riid
));
3532 return E_NOINTERFACE
;
3535 IMimePropertySchema_AddRef(iface
);
3539 static ULONG WINAPI
propschema_AddRef(IMimePropertySchema
*iface
)
3541 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3542 LONG ref
= InterlockedIncrement(&This
->ref
);
3544 TRACE("(%p) ref=%d\n", This
, ref
);
3549 static ULONG WINAPI
propschema_Release(IMimePropertySchema
*iface
)
3551 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3552 LONG ref
= InterlockedDecrement(&This
->ref
);
3554 TRACE("(%p) ref=%d\n", This
, ref
);
3558 HeapFree(GetProcessHeap(), 0, This
);
3564 static HRESULT WINAPI
propschema_RegisterProperty(IMimePropertySchema
*iface
, const char *name
, DWORD flags
,
3565 DWORD rownumber
, VARTYPE vtdefault
, DWORD
*propid
)
3567 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3568 FIXME("(%p)->(%s, %x, %d, %d, %p) stub\n", This
, debugstr_a(name
), flags
, rownumber
, vtdefault
, propid
);
3572 static HRESULT WINAPI
propschema_ModifyProperty(IMimePropertySchema
*iface
, const char *name
, DWORD flags
,
3573 DWORD rownumber
, VARTYPE vtdefault
)
3575 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3576 FIXME("(%p)->(%s, %x, %d, %d) stub\n", This
, debugstr_a(name
), flags
, rownumber
, vtdefault
);
3580 static HRESULT WINAPI
propschema_GetPropertyId(IMimePropertySchema
*iface
, const char *name
, DWORD
*propid
)
3582 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3583 FIXME("(%p)->(%s, %p) stub\n", This
, debugstr_a(name
), propid
);
3587 static HRESULT WINAPI
propschema_GetPropertyName(IMimePropertySchema
*iface
, DWORD propid
, char **name
)
3589 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3590 FIXME("(%p)->(%d, %p) stub\n", This
, propid
, name
);
3594 static HRESULT WINAPI
propschema_RegisterAddressType(IMimePropertySchema
*iface
, const char *name
, DWORD
*adrtype
)
3596 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3597 FIXME("(%p)->(%s, %p) stub\n", This
, debugstr_a(name
), adrtype
);
3601 static IMimePropertySchemaVtbl prop_schema_vtbl
=
3603 propschema_QueryInterface
,
3606 propschema_RegisterProperty
,
3607 propschema_ModifyProperty
,
3608 propschema_GetPropertyId
,
3609 propschema_GetPropertyName
,
3610 propschema_RegisterAddressType
3614 HRESULT WINAPI
MimeOleGetPropertySchema(IMimePropertySchema
**schema
)
3618 TRACE("(%p) stub\n", schema
);
3620 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
3622 return E_OUTOFMEMORY
;
3624 This
->IMimePropertySchema_iface
.lpVtbl
= &prop_schema_vtbl
;
3627 *schema
= &This
->IMimePropertySchema_iface
;
3632 HRESULT WINAPI
MimeGetAddressFormatW(REFIID riid
, void *object
, DWORD addr_type
,
3633 ADDRESSFORMAT addr_format
, WCHAR
**address
)
3635 FIXME("(%s, %p, %d, %d, %p) stub\n", debugstr_guid(riid
), object
, addr_type
, addr_format
, address
);
3640 static HRESULT WINAPI
mime_obj_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppv
)
3642 FIXME("(%s %p)\n", debugstr_guid(riid
), ppv
);
3644 return E_NOINTERFACE
;
3647 static ULONG WINAPI
mime_obj_AddRef(IUnknown
*iface
)
3653 static ULONG WINAPI
mime_obj_Release(IUnknown
*iface
)
3659 static const IUnknownVtbl mime_obj_vtbl
= {
3660 mime_obj_QueryInterface
,
3665 static IUnknown mime_obj
= { &mime_obj_vtbl
};
3667 HRESULT WINAPI
MimeOleObjectFromMoniker(BINDF bindf
, IMoniker
*moniker
, IBindCtx
*binding
,
3668 REFIID riid
, void **out
, IMoniker
**moniker_new
)
3670 WCHAR
*display_name
, *mhtml_url
;
3674 static const WCHAR mhtml_prefixW
[] = {'m','h','t','m','l',':'};
3676 WARN("(0x%08x, %p, %p, %s, %p, %p) semi-stub\n", bindf
, moniker
, binding
, debugstr_guid(riid
), out
, moniker_new
);
3678 if(!IsEqualGUID(&IID_IUnknown
, riid
)) {
3679 FIXME("Unsupported riid %s\n", debugstr_guid(riid
));
3680 return E_NOINTERFACE
;
3683 hres
= IMoniker_GetDisplayName(moniker
, NULL
, NULL
, &display_name
);
3687 TRACE("display name %s\n", debugstr_w(display_name
));
3689 len
= strlenW(display_name
);
3690 mhtml_url
= heap_alloc((len
+1)*sizeof(WCHAR
) + sizeof(mhtml_prefixW
));
3692 return E_OUTOFMEMORY
;
3694 memcpy(mhtml_url
, mhtml_prefixW
, sizeof(mhtml_prefixW
));
3695 strcpyW(mhtml_url
+ sizeof(mhtml_prefixW
)/sizeof(WCHAR
), display_name
);
3696 HeapFree(GetProcessHeap(), 0, display_name
);
3698 hres
= CreateURLMoniker(NULL
, mhtml_url
, moniker_new
);
3699 heap_free(mhtml_url
);
3703 /* FIXME: We most likely should start binding here and return something more meaningful as mime object. */