4 * Copyright 2006 Robert Shearman for CodeWeavers
5 * Copyright 2007 Huw Davies for CodeWeavers
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #define NONAMELESSUNION
37 #include "propvarutil.h"
39 #include "wine/heap.h"
40 #include "wine/list.h"
41 #include "wine/debug.h"
42 #include "wine/unicode.h"
44 #include "inetcomm_private.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(inetcomm
);
52 DWORD flags
; /* MIMEPROPFLAGS */
60 } property_list_entry_t
;
62 static const property_t default_props
[] =
64 {"X-Newsgroup", PID_HDR_NEWSGROUP
, 0, VT_LPSTR
},
65 {"Newsgroups", PID_HDR_NEWSGROUPS
, 0, VT_LPSTR
},
66 {"References", PID_HDR_REFS
, 0, VT_LPSTR
},
67 {"Subject", PID_HDR_SUBJECT
, 0, VT_LPSTR
},
68 {"From", PID_HDR_FROM
, MPF_ADDRESS
, VT_LPSTR
},
69 {"Message-ID", PID_HDR_MESSAGEID
, 0, VT_LPSTR
},
70 {"Return-Path", PID_HDR_RETURNPATH
, MPF_ADDRESS
, VT_LPSTR
},
71 {"Rr", PID_HDR_RR
, 0, VT_LPSTR
},
72 {"Return-Receipt-To", PID_HDR_RETRCPTO
, MPF_ADDRESS
, VT_LPSTR
},
73 {"Apparently-To", PID_HDR_APPARTO
, MPF_ADDRESS
, VT_LPSTR
},
74 {"Date", PID_HDR_DATE
, 0, VT_LPSTR
},
75 {"Received", PID_HDR_RECEIVED
, 0, VT_LPSTR
},
76 {"Reply-To", PID_HDR_REPLYTO
, MPF_ADDRESS
, VT_LPSTR
},
77 {"X-Mailer", PID_HDR_XMAILER
, 0, VT_LPSTR
},
78 {"Bcc", PID_HDR_BCC
, MPF_ADDRESS
, VT_LPSTR
},
79 {"MIME-Version", PID_HDR_MIMEVER
, MPF_MIME
, VT_LPSTR
},
80 {"Content-Type", PID_HDR_CNTTYPE
, MPF_MIME
| MPF_HASPARAMS
, VT_LPSTR
},
81 {"Content-Transfer-Encoding", PID_HDR_CNTXFER
, MPF_MIME
, VT_LPSTR
},
82 {"Content-ID", PID_HDR_CNTID
, MPF_MIME
, VT_LPSTR
},
83 {"Content-Description", PID_HDR_CNTDESC
, MPF_MIME
, VT_LPSTR
},
84 {"Content-Disposition", PID_HDR_CNTDISP
, MPF_MIME
| MPF_HASPARAMS
, VT_LPSTR
},
85 {"Content-Base", PID_HDR_CNTBASE
, MPF_MIME
, VT_LPSTR
},
86 {"Content-Location", PID_HDR_CNTLOC
, MPF_MIME
, VT_LPSTR
},
87 {"To", PID_HDR_TO
, MPF_ADDRESS
, VT_LPSTR
},
88 {"Path", PID_HDR_PATH
, 0, VT_LPSTR
},
89 {"Followup-To", PID_HDR_FOLLOWUPTO
, 0, VT_LPSTR
},
90 {"Expires", PID_HDR_EXPIRES
, 0, VT_LPSTR
},
91 {"Cc", PID_HDR_CC
, MPF_ADDRESS
, VT_LPSTR
},
92 {"Control", PID_HDR_CONTROL
, 0, VT_LPSTR
},
93 {"Distribution", PID_HDR_DISTRIB
, 0, VT_LPSTR
},
94 {"Keywords", PID_HDR_KEYWORDS
, 0, VT_LPSTR
},
95 {"Summary", PID_HDR_SUMMARY
, 0, VT_LPSTR
},
96 {"Approved", PID_HDR_APPROVED
, 0, VT_LPSTR
},
97 {"Lines", PID_HDR_LINES
, 0, VT_LPSTR
},
98 {"Xref", PID_HDR_XREF
, 0, VT_LPSTR
},
99 {"Organization", PID_HDR_ORG
, 0, VT_LPSTR
},
100 {"X-Newsreader", PID_HDR_XNEWSRDR
, 0, VT_LPSTR
},
101 {"X-Priority", PID_HDR_XPRI
, 0, VT_LPSTR
},
102 {"X-MSMail-Priority", PID_HDR_XMSPRI
, 0, VT_LPSTR
},
103 {"par:content-disposition:filename", PID_PAR_FILENAME
, 0, VT_LPSTR
},
104 {"par:content-type:boundary", PID_PAR_BOUNDARY
, 0, VT_LPSTR
},
105 {"par:content-type:charset", PID_PAR_CHARSET
, 0, VT_LPSTR
},
106 {"par:content-type:name", PID_PAR_NAME
, 0, VT_LPSTR
},
107 {"att:filename", PID_ATT_FILENAME
, 0, VT_LPSTR
},
108 {"att:pri-content-type", PID_ATT_PRITYPE
, 0, VT_LPSTR
},
109 {"att:sub-content-type", PID_ATT_SUBTYPE
, 0, VT_LPSTR
},
110 {"att:illegal-lines", PID_ATT_ILLEGAL
, 0, VT_LPSTR
},
111 {"att:rendered", PID_ATT_RENDERED
, 0, VT_LPSTR
},
112 {"att:sent-time", PID_ATT_SENTTIME
, 0, VT_LPSTR
},
113 {"att:priority", PID_ATT_PRIORITY
, 0, VT_LPSTR
},
114 {"Comment", PID_HDR_COMMENT
, 0, VT_LPSTR
},
115 {"Encoding", PID_HDR_ENCODING
, 0, VT_LPSTR
},
116 {"Encrypted", PID_HDR_ENCRYPTED
, 0, VT_LPSTR
},
117 {"X-Offsets", PID_HDR_OFFSETS
, 0, VT_LPSTR
},
118 {"X-Unsent", PID_HDR_XUNSENT
, 0, VT_LPSTR
},
119 {"X-ArticleId", PID_HDR_ARTICLEID
, 0, VT_LPSTR
},
120 {"Sender", PID_HDR_SENDER
, MPF_ADDRESS
, VT_LPSTR
},
121 {"att:athena-server", PID_ATT_SERVER
, 0, VT_LPSTR
},
122 {"att:athena-account-id", PID_ATT_ACCOUNT
, 0, VT_LPSTR
},
123 {"att:athena-pop3-uidl", PID_ATT_UIDL
, 0, VT_LPSTR
},
124 {"att:athena-store-msgid", PID_ATT_STOREMSGID
, 0, VT_LPSTR
},
125 {"att:athena-user-name", PID_ATT_USERNAME
, 0, VT_LPSTR
},
126 {"att:athena-forward-to", PID_ATT_FORWARDTO
, 0, VT_LPSTR
},
127 {"att:athena-store-fdrid", PID_ATT_STOREFOLDERID
,0, VT_LPSTR
},
128 {"att:athena-ghosted", PID_ATT_GHOSTED
, 0, VT_LPSTR
},
129 {"att:athena-uncachedsize", PID_ATT_UNCACHEDSIZE
, 0, VT_LPSTR
},
130 {"att:athena-combined", PID_ATT_COMBINED
, 0, VT_LPSTR
},
131 {"att:auto-inlined", PID_ATT_AUTOINLINED
, 0, VT_LPSTR
},
132 {"Disposition-Notification-To", PID_HDR_DISP_NOTIFICATION_TO
, 0, VT_LPSTR
},
133 {"par:Content-Type:reply-type", PID_PAR_REPLYTYPE
, 0, VT_LPSTR
},
134 {"par:Content-Type:format", PID_PAR_FORMAT
, 0, VT_LPSTR
},
135 {"att:format", PID_ATT_FORMAT
, 0, VT_LPSTR
},
136 {"In-Reply-To", PID_HDR_INREPLYTO
, 0, VT_LPSTR
},
137 {"att:athena-account-name", PID_ATT_ACCOUNTNAME
, 0, VT_LPSTR
},
151 const property_t
*prop
;
156 typedef struct MimeBody
158 IMimeBody IMimeBody_iface
;
164 struct list new_props
; /* FIXME: This should be in a PropertySchema */
166 char *content_pri_type
;
167 char *content_sub_type
;
168 ENCODINGTYPE encoding
;
171 BODYOFFSETS body_offsets
;
176 IStream IStream_iface
;
179 ULARGE_INTEGER pos
, start
, length
;
182 static inline sub_stream_t
*impl_from_IStream(IStream
*iface
)
184 return CONTAINING_RECORD(iface
, sub_stream_t
, IStream_iface
);
187 static HRESULT WINAPI
sub_stream_QueryInterface(IStream
*iface
, REFIID riid
, void **ppv
)
189 sub_stream_t
*This
= impl_from_IStream(iface
);
191 TRACE("(%p)->(%s, %p)\n", This
, debugstr_guid(riid
), ppv
);
194 if(IsEqualIID(riid
, &IID_IUnknown
) ||
195 IsEqualIID(riid
, &IID_ISequentialStream
) ||
196 IsEqualIID(riid
, &IID_IStream
))
198 IStream_AddRef(iface
);
202 return E_NOINTERFACE
;
205 static ULONG WINAPI
sub_stream_AddRef(IStream
*iface
)
207 sub_stream_t
*This
= impl_from_IStream(iface
);
208 LONG ref
= InterlockedIncrement(&This
->ref
);
210 TRACE("(%p) ref=%d\n", This
, ref
);
215 static ULONG WINAPI
sub_stream_Release(IStream
*iface
)
217 sub_stream_t
*This
= impl_from_IStream(iface
);
218 LONG ref
= InterlockedDecrement(&This
->ref
);
220 TRACE("(%p) ref=%d\n", This
, ref
);
224 IStream_Release(This
->base
);
225 HeapFree(GetProcessHeap(), 0, This
);
230 static HRESULT WINAPI
sub_stream_Read(
236 sub_stream_t
*This
= impl_from_IStream(iface
);
238 LARGE_INTEGER tmp_pos
;
240 TRACE("(%p, %d, %p)\n", pv
, cb
, pcbRead
);
242 tmp_pos
.QuadPart
= This
->pos
.QuadPart
+ This
->start
.QuadPart
;
243 IStream_Seek(This
->base
, tmp_pos
, STREAM_SEEK_SET
, NULL
);
245 if(This
->pos
.QuadPart
+ cb
> This
->length
.QuadPart
)
246 cb
= This
->length
.QuadPart
- This
->pos
.QuadPart
;
248 hr
= IStream_Read(This
->base
, pv
, cb
, pcbRead
);
250 This
->pos
.QuadPart
+= *pcbRead
;
255 static HRESULT WINAPI
sub_stream_Write(
265 static HRESULT WINAPI
sub_stream_Seek(
267 LARGE_INTEGER dlibMove
,
269 ULARGE_INTEGER
*plibNewPosition
)
271 sub_stream_t
*This
= impl_from_IStream(iface
);
272 LARGE_INTEGER new_pos
;
274 TRACE("(%08x.%08x, %x, %p)\n", dlibMove
.u
.HighPart
, dlibMove
.u
.LowPart
, dwOrigin
, plibNewPosition
);
278 case STREAM_SEEK_SET
:
281 case STREAM_SEEK_CUR
:
282 new_pos
.QuadPart
= This
->pos
.QuadPart
+ dlibMove
.QuadPart
;
284 case STREAM_SEEK_END
:
285 new_pos
.QuadPart
= This
->length
.QuadPart
+ dlibMove
.QuadPart
;
288 return STG_E_INVALIDFUNCTION
;
291 if(new_pos
.QuadPart
< 0) new_pos
.QuadPart
= 0;
292 else if(new_pos
.QuadPart
> This
->length
.QuadPart
) new_pos
.QuadPart
= This
->length
.QuadPart
;
294 This
->pos
.QuadPart
= new_pos
.QuadPart
;
296 if(plibNewPosition
) *plibNewPosition
= This
->pos
;
300 static HRESULT WINAPI
sub_stream_SetSize(
302 ULARGE_INTEGER libNewSize
)
308 static HRESULT WINAPI
sub_stream_CopyTo(
312 ULARGE_INTEGER
*pcbRead
,
313 ULARGE_INTEGER
*pcbWritten
)
317 ULONG bytesRead
, bytesWritten
, copySize
;
318 ULARGE_INTEGER totalBytesRead
;
319 ULARGE_INTEGER totalBytesWritten
;
321 TRACE("(%p)->(%p, %d, %p, %p)\n", iface
, pstm
, cb
.u
.LowPart
, pcbRead
, pcbWritten
);
323 totalBytesRead
.QuadPart
= 0;
324 totalBytesWritten
.QuadPart
= 0;
326 while ( cb
.QuadPart
> 0 )
328 if ( cb
.QuadPart
>= sizeof(tmpBuffer
) )
329 copySize
= sizeof(tmpBuffer
);
331 copySize
= cb
.u
.LowPart
;
333 hr
= IStream_Read(iface
, tmpBuffer
, copySize
, &bytesRead
);
334 if (FAILED(hr
)) break;
336 totalBytesRead
.QuadPart
+= bytesRead
;
340 hr
= IStream_Write(pstm
, tmpBuffer
, bytesRead
, &bytesWritten
);
341 if (FAILED(hr
)) break;
342 totalBytesWritten
.QuadPart
+= bytesWritten
;
345 if (bytesRead
!= copySize
)
348 cb
.QuadPart
-= bytesRead
;
351 if (pcbRead
) pcbRead
->QuadPart
= totalBytesRead
.QuadPart
;
352 if (pcbWritten
) pcbWritten
->QuadPart
= totalBytesWritten
.QuadPart
;
357 static HRESULT WINAPI
sub_stream_Commit(
359 DWORD grfCommitFlags
)
365 static HRESULT WINAPI
sub_stream_Revert(
372 static HRESULT WINAPI
sub_stream_LockRegion(
374 ULARGE_INTEGER libOffset
,
382 static HRESULT WINAPI
sub_stream_UnlockRegion(
384 ULARGE_INTEGER libOffset
,
392 static HRESULT WINAPI
sub_stream_Stat(
397 sub_stream_t
*This
= impl_from_IStream(iface
);
398 FIXME("(%p)->(%p, %08x)\n", This
, pstatstg
, grfStatFlag
);
399 memset(pstatstg
, 0, sizeof(*pstatstg
));
400 pstatstg
->cbSize
= This
->length
;
404 static HRESULT WINAPI
sub_stream_Clone(
412 static struct IStreamVtbl sub_stream_vtbl
=
414 sub_stream_QueryInterface
,
424 sub_stream_LockRegion
,
425 sub_stream_UnlockRegion
,
430 static HRESULT
create_sub_stream(IStream
*stream
, ULARGE_INTEGER start
, ULARGE_INTEGER length
, IStream
**out
)
435 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
436 if(!This
) return E_OUTOFMEMORY
;
438 This
->IStream_iface
.lpVtbl
= &sub_stream_vtbl
;
441 This
->length
= length
;
442 This
->pos
.QuadPart
= 0;
443 IStream_AddRef(stream
);
446 *out
= &This
->IStream_iface
;
450 static HRESULT
get_stream_size(IStream
*stream
, ULARGE_INTEGER
*size
)
452 STATSTG statstg
= {NULL
};
456 hres
= IStream_Stat(stream
, &statstg
, STATFLAG_NONAME
);
457 if(SUCCEEDED(hres
)) {
458 *size
= statstg
.cbSize
;
463 return IStream_Seek(stream
, zero
, STREAM_SEEK_END
, size
);
466 static inline MimeBody
*impl_from_IMimeBody(IMimeBody
*iface
)
468 return CONTAINING_RECORD(iface
, MimeBody
, IMimeBody_iface
);
471 typedef struct propschema
473 IMimePropertySchema IMimePropertySchema_iface
;
477 static inline propschema
*impl_from_IMimePropertySchema(IMimePropertySchema
*iface
)
479 return CONTAINING_RECORD(iface
, propschema
, IMimePropertySchema_iface
);
482 static LPSTR
strdupA(LPCSTR str
)
485 int len
= strlen(str
);
486 ret
= HeapAlloc(GetProcessHeap(), 0, len
+ 1);
487 memcpy(ret
, str
, len
+ 1);
491 #define PARSER_BUF_SIZE 1024
493 /*****************************************************
494 * copy_headers_to_buf [internal]
496 * Copies the headers into a '\0' terminated memory block and leave
497 * the stream's current position set to after the blank line.
499 static HRESULT
copy_headers_to_buf(IStream
*stm
, char **ptr
)
502 DWORD size
= PARSER_BUF_SIZE
, offset
= 0, last_end
= 0;
514 buf
= HeapAlloc(GetProcessHeap(), 0, size
+ 1);
518 buf
= HeapReAlloc(GetProcessHeap(), 0, buf
, size
+ 1);
526 hr
= IStream_Read(stm
, buf
+ offset
, size
- offset
, &read
);
527 if(FAILED(hr
)) goto fail
;
532 if(read
== 0) done
= TRUE
;
534 while(!done
&& (end
= strstr(buf
+ last_end
, "\r\n")))
536 DWORD new_end
= end
- buf
+ 2;
537 if(new_end
- last_end
== 2)
540 off
.QuadPart
= (LONGLONG
)new_end
- offset
;
541 IStream_Seek(stm
, off
, STREAM_SEEK_CUR
, NULL
);
554 HeapFree(GetProcessHeap(), 0, buf
);
558 static header_t
*read_prop(MimeBody
*body
, char **ptr
)
560 char *colon
= strchr(*ptr
, ':');
561 const property_t
*prop
;
564 if(!colon
) return NULL
;
568 for(prop
= default_props
; prop
->name
; prop
++)
570 if(!lstrcmpiA(*ptr
, prop
->name
))
572 TRACE("%s: found match with default property id %d\n", *ptr
, prop
->id
);
579 property_list_entry_t
*prop_entry
;
580 LIST_FOR_EACH_ENTRY(prop_entry
, &body
->new_props
, property_list_entry_t
, entry
)
582 if(!lstrcmpiA(*ptr
, prop_entry
->prop
.name
))
584 TRACE("%s: found match with already added new property id %d\n", *ptr
, prop_entry
->prop
.id
);
585 prop
= &prop_entry
->prop
;
591 prop_entry
= HeapAlloc(GetProcessHeap(), 0, sizeof(*prop_entry
));
592 prop_entry
->prop
.name
= strdupA(*ptr
);
593 prop_entry
->prop
.id
= body
->next_prop_id
++;
594 prop_entry
->prop
.flags
= 0;
595 prop_entry
->prop
.default_vt
= VT_LPSTR
;
596 list_add_tail(&body
->new_props
, &prop_entry
->entry
);
597 prop
= &prop_entry
->prop
;
598 TRACE("%s: allocating new prop id %d\n", *ptr
, prop_entry
->prop
.id
);
602 ret
= HeapAlloc(GetProcessHeap(), 0, sizeof(*ret
));
604 PropVariantInit(&ret
->value
);
605 list_init(&ret
->params
);
611 static void unfold_header(char *header
, int len
)
613 char *start
= header
, *cp
= header
;
616 while(*cp
== ' ' || *cp
== '\t')
622 memmove(start
, cp
, len
+ 1);
624 cp
= strstr(start
, "\r\n");
631 } while(*cp
== ' ' || *cp
== '\t');
636 static char *unquote_string(const char *str
)
641 while(*str
== ' ' || *str
== '\t') str
++;
649 for(cp
= ret
; *cp
; cp
++)
652 memmove(cp
, cp
+ 1, strlen(cp
+ 1) + 1);
657 WARN("quote in unquoted string\n");
669 static void add_param(header_t
*header
, const char *p
)
671 const char *key
= p
, *value
, *cp
= p
;
675 TRACE("got param %s\n", p
);
677 while (*key
== ' ' || *key
== '\t' ) key
++;
679 cp
= strchr(key
, '=');
682 WARN("malformed parameter - skipping\n");
686 name
= HeapAlloc(GetProcessHeap(), 0, cp
- key
+ 1);
687 memcpy(name
, key
, cp
- key
);
688 name
[cp
- key
] = '\0';
692 param
= HeapAlloc(GetProcessHeap(), 0, sizeof(*param
));
694 param
->value
= unquote_string(value
);
695 list_add_tail(&header
->params
, ¶m
->entry
);
698 static void split_params(header_t
*header
, char *value
)
700 char *cp
= value
, *start
= value
;
701 BOOL in_quotes
= FALSE
, done_value
= FALSE
;
705 if(!in_quotes
&& *cp
== ';')
708 if(done_value
) add_param(header
, start
);
713 in_quotes
= !in_quotes
;
716 if(done_value
) add_param(header
, start
);
719 static void read_value(header_t
*header
, char **cur
)
721 char *end
= *cur
, *value
;
725 end
= strstr(end
, "\r\n");
727 } while(*end
== ' ' || *end
== '\t');
730 value
= HeapAlloc(GetProcessHeap(), 0, len
+ 1);
731 memcpy(value
, *cur
, len
);
734 unfold_header(value
, len
);
735 TRACE("value %s\n", debugstr_a(value
));
737 if(header
->prop
->flags
& MPF_HASPARAMS
)
739 split_params(header
, value
);
740 TRACE("value w/o params %s\n", debugstr_a(value
));
743 header
->value
.vt
= VT_LPSTR
;
744 header
->value
.u
.pszVal
= value
;
749 static void init_content_type(MimeBody
*body
, header_t
*header
)
754 slash
= strchr(header
->value
.u
.pszVal
, '/');
757 WARN("malformed context type value\n");
760 len
= slash
- header
->value
.u
.pszVal
;
761 body
->content_pri_type
= HeapAlloc(GetProcessHeap(), 0, len
+ 1);
762 memcpy(body
->content_pri_type
, header
->value
.u
.pszVal
, len
);
763 body
->content_pri_type
[len
] = '\0';
764 body
->content_sub_type
= strdupA(slash
+ 1);
767 static void init_content_encoding(MimeBody
*body
, header_t
*header
)
769 const char *encoding
= header
->value
.u
.pszVal
;
771 if(!strcasecmp(encoding
, "base64"))
772 body
->encoding
= IET_BASE64
;
773 else if(!strcasecmp(encoding
, "quoted-printable"))
774 body
->encoding
= IET_QP
;
775 else if(!strcasecmp(encoding
, "7bit"))
776 body
->encoding
= IET_7BIT
;
777 else if(!strcasecmp(encoding
, "8bit"))
778 body
->encoding
= IET_8BIT
;
780 FIXME("unknown encoding %s\n", debugstr_a(encoding
));
783 static HRESULT
parse_headers(MimeBody
*body
, IStream
*stm
)
785 char *header_buf
, *cur_header_ptr
;
789 hr
= copy_headers_to_buf(stm
, &header_buf
);
790 if(FAILED(hr
)) return hr
;
792 cur_header_ptr
= header_buf
;
793 while((header
= read_prop(body
, &cur_header_ptr
)))
795 read_value(header
, &cur_header_ptr
);
796 list_add_tail(&body
->headers
, &header
->entry
);
798 switch(header
->prop
->id
) {
799 case PID_HDR_CNTTYPE
:
800 init_content_type(body
, header
);
802 case PID_HDR_CNTXFER
:
803 init_content_encoding(body
, header
);
808 HeapFree(GetProcessHeap(), 0, header_buf
);
812 static void empty_param_list(struct list
*list
)
814 param_t
*param
, *cursor2
;
816 LIST_FOR_EACH_ENTRY_SAFE(param
, cursor2
, list
, param_t
, entry
)
818 list_remove(¶m
->entry
);
819 HeapFree(GetProcessHeap(), 0, param
->name
);
820 HeapFree(GetProcessHeap(), 0, param
->value
);
821 HeapFree(GetProcessHeap(), 0, param
);
825 static void empty_header_list(struct list
*list
)
827 header_t
*header
, *cursor2
;
829 LIST_FOR_EACH_ENTRY_SAFE(header
, cursor2
, list
, header_t
, entry
)
831 list_remove(&header
->entry
);
832 PropVariantClear(&header
->value
);
833 empty_param_list(&header
->params
);
834 HeapFree(GetProcessHeap(), 0, header
);
838 static void empty_new_prop_list(struct list
*list
)
840 property_list_entry_t
*prop
, *cursor2
;
842 LIST_FOR_EACH_ENTRY_SAFE(prop
, cursor2
, list
, property_list_entry_t
, entry
)
844 list_remove(&prop
->entry
);
845 HeapFree(GetProcessHeap(), 0, (char *)prop
->prop
.name
);
846 HeapFree(GetProcessHeap(), 0, prop
);
850 static void release_data(REFIID riid
, void *data
)
854 if(IsEqualIID(riid
, &IID_IStream
))
855 IStream_Release((IStream
*)data
);
857 FIXME("Unhandled data format %s\n", debugstr_guid(riid
));
860 static HRESULT
find_prop(MimeBody
*body
, const char *name
, header_t
**prop
)
866 LIST_FOR_EACH_ENTRY(header
, &body
->headers
, header_t
, entry
)
870 if(STRTOPID(name
) == header
->prop
->id
)
876 else if(!lstrcmpiA(name
, header
->prop
->name
))
883 return MIME_E_NOT_FOUND
;
886 static const property_t
*find_default_prop(const char *name
)
888 const property_t
*prop_def
= NULL
;
890 for(prop_def
= default_props
; prop_def
->name
; prop_def
++)
894 if(STRTOPID(name
) == prop_def
->id
)
899 else if(!lstrcmpiA(name
, prop_def
->name
))
906 TRACE("%s: found match with default property id %d\n", prop_def
->name
, prop_def
->id
);
913 static HRESULT WINAPI
MimeBody_QueryInterface(IMimeBody
* iface
,
917 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ppvObject
);
921 if (IsEqualIID(riid
, &IID_IUnknown
) ||
922 IsEqualIID(riid
, &IID_IPersist
) ||
923 IsEqualIID(riid
, &IID_IPersistStreamInit
) ||
924 IsEqualIID(riid
, &IID_IMimePropertySet
) ||
925 IsEqualIID(riid
, &IID_IMimeBody
))
932 IUnknown_AddRef((IUnknown
*)*ppvObject
);
936 FIXME("no interface for %s\n", debugstr_guid(riid
));
937 return E_NOINTERFACE
;
940 static ULONG WINAPI
MimeBody_AddRef(IMimeBody
*iface
)
942 MimeBody
*This
= impl_from_IMimeBody(iface
);
943 LONG ref
= InterlockedIncrement(&This
->ref
);
945 TRACE("(%p) ref=%d\n", This
, ref
);
950 static ULONG WINAPI
MimeBody_Release(IMimeBody
*iface
)
952 MimeBody
*This
= impl_from_IMimeBody(iface
);
953 LONG ref
= InterlockedDecrement(&This
->ref
);
955 TRACE("(%p) ref=%d\n", This
, ref
);
959 empty_header_list(&This
->headers
);
960 empty_new_prop_list(&This
->new_props
);
962 HeapFree(GetProcessHeap(), 0, This
->content_pri_type
);
963 HeapFree(GetProcessHeap(), 0, This
->content_sub_type
);
965 release_data(&This
->data_iid
, This
->data
);
967 HeapFree(GetProcessHeap(), 0, This
);
973 static HRESULT WINAPI
MimeBody_GetClassID(
977 MimeBody
*This
= impl_from_IMimeBody(iface
);
979 TRACE("(%p)->(%p)\n", This
, pClassID
);
984 *pClassID
= IID_IMimeBody
;
988 static HRESULT WINAPI
MimeBody_IsDirty(
991 MimeBody
*This
= impl_from_IMimeBody(iface
);
992 FIXME("(%p)->() stub\n", This
);
996 static HRESULT WINAPI
MimeBody_Load(IMimeBody
*iface
, IStream
*pStm
)
998 MimeBody
*This
= impl_from_IMimeBody(iface
);
999 TRACE("(%p)->(%p)\n", This
, pStm
);
1000 return parse_headers(This
, pStm
);
1003 static HRESULT WINAPI
MimeBody_Save(IMimeBody
*iface
, IStream
*pStm
, BOOL fClearDirty
)
1005 MimeBody
*This
= impl_from_IMimeBody(iface
);
1006 FIXME("(%p)->(%p, %d)\n", This
, pStm
, fClearDirty
);
1010 static HRESULT WINAPI
MimeBody_GetSizeMax(
1012 ULARGE_INTEGER
* pcbSize
)
1014 MimeBody
*This
= impl_from_IMimeBody(iface
);
1015 FIXME("(%p)->(%p) stub\n", This
, pcbSize
);
1019 static HRESULT WINAPI
MimeBody_InitNew(
1022 MimeBody
*This
= impl_from_IMimeBody(iface
);
1023 TRACE("(%p)->()\n", This
);
1027 static HRESULT WINAPI
MimeBody_GetPropInfo(
1030 LPMIMEPROPINFO pInfo
)
1032 MimeBody
*This
= impl_from_IMimeBody(iface
);
1035 DWORD supported
= PIM_PROPID
| PIM_VTDEFAULT
;
1037 TRACE("(%p)->(%s, %p) semi-stub\n", This
, debugstr_a(pszName
), pInfo
);
1039 if(!pszName
|| !pInfo
)
1040 return E_INVALIDARG
;
1042 TRACE("mask 0x%04x\n", pInfo
->dwMask
);
1044 if(pInfo
->dwMask
& ~supported
)
1045 FIXME("Unsupported mask flags 0x%04x\n", pInfo
->dwMask
& ~supported
);
1047 hr
= find_prop(This
, pszName
, &header
);
1050 if(pInfo
->dwMask
& PIM_CHARSET
)
1051 pInfo
->hCharset
= 0;
1052 if(pInfo
->dwMask
& PIM_FLAGS
)
1053 pInfo
->dwFlags
= 0x00000000;
1054 if(pInfo
->dwMask
& PIM_ROWNUMBER
)
1055 pInfo
->dwRowNumber
= 0;
1056 if(pInfo
->dwMask
& PIM_ENCODINGTYPE
)
1057 pInfo
->ietEncoding
= 0;
1058 if(pInfo
->dwMask
& PIM_VALUES
)
1060 if(pInfo
->dwMask
& PIM_PROPID
)
1061 pInfo
->dwPropId
= header
->prop
->id
;
1062 if(pInfo
->dwMask
& PIM_VTDEFAULT
)
1063 pInfo
->vtDefault
= header
->prop
->default_vt
;
1064 if(pInfo
->dwMask
& PIM_VTCURRENT
)
1065 pInfo
->vtCurrent
= 0;
1071 static HRESULT WINAPI
MimeBody_SetPropInfo(
1074 LPCMIMEPROPINFO pInfo
)
1076 MimeBody
*This
= impl_from_IMimeBody(iface
);
1077 FIXME("(%p)->(%s, %p) stub\n", This
, debugstr_a(pszName
), pInfo
);
1081 static HRESULT WINAPI
MimeBody_GetProp(
1085 LPPROPVARIANT pValue
)
1087 MimeBody
*This
= impl_from_IMimeBody(iface
);
1091 TRACE("(%p)->(%s, 0x%x, %p)\n", This
, debugstr_a(pszName
), dwFlags
, pValue
);
1093 if(!pszName
|| !pValue
)
1094 return E_INVALIDARG
;
1096 if(!ISPIDSTR(pszName
) && !lstrcmpiA(pszName
, "att:pri-content-type"))
1098 PropVariantClear(pValue
);
1099 pValue
->vt
= VT_LPSTR
;
1100 pValue
->u
.pszVal
= strdupA(This
->content_pri_type
);
1104 hr
= find_prop(This
, pszName
, &header
);
1107 TRACE("type %d->%d\n", header
->value
.vt
, pValue
->vt
);
1109 hr
= PropVariantChangeType(pValue
, &header
->value
, 0, pValue
->vt
);
1111 FIXME("Conversion not currently supported (%d->%d)\n", header
->value
.vt
, pValue
->vt
);
1117 static HRESULT WINAPI
MimeBody_SetProp(
1121 LPCPROPVARIANT pValue
)
1123 MimeBody
*This
= impl_from_IMimeBody(iface
);
1127 TRACE("(%p)->(%s, 0x%x, %p)\n", This
, debugstr_a(pszName
), dwFlags
, pValue
);
1129 if(!pszName
|| !pValue
)
1130 return E_INVALIDARG
;
1132 hr
= find_prop(This
, pszName
, &header
);
1135 property_list_entry_t
*prop_entry
;
1136 const property_t
*prop
= NULL
;
1138 LIST_FOR_EACH_ENTRY(prop_entry
, &This
->new_props
, property_list_entry_t
, entry
)
1140 if(ISPIDSTR(pszName
))
1142 if(STRTOPID(pszName
) == prop_entry
->prop
.id
)
1144 TRACE("Found match with already added new property id %d\n", prop_entry
->prop
.id
);
1145 prop
= &prop_entry
->prop
;
1149 else if(!lstrcmpiA(pszName
, prop_entry
->prop
.name
))
1151 TRACE("Found match with already added new property id %d\n", prop_entry
->prop
.id
);
1152 prop
= &prop_entry
->prop
;
1157 header
= HeapAlloc(GetProcessHeap(), 0, sizeof(*header
));
1159 return E_OUTOFMEMORY
;
1163 const property_t
*prop_def
= NULL
;
1164 prop_entry
= HeapAlloc(GetProcessHeap(), 0, sizeof(*prop_entry
));
1167 HeapFree(GetProcessHeap(), 0, header
);
1168 return E_OUTOFMEMORY
;
1171 prop_def
= find_default_prop(pszName
);
1174 prop_entry
->prop
.name
= strdupA(prop_def
->name
);
1175 prop_entry
->prop
.id
= prop_def
->id
;
1179 if(ISPIDSTR(pszName
))
1181 HeapFree(GetProcessHeap(), 0, prop_entry
);
1182 HeapFree(GetProcessHeap(), 0, header
);
1183 return MIME_E_NOT_FOUND
;
1186 prop_entry
->prop
.name
= strdupA(pszName
);
1187 prop_entry
->prop
.id
= This
->next_prop_id
++;
1190 prop_entry
->prop
.flags
= 0;
1191 prop_entry
->prop
.default_vt
= pValue
->vt
;
1192 list_add_tail(&This
->new_props
, &prop_entry
->entry
);
1193 prop
= &prop_entry
->prop
;
1194 TRACE("Allocating new prop id %d\n", prop_entry
->prop
.id
);
1197 header
->prop
= prop
;
1198 PropVariantInit(&header
->value
);
1199 list_init(&header
->params
);
1200 list_add_tail(&This
->headers
, &header
->entry
);
1203 PropVariantCopy(&header
->value
, pValue
);
1208 static HRESULT WINAPI
MimeBody_AppendProp(
1212 LPPROPVARIANT pValue
)
1214 MimeBody
*This
= impl_from_IMimeBody(iface
);
1215 FIXME("(%p)->(%s, 0x%x, %p) stub\n", This
, debugstr_a(pszName
), dwFlags
, pValue
);
1219 static HRESULT WINAPI
MimeBody_DeleteProp(
1223 MimeBody
*This
= impl_from_IMimeBody(iface
);
1227 TRACE("(%p)->(%s) stub\n", This
, debugstr_a(pszName
));
1229 LIST_FOR_EACH_ENTRY(cursor
, &This
->headers
, header_t
, entry
)
1231 if(ISPIDSTR(pszName
))
1232 found
= STRTOPID(pszName
) == cursor
->prop
->id
;
1234 found
= !lstrcmpiA(pszName
, cursor
->prop
->name
);
1238 list_remove(&cursor
->entry
);
1239 HeapFree(GetProcessHeap(), 0, cursor
);
1244 return MIME_E_NOT_FOUND
;
1247 static HRESULT WINAPI
MimeBody_CopyProps(
1251 IMimePropertySet
* pPropertySet
)
1253 MimeBody
*This
= impl_from_IMimeBody(iface
);
1254 FIXME("(%p)->(%d, %p, %p) stub\n", This
, cNames
, prgszName
, pPropertySet
);
1258 static HRESULT WINAPI
MimeBody_MoveProps(
1262 IMimePropertySet
* pPropertySet
)
1264 MimeBody
*This
= impl_from_IMimeBody(iface
);
1265 FIXME("(%p)->(%d, %p, %p) stub\n", This
, cNames
, prgszName
, pPropertySet
);
1269 static HRESULT WINAPI
MimeBody_DeleteExcept(
1274 MimeBody
*This
= impl_from_IMimeBody(iface
);
1275 FIXME("(%p)->(%d, %p) stub\n", This
, cNames
, prgszName
);
1279 static HRESULT WINAPI
MimeBody_QueryProp(
1284 boolean fCaseSensitive
)
1286 MimeBody
*This
= impl_from_IMimeBody(iface
);
1287 FIXME("(%p)->(%s, %s, %d, %d) stub\n", This
, debugstr_a(pszName
), debugstr_a(pszCriteria
), fSubString
, fCaseSensitive
);
1291 static HRESULT WINAPI
MimeBody_GetCharset(
1293 LPHCHARSET phCharset
)
1295 MimeBody
*This
= impl_from_IMimeBody(iface
);
1296 FIXME("(%p)->(%p) stub\n", This
, phCharset
);
1301 static HRESULT WINAPI
MimeBody_SetCharset(
1304 CSETAPPLYTYPE applytype
)
1306 MimeBody
*This
= impl_from_IMimeBody(iface
);
1307 FIXME("(%p)->(%p, %d) stub\n", This
, hCharset
, applytype
);
1311 static HRESULT WINAPI
MimeBody_GetParameters(
1315 LPMIMEPARAMINFO
* pprgParam
)
1317 MimeBody
*This
= impl_from_IMimeBody(iface
);
1321 TRACE("(%p)->(%s, %p, %p)\n", iface
, debugstr_a(pszName
), pcParams
, pprgParam
);
1326 hr
= find_prop(This
, pszName
, &header
);
1327 if(hr
!= S_OK
) return hr
;
1329 *pcParams
= list_count(&header
->params
);
1332 IMimeAllocator
*alloc
;
1334 MIMEPARAMINFO
*info
;
1336 MimeOleGetAllocator(&alloc
);
1338 *pprgParam
= info
= IMimeAllocator_Alloc(alloc
, *pcParams
* sizeof(**pprgParam
));
1339 LIST_FOR_EACH_ENTRY(param
, &header
->params
, param_t
, entry
)
1343 len
= strlen(param
->name
) + 1;
1344 info
->pszName
= IMimeAllocator_Alloc(alloc
, len
);
1345 memcpy(info
->pszName
, param
->name
, len
);
1346 len
= strlen(param
->value
) + 1;
1347 info
->pszData
= IMimeAllocator_Alloc(alloc
, len
);
1348 memcpy(info
->pszData
, param
->value
, len
);
1351 IMimeAllocator_Release(alloc
);
1356 static HRESULT WINAPI
MimeBody_IsContentType(
1361 MimeBody
*This
= impl_from_IMimeBody(iface
);
1363 TRACE("(%p)->(%s, %s)\n", This
, debugstr_a(pszPriType
), debugstr_a(pszSubType
));
1366 const char *pri
= This
->content_pri_type
;
1367 if(!pri
) pri
= "text";
1368 if(lstrcmpiA(pri
, pszPriType
)) return S_FALSE
;
1373 const char *sub
= This
->content_sub_type
;
1374 if(!sub
) sub
= "plain";
1375 if(lstrcmpiA(sub
, pszSubType
)) return S_FALSE
;
1381 static HRESULT WINAPI
MimeBody_BindToObject(
1386 MimeBody
*This
= impl_from_IMimeBody(iface
);
1387 FIXME("(%p)->(%s, %p) stub\n", This
, debugstr_guid(riid
), ppvObject
);
1391 static HRESULT WINAPI
MimeBody_Clone(
1393 IMimePropertySet
** ppPropertySet
)
1395 MimeBody
*This
= impl_from_IMimeBody(iface
);
1396 FIXME("(%p)->(%p) stub\n", This
, ppPropertySet
);
1400 static HRESULT WINAPI
MimeBody_SetOption(
1403 LPCPROPVARIANT pValue
)
1405 MimeBody
*This
= impl_from_IMimeBody(iface
);
1406 HRESULT hr
= E_NOTIMPL
;
1407 TRACE("(%p)->(%08x, %p)\n", This
, oid
, pValue
);
1409 if(pValue
->vt
!= TYPEDID_TYPE(oid
))
1411 WARN("Called with vartype %04x and oid %08x\n", pValue
->vt
, oid
);
1412 return E_INVALIDARG
;
1417 case OID_SECURITY_HWND_OWNER
:
1418 FIXME("OID_SECURITY_HWND_OWNER (value %08x): ignoring\n", pValue
->u
.ulVal
);
1421 case OID_TRANSMIT_BODY_ENCODING
:
1422 FIXME("OID_TRANSMIT_BODY_ENCODING (value %08x): ignoring\n", pValue
->u
.ulVal
);
1426 FIXME("Unhandled oid %08x\n", oid
);
1432 static HRESULT WINAPI
MimeBody_GetOption(
1435 LPPROPVARIANT pValue
)
1437 MimeBody
*This
= impl_from_IMimeBody(iface
);
1438 FIXME("(%p)->(%08x, %p): stub\n", This
, oid
, pValue
);
1442 static HRESULT WINAPI
MimeBody_EnumProps(
1445 IMimeEnumProperties
** ppEnum
)
1447 MimeBody
*This
= impl_from_IMimeBody(iface
);
1448 FIXME("(%p)->(0x%x, %p) stub\n", This
, dwFlags
, ppEnum
);
1452 static HRESULT WINAPI
MimeBody_IsType(
1454 IMSGBODYTYPE bodytype
)
1456 MimeBody
*This
= impl_from_IMimeBody(iface
);
1458 TRACE("(%p)->(%d)\n", This
, bodytype
);
1462 return This
->data
? S_FALSE
: S_OK
;
1464 FIXME("Unimplemented bodytype %d - returning S_OK\n", bodytype
);
1469 static HRESULT WINAPI
MimeBody_SetDisplayName(
1473 MimeBody
*This
= impl_from_IMimeBody(iface
);
1474 FIXME("(%p)->(%s) stub\n", This
, debugstr_a(pszDisplay
));
1478 static HRESULT WINAPI
MimeBody_GetDisplayName(
1482 MimeBody
*This
= impl_from_IMimeBody(iface
);
1483 FIXME("(%p)->(%p) stub\n", This
, ppszDisplay
);
1487 static HRESULT WINAPI
MimeBody_GetOffsets(
1489 LPBODYOFFSETS pOffsets
)
1491 MimeBody
*This
= impl_from_IMimeBody(iface
);
1492 TRACE("(%p)->(%p)\n", This
, pOffsets
);
1494 *pOffsets
= This
->body_offsets
;
1496 if(This
->body_offsets
.cbBodyEnd
== 0) return MIME_E_NO_DATA
;
1500 static HRESULT WINAPI
MimeBody_GetCurrentEncoding(
1502 ENCODINGTYPE
* pietEncoding
)
1504 MimeBody
*This
= impl_from_IMimeBody(iface
);
1506 TRACE("(%p)->(%p)\n", This
, pietEncoding
);
1508 *pietEncoding
= This
->encoding
;
1512 static HRESULT WINAPI
MimeBody_SetCurrentEncoding(
1514 ENCODINGTYPE ietEncoding
)
1516 MimeBody
*This
= impl_from_IMimeBody(iface
);
1518 TRACE("(%p)->(%d)\n", This
, ietEncoding
);
1520 This
->encoding
= ietEncoding
;
1524 static HRESULT WINAPI
MimeBody_GetEstimatedSize(
1526 ENCODINGTYPE ietEncoding
,
1529 MimeBody
*This
= impl_from_IMimeBody(iface
);
1530 FIXME("(%p)->(%d, %p) stub\n", This
, ietEncoding
, pcbSize
);
1534 static HRESULT WINAPI
MimeBody_GetDataHere(
1536 ENCODINGTYPE ietEncoding
,
1539 MimeBody
*This
= impl_from_IMimeBody(iface
);
1540 FIXME("(%p)->(%d, %p) stub\n", This
, ietEncoding
, pStream
);
1544 static const signed char base64_decode_table
[] =
1546 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x00 */
1547 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x10 */
1548 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, /* 0x20 */
1549 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, /* 0x30 */
1550 -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 0x40 */
1551 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, /* 0x50 */
1552 -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, /* 0x60 */
1553 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1 /* 0x70 */
1556 static HRESULT
decode_base64(IStream
*input
, IStream
**ret_stream
)
1558 const unsigned char *ptr
, *end
;
1559 unsigned char buf
[1024];
1562 unsigned char in
[4];
1569 hres
= IStream_Seek(input
, pos
, STREAM_SEEK_SET
, NULL
);
1573 hres
= CreateStreamOnHGlobal(NULL
, TRUE
, &output
);
1578 hres
= IStream_Read(input
, buf
, sizeof(buf
), &size
);
1579 if(FAILED(hres
) || !size
)
1586 /* skip invalid chars */
1587 while(ptr
< end
&& (*ptr
>= ARRAY_SIZE(base64_decode_table
)
1588 || base64_decode_table
[*ptr
] == -1))
1593 in
[n
++] = base64_decode_table
[*ptr
++];
1596 *ret
++ = in
[0] << 2 | in
[1] >> 4;
1599 *ret
++ = in
[1] << 4 | in
[2] >> 2;
1602 *ret
++ = ((in
[2] << 6) & 0xc0) | in
[3];
1608 hres
= IStream_Write(output
, buf
, ret
- buf
, NULL
);
1615 hres
= IStream_Seek(output
, pos
, STREAM_SEEK_SET
, NULL
);
1617 IStream_Release(output
);
1621 *ret_stream
= output
;
1625 static int hex_digit(char c
)
1627 if('0' <= c
&& c
<= '9')
1629 if('A' <= c
&& c
<= 'F')
1630 return c
- 'A' + 10;
1631 if('a' <= c
&& c
<= 'f')
1632 return c
- 'a' + 10;
1636 static HRESULT
decode_qp(IStream
*input
, IStream
**ret_stream
)
1638 const unsigned char *ptr
, *end
;
1639 unsigned char *ret
, prev
= 0;
1640 unsigned char buf
[1024];
1648 hres
= IStream_Seek(input
, pos
, STREAM_SEEK_SET
, NULL
);
1652 hres
= CreateStreamOnHGlobal(NULL
, TRUE
, &output
);
1657 hres
= IStream_Read(input
, buf
, sizeof(buf
), &size
);
1658 if(FAILED(hres
) || !size
)
1665 unsigned char byte
= *ptr
++;
1679 if(prev
!= '\r' || byte
!= '\n') {
1680 int h1
= hex_digit(prev
), h2
= hex_digit(byte
);
1681 if(h1
!= -1 && h2
!= -1)
1682 *ret
++ = (h1
<< 4) | h2
;
1692 hres
= IStream_Write(output
, buf
, ret
- buf
, NULL
);
1699 hres
= IStream_Seek(output
, pos
, STREAM_SEEK_SET
, NULL
);
1701 IStream_Release(output
);
1705 *ret_stream
= output
;
1709 static HRESULT WINAPI
MimeBody_GetData(
1711 ENCODINGTYPE ietEncoding
,
1714 MimeBody
*This
= impl_from_IMimeBody(iface
);
1715 ULARGE_INTEGER start
, size
;
1718 TRACE("(%p)->(%d %p)\n", This
, ietEncoding
, ppStream
);
1720 if(This
->encoding
!= ietEncoding
) {
1721 switch(This
->encoding
) {
1723 hres
= decode_base64(This
->data
, ppStream
);
1726 hres
= decode_qp(This
->data
, ppStream
);
1729 FIXME("Decoding %d is not supported.\n", This
->encoding
);
1732 if(ietEncoding
!= IET_BINARY
)
1733 FIXME("Encoding %d is not supported.\n", ietEncoding
);
1739 hres
= get_stream_size(This
->data
, &size
);
1741 hres
= create_sub_stream(This
->data
, start
, size
, ppStream
);
1745 static HRESULT WINAPI
MimeBody_SetData(
1747 ENCODINGTYPE ietEncoding
,
1753 MimeBody
*This
= impl_from_IMimeBody(iface
);
1754 TRACE("(%p)->(%d, %s, %s, %s %p)\n", This
, ietEncoding
, debugstr_a(pszPriType
), debugstr_a(pszSubType
),
1755 debugstr_guid(riid
), pvObject
);
1757 if(IsEqualIID(riid
, &IID_IStream
))
1758 IStream_AddRef((IStream
*)pvObject
);
1761 FIXME("Unhandled object type %s\n", debugstr_guid(riid
));
1762 return E_INVALIDARG
;
1766 release_data(&This
->data_iid
, This
->data
);
1768 This
->data_iid
= *riid
;
1769 This
->data
= pvObject
;
1771 IMimeBody_SetCurrentEncoding(iface
, ietEncoding
);
1773 /* FIXME: Update the content type.
1774 If pszPriType == NULL use 'application'
1775 If pszSubType == NULL use 'octet-stream' */
1780 static HRESULT WINAPI
MimeBody_EmptyData(
1783 MimeBody
*This
= impl_from_IMimeBody(iface
);
1784 FIXME("(%p)->() stub\n", This
);
1788 static HRESULT WINAPI
MimeBody_CopyTo(
1792 MimeBody
*This
= impl_from_IMimeBody(iface
);
1793 FIXME("(%p)->(%p) stub\n", This
, pBody
);
1797 static HRESULT WINAPI
MimeBody_GetTransmitInfo(
1799 LPTRANSMITINFO pTransmitInfo
)
1801 MimeBody
*This
= impl_from_IMimeBody(iface
);
1802 FIXME("(%p)->(%p) stub\n", This
, pTransmitInfo
);
1806 static HRESULT WINAPI
MimeBody_SaveToFile(
1808 ENCODINGTYPE ietEncoding
,
1811 MimeBody
*This
= impl_from_IMimeBody(iface
);
1812 FIXME("(%p)->(%d, %s) stub\n", This
, ietEncoding
, debugstr_a(pszFilePath
));
1816 static HRESULT WINAPI
MimeBody_GetHandle(
1820 MimeBody
*This
= impl_from_IMimeBody(iface
);
1821 TRACE("(%p)->(%p)\n", iface
, phBody
);
1824 return E_INVALIDARG
;
1826 *phBody
= This
->handle
;
1827 return This
->handle
? S_OK
: MIME_E_NO_DATA
;
1830 static IMimeBodyVtbl body_vtbl
=
1832 MimeBody_QueryInterface
,
1835 MimeBody_GetClassID
,
1839 MimeBody_GetSizeMax
,
1841 MimeBody_GetPropInfo
,
1842 MimeBody_SetPropInfo
,
1845 MimeBody_AppendProp
,
1846 MimeBody_DeleteProp
,
1849 MimeBody_DeleteExcept
,
1851 MimeBody_GetCharset
,
1852 MimeBody_SetCharset
,
1853 MimeBody_GetParameters
,
1854 MimeBody_IsContentType
,
1855 MimeBody_BindToObject
,
1861 MimeBody_SetDisplayName
,
1862 MimeBody_GetDisplayName
,
1863 MimeBody_GetOffsets
,
1864 MimeBody_GetCurrentEncoding
,
1865 MimeBody_SetCurrentEncoding
,
1866 MimeBody_GetEstimatedSize
,
1867 MimeBody_GetDataHere
,
1872 MimeBody_GetTransmitInfo
,
1873 MimeBody_SaveToFile
,
1877 static HRESULT
MimeBody_set_offsets(MimeBody
*body
, const BODYOFFSETS
*offsets
)
1879 TRACE("setting offsets to %d, %d, %d, %d\n", offsets
->cbBoundaryStart
,
1880 offsets
->cbHeaderStart
, offsets
->cbBodyStart
, offsets
->cbBodyEnd
);
1882 body
->body_offsets
= *offsets
;
1886 #define FIRST_CUSTOM_PROP_ID 0x100
1888 static MimeBody
*mimebody_create(void)
1891 BODYOFFSETS body_offsets
;
1893 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
1897 This
->IMimeBody_iface
.lpVtbl
= &body_vtbl
;
1899 This
->handle
= NULL
;
1900 list_init(&This
->headers
);
1901 list_init(&This
->new_props
);
1902 This
->next_prop_id
= FIRST_CUSTOM_PROP_ID
;
1903 This
->content_pri_type
= NULL
;
1904 This
->content_sub_type
= NULL
;
1905 This
->encoding
= IET_7BIT
;
1907 This
->data_iid
= IID_NULL
;
1909 body_offsets
.cbBoundaryStart
= body_offsets
.cbHeaderStart
= 0;
1910 body_offsets
.cbBodyStart
= body_offsets
.cbBodyEnd
= 0;
1911 MimeBody_set_offsets(This
, &body_offsets
);
1916 HRESULT
MimeBody_create(IUnknown
*outer
, void **ppv
)
1921 return CLASS_E_NOAGGREGATION
;
1923 if ((mb
= mimebody_create()))
1925 *ppv
= &mb
->IMimeBody_iface
;
1931 return E_OUTOFMEMORY
;
1935 typedef struct body_t
1939 MimeBody
*mime_body
;
1941 struct body_t
*parent
;
1942 struct list children
;
1945 typedef struct MimeMessage
1947 IMimeMessage IMimeMessage_iface
;
1951 struct list body_tree
;
1955 static inline MimeMessage
*impl_from_IMimeMessage(IMimeMessage
*iface
)
1957 return CONTAINING_RECORD(iface
, MimeMessage
, IMimeMessage_iface
);
1960 static HRESULT WINAPI
MimeMessage_QueryInterface(IMimeMessage
*iface
, REFIID riid
, void **ppv
)
1962 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ppv
);
1964 if (IsEqualIID(riid
, &IID_IUnknown
) ||
1965 IsEqualIID(riid
, &IID_IPersist
) ||
1966 IsEqualIID(riid
, &IID_IPersistStreamInit
) ||
1967 IsEqualIID(riid
, &IID_IMimeMessageTree
) ||
1968 IsEqualIID(riid
, &IID_IMimeMessage
))
1971 IMimeMessage_AddRef(iface
);
1975 FIXME("no interface for %s\n", debugstr_guid(riid
));
1977 return E_NOINTERFACE
;
1980 static ULONG WINAPI
MimeMessage_AddRef(IMimeMessage
*iface
)
1982 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
1983 ULONG ref
= InterlockedIncrement(&This
->ref
);
1985 TRACE("(%p) ref=%d\n", This
, ref
);
1990 static void empty_body_list(struct list
*list
)
1992 body_t
*body
, *cursor2
;
1993 LIST_FOR_EACH_ENTRY_SAFE(body
, cursor2
, list
, body_t
, entry
)
1995 empty_body_list(&body
->children
);
1996 list_remove(&body
->entry
);
1997 IMimeBody_Release(&body
->mime_body
->IMimeBody_iface
);
1998 HeapFree(GetProcessHeap(), 0, body
);
2002 static ULONG WINAPI
MimeMessage_Release(IMimeMessage
*iface
)
2004 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2005 ULONG ref
= InterlockedDecrement(&This
->ref
);
2007 TRACE("(%p) ref=%d\n", This
, ref
);
2011 empty_body_list(&This
->body_tree
);
2013 if(This
->stream
) IStream_Release(This
->stream
);
2014 HeapFree(GetProcessHeap(), 0, This
);
2020 /*** IPersist methods ***/
2021 static HRESULT WINAPI
MimeMessage_GetClassID(
2022 IMimeMessage
*iface
,
2025 FIXME("(%p)->(%p)\n", iface
, pClassID
);
2029 /*** IPersistStreamInit methods ***/
2030 static HRESULT WINAPI
MimeMessage_IsDirty(
2031 IMimeMessage
*iface
)
2033 FIXME("(%p)->()\n", iface
);
2037 static body_t
*new_body_entry(MimeBody
*mime_body
, DWORD index
, body_t
*parent
)
2039 body_t
*body
= HeapAlloc(GetProcessHeap(), 0, sizeof(*body
));
2042 body
->mime_body
= mime_body
;
2043 body
->index
= index
;
2044 list_init(&body
->children
);
2045 body
->parent
= parent
;
2047 mime_body
->handle
= UlongToHandle(body
->index
);
2055 BODYOFFSETS offsets
;
2058 static HRESULT
create_body_offset_list(IStream
*stm
, const char *boundary
, struct list
*body_offsets
)
2061 DWORD read
, boundary_start
;
2062 int boundary_len
= strlen(boundary
);
2063 char *buf
, *ptr
, *overlap
;
2064 DWORD start
= 0, overlap_no
;
2065 offset_entry_t
*cur_body
= NULL
;
2066 BOOL is_first_line
= TRUE
;
2070 list_init(body_offsets
);
2072 overlap_no
= boundary_len
+ 5;
2074 overlap
= buf
= HeapAlloc(GetProcessHeap(), 0, overlap_no
+ PARSER_BUF_SIZE
+ 1);
2077 hr
= IStream_Seek(stm
, zero
, STREAM_SEEK_CUR
, &cur
);
2078 start
= cur
.u
.LowPart
;
2081 hr
= IStream_Read(stm
, overlap
, PARSER_BUF_SIZE
, &read
);
2082 if(FAILED(hr
)) goto end
;
2083 if(read
== 0) break;
2084 overlap
[read
] = '\0';
2089 is_first_line
= FALSE
;
2091 ptr
= strstr(ptr
, "\r\n");
2097 boundary_start
= start
+ ptr
- buf
;
2099 if(*ptr
== '-' && *(ptr
+ 1) == '-' && !memcmp(ptr
+ 2, boundary
, boundary_len
)) {
2100 ptr
+= boundary_len
+ 2;
2102 if(*ptr
== '\r' && *(ptr
+ 1) == '\n')
2107 cur_body
->offsets
.cbBodyEnd
= boundary_start
- 2;
2108 list_add_tail(body_offsets
, &cur_body
->entry
);
2110 cur_body
= HeapAlloc(GetProcessHeap(), 0, sizeof(*cur_body
));
2111 cur_body
->offsets
.cbBoundaryStart
= boundary_start
;
2112 cur_body
->offsets
.cbHeaderStart
= start
+ ptr
- buf
;
2114 else if(*ptr
== '-' && *(ptr
+ 1) == '-')
2118 cur_body
->offsets
.cbBodyEnd
= boundary_start
- 2;
2119 list_add_tail(body_offsets
, &cur_body
->entry
);
2126 if(overlap
== buf
) /* 1st iteration */
2128 memmove(buf
, buf
+ PARSER_BUF_SIZE
- overlap_no
, overlap_no
);
2129 overlap
= buf
+ overlap_no
;
2130 start
+= read
- overlap_no
;
2134 memmove(buf
, buf
+ PARSER_BUF_SIZE
, overlap_no
);
2140 HeapFree(GetProcessHeap(), 0, buf
);
2144 static body_t
*create_sub_body(MimeMessage
*msg
, IStream
*pStm
, BODYOFFSETS
*offset
, body_t
*parent
)
2146 ULARGE_INTEGER start
, length
;
2147 MimeBody
*mime_body
;
2152 pos
.QuadPart
= offset
->cbHeaderStart
;
2153 IStream_Seek(pStm
, pos
, STREAM_SEEK_SET
, NULL
);
2155 mime_body
= mimebody_create();
2156 IMimeBody_Load(&mime_body
->IMimeBody_iface
, pStm
);
2159 hr
= IStream_Seek(pStm
, pos
, STREAM_SEEK_CUR
, &start
);
2160 offset
->cbBodyStart
= start
.QuadPart
;
2161 if (parent
) MimeBody_set_offsets(mime_body
, offset
);
2163 length
.QuadPart
= offset
->cbBodyEnd
- offset
->cbBodyStart
;
2164 create_sub_stream(pStm
, start
, length
, (IStream
**)&mime_body
->data
);
2165 mime_body
->data_iid
= IID_IStream
;
2167 body
= new_body_entry(mime_body
, msg
->next_index
++, parent
);
2169 if(IMimeBody_IsContentType(&mime_body
->IMimeBody_iface
, "multipart", NULL
) == S_OK
)
2171 MIMEPARAMINFO
*param_info
;
2173 IMimeAllocator
*alloc
;
2175 hr
= IMimeBody_GetParameters(&mime_body
->IMimeBody_iface
, "Content-Type", &count
,
2177 if(hr
!= S_OK
|| count
== 0) return body
;
2179 MimeOleGetAllocator(&alloc
);
2181 for(i
= 0; i
< count
; i
++)
2183 if(!lstrcmpiA(param_info
[i
].pszName
, "boundary"))
2185 struct list offset_list
;
2186 offset_entry_t
*cur
, *cursor2
;
2187 hr
= create_body_offset_list(pStm
, param_info
[i
].pszData
, &offset_list
);
2188 LIST_FOR_EACH_ENTRY_SAFE(cur
, cursor2
, &offset_list
, offset_entry_t
, entry
)
2192 sub_body
= create_sub_body(msg
, pStm
, &cur
->offsets
, body
);
2193 list_add_tail(&body
->children
, &sub_body
->entry
);
2194 list_remove(&cur
->entry
);
2195 HeapFree(GetProcessHeap(), 0, cur
);
2200 IMimeAllocator_FreeParamInfoArray(alloc
, count
, param_info
, TRUE
);
2201 IMimeAllocator_Release(alloc
);
2206 static HRESULT WINAPI
MimeMessage_Load(IMimeMessage
*iface
, IStream
*pStm
)
2208 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2210 BODYOFFSETS offsets
;
2214 TRACE("(%p)->(%p)\n", iface
, pStm
);
2218 FIXME("already loaded a message\n");
2222 empty_body_list(&This
->body_tree
);
2224 IStream_AddRef(pStm
);
2225 This
->stream
= pStm
;
2226 offsets
.cbBoundaryStart
= offsets
.cbHeaderStart
= 0;
2227 offsets
.cbBodyStart
= offsets
.cbBodyEnd
= 0;
2229 root_body
= create_sub_body(This
, pStm
, &offsets
, NULL
);
2232 IStream_Seek(pStm
, zero
, STREAM_SEEK_END
, &cur
);
2233 offsets
.cbBodyEnd
= cur
.u
.LowPart
;
2234 MimeBody_set_offsets(root_body
->mime_body
, &offsets
);
2236 list_add_head(&This
->body_tree
, &root_body
->entry
);
2241 static HRESULT WINAPI
MimeMessage_Save(IMimeMessage
*iface
, IStream
*pStm
, BOOL fClearDirty
)
2243 FIXME("(%p)->(%p, %s)\n", iface
, pStm
, fClearDirty
? "TRUE" : "FALSE");
2247 static HRESULT WINAPI
MimeMessage_GetSizeMax(
2248 IMimeMessage
*iface
,
2249 ULARGE_INTEGER
*pcbSize
)
2251 FIXME("(%p)->(%p)\n", iface
, pcbSize
);
2255 static HRESULT WINAPI
MimeMessage_InitNew(
2256 IMimeMessage
*iface
)
2258 FIXME("(%p)->()\n", iface
);
2262 /*** IMimeMessageTree methods ***/
2263 static HRESULT WINAPI
MimeMessage_GetMessageSource(IMimeMessage
*iface
, IStream
**ppStream
,
2266 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2268 FIXME("(%p)->(%p, 0x%x)\n", iface
, ppStream
, dwFlags
);
2270 IStream_AddRef(This
->stream
);
2271 *ppStream
= This
->stream
;
2275 static HRESULT WINAPI
MimeMessage_GetMessageSize(
2276 IMimeMessage
*iface
,
2280 FIXME("(%p)->(%p, 0x%x)\n", iface
, pcbSize
, dwFlags
);
2284 static HRESULT WINAPI
MimeMessage_LoadOffsetTable(
2285 IMimeMessage
*iface
,
2288 FIXME("(%p)->(%p)\n", iface
, pStream
);
2292 static HRESULT WINAPI
MimeMessage_SaveOffsetTable(
2293 IMimeMessage
*iface
,
2297 FIXME("(%p)->(%p, 0x%x)\n", iface
, pStream
, dwFlags
);
2302 static HRESULT WINAPI
MimeMessage_GetFlags(
2303 IMimeMessage
*iface
,
2306 FIXME("(%p)->(%p)\n", iface
, pdwFlags
);
2310 static HRESULT WINAPI
MimeMessage_Commit(
2311 IMimeMessage
*iface
,
2314 FIXME("(%p)->(0x%x)\n", iface
, dwFlags
);
2319 static HRESULT WINAPI
MimeMessage_HandsOffStorage(
2320 IMimeMessage
*iface
)
2322 FIXME("(%p)->()\n", iface
);
2326 static HRESULT
find_body(struct list
*list
, HBODY hbody
, body_t
**body
)
2331 if(hbody
== HBODY_ROOT
)
2333 *body
= LIST_ENTRY(list_head(list
), body_t
, entry
);
2337 LIST_FOR_EACH_ENTRY(cur
, list
, body_t
, entry
)
2339 if(cur
->index
== HandleToUlong(hbody
))
2344 hr
= find_body(&cur
->children
, hbody
, body
);
2345 if(hr
== S_OK
) return S_OK
;
2350 static HRESULT WINAPI
MimeMessage_BindToObject(IMimeMessage
*iface
, const HBODY hBody
, REFIID riid
,
2353 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2357 TRACE("(%p)->(%p, %s, %p)\n", iface
, hBody
, debugstr_guid(riid
), ppvObject
);
2359 hr
= find_body(&This
->body_tree
, hBody
, &body
);
2361 if(hr
!= S_OK
) return hr
;
2363 if(IsEqualIID(riid
, &IID_IMimeBody
))
2365 IMimeBody_AddRef(&body
->mime_body
->IMimeBody_iface
);
2366 *ppvObject
= &body
->mime_body
->IMimeBody_iface
;
2370 return E_NOINTERFACE
;
2373 static HRESULT WINAPI
MimeMessage_SaveBody(
2374 IMimeMessage
*iface
,
2379 FIXME("(%p)->(%p, 0x%x, %p)\n", iface
, hBody
, dwFlags
, pStream
);
2383 static HRESULT
get_body(MimeMessage
*msg
, BODYLOCATION location
, HBODY pivot
, body_t
**out
)
2385 body_t
*root
= LIST_ENTRY(list_head(&msg
->body_tree
), body_t
, entry
);
2390 if(location
== IBL_ROOT
)
2396 hr
= find_body(&msg
->body_tree
, pivot
, &body
);
2404 *out
= body
->parent
;
2406 hr
= MIME_E_NOT_FOUND
;
2410 list
= list_head(&body
->children
);
2412 *out
= LIST_ENTRY(list
, body_t
, entry
);
2414 hr
= MIME_E_NOT_FOUND
;
2418 list
= list_tail(&body
->children
);
2420 *out
= LIST_ENTRY(list
, body_t
, entry
);
2422 hr
= MIME_E_NOT_FOUND
;
2426 list
= list_next(&body
->parent
->children
, &body
->entry
);
2428 *out
= LIST_ENTRY(list
, body_t
, entry
);
2430 hr
= MIME_E_NOT_FOUND
;
2434 list
= list_prev(&body
->parent
->children
, &body
->entry
);
2436 *out
= LIST_ENTRY(list
, body_t
, entry
);
2438 hr
= MIME_E_NOT_FOUND
;
2451 static HRESULT WINAPI
MimeMessage_InsertBody(
2452 IMimeMessage
*iface
,
2453 BODYLOCATION location
,
2457 FIXME("(%p)->(%d, %p, %p)\n", iface
, location
, hPivot
, phBody
);
2461 static HRESULT WINAPI
MimeMessage_GetBody(IMimeMessage
*iface
, BODYLOCATION location
, HBODY hPivot
,
2464 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2468 TRACE("(%p)->(%d, %p, %p)\n", iface
, location
, hPivot
, phBody
);
2471 return E_INVALIDARG
;
2475 hr
= get_body(This
, location
, hPivot
, &body
);
2477 if(hr
== S_OK
) *phBody
= UlongToHandle(body
->index
);
2482 static HRESULT WINAPI
MimeMessage_DeleteBody(
2483 IMimeMessage
*iface
,
2487 FIXME("(%p)->(%p, %08x)\n", iface
, hBody
, dwFlags
);
2491 static HRESULT WINAPI
MimeMessage_MoveBody(
2492 IMimeMessage
*iface
,
2494 BODYLOCATION location
)
2496 FIXME("(%p)->(%d)\n", iface
, location
);
2500 static void count_children(body_t
*body
, boolean recurse
, ULONG
*count
)
2504 LIST_FOR_EACH_ENTRY(child
, &body
->children
, body_t
, entry
)
2507 if(recurse
) count_children(child
, recurse
, count
);
2511 static HRESULT WINAPI
MimeMessage_CountBodies(IMimeMessage
*iface
, HBODY hParent
, boolean fRecurse
,
2515 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2518 TRACE("(%p)->(%p, %s, %p)\n", iface
, hParent
, fRecurse
? "TRUE" : "FALSE", pcBodies
);
2520 hr
= find_body(&This
->body_tree
, hParent
, &body
);
2521 if(hr
!= S_OK
) return hr
;
2524 count_children(body
, fRecurse
, pcBodies
);
2529 static HRESULT
find_next(MimeMessage
*This
, body_t
*body
, FINDBODY
*find
, HBODY
*out
)
2536 if (!body
) ptr
= list_head( &This
->body_tree
);
2539 ptr
= list_head( &body
->children
);
2542 if (!body
->parent
) return MIME_E_NOT_FOUND
;
2543 if (!(ptr
= list_next( &body
->parent
->children
, &body
->entry
))) body
= body
->parent
;
2547 body
= LIST_ENTRY( ptr
, body_t
, entry
);
2548 next
= UlongToHandle( body
->index
);
2549 find
->dwReserved
= body
->index
;
2550 if (IMimeBody_IsContentType(&body
->mime_body
->IMimeBody_iface
, find
->pszPriType
,
2551 find
->pszSubType
) == S_OK
)
2557 return MIME_E_NOT_FOUND
;
2560 static HRESULT WINAPI
MimeMessage_FindFirst(IMimeMessage
*iface
, FINDBODY
*pFindBody
, HBODY
*phBody
)
2562 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2564 TRACE("(%p)->(%p, %p)\n", iface
, pFindBody
, phBody
);
2566 pFindBody
->dwReserved
= 0;
2567 return find_next(This
, NULL
, pFindBody
, phBody
);
2570 static HRESULT WINAPI
MimeMessage_FindNext(IMimeMessage
*iface
, FINDBODY
*pFindBody
, HBODY
*phBody
)
2572 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2576 TRACE("(%p)->(%p, %p)\n", iface
, pFindBody
, phBody
);
2578 hr
= find_body( &This
->body_tree
, UlongToHandle( pFindBody
->dwReserved
), &body
);
2579 if (hr
!= S_OK
) return MIME_E_NOT_FOUND
;
2580 return find_next(This
, body
, pFindBody
, phBody
);
2583 static HRESULT WINAPI
MimeMessage_ResolveURL(
2584 IMimeMessage
*iface
,
2591 FIXME("(%p)->(%p, %s, %s, 0x%x, %p)\n", iface
, hRelated
, pszBase
, pszURL
, dwFlags
, phBody
);
2595 static HRESULT WINAPI
MimeMessage_ToMultipart(
2596 IMimeMessage
*iface
,
2599 LPHBODY phMultipart
)
2601 FIXME("(%p)->(%p, %s, %p)\n", iface
, hBody
, pszSubType
, phMultipart
);
2605 static HRESULT WINAPI
MimeMessage_GetBodyOffsets(
2606 IMimeMessage
*iface
,
2608 LPBODYOFFSETS pOffsets
)
2610 FIXME("(%p)->(%p, %p)\n", iface
, hBody
, pOffsets
);
2614 static HRESULT WINAPI
MimeMessage_GetCharset(
2615 IMimeMessage
*iface
,
2616 LPHCHARSET phCharset
)
2618 FIXME("(%p)->(%p)\n", iface
, phCharset
);
2623 static HRESULT WINAPI
MimeMessage_SetCharset(
2624 IMimeMessage
*iface
,
2626 CSETAPPLYTYPE applytype
)
2628 FIXME("(%p)->(%p, %d)\n", iface
, hCharset
, applytype
);
2632 static HRESULT WINAPI
MimeMessage_IsBodyType(
2633 IMimeMessage
*iface
,
2635 IMSGBODYTYPE bodytype
)
2638 IMimeBody
*mime_body
;
2639 TRACE("(%p)->(%p, %d)\n", iface
, hBody
, bodytype
);
2641 hr
= IMimeMessage_BindToObject(iface
, hBody
, &IID_IMimeBody
, (void**)&mime_body
);
2642 if(hr
!= S_OK
) return hr
;
2644 hr
= IMimeBody_IsType(mime_body
, bodytype
);
2645 MimeBody_Release(mime_body
);
2649 static HRESULT WINAPI
MimeMessage_IsContentType(
2650 IMimeMessage
*iface
,
2656 IMimeBody
*mime_body
;
2657 TRACE("(%p)->(%p, %s, %s)\n", iface
, hBody
, debugstr_a(pszPriType
),
2658 debugstr_a(pszSubType
));
2660 hr
= IMimeMessage_BindToObject(iface
, hBody
, &IID_IMimeBody
, (void**)&mime_body
);
2661 if(FAILED(hr
)) return hr
;
2663 hr
= IMimeBody_IsContentType(mime_body
, pszPriType
, pszSubType
);
2664 IMimeBody_Release(mime_body
);
2668 static HRESULT WINAPI
MimeMessage_QueryBodyProp(
2669 IMimeMessage
*iface
,
2674 boolean fCaseSensitive
)
2676 FIXME("(%p)->(%p, %s, %s, %s, %s)\n", iface
, hBody
, pszName
, pszCriteria
, fSubString
? "TRUE" : "FALSE", fCaseSensitive
? "TRUE" : "FALSE");
2680 static HRESULT WINAPI
MimeMessage_GetBodyProp(
2681 IMimeMessage
*iface
,
2685 LPPROPVARIANT pValue
)
2688 IMimeBody
*mime_body
;
2690 TRACE("(%p)->(%p, %s, 0x%x, %p)\n", iface
, hBody
, pszName
, dwFlags
, pValue
);
2692 hr
= IMimeMessage_BindToObject(iface
, hBody
, &IID_IMimeBody
, (void**)&mime_body
);
2693 if(hr
!= S_OK
) return hr
;
2695 hr
= IMimeBody_GetProp(mime_body
, pszName
, dwFlags
, pValue
);
2696 IMimeBody_Release(mime_body
);
2701 static HRESULT WINAPI
MimeMessage_SetBodyProp(
2702 IMimeMessage
*iface
,
2706 LPCPROPVARIANT pValue
)
2708 FIXME("(%p)->(%p, %s, 0x%x, %p)\n", iface
, hBody
, pszName
, dwFlags
, pValue
);
2712 static HRESULT WINAPI
MimeMessage_DeleteBodyProp(
2713 IMimeMessage
*iface
,
2717 FIXME("(%p)->(%p, %s)\n", iface
, hBody
, pszName
);
2721 static HRESULT WINAPI
MimeMessage_SetOption(
2722 IMimeMessage
*iface
,
2724 LPCPROPVARIANT pValue
)
2727 TRACE("(%p)->(%08x, %p)\n", iface
, oid
, pValue
);
2729 /* Message ID is checked before type.
2730 * OID 0x4D -> 0x56 and 0x58 aren't defined but will filtered out later.
2732 if(TYPEDID_ID(oid
) < TYPEDID_ID(OID_ALLOW_8BIT_HEADER
) || TYPEDID_ID(oid
) > TYPEDID_ID(OID_SECURITY_2KEY_CERT_BAG_64
))
2734 WARN("oid (%08x) out of range\n", oid
);
2735 return MIME_E_INVALID_OPTION_ID
;
2738 if(pValue
->vt
!= TYPEDID_TYPE(oid
))
2740 WARN("Called with vartype %04x and oid %08x\n", pValue
->vt
, oid
);
2746 case OID_HIDE_TNEF_ATTACHMENTS
:
2747 FIXME("OID_HIDE_TNEF_ATTACHMENTS (value %d): ignoring\n", pValue
->u
.boolVal
);
2749 case OID_SHOW_MACBINARY
:
2750 FIXME("OID_SHOW_MACBINARY (value %d): ignoring\n", pValue
->u
.boolVal
);
2752 case OID_SAVEBODY_KEEPBOUNDARY
:
2753 FIXME("OID_SAVEBODY_KEEPBOUNDARY (value %d): ignoring\n", pValue
->u
.boolVal
);
2755 case OID_CLEANUP_TREE_ON_SAVE
:
2756 FIXME("OID_CLEANUP_TREE_ON_SAVE (value %d): ignoring\n", pValue
->u
.boolVal
);
2759 FIXME("Unhandled oid %08x\n", oid
);
2760 hr
= MIME_E_INVALID_OPTION_ID
;
2766 static HRESULT WINAPI
MimeMessage_GetOption(
2767 IMimeMessage
*iface
,
2769 LPPROPVARIANT pValue
)
2771 FIXME("(%p)->(%08x, %p)\n", iface
, oid
, pValue
);
2775 /*** IMimeMessage methods ***/
2776 static HRESULT WINAPI
MimeMessage_CreateWebPage(
2777 IMimeMessage
*iface
,
2779 LPWEBPAGEOPTIONS pOptions
,
2780 IMimeMessageCallback
*pCallback
,
2781 IMoniker
**ppMoniker
)
2783 FIXME("(%p)->(%p, %p, %p, %p)\n", iface
, pRootStm
, pOptions
, pCallback
, ppMoniker
);
2788 static HRESULT WINAPI
MimeMessage_GetProp(
2789 IMimeMessage
*iface
,
2792 LPPROPVARIANT pValue
)
2794 FIXME("(%p)->(%s, 0x%x, %p)\n", iface
, pszName
, dwFlags
, pValue
);
2798 static HRESULT WINAPI
MimeMessage_SetProp(
2799 IMimeMessage
*iface
,
2802 LPCPROPVARIANT pValue
)
2804 FIXME("(%p)->(%s, 0x%x, %p)\n", iface
, pszName
, dwFlags
, pValue
);
2808 static HRESULT WINAPI
MimeMessage_DeleteProp(
2809 IMimeMessage
*iface
,
2812 FIXME("(%p)->(%s)\n", iface
, pszName
);
2816 static HRESULT WINAPI
MimeMessage_QueryProp(
2817 IMimeMessage
*iface
,
2821 boolean fCaseSensitive
)
2823 FIXME("(%p)->(%s, %s, %s, %s)\n", iface
, pszName
, pszCriteria
, fSubString
? "TRUE" : "FALSE", fCaseSensitive
? "TRUE" : "FALSE");
2827 static HRESULT WINAPI
MimeMessage_GetTextBody(
2828 IMimeMessage
*iface
,
2830 ENCODINGTYPE ietEncoding
,
2836 FINDBODY find_struct
;
2837 IMimeBody
*mime_body
;
2838 static char text
[] = "text";
2839 static char plain
[] = "plain";
2840 static char html
[] = "html";
2842 TRACE("(%p)->(%d, %d, %p, %p)\n", iface
, dwTxtType
, ietEncoding
, pStream
, phBody
);
2844 find_struct
.pszPriType
= text
;
2849 find_struct
.pszSubType
= plain
;
2852 find_struct
.pszSubType
= html
;
2855 return MIME_E_INVALID_TEXT_TYPE
;
2858 hr
= IMimeMessage_FindFirst(iface
, &find_struct
, &hbody
);
2861 TRACE("not found hr %08x\n", hr
);
2866 IMimeMessage_BindToObject(iface
, hbody
, &IID_IMimeBody
, (void**)&mime_body
);
2868 IMimeBody_GetData(mime_body
, ietEncoding
, pStream
);
2870 IMimeBody_Release(mime_body
);
2874 static HRESULT WINAPI
MimeMessage_SetTextBody(
2875 IMimeMessage
*iface
,
2877 ENCODINGTYPE ietEncoding
,
2882 FIXME("(%p)->(%d, %d, %p, %p, %p)\n", iface
, dwTxtType
, ietEncoding
, hAlternative
, pStream
, phBody
);
2886 static HRESULT WINAPI
MimeMessage_AttachObject(
2887 IMimeMessage
*iface
,
2892 FIXME("(%p)->(%s, %p, %p)\n", iface
, debugstr_guid(riid
), pvObject
, phBody
);
2896 static HRESULT WINAPI
MimeMessage_AttachFile(
2897 IMimeMessage
*iface
,
2902 FIXME("(%p)->(%s, %p, %p)\n", iface
, pszFilePath
, pstmFile
, phBody
);
2906 static HRESULT WINAPI
MimeMessage_AttachURL(
2907 IMimeMessage
*iface
,
2915 FIXME("(%p)->(%s, %s, 0x%x, %p, %p, %p)\n", iface
, pszBase
, pszURL
, dwFlags
, pstmURL
, ppszCIDURL
, phBody
);
2919 static HRESULT WINAPI
MimeMessage_GetAttachments(
2920 IMimeMessage
*iface
,
2922 LPHBODY
*pprghAttach
)
2925 FINDBODY find_struct
;
2930 TRACE("(%p)->(%p, %p)\n", iface
, pcAttach
, pprghAttach
);
2933 array
= CoTaskMemAlloc(size
* sizeof(HBODY
));
2935 find_struct
.pszPriType
= find_struct
.pszSubType
= NULL
;
2936 hr
= IMimeMessage_FindFirst(iface
, &find_struct
, &hbody
);
2939 hr
= IMimeMessage_IsContentType(iface
, hbody
, "multipart", NULL
);
2940 TRACE("IsCT rets %08x %d\n", hr
, *pcAttach
);
2943 if(*pcAttach
+ 1 > size
)
2946 array
= CoTaskMemRealloc(array
, size
* sizeof(HBODY
));
2948 array
[*pcAttach
] = hbody
;
2951 hr
= IMimeMessage_FindNext(iface
, &find_struct
, &hbody
);
2954 *pprghAttach
= array
;
2958 static HRESULT WINAPI
MimeMessage_GetAddressTable(
2959 IMimeMessage
*iface
,
2960 IMimeAddressTable
**ppTable
)
2962 FIXME("(%p)->(%p)\n", iface
, ppTable
);
2966 static HRESULT WINAPI
MimeMessage_GetSender(
2967 IMimeMessage
*iface
,
2968 LPADDRESSPROPS pAddress
)
2970 FIXME("(%p)->(%p)\n", iface
, pAddress
);
2974 static HRESULT WINAPI
MimeMessage_GetAddressTypes(
2975 IMimeMessage
*iface
,
2978 LPADDRESSLIST pList
)
2980 FIXME("(%p)->(%d, %d, %p)\n", iface
, dwAdrTypes
, dwProps
, pList
);
2984 static HRESULT WINAPI
MimeMessage_GetAddressFormat(
2985 IMimeMessage
*iface
,
2987 ADDRESSFORMAT format
,
2990 FIXME("(%p)->(%d, %d, %p)\n", iface
, dwAdrTypes
, format
, ppszFormat
);
2994 static HRESULT WINAPI
MimeMessage_EnumAddressTypes(
2995 IMimeMessage
*iface
,
2998 IMimeEnumAddressTypes
**ppEnum
)
3000 FIXME("(%p)->(%d, %d, %p)\n", iface
, dwAdrTypes
, dwProps
, ppEnum
);
3004 static HRESULT WINAPI
MimeMessage_SplitMessage(
3005 IMimeMessage
*iface
,
3007 IMimeMessageParts
**ppParts
)
3009 FIXME("(%p)->(%d, %p)\n", iface
, cbMaxPart
, ppParts
);
3013 static HRESULT WINAPI
MimeMessage_GetRootMoniker(
3014 IMimeMessage
*iface
,
3015 IMoniker
**ppMoniker
)
3017 FIXME("(%p)->(%p)\n", iface
, ppMoniker
);
3021 static const IMimeMessageVtbl MimeMessageVtbl
=
3023 MimeMessage_QueryInterface
,
3025 MimeMessage_Release
,
3026 MimeMessage_GetClassID
,
3027 MimeMessage_IsDirty
,
3030 MimeMessage_GetSizeMax
,
3031 MimeMessage_InitNew
,
3032 MimeMessage_GetMessageSource
,
3033 MimeMessage_GetMessageSize
,
3034 MimeMessage_LoadOffsetTable
,
3035 MimeMessage_SaveOffsetTable
,
3036 MimeMessage_GetFlags
,
3038 MimeMessage_HandsOffStorage
,
3039 MimeMessage_BindToObject
,
3040 MimeMessage_SaveBody
,
3041 MimeMessage_InsertBody
,
3042 MimeMessage_GetBody
,
3043 MimeMessage_DeleteBody
,
3044 MimeMessage_MoveBody
,
3045 MimeMessage_CountBodies
,
3046 MimeMessage_FindFirst
,
3047 MimeMessage_FindNext
,
3048 MimeMessage_ResolveURL
,
3049 MimeMessage_ToMultipart
,
3050 MimeMessage_GetBodyOffsets
,
3051 MimeMessage_GetCharset
,
3052 MimeMessage_SetCharset
,
3053 MimeMessage_IsBodyType
,
3054 MimeMessage_IsContentType
,
3055 MimeMessage_QueryBodyProp
,
3056 MimeMessage_GetBodyProp
,
3057 MimeMessage_SetBodyProp
,
3058 MimeMessage_DeleteBodyProp
,
3059 MimeMessage_SetOption
,
3060 MimeMessage_GetOption
,
3061 MimeMessage_CreateWebPage
,
3062 MimeMessage_GetProp
,
3063 MimeMessage_SetProp
,
3064 MimeMessage_DeleteProp
,
3065 MimeMessage_QueryProp
,
3066 MimeMessage_GetTextBody
,
3067 MimeMessage_SetTextBody
,
3068 MimeMessage_AttachObject
,
3069 MimeMessage_AttachFile
,
3070 MimeMessage_AttachURL
,
3071 MimeMessage_GetAttachments
,
3072 MimeMessage_GetAddressTable
,
3073 MimeMessage_GetSender
,
3074 MimeMessage_GetAddressTypes
,
3075 MimeMessage_GetAddressFormat
,
3076 MimeMessage_EnumAddressTypes
,
3077 MimeMessage_SplitMessage
,
3078 MimeMessage_GetRootMoniker
,
3081 HRESULT
MimeMessage_create(IUnknown
*outer
, void **obj
)
3084 MimeBody
*mime_body
;
3087 TRACE("(%p, %p)\n", outer
, obj
);
3091 FIXME("outer unknown not supported yet\n");
3097 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
3098 if (!This
) return E_OUTOFMEMORY
;
3100 This
->IMimeMessage_iface
.lpVtbl
= &MimeMessageVtbl
;
3102 This
->stream
= NULL
;
3103 list_init(&This
->body_tree
);
3104 This
->next_index
= 1;
3106 mime_body
= mimebody_create();
3107 root_body
= new_body_entry(mime_body
, This
->next_index
++, NULL
);
3108 list_add_head(&This
->body_tree
, &root_body
->entry
);
3110 *obj
= &This
->IMimeMessage_iface
;
3114 /***********************************************************************
3115 * MimeOleCreateMessage (INETCOMM.@)
3117 HRESULT WINAPI
MimeOleCreateMessage(IUnknown
*pUnkOuter
, IMimeMessage
**ppMessage
)
3119 TRACE("(%p, %p)\n", pUnkOuter
, ppMessage
);
3120 return MimeMessage_create(NULL
, (void **)ppMessage
);
3123 /***********************************************************************
3124 * MimeOleSetCompatMode (INETCOMM.@)
3126 HRESULT WINAPI
MimeOleSetCompatMode(DWORD dwMode
)
3128 FIXME("(0x%x)\n", dwMode
);
3132 /***********************************************************************
3133 * MimeOleCreateVirtualStream (INETCOMM.@)
3135 HRESULT WINAPI
MimeOleCreateVirtualStream(IStream
**ppStream
)
3138 FIXME("(%p)\n", ppStream
);
3140 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, ppStream
);
3144 typedef struct MimeSecurity
3146 IMimeSecurity IMimeSecurity_iface
;
3150 static inline MimeSecurity
*impl_from_IMimeSecurity(IMimeSecurity
*iface
)
3152 return CONTAINING_RECORD(iface
, MimeSecurity
, IMimeSecurity_iface
);
3155 static HRESULT WINAPI
MimeSecurity_QueryInterface(IMimeSecurity
*iface
, REFIID riid
, void **ppv
)
3157 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ppv
);
3159 if (IsEqualIID(riid
, &IID_IUnknown
) ||
3160 IsEqualIID(riid
, &IID_IMimeSecurity
))
3163 IMimeSecurity_AddRef(iface
);
3167 FIXME("no interface for %s\n", debugstr_guid(riid
));
3169 return E_NOINTERFACE
;
3172 static ULONG WINAPI
MimeSecurity_AddRef(IMimeSecurity
*iface
)
3174 MimeSecurity
*This
= impl_from_IMimeSecurity(iface
);
3175 LONG ref
= InterlockedIncrement(&This
->ref
);
3177 TRACE("(%p) ref=%d\n", This
, ref
);
3182 static ULONG WINAPI
MimeSecurity_Release(IMimeSecurity
*iface
)
3184 MimeSecurity
*This
= impl_from_IMimeSecurity(iface
);
3185 LONG ref
= InterlockedDecrement(&This
->ref
);
3187 TRACE("(%p) ref=%d\n", This
, ref
);
3190 HeapFree(GetProcessHeap(), 0, This
);
3195 static HRESULT WINAPI
MimeSecurity_InitNew(
3196 IMimeSecurity
* iface
)
3198 FIXME("(%p)->(): stub\n", iface
);
3202 static HRESULT WINAPI
MimeSecurity_CheckInit(
3203 IMimeSecurity
* iface
)
3205 FIXME("(%p)->(): stub\n", iface
);
3209 static HRESULT WINAPI
MimeSecurity_EncodeMessage(
3210 IMimeSecurity
* iface
,
3211 IMimeMessageTree
* pTree
,
3214 FIXME("(%p)->(%p, %08x): stub\n", iface
, pTree
, dwFlags
);
3218 static HRESULT WINAPI
MimeSecurity_EncodeBody(
3219 IMimeSecurity
* iface
,
3220 IMimeMessageTree
* pTree
,
3224 FIXME("(%p)->(%p, %p, %08x): stub\n", iface
, pTree
, hEncodeRoot
, dwFlags
);
3228 static HRESULT WINAPI
MimeSecurity_DecodeMessage(
3229 IMimeSecurity
* iface
,
3230 IMimeMessageTree
* pTree
,
3233 FIXME("(%p)->(%p, %08x): stub\n", iface
, pTree
, dwFlags
);
3237 static HRESULT WINAPI
MimeSecurity_DecodeBody(
3238 IMimeSecurity
* iface
,
3239 IMimeMessageTree
* pTree
,
3243 FIXME("(%p)->(%p, %p, %08x): stub\n", iface
, pTree
, hDecodeRoot
, dwFlags
);
3247 static HRESULT WINAPI
MimeSecurity_EnumCertificates(
3248 IMimeSecurity
* iface
,
3254 FIXME("(%p)->(%p, %08x, %p, %p): stub\n", iface
, hc
, dwUsage
, pPrev
, ppCert
);
3258 static HRESULT WINAPI
MimeSecurity_GetCertificateName(
3259 IMimeSecurity
* iface
,
3260 const PCX509CERT pX509Cert
,
3261 const CERTNAMETYPE cn
,
3264 FIXME("(%p)->(%p, %08x, %p): stub\n", iface
, pX509Cert
, cn
, ppszName
);
3268 static HRESULT WINAPI
MimeSecurity_GetMessageType(
3269 IMimeSecurity
* iface
,
3270 const HWND hwndParent
,
3274 FIXME("(%p)->(%p, %p, %p): stub\n", iface
, hwndParent
, pBody
, pdwSecType
);
3278 static HRESULT WINAPI
MimeSecurity_GetCertData(
3279 IMimeSecurity
* iface
,
3280 const PCX509CERT pX509Cert
,
3281 const CERTDATAID dataid
,
3282 LPPROPVARIANT pValue
)
3284 FIXME("(%p)->(%p, %x, %p): stub\n", iface
, pX509Cert
, dataid
, pValue
);
3289 static const IMimeSecurityVtbl MimeSecurityVtbl
=
3291 MimeSecurity_QueryInterface
,
3292 MimeSecurity_AddRef
,
3293 MimeSecurity_Release
,
3294 MimeSecurity_InitNew
,
3295 MimeSecurity_CheckInit
,
3296 MimeSecurity_EncodeMessage
,
3297 MimeSecurity_EncodeBody
,
3298 MimeSecurity_DecodeMessage
,
3299 MimeSecurity_DecodeBody
,
3300 MimeSecurity_EnumCertificates
,
3301 MimeSecurity_GetCertificateName
,
3302 MimeSecurity_GetMessageType
,
3303 MimeSecurity_GetCertData
3306 HRESULT
MimeSecurity_create(IUnknown
*outer
, void **obj
)
3312 if (outer
) return CLASS_E_NOAGGREGATION
;
3314 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
3315 if (!This
) return E_OUTOFMEMORY
;
3317 This
->IMimeSecurity_iface
.lpVtbl
= &MimeSecurityVtbl
;
3320 *obj
= &This
->IMimeSecurity_iface
;
3324 /***********************************************************************
3325 * MimeOleCreateSecurity (INETCOMM.@)
3327 HRESULT WINAPI
MimeOleCreateSecurity(IMimeSecurity
**ppSecurity
)
3329 return MimeSecurity_create(NULL
, (void **)ppSecurity
);
3332 static HRESULT WINAPI
MimeAlloc_QueryInterface(
3333 IMimeAllocator
* iface
,
3337 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), obj
);
3339 if (IsEqualIID(riid
, &IID_IUnknown
) ||
3340 IsEqualIID(riid
, &IID_IMalloc
) ||
3341 IsEqualIID(riid
, &IID_IMimeAllocator
))
3344 IMimeAllocator_AddRef(iface
);
3348 FIXME("no interface for %s\n", debugstr_guid(riid
));
3350 return E_NOINTERFACE
;
3353 static ULONG WINAPI
MimeAlloc_AddRef(
3354 IMimeAllocator
* iface
)
3359 static ULONG WINAPI
MimeAlloc_Release(
3360 IMimeAllocator
* iface
)
3365 static LPVOID WINAPI
MimeAlloc_Alloc(
3366 IMimeAllocator
* iface
,
3369 return CoTaskMemAlloc(cb
);
3372 static LPVOID WINAPI
MimeAlloc_Realloc(
3373 IMimeAllocator
* iface
,
3377 return CoTaskMemRealloc(pv
, cb
);
3380 static void WINAPI
MimeAlloc_Free(
3381 IMimeAllocator
* iface
,
3387 static SIZE_T WINAPI
MimeAlloc_GetSize(
3388 IMimeAllocator
* iface
,
3395 static int WINAPI
MimeAlloc_DidAlloc(
3396 IMimeAllocator
* iface
,
3403 static void WINAPI
MimeAlloc_HeapMinimize(
3404 IMimeAllocator
* iface
)
3410 static HRESULT WINAPI
MimeAlloc_FreeParamInfoArray(
3411 IMimeAllocator
* iface
,
3413 LPMIMEPARAMINFO prgParam
,
3417 TRACE("(%p)->(%d, %p, %d)\n", iface
, cParams
, prgParam
, fFreeArray
);
3419 for(i
= 0; i
< cParams
; i
++)
3421 IMimeAllocator_Free(iface
, prgParam
[i
].pszName
);
3422 IMimeAllocator_Free(iface
, prgParam
[i
].pszData
);
3424 if(fFreeArray
) IMimeAllocator_Free(iface
, prgParam
);
3428 static HRESULT WINAPI
MimeAlloc_FreeAddressList(
3429 IMimeAllocator
* iface
,
3430 LPADDRESSLIST pList
)
3436 static HRESULT WINAPI
MimeAlloc_FreeAddressProps(
3437 IMimeAllocator
* iface
,
3438 LPADDRESSPROPS pAddress
)
3444 static HRESULT WINAPI
MimeAlloc_ReleaseObjects(
3445 IMimeAllocator
* iface
,
3447 IUnknown
**prgpUnknown
,
3455 static HRESULT WINAPI
MimeAlloc_FreeEnumHeaderRowArray(
3456 IMimeAllocator
* iface
,
3458 LPENUMHEADERROW prgRow
,
3465 static HRESULT WINAPI
MimeAlloc_FreeEnumPropertyArray(
3466 IMimeAllocator
* iface
,
3468 LPENUMPROPERTY prgProp
,
3475 static HRESULT WINAPI
MimeAlloc_FreeThumbprint(
3476 IMimeAllocator
* iface
,
3477 THUMBBLOB
*pthumbprint
)
3484 static HRESULT WINAPI
MimeAlloc_PropVariantClear(
3485 IMimeAllocator
* iface
,
3486 LPPROPVARIANT pProp
)
3492 static IMimeAllocatorVtbl mime_alloc_vtbl
=
3494 MimeAlloc_QueryInterface
,
3502 MimeAlloc_HeapMinimize
,
3503 MimeAlloc_FreeParamInfoArray
,
3504 MimeAlloc_FreeAddressList
,
3505 MimeAlloc_FreeAddressProps
,
3506 MimeAlloc_ReleaseObjects
,
3507 MimeAlloc_FreeEnumHeaderRowArray
,
3508 MimeAlloc_FreeEnumPropertyArray
,
3509 MimeAlloc_FreeThumbprint
,
3510 MimeAlloc_PropVariantClear
3513 static IMimeAllocator mime_allocator
=
3518 HRESULT
MimeAllocator_create(IUnknown
*outer
, void **obj
)
3520 if(outer
) return CLASS_E_NOAGGREGATION
;
3522 *obj
= &mime_allocator
;
3526 HRESULT WINAPI
MimeOleGetAllocator(IMimeAllocator
**alloc
)
3528 return MimeAllocator_create(NULL
, (void**)alloc
);
3531 HRESULT
VirtualStream_create(IUnknown
*outer
, void **obj
)
3533 FIXME("(%p, %p)\n", outer
, obj
);
3536 if (outer
) return CLASS_E_NOAGGREGATION
;
3538 return MimeOleCreateVirtualStream((IStream
**)obj
);
3541 /* IMimePropertySchema Interface */
3542 static HRESULT WINAPI
propschema_QueryInterface(IMimePropertySchema
*iface
, REFIID riid
, void **out
)
3544 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3545 TRACE("(%p)->(%s, %p)\n", This
, debugstr_guid(riid
), out
);
3549 if (IsEqualIID(riid
, &IID_IUnknown
) ||
3550 IsEqualIID(riid
, &IID_IMimePropertySchema
))
3556 FIXME("no interface for %s\n", debugstr_guid(riid
));
3557 return E_NOINTERFACE
;
3560 IMimePropertySchema_AddRef(iface
);
3564 static ULONG WINAPI
propschema_AddRef(IMimePropertySchema
*iface
)
3566 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3567 LONG ref
= InterlockedIncrement(&This
->ref
);
3569 TRACE("(%p) ref=%d\n", This
, ref
);
3574 static ULONG WINAPI
propschema_Release(IMimePropertySchema
*iface
)
3576 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3577 LONG ref
= InterlockedDecrement(&This
->ref
);
3579 TRACE("(%p) ref=%d\n", This
, ref
);
3583 HeapFree(GetProcessHeap(), 0, This
);
3589 static HRESULT WINAPI
propschema_RegisterProperty(IMimePropertySchema
*iface
, const char *name
, DWORD flags
,
3590 DWORD rownumber
, VARTYPE vtdefault
, DWORD
*propid
)
3592 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3593 FIXME("(%p)->(%s, %x, %d, %d, %p) stub\n", This
, debugstr_a(name
), flags
, rownumber
, vtdefault
, propid
);
3597 static HRESULT WINAPI
propschema_ModifyProperty(IMimePropertySchema
*iface
, const char *name
, DWORD flags
,
3598 DWORD rownumber
, VARTYPE vtdefault
)
3600 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3601 FIXME("(%p)->(%s, %x, %d, %d) stub\n", This
, debugstr_a(name
), flags
, rownumber
, vtdefault
);
3605 static HRESULT WINAPI
propschema_GetPropertyId(IMimePropertySchema
*iface
, const char *name
, DWORD
*propid
)
3607 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3608 FIXME("(%p)->(%s, %p) stub\n", This
, debugstr_a(name
), propid
);
3612 static HRESULT WINAPI
propschema_GetPropertyName(IMimePropertySchema
*iface
, DWORD propid
, char **name
)
3614 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3615 FIXME("(%p)->(%d, %p) stub\n", This
, propid
, name
);
3619 static HRESULT WINAPI
propschema_RegisterAddressType(IMimePropertySchema
*iface
, const char *name
, DWORD
*adrtype
)
3621 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3622 FIXME("(%p)->(%s, %p) stub\n", This
, debugstr_a(name
), adrtype
);
3626 static IMimePropertySchemaVtbl prop_schema_vtbl
=
3628 propschema_QueryInterface
,
3631 propschema_RegisterProperty
,
3632 propschema_ModifyProperty
,
3633 propschema_GetPropertyId
,
3634 propschema_GetPropertyName
,
3635 propschema_RegisterAddressType
3639 HRESULT WINAPI
MimeOleGetPropertySchema(IMimePropertySchema
**schema
)
3643 TRACE("(%p) stub\n", schema
);
3645 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
));
3647 return E_OUTOFMEMORY
;
3649 This
->IMimePropertySchema_iface
.lpVtbl
= &prop_schema_vtbl
;
3652 *schema
= &This
->IMimePropertySchema_iface
;
3657 HRESULT WINAPI
MimeGetAddressFormatW(REFIID riid
, void *object
, DWORD addr_type
,
3658 ADDRESSFORMAT addr_format
, WCHAR
**address
)
3660 FIXME("(%s, %p, %d, %d, %p) stub\n", debugstr_guid(riid
), object
, addr_type
, addr_format
, address
);
3665 static HRESULT WINAPI
mime_obj_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppv
)
3667 FIXME("(%s %p)\n", debugstr_guid(riid
), ppv
);
3669 return E_NOINTERFACE
;
3672 static ULONG WINAPI
mime_obj_AddRef(IUnknown
*iface
)
3678 static ULONG WINAPI
mime_obj_Release(IUnknown
*iface
)
3684 static const IUnknownVtbl mime_obj_vtbl
= {
3685 mime_obj_QueryInterface
,
3690 static IUnknown mime_obj
= { &mime_obj_vtbl
};
3692 HRESULT WINAPI
MimeOleObjectFromMoniker(BINDF bindf
, IMoniker
*moniker
, IBindCtx
*binding
,
3693 REFIID riid
, void **out
, IMoniker
**moniker_new
)
3695 WCHAR
*display_name
, *mhtml_url
;
3699 static const WCHAR mhtml_prefixW
[] = {'m','h','t','m','l',':'};
3701 WARN("(0x%08x, %p, %p, %s, %p, %p) semi-stub\n", bindf
, moniker
, binding
, debugstr_guid(riid
), out
, moniker_new
);
3703 if(!IsEqualGUID(&IID_IUnknown
, riid
)) {
3704 FIXME("Unsupported riid %s\n", debugstr_guid(riid
));
3705 return E_NOINTERFACE
;
3708 hres
= IMoniker_GetDisplayName(moniker
, NULL
, NULL
, &display_name
);
3712 TRACE("display name %s\n", debugstr_w(display_name
));
3714 len
= strlenW(display_name
);
3715 mhtml_url
= heap_alloc((len
+1)*sizeof(WCHAR
) + sizeof(mhtml_prefixW
));
3717 return E_OUTOFMEMORY
;
3719 memcpy(mhtml_url
, mhtml_prefixW
, sizeof(mhtml_prefixW
));
3720 strcpyW(mhtml_url
+ ARRAY_SIZE(mhtml_prefixW
), display_name
);
3721 HeapFree(GetProcessHeap(), 0, display_name
);
3723 hres
= CreateURLMoniker(NULL
, mhtml_url
, moniker_new
);
3724 heap_free(mhtml_url
);
3728 /* FIXME: We most likely should start binding here and return something more meaningful as mime object. */