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
34 #include "propvarutil.h"
36 #include "wine/list.h"
37 #include "wine/debug.h"
39 #include "inetcomm_private.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(inetcomm
);
47 DWORD flags
; /* MIMEPROPFLAGS */
55 } property_list_entry_t
;
57 static const property_t default_props
[] =
59 {"X-Newsgroup", PID_HDR_NEWSGROUP
, 0, VT_LPSTR
},
60 {"Newsgroups", PID_HDR_NEWSGROUPS
, 0, VT_LPSTR
},
61 {"References", PID_HDR_REFS
, 0, VT_LPSTR
},
62 {"Subject", PID_HDR_SUBJECT
, 0, VT_LPSTR
},
63 {"From", PID_HDR_FROM
, MPF_ADDRESS
, VT_LPSTR
},
64 {"Message-ID", PID_HDR_MESSAGEID
, 0, VT_LPSTR
},
65 {"Return-Path", PID_HDR_RETURNPATH
, MPF_ADDRESS
, VT_LPSTR
},
66 {"Rr", PID_HDR_RR
, 0, VT_LPSTR
},
67 {"Return-Receipt-To", PID_HDR_RETRCPTO
, MPF_ADDRESS
, VT_LPSTR
},
68 {"Apparently-To", PID_HDR_APPARTO
, MPF_ADDRESS
, VT_LPSTR
},
69 {"Date", PID_HDR_DATE
, 0, VT_LPSTR
},
70 {"Received", PID_HDR_RECEIVED
, 0, VT_LPSTR
},
71 {"Reply-To", PID_HDR_REPLYTO
, MPF_ADDRESS
, VT_LPSTR
},
72 {"X-Mailer", PID_HDR_XMAILER
, 0, VT_LPSTR
},
73 {"Bcc", PID_HDR_BCC
, MPF_ADDRESS
, VT_LPSTR
},
74 {"MIME-Version", PID_HDR_MIMEVER
, MPF_MIME
, VT_LPSTR
},
75 {"Content-Type", PID_HDR_CNTTYPE
, MPF_MIME
| MPF_HASPARAMS
, VT_LPSTR
},
76 {"Content-Transfer-Encoding", PID_HDR_CNTXFER
, MPF_MIME
, VT_LPSTR
},
77 {"Content-ID", PID_HDR_CNTID
, MPF_MIME
, VT_LPSTR
},
78 {"Content-Description", PID_HDR_CNTDESC
, MPF_MIME
, VT_LPSTR
},
79 {"Content-Disposition", PID_HDR_CNTDISP
, MPF_MIME
| MPF_HASPARAMS
, VT_LPSTR
},
80 {"Content-Base", PID_HDR_CNTBASE
, MPF_MIME
, VT_LPSTR
},
81 {"Content-Location", PID_HDR_CNTLOC
, MPF_MIME
, VT_LPSTR
},
82 {"To", PID_HDR_TO
, MPF_ADDRESS
, VT_LPSTR
},
83 {"Path", PID_HDR_PATH
, 0, VT_LPSTR
},
84 {"Followup-To", PID_HDR_FOLLOWUPTO
, 0, VT_LPSTR
},
85 {"Expires", PID_HDR_EXPIRES
, 0, VT_LPSTR
},
86 {"Cc", PID_HDR_CC
, MPF_ADDRESS
, VT_LPSTR
},
87 {"Control", PID_HDR_CONTROL
, 0, VT_LPSTR
},
88 {"Distribution", PID_HDR_DISTRIB
, 0, VT_LPSTR
},
89 {"Keywords", PID_HDR_KEYWORDS
, 0, VT_LPSTR
},
90 {"Summary", PID_HDR_SUMMARY
, 0, VT_LPSTR
},
91 {"Approved", PID_HDR_APPROVED
, 0, VT_LPSTR
},
92 {"Lines", PID_HDR_LINES
, 0, VT_LPSTR
},
93 {"Xref", PID_HDR_XREF
, 0, VT_LPSTR
},
94 {"Organization", PID_HDR_ORG
, 0, VT_LPSTR
},
95 {"X-Newsreader", PID_HDR_XNEWSRDR
, 0, VT_LPSTR
},
96 {"X-Priority", PID_HDR_XPRI
, 0, VT_LPSTR
},
97 {"X-MSMail-Priority", PID_HDR_XMSPRI
, 0, VT_LPSTR
},
98 {"par:content-disposition:filename", PID_PAR_FILENAME
, 0, VT_LPSTR
},
99 {"par:content-type:boundary", PID_PAR_BOUNDARY
, 0, VT_LPSTR
},
100 {"par:content-type:charset", PID_PAR_CHARSET
, 0, VT_LPSTR
},
101 {"par:content-type:name", PID_PAR_NAME
, 0, VT_LPSTR
},
102 {"att:filename", PID_ATT_FILENAME
, 0, VT_LPSTR
},
103 {"att:pri-content-type", PID_ATT_PRITYPE
, 0, VT_LPSTR
},
104 {"att:sub-content-type", PID_ATT_SUBTYPE
, 0, VT_LPSTR
},
105 {"att:illegal-lines", PID_ATT_ILLEGAL
, 0, VT_LPSTR
},
106 {"att:rendered", PID_ATT_RENDERED
, 0, VT_LPSTR
},
107 {"att:sent-time", PID_ATT_SENTTIME
, 0, VT_LPSTR
},
108 {"att:priority", PID_ATT_PRIORITY
, 0, VT_LPSTR
},
109 {"Comment", PID_HDR_COMMENT
, 0, VT_LPSTR
},
110 {"Encoding", PID_HDR_ENCODING
, 0, VT_LPSTR
},
111 {"Encrypted", PID_HDR_ENCRYPTED
, 0, VT_LPSTR
},
112 {"X-Offsets", PID_HDR_OFFSETS
, 0, VT_LPSTR
},
113 {"X-Unsent", PID_HDR_XUNSENT
, 0, VT_LPSTR
},
114 {"X-ArticleId", PID_HDR_ARTICLEID
, 0, VT_LPSTR
},
115 {"Sender", PID_HDR_SENDER
, MPF_ADDRESS
, VT_LPSTR
},
116 {"att:athena-server", PID_ATT_SERVER
, 0, VT_LPSTR
},
117 {"att:athena-account-id", PID_ATT_ACCOUNT
, 0, VT_LPSTR
},
118 {"att:athena-pop3-uidl", PID_ATT_UIDL
, 0, VT_LPSTR
},
119 {"att:athena-store-msgid", PID_ATT_STOREMSGID
, 0, VT_LPSTR
},
120 {"att:athena-user-name", PID_ATT_USERNAME
, 0, VT_LPSTR
},
121 {"att:athena-forward-to", PID_ATT_FORWARDTO
, 0, VT_LPSTR
},
122 {"att:athena-store-fdrid", PID_ATT_STOREFOLDERID
,0, VT_LPSTR
},
123 {"att:athena-ghosted", PID_ATT_GHOSTED
, 0, VT_LPSTR
},
124 {"att:athena-uncachedsize", PID_ATT_UNCACHEDSIZE
, 0, VT_LPSTR
},
125 {"att:athena-combined", PID_ATT_COMBINED
, 0, VT_LPSTR
},
126 {"att:auto-inlined", PID_ATT_AUTOINLINED
, 0, VT_LPSTR
},
127 {"Disposition-Notification-To", PID_HDR_DISP_NOTIFICATION_TO
, 0, VT_LPSTR
},
128 {"par:Content-Type:reply-type", PID_PAR_REPLYTYPE
, 0, VT_LPSTR
},
129 {"par:Content-Type:format", PID_PAR_FORMAT
, 0, VT_LPSTR
},
130 {"att:format", PID_ATT_FORMAT
, 0, VT_LPSTR
},
131 {"In-Reply-To", PID_HDR_INREPLYTO
, 0, VT_LPSTR
},
132 {"att:athena-account-name", PID_ATT_ACCOUNTNAME
, 0, VT_LPSTR
},
146 const property_t
*prop
;
151 typedef struct MimeBody
153 IMimeBody IMimeBody_iface
;
159 struct list new_props
; /* FIXME: This should be in a PropertySchema */
161 char *content_pri_type
;
162 char *content_sub_type
;
163 ENCODINGTYPE encoding
;
166 BODYOFFSETS body_offsets
;
171 IStream IStream_iface
;
174 ULARGE_INTEGER pos
, start
, length
;
177 static inline sub_stream_t
*impl_from_IStream(IStream
*iface
)
179 return CONTAINING_RECORD(iface
, sub_stream_t
, IStream_iface
);
182 static HRESULT WINAPI
sub_stream_QueryInterface(IStream
*iface
, REFIID riid
, void **ppv
)
184 sub_stream_t
*This
= impl_from_IStream(iface
);
186 TRACE("(%p)->(%s, %p)\n", This
, debugstr_guid(riid
), ppv
);
189 if(IsEqualIID(riid
, &IID_IUnknown
) ||
190 IsEqualIID(riid
, &IID_ISequentialStream
) ||
191 IsEqualIID(riid
, &IID_IStream
))
193 IStream_AddRef(iface
);
197 return E_NOINTERFACE
;
200 static ULONG WINAPI
sub_stream_AddRef(IStream
*iface
)
202 sub_stream_t
*This
= impl_from_IStream(iface
);
203 LONG ref
= InterlockedIncrement(&This
->ref
);
205 TRACE("(%p) ref=%ld\n", This
, ref
);
210 static ULONG WINAPI
sub_stream_Release(IStream
*iface
)
212 sub_stream_t
*This
= impl_from_IStream(iface
);
213 LONG ref
= InterlockedDecrement(&This
->ref
);
215 TRACE("(%p) ref=%ld\n", This
, ref
);
219 IStream_Release(This
->base
);
225 static HRESULT WINAPI
sub_stream_Read(
231 sub_stream_t
*This
= impl_from_IStream(iface
);
233 LARGE_INTEGER tmp_pos
;
235 TRACE("(%p, %ld, %p)\n", pv
, cb
, pcbRead
);
237 tmp_pos
.QuadPart
= This
->pos
.QuadPart
+ This
->start
.QuadPart
;
238 IStream_Seek(This
->base
, tmp_pos
, STREAM_SEEK_SET
, NULL
);
240 if(This
->pos
.QuadPart
+ cb
> This
->length
.QuadPart
)
241 cb
= This
->length
.QuadPart
- This
->pos
.QuadPart
;
243 hr
= IStream_Read(This
->base
, pv
, cb
, pcbRead
);
245 This
->pos
.QuadPart
+= *pcbRead
;
250 static HRESULT WINAPI
sub_stream_Write(
260 static HRESULT WINAPI
sub_stream_Seek(
262 LARGE_INTEGER dlibMove
,
264 ULARGE_INTEGER
*plibNewPosition
)
266 sub_stream_t
*This
= impl_from_IStream(iface
);
267 LARGE_INTEGER new_pos
;
269 TRACE("(%08lx.%08lx, %lx, %p)\n", dlibMove
.HighPart
, dlibMove
.LowPart
, dwOrigin
, plibNewPosition
);
273 case STREAM_SEEK_SET
:
276 case STREAM_SEEK_CUR
:
277 new_pos
.QuadPart
= This
->pos
.QuadPart
+ dlibMove
.QuadPart
;
279 case STREAM_SEEK_END
:
280 new_pos
.QuadPart
= This
->length
.QuadPart
+ dlibMove
.QuadPart
;
283 return STG_E_INVALIDFUNCTION
;
286 if(new_pos
.QuadPart
< 0) new_pos
.QuadPart
= 0;
287 else if(new_pos
.QuadPart
> This
->length
.QuadPart
) new_pos
.QuadPart
= This
->length
.QuadPart
;
289 This
->pos
.QuadPart
= new_pos
.QuadPart
;
291 if(plibNewPosition
) *plibNewPosition
= This
->pos
;
295 static HRESULT WINAPI
sub_stream_SetSize(
297 ULARGE_INTEGER libNewSize
)
303 static HRESULT WINAPI
sub_stream_CopyTo(
307 ULARGE_INTEGER
*pcbRead
,
308 ULARGE_INTEGER
*pcbWritten
)
312 ULONG bytesRead
, bytesWritten
, copySize
;
313 ULARGE_INTEGER totalBytesRead
;
314 ULARGE_INTEGER totalBytesWritten
;
316 TRACE("(%p)->(%p, %ld, %p, %p)\n", iface
, pstm
, cb
.LowPart
, pcbRead
, pcbWritten
);
318 totalBytesRead
.QuadPart
= 0;
319 totalBytesWritten
.QuadPart
= 0;
321 while ( cb
.QuadPart
> 0 )
323 if ( cb
.QuadPart
>= sizeof(tmpBuffer
) )
324 copySize
= sizeof(tmpBuffer
);
326 copySize
= cb
.LowPart
;
328 hr
= IStream_Read(iface
, tmpBuffer
, copySize
, &bytesRead
);
329 if (FAILED(hr
)) break;
331 totalBytesRead
.QuadPart
+= bytesRead
;
335 hr
= IStream_Write(pstm
, tmpBuffer
, bytesRead
, &bytesWritten
);
336 if (FAILED(hr
)) break;
337 totalBytesWritten
.QuadPart
+= bytesWritten
;
340 if (bytesRead
!= copySize
)
343 cb
.QuadPart
-= bytesRead
;
346 if (pcbRead
) pcbRead
->QuadPart
= totalBytesRead
.QuadPart
;
347 if (pcbWritten
) pcbWritten
->QuadPart
= totalBytesWritten
.QuadPart
;
352 static HRESULT WINAPI
sub_stream_Commit(
354 DWORD grfCommitFlags
)
360 static HRESULT WINAPI
sub_stream_Revert(
367 static HRESULT WINAPI
sub_stream_LockRegion(
369 ULARGE_INTEGER libOffset
,
377 static HRESULT WINAPI
sub_stream_UnlockRegion(
379 ULARGE_INTEGER libOffset
,
387 static HRESULT WINAPI
sub_stream_Stat(
392 sub_stream_t
*This
= impl_from_IStream(iface
);
393 FIXME("(%p)->(%p, %08lx)\n", This
, pstatstg
, grfStatFlag
);
394 memset(pstatstg
, 0, sizeof(*pstatstg
));
395 pstatstg
->cbSize
= This
->length
;
399 static HRESULT WINAPI
sub_stream_Clone(
407 static struct IStreamVtbl sub_stream_vtbl
=
409 sub_stream_QueryInterface
,
419 sub_stream_LockRegion
,
420 sub_stream_UnlockRegion
,
425 static HRESULT
create_sub_stream(IStream
*stream
, ULARGE_INTEGER start
, ULARGE_INTEGER length
, IStream
**out
)
430 This
= malloc(sizeof(*This
));
431 if(!This
) return E_OUTOFMEMORY
;
433 This
->IStream_iface
.lpVtbl
= &sub_stream_vtbl
;
436 This
->length
= length
;
437 This
->pos
.QuadPart
= 0;
438 IStream_AddRef(stream
);
441 *out
= &This
->IStream_iface
;
445 static HRESULT
get_stream_size(IStream
*stream
, ULARGE_INTEGER
*size
)
447 STATSTG statstg
= {NULL
};
451 hres
= IStream_Stat(stream
, &statstg
, STATFLAG_NONAME
);
452 if(SUCCEEDED(hres
)) {
453 *size
= statstg
.cbSize
;
458 return IStream_Seek(stream
, zero
, STREAM_SEEK_END
, size
);
461 static inline MimeBody
*impl_from_IMimeBody(IMimeBody
*iface
)
463 return CONTAINING_RECORD(iface
, MimeBody
, IMimeBody_iface
);
466 typedef struct propschema
468 IMimePropertySchema IMimePropertySchema_iface
;
472 static inline propschema
*impl_from_IMimePropertySchema(IMimePropertySchema
*iface
)
474 return CONTAINING_RECORD(iface
, propschema
, IMimePropertySchema_iface
);
477 #define PARSER_BUF_SIZE 1024
479 /*****************************************************
480 * copy_headers_to_buf [internal]
482 * Copies the headers into a '\0' terminated memory block and leave
483 * the stream's current position set to after the blank line.
485 static HRESULT
copy_headers_to_buf(IStream
*stm
, char **ptr
)
487 char *buf
= NULL
, *new_buf
;
488 DWORD size
= PARSER_BUF_SIZE
, offset
= 0, last_end
= 0;
500 new_buf
= realloc(buf
, size
+ 1);
508 hr
= IStream_Read(stm
, buf
+ offset
, size
- offset
, &read
);
509 if(FAILED(hr
)) goto fail
;
514 if(read
== 0) done
= TRUE
;
516 while(!done
&& (end
= strstr(buf
+ last_end
, "\r\n")))
518 DWORD new_end
= end
- buf
+ 2;
519 if(new_end
- last_end
== 2)
522 off
.QuadPart
= (LONGLONG
)new_end
- offset
;
523 IStream_Seek(stm
, off
, STREAM_SEEK_CUR
, NULL
);
540 static header_t
*read_prop(MimeBody
*body
, char **ptr
)
542 char *colon
= strchr(*ptr
, ':');
543 const property_t
*prop
;
546 if(!colon
) return NULL
;
550 for(prop
= default_props
; prop
->name
; prop
++)
552 if(!lstrcmpiA(*ptr
, prop
->name
))
554 TRACE("%s: found match with default property id %ld\n", *ptr
, prop
->id
);
561 property_list_entry_t
*prop_entry
;
562 LIST_FOR_EACH_ENTRY(prop_entry
, &body
->new_props
, property_list_entry_t
, entry
)
564 if(!lstrcmpiA(*ptr
, prop_entry
->prop
.name
))
566 TRACE("%s: found match with already added new property id %ld\n", *ptr
, prop_entry
->prop
.id
);
567 prop
= &prop_entry
->prop
;
573 prop_entry
= malloc(sizeof(*prop_entry
));
574 prop_entry
->prop
.name
= strdup(*ptr
);
575 prop_entry
->prop
.id
= body
->next_prop_id
++;
576 prop_entry
->prop
.flags
= 0;
577 prop_entry
->prop
.default_vt
= VT_LPSTR
;
578 list_add_tail(&body
->new_props
, &prop_entry
->entry
);
579 prop
= &prop_entry
->prop
;
580 TRACE("%s: allocating new prop id %ld\n", *ptr
, prop_entry
->prop
.id
);
584 ret
= malloc(sizeof(*ret
));
586 PropVariantInit(&ret
->value
);
587 list_init(&ret
->params
);
593 static void unfold_header(char *header
, int len
)
595 char *start
= header
, *cp
= header
;
598 while(*cp
== ' ' || *cp
== '\t')
604 memmove(start
, cp
, len
+ 1);
606 cp
= strstr(start
, "\r\n");
613 } while(*cp
== ' ' || *cp
== '\t');
618 static char *unquote_string(const char *str
)
623 while(*str
== ' ' || *str
== '\t') str
++;
631 for(cp
= ret
; *cp
; cp
++)
634 memmove(cp
, cp
+ 1, strlen(cp
+ 1) + 1);
639 WARN("quote in unquoted string\n");
651 static void add_param(header_t
*header
, const char *p
)
653 const char *key
= p
, *value
, *cp
= p
;
657 TRACE("got param %s\n", p
);
659 while (*key
== ' ' || *key
== '\t' ) key
++;
661 cp
= strchr(key
, '=');
664 WARN("malformed parameter - skipping\n");
668 name
= malloc(cp
- key
+ 1);
669 memcpy(name
, key
, cp
- key
);
670 name
[cp
- key
] = '\0';
674 param
= malloc(sizeof(*param
));
676 param
->value
= unquote_string(value
);
677 list_add_tail(&header
->params
, ¶m
->entry
);
680 static void split_params(header_t
*header
, char *value
)
682 char *cp
= value
, *start
= value
;
683 BOOL in_quotes
= FALSE
, done_value
= FALSE
;
687 if(!in_quotes
&& *cp
== ';')
690 if(done_value
) add_param(header
, start
);
695 in_quotes
= !in_quotes
;
698 if(done_value
) add_param(header
, start
);
701 static void read_value(header_t
*header
, char **cur
)
703 char *end
= *cur
, *value
;
707 end
= strstr(end
, "\r\n");
709 } while(*end
== ' ' || *end
== '\t');
712 value
= CoTaskMemAlloc(len
+ 1);
713 memcpy(value
, *cur
, len
);
716 unfold_header(value
, len
);
717 TRACE("value %s\n", debugstr_a(value
));
719 if(header
->prop
->flags
& MPF_HASPARAMS
)
721 split_params(header
, value
);
722 TRACE("value w/o params %s\n", debugstr_a(value
));
725 header
->value
.vt
= VT_LPSTR
;
726 header
->value
.pszVal
= value
;
731 static void init_content_type(MimeBody
*body
, header_t
*header
)
736 slash
= strchr(header
->value
.pszVal
, '/');
739 WARN("malformed context type value\n");
742 len
= slash
- header
->value
.pszVal
;
743 body
->content_pri_type
= malloc(len
+ 1);
744 memcpy(body
->content_pri_type
, header
->value
.pszVal
, len
);
745 body
->content_pri_type
[len
] = '\0';
746 body
->content_sub_type
= strdup(slash
+ 1);
749 static void init_content_encoding(MimeBody
*body
, header_t
*header
)
751 const char *encoding
= header
->value
.pszVal
;
753 if(!stricmp(encoding
, "base64"))
754 body
->encoding
= IET_BASE64
;
755 else if(!stricmp(encoding
, "quoted-printable"))
756 body
->encoding
= IET_QP
;
757 else if(!stricmp(encoding
, "7bit"))
758 body
->encoding
= IET_7BIT
;
759 else if(!stricmp(encoding
, "8bit"))
760 body
->encoding
= IET_8BIT
;
762 FIXME("unknown encoding %s\n", debugstr_a(encoding
));
765 static HRESULT
parse_headers(MimeBody
*body
, IStream
*stm
)
767 char *header_buf
, *cur_header_ptr
;
771 hr
= copy_headers_to_buf(stm
, &header_buf
);
772 if(FAILED(hr
)) return hr
;
774 cur_header_ptr
= header_buf
;
775 while((header
= read_prop(body
, &cur_header_ptr
)))
777 read_value(header
, &cur_header_ptr
);
778 list_add_tail(&body
->headers
, &header
->entry
);
780 switch(header
->prop
->id
) {
781 case PID_HDR_CNTTYPE
:
782 init_content_type(body
, header
);
784 case PID_HDR_CNTXFER
:
785 init_content_encoding(body
, header
);
794 static void empty_param_list(struct list
*list
)
796 param_t
*param
, *cursor2
;
798 LIST_FOR_EACH_ENTRY_SAFE(param
, cursor2
, list
, param_t
, entry
)
800 list_remove(¶m
->entry
);
807 static void free_header(header_t
*header
)
809 list_remove(&header
->entry
);
810 PropVariantClear(&header
->value
);
811 empty_param_list(&header
->params
);
815 static void empty_header_list(struct list
*list
)
817 header_t
*header
, *cursor2
;
819 LIST_FOR_EACH_ENTRY_SAFE(header
, cursor2
, list
, header_t
, entry
)
825 static void empty_new_prop_list(struct list
*list
)
827 property_list_entry_t
*prop
, *cursor2
;
829 LIST_FOR_EACH_ENTRY_SAFE(prop
, cursor2
, list
, property_list_entry_t
, entry
)
831 list_remove(&prop
->entry
);
832 free((char *)prop
->prop
.name
);
837 static void release_data(REFIID riid
, void *data
)
841 if(IsEqualIID(riid
, &IID_IStream
))
842 IStream_Release((IStream
*)data
);
844 FIXME("Unhandled data format %s\n", debugstr_guid(riid
));
847 static HRESULT
find_prop(MimeBody
*body
, const char *name
, header_t
**prop
)
853 LIST_FOR_EACH_ENTRY(header
, &body
->headers
, header_t
, entry
)
857 if(STRTOPID(name
) == header
->prop
->id
)
863 else if(!lstrcmpiA(name
, header
->prop
->name
))
870 return MIME_E_NOT_FOUND
;
873 static const property_t
*find_default_prop(const char *name
)
875 const property_t
*prop_def
= NULL
;
877 for(prop_def
= default_props
; prop_def
->name
; prop_def
++)
881 if(STRTOPID(name
) == prop_def
->id
)
886 else if(!lstrcmpiA(name
, prop_def
->name
))
893 TRACE("%s: found match with default property id %ld\n", prop_def
->name
, prop_def
->id
);
900 static HRESULT WINAPI
MimeBody_QueryInterface(IMimeBody
* iface
,
904 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ppvObject
);
908 if (IsEqualIID(riid
, &IID_IUnknown
) ||
909 IsEqualIID(riid
, &IID_IPersist
) ||
910 IsEqualIID(riid
, &IID_IPersistStreamInit
) ||
911 IsEqualIID(riid
, &IID_IMimePropertySet
) ||
912 IsEqualIID(riid
, &IID_IMimeBody
))
919 IUnknown_AddRef((IUnknown
*)*ppvObject
);
923 FIXME("no interface for %s\n", debugstr_guid(riid
));
924 return E_NOINTERFACE
;
927 static ULONG WINAPI
MimeBody_AddRef(IMimeBody
*iface
)
929 MimeBody
*This
= impl_from_IMimeBody(iface
);
930 LONG ref
= InterlockedIncrement(&This
->ref
);
932 TRACE("(%p) ref=%ld\n", This
, ref
);
937 static ULONG WINAPI
MimeBody_Release(IMimeBody
*iface
)
939 MimeBody
*This
= impl_from_IMimeBody(iface
);
940 LONG ref
= InterlockedDecrement(&This
->ref
);
942 TRACE("(%p) ref=%ld\n", This
, ref
);
946 empty_header_list(&This
->headers
);
947 empty_new_prop_list(&This
->new_props
);
949 free(This
->content_pri_type
);
950 free(This
->content_sub_type
);
952 release_data(&This
->data_iid
, This
->data
);
960 static HRESULT WINAPI
MimeBody_GetClassID(
964 MimeBody
*This
= impl_from_IMimeBody(iface
);
966 TRACE("(%p)->(%p)\n", This
, pClassID
);
971 *pClassID
= IID_IMimeBody
;
975 static HRESULT WINAPI
MimeBody_IsDirty(
978 MimeBody
*This
= impl_from_IMimeBody(iface
);
979 FIXME("(%p)->() stub\n", This
);
983 static HRESULT WINAPI
MimeBody_Load(IMimeBody
*iface
, IStream
*pStm
)
985 MimeBody
*This
= impl_from_IMimeBody(iface
);
986 TRACE("(%p)->(%p)\n", This
, pStm
);
987 return parse_headers(This
, pStm
);
990 static HRESULT WINAPI
MimeBody_Save(IMimeBody
*iface
, IStream
*pStm
, BOOL fClearDirty
)
992 MimeBody
*This
= impl_from_IMimeBody(iface
);
993 FIXME("(%p)->(%p, %d)\n", This
, pStm
, fClearDirty
);
997 static HRESULT WINAPI
MimeBody_GetSizeMax(
999 ULARGE_INTEGER
* pcbSize
)
1001 MimeBody
*This
= impl_from_IMimeBody(iface
);
1002 FIXME("(%p)->(%p) stub\n", This
, pcbSize
);
1006 static HRESULT WINAPI
MimeBody_InitNew(
1009 MimeBody
*This
= impl_from_IMimeBody(iface
);
1010 TRACE("(%p)->()\n", This
);
1014 static HRESULT WINAPI
MimeBody_GetPropInfo(
1017 LPMIMEPROPINFO pInfo
)
1019 MimeBody
*This
= impl_from_IMimeBody(iface
);
1022 DWORD supported
= PIM_PROPID
| PIM_VTDEFAULT
;
1024 TRACE("(%p)->(%s, %p) semi-stub\n", This
, debugstr_a(pszName
), pInfo
);
1026 if(!pszName
|| !pInfo
)
1027 return E_INVALIDARG
;
1029 TRACE("mask 0x%04lx\n", pInfo
->dwMask
);
1031 if(pInfo
->dwMask
& ~supported
)
1032 FIXME("Unsupported mask flags 0x%04lx\n", pInfo
->dwMask
& ~supported
);
1034 hr
= find_prop(This
, pszName
, &header
);
1037 if(pInfo
->dwMask
& PIM_CHARSET
)
1038 pInfo
->hCharset
= 0;
1039 if(pInfo
->dwMask
& PIM_FLAGS
)
1040 pInfo
->dwFlags
= 0x00000000;
1041 if(pInfo
->dwMask
& PIM_ROWNUMBER
)
1042 pInfo
->dwRowNumber
= 0;
1043 if(pInfo
->dwMask
& PIM_ENCODINGTYPE
)
1044 pInfo
->ietEncoding
= 0;
1045 if(pInfo
->dwMask
& PIM_VALUES
)
1047 if(pInfo
->dwMask
& PIM_PROPID
)
1048 pInfo
->dwPropId
= header
->prop
->id
;
1049 if(pInfo
->dwMask
& PIM_VTDEFAULT
)
1050 pInfo
->vtDefault
= header
->prop
->default_vt
;
1051 if(pInfo
->dwMask
& PIM_VTCURRENT
)
1052 pInfo
->vtCurrent
= 0;
1058 static HRESULT WINAPI
MimeBody_SetPropInfo(
1061 LPCMIMEPROPINFO pInfo
)
1063 MimeBody
*This
= impl_from_IMimeBody(iface
);
1064 FIXME("(%p)->(%s, %p) stub\n", This
, debugstr_a(pszName
), pInfo
);
1068 static HRESULT WINAPI
MimeBody_GetProp(
1072 LPPROPVARIANT pValue
)
1074 MimeBody
*This
= impl_from_IMimeBody(iface
);
1078 TRACE("(%p)->(%s, 0x%lx, %p)\n", This
, debugstr_a(pszName
), dwFlags
, pValue
);
1080 if(!pszName
|| !pValue
)
1081 return E_INVALIDARG
;
1083 if(!ISPIDSTR(pszName
) && !lstrcmpiA(pszName
, "att:pri-content-type"))
1085 PropVariantClear(pValue
);
1086 pValue
->vt
= VT_LPSTR
;
1087 pValue
->pszVal
= CoTaskMemAlloc(strlen(This
->content_pri_type
) + 1);
1088 strcpy(pValue
->pszVal
, This
->content_pri_type
);
1092 hr
= find_prop(This
, pszName
, &header
);
1095 TRACE("type %d->%d\n", header
->value
.vt
, pValue
->vt
);
1097 hr
= PropVariantChangeType(pValue
, &header
->value
, 0, pValue
->vt
);
1099 FIXME("Conversion not currently supported (%d->%d)\n", header
->value
.vt
, pValue
->vt
);
1105 static HRESULT WINAPI
MimeBody_SetProp(
1109 LPCPROPVARIANT pValue
)
1111 MimeBody
*This
= impl_from_IMimeBody(iface
);
1115 TRACE("(%p)->(%s, 0x%lx, %p)\n", This
, debugstr_a(pszName
), dwFlags
, pValue
);
1117 if(!pszName
|| !pValue
)
1118 return E_INVALIDARG
;
1120 hr
= find_prop(This
, pszName
, &header
);
1123 property_list_entry_t
*prop_entry
;
1124 const property_t
*prop
= NULL
;
1126 LIST_FOR_EACH_ENTRY(prop_entry
, &This
->new_props
, property_list_entry_t
, entry
)
1128 if(ISPIDSTR(pszName
))
1130 if(STRTOPID(pszName
) == prop_entry
->prop
.id
)
1132 TRACE("Found match with already added new property id %ld\n", prop_entry
->prop
.id
);
1133 prop
= &prop_entry
->prop
;
1137 else if(!lstrcmpiA(pszName
, prop_entry
->prop
.name
))
1139 TRACE("Found match with already added new property id %ld\n", prop_entry
->prop
.id
);
1140 prop
= &prop_entry
->prop
;
1145 header
= malloc(sizeof(*header
));
1147 return E_OUTOFMEMORY
;
1151 const property_t
*prop_def
= NULL
;
1152 prop_entry
= malloc(sizeof(*prop_entry
));
1156 return E_OUTOFMEMORY
;
1159 prop_def
= find_default_prop(pszName
);
1162 prop_entry
->prop
.name
= strdup(prop_def
->name
);
1163 prop_entry
->prop
.id
= prop_def
->id
;
1167 if(ISPIDSTR(pszName
))
1171 return MIME_E_NOT_FOUND
;
1174 prop_entry
->prop
.name
= strdup(pszName
);
1175 prop_entry
->prop
.id
= This
->next_prop_id
++;
1178 prop_entry
->prop
.flags
= 0;
1179 prop_entry
->prop
.default_vt
= pValue
->vt
;
1180 list_add_tail(&This
->new_props
, &prop_entry
->entry
);
1181 prop
= &prop_entry
->prop
;
1182 TRACE("Allocating new prop id %ld\n", prop_entry
->prop
.id
);
1185 header
->prop
= prop
;
1186 PropVariantInit(&header
->value
);
1187 list_init(&header
->params
);
1188 list_add_tail(&This
->headers
, &header
->entry
);
1191 PropVariantCopy(&header
->value
, pValue
);
1196 static HRESULT WINAPI
MimeBody_AppendProp(
1200 LPPROPVARIANT pValue
)
1202 MimeBody
*This
= impl_from_IMimeBody(iface
);
1203 FIXME("(%p)->(%s, 0x%lx, %p) stub\n", This
, debugstr_a(pszName
), dwFlags
, pValue
);
1207 static HRESULT WINAPI
MimeBody_DeleteProp(
1211 MimeBody
*This
= impl_from_IMimeBody(iface
);
1215 TRACE("(%p)->(%s) stub\n", This
, debugstr_a(pszName
));
1217 LIST_FOR_EACH_ENTRY(cursor
, &This
->headers
, header_t
, entry
)
1219 if(ISPIDSTR(pszName
))
1220 found
= STRTOPID(pszName
) == cursor
->prop
->id
;
1222 found
= !lstrcmpiA(pszName
, cursor
->prop
->name
);
1226 free_header(cursor
);
1231 return MIME_E_NOT_FOUND
;
1234 static HRESULT WINAPI
MimeBody_CopyProps(
1238 IMimePropertySet
* pPropertySet
)
1240 MimeBody
*This
= impl_from_IMimeBody(iface
);
1241 FIXME("(%p)->(%ld, %p, %p) stub\n", This
, cNames
, prgszName
, pPropertySet
);
1245 static HRESULT WINAPI
MimeBody_MoveProps(
1249 IMimePropertySet
* pPropertySet
)
1251 MimeBody
*This
= impl_from_IMimeBody(iface
);
1252 FIXME("(%p)->(%ld, %p, %p) stub\n", This
, cNames
, prgszName
, pPropertySet
);
1256 static HRESULT WINAPI
MimeBody_DeleteExcept(
1261 MimeBody
*This
= impl_from_IMimeBody(iface
);
1262 FIXME("(%p)->(%ld, %p) stub\n", This
, cNames
, prgszName
);
1266 static HRESULT WINAPI
MimeBody_QueryProp(
1271 boolean fCaseSensitive
)
1273 MimeBody
*This
= impl_from_IMimeBody(iface
);
1274 FIXME("(%p)->(%s, %s, %d, %d) stub\n", This
, debugstr_a(pszName
), debugstr_a(pszCriteria
), fSubString
, fCaseSensitive
);
1278 static HRESULT WINAPI
MimeBody_GetCharset(
1280 LPHCHARSET phCharset
)
1282 MimeBody
*This
= impl_from_IMimeBody(iface
);
1283 FIXME("(%p)->(%p) stub\n", This
, phCharset
);
1288 static HRESULT WINAPI
MimeBody_SetCharset(
1291 CSETAPPLYTYPE applytype
)
1293 MimeBody
*This
= impl_from_IMimeBody(iface
);
1294 FIXME("(%p)->(%p, %d) stub\n", This
, hCharset
, applytype
);
1298 static HRESULT WINAPI
MimeBody_GetParameters(
1302 LPMIMEPARAMINFO
* pprgParam
)
1304 MimeBody
*This
= impl_from_IMimeBody(iface
);
1308 TRACE("(%p)->(%s, %p, %p)\n", iface
, debugstr_a(pszName
), pcParams
, pprgParam
);
1313 hr
= find_prop(This
, pszName
, &header
);
1314 if(hr
!= S_OK
) return hr
;
1316 *pcParams
= list_count(&header
->params
);
1319 IMimeAllocator
*alloc
;
1321 MIMEPARAMINFO
*info
;
1323 MimeOleGetAllocator(&alloc
);
1325 *pprgParam
= info
= IMimeAllocator_Alloc(alloc
, *pcParams
* sizeof(**pprgParam
));
1326 LIST_FOR_EACH_ENTRY(param
, &header
->params
, param_t
, entry
)
1330 len
= strlen(param
->name
) + 1;
1331 info
->pszName
= IMimeAllocator_Alloc(alloc
, len
);
1332 memcpy(info
->pszName
, param
->name
, len
);
1333 len
= strlen(param
->value
) + 1;
1334 info
->pszData
= IMimeAllocator_Alloc(alloc
, len
);
1335 memcpy(info
->pszData
, param
->value
, len
);
1338 IMimeAllocator_Release(alloc
);
1343 static HRESULT WINAPI
MimeBody_IsContentType(
1348 MimeBody
*This
= impl_from_IMimeBody(iface
);
1350 TRACE("(%p)->(%s, %s)\n", This
, debugstr_a(pszPriType
), debugstr_a(pszSubType
));
1353 const char *pri
= This
->content_pri_type
;
1354 if(!pri
) pri
= "text";
1355 if(lstrcmpiA(pri
, pszPriType
)) return S_FALSE
;
1360 const char *sub
= This
->content_sub_type
;
1361 if(!sub
) sub
= "plain";
1362 if(lstrcmpiA(sub
, pszSubType
)) return S_FALSE
;
1368 static HRESULT WINAPI
MimeBody_BindToObject(
1373 MimeBody
*This
= impl_from_IMimeBody(iface
);
1374 FIXME("(%p)->(%s, %p) stub\n", This
, debugstr_guid(riid
), ppvObject
);
1378 static HRESULT WINAPI
MimeBody_Clone(
1380 IMimePropertySet
** ppPropertySet
)
1382 MimeBody
*This
= impl_from_IMimeBody(iface
);
1383 FIXME("(%p)->(%p) stub\n", This
, ppPropertySet
);
1387 static HRESULT WINAPI
MimeBody_SetOption(
1390 LPCPROPVARIANT pValue
)
1392 MimeBody
*This
= impl_from_IMimeBody(iface
);
1393 HRESULT hr
= E_NOTIMPL
;
1394 TRACE("(%p)->(%08lx, %p)\n", This
, oid
, pValue
);
1396 if(pValue
->vt
!= TYPEDID_TYPE(oid
))
1398 WARN("Called with vartype %04x and oid %08lx\n", pValue
->vt
, oid
);
1399 return E_INVALIDARG
;
1404 case OID_SECURITY_HWND_OWNER
:
1405 FIXME("OID_SECURITY_HWND_OWNER (value %08lx): ignoring\n", pValue
->ulVal
);
1408 case OID_TRANSMIT_BODY_ENCODING
:
1409 FIXME("OID_TRANSMIT_BODY_ENCODING (value %08lx): ignoring\n", pValue
->ulVal
);
1413 FIXME("Unhandled oid %08lx\n", oid
);
1419 static HRESULT WINAPI
MimeBody_GetOption(
1422 LPPROPVARIANT pValue
)
1424 MimeBody
*This
= impl_from_IMimeBody(iface
);
1425 FIXME("(%p)->(%08lx, %p): stub\n", This
, oid
, pValue
);
1429 static HRESULT WINAPI
MimeBody_EnumProps(
1432 IMimeEnumProperties
** ppEnum
)
1434 MimeBody
*This
= impl_from_IMimeBody(iface
);
1435 FIXME("(%p)->(0x%lx, %p) stub\n", This
, dwFlags
, ppEnum
);
1439 static HRESULT WINAPI
MimeBody_IsType(
1441 IMSGBODYTYPE bodytype
)
1443 MimeBody
*This
= impl_from_IMimeBody(iface
);
1445 TRACE("(%p)->(%d)\n", This
, bodytype
);
1449 return This
->data
? S_FALSE
: S_OK
;
1451 FIXME("Unimplemented bodytype %d - returning S_OK\n", bodytype
);
1456 static HRESULT WINAPI
MimeBody_SetDisplayName(
1460 MimeBody
*This
= impl_from_IMimeBody(iface
);
1461 FIXME("(%p)->(%s) stub\n", This
, debugstr_a(pszDisplay
));
1465 static HRESULT WINAPI
MimeBody_GetDisplayName(
1469 MimeBody
*This
= impl_from_IMimeBody(iface
);
1470 FIXME("(%p)->(%p) stub\n", This
, ppszDisplay
);
1474 static HRESULT WINAPI
MimeBody_GetOffsets(
1476 LPBODYOFFSETS pOffsets
)
1478 MimeBody
*This
= impl_from_IMimeBody(iface
);
1479 TRACE("(%p)->(%p)\n", This
, pOffsets
);
1481 *pOffsets
= This
->body_offsets
;
1483 if(This
->body_offsets
.cbBodyEnd
== 0) return MIME_E_NO_DATA
;
1487 static HRESULT WINAPI
MimeBody_GetCurrentEncoding(
1489 ENCODINGTYPE
* pietEncoding
)
1491 MimeBody
*This
= impl_from_IMimeBody(iface
);
1493 TRACE("(%p)->(%p)\n", This
, pietEncoding
);
1495 *pietEncoding
= This
->encoding
;
1499 static HRESULT WINAPI
MimeBody_SetCurrentEncoding(
1501 ENCODINGTYPE ietEncoding
)
1503 MimeBody
*This
= impl_from_IMimeBody(iface
);
1505 TRACE("(%p)->(%d)\n", This
, ietEncoding
);
1507 This
->encoding
= ietEncoding
;
1511 static HRESULT WINAPI
MimeBody_GetEstimatedSize(
1513 ENCODINGTYPE ietEncoding
,
1516 MimeBody
*This
= impl_from_IMimeBody(iface
);
1517 FIXME("(%p)->(%d, %p) stub\n", This
, ietEncoding
, pcbSize
);
1521 static HRESULT WINAPI
MimeBody_GetDataHere(
1523 ENCODINGTYPE ietEncoding
,
1526 MimeBody
*This
= impl_from_IMimeBody(iface
);
1527 FIXME("(%p)->(%d, %p) stub\n", This
, ietEncoding
, pStream
);
1531 static const signed char base64_decode_table
[] =
1533 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x00 */
1534 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 0x10 */
1535 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, /* 0x20 */
1536 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, /* 0x30 */
1537 -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 0x40 */
1538 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, /* 0x50 */
1539 -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, /* 0x60 */
1540 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1 /* 0x70 */
1543 static HRESULT
decode_base64(IStream
*input
, IStream
**ret_stream
)
1545 const unsigned char *ptr
, *end
;
1546 unsigned char buf
[1024];
1549 unsigned char in
[4];
1556 hres
= IStream_Seek(input
, pos
, STREAM_SEEK_SET
, NULL
);
1560 hres
= CreateStreamOnHGlobal(NULL
, TRUE
, &output
);
1565 hres
= IStream_Read(input
, buf
, sizeof(buf
), &size
);
1566 if(FAILED(hres
) || !size
)
1573 /* skip invalid chars */
1574 while(ptr
< end
&& (*ptr
>= ARRAY_SIZE(base64_decode_table
)
1575 || base64_decode_table
[*ptr
] == -1))
1580 in
[n
++] = base64_decode_table
[*ptr
++];
1583 *ret
++ = in
[0] << 2 | in
[1] >> 4;
1586 *ret
++ = in
[1] << 4 | in
[2] >> 2;
1589 *ret
++ = ((in
[2] << 6) & 0xc0) | in
[3];
1595 hres
= IStream_Write(output
, buf
, ret
- buf
, NULL
);
1602 hres
= IStream_Seek(output
, pos
, STREAM_SEEK_SET
, NULL
);
1604 IStream_Release(output
);
1608 *ret_stream
= output
;
1612 static int hex_digit(char c
)
1614 if('0' <= c
&& c
<= '9')
1616 if('A' <= c
&& c
<= 'F')
1617 return c
- 'A' + 10;
1618 if('a' <= c
&& c
<= 'f')
1619 return c
- 'a' + 10;
1623 static HRESULT
decode_qp(IStream
*input
, IStream
**ret_stream
)
1625 const unsigned char *ptr
, *end
;
1626 unsigned char *ret
, prev
= 0;
1627 unsigned char buf
[1024];
1635 hres
= IStream_Seek(input
, pos
, STREAM_SEEK_SET
, NULL
);
1639 hres
= CreateStreamOnHGlobal(NULL
, TRUE
, &output
);
1644 hres
= IStream_Read(input
, buf
, sizeof(buf
), &size
);
1645 if(FAILED(hres
) || !size
)
1652 unsigned char byte
= *ptr
++;
1666 if(prev
!= '\r' || byte
!= '\n') {
1667 int h1
= hex_digit(prev
), h2
= hex_digit(byte
);
1668 if(h1
!= -1 && h2
!= -1)
1669 *ret
++ = (h1
<< 4) | h2
;
1679 hres
= IStream_Write(output
, buf
, ret
- buf
, NULL
);
1686 hres
= IStream_Seek(output
, pos
, STREAM_SEEK_SET
, NULL
);
1688 IStream_Release(output
);
1692 *ret_stream
= output
;
1696 static HRESULT WINAPI
MimeBody_GetData(
1698 ENCODINGTYPE ietEncoding
,
1701 MimeBody
*This
= impl_from_IMimeBody(iface
);
1702 ULARGE_INTEGER start
, size
;
1705 TRACE("(%p)->(%d %p)\n", This
, ietEncoding
, ppStream
);
1707 if(This
->encoding
!= ietEncoding
) {
1708 switch(This
->encoding
) {
1710 hres
= decode_base64(This
->data
, ppStream
);
1713 hres
= decode_qp(This
->data
, ppStream
);
1716 FIXME("Decoding %d is not supported.\n", This
->encoding
);
1719 if(ietEncoding
!= IET_BINARY
)
1720 FIXME("Encoding %d is not supported.\n", ietEncoding
);
1726 hres
= get_stream_size(This
->data
, &size
);
1728 hres
= create_sub_stream(This
->data
, start
, size
, ppStream
);
1732 static HRESULT WINAPI
MimeBody_SetData(
1734 ENCODINGTYPE ietEncoding
,
1740 MimeBody
*This
= impl_from_IMimeBody(iface
);
1741 TRACE("(%p)->(%d, %s, %s, %s %p)\n", This
, ietEncoding
, debugstr_a(pszPriType
), debugstr_a(pszSubType
),
1742 debugstr_guid(riid
), pvObject
);
1744 if(IsEqualIID(riid
, &IID_IStream
))
1745 IStream_AddRef((IStream
*)pvObject
);
1748 FIXME("Unhandled object type %s\n", debugstr_guid(riid
));
1749 return E_INVALIDARG
;
1753 release_data(&This
->data_iid
, This
->data
);
1755 This
->data_iid
= *riid
;
1756 This
->data
= pvObject
;
1758 IMimeBody_SetCurrentEncoding(iface
, ietEncoding
);
1760 /* FIXME: Update the content type.
1761 If pszPriType == NULL use 'application'
1762 If pszSubType == NULL use 'octet-stream' */
1767 static HRESULT WINAPI
MimeBody_EmptyData(
1770 MimeBody
*This
= impl_from_IMimeBody(iface
);
1771 FIXME("(%p)->() stub\n", This
);
1775 static HRESULT WINAPI
MimeBody_CopyTo(
1779 MimeBody
*This
= impl_from_IMimeBody(iface
);
1780 FIXME("(%p)->(%p) stub\n", This
, pBody
);
1784 static HRESULT WINAPI
MimeBody_GetTransmitInfo(
1786 LPTRANSMITINFO pTransmitInfo
)
1788 MimeBody
*This
= impl_from_IMimeBody(iface
);
1789 FIXME("(%p)->(%p) stub\n", This
, pTransmitInfo
);
1793 static HRESULT WINAPI
MimeBody_SaveToFile(
1795 ENCODINGTYPE ietEncoding
,
1798 MimeBody
*This
= impl_from_IMimeBody(iface
);
1799 FIXME("(%p)->(%d, %s) stub\n", This
, ietEncoding
, debugstr_a(pszFilePath
));
1803 static HRESULT WINAPI
MimeBody_GetHandle(
1807 MimeBody
*This
= impl_from_IMimeBody(iface
);
1808 TRACE("(%p)->(%p)\n", iface
, phBody
);
1811 return E_INVALIDARG
;
1813 *phBody
= This
->handle
;
1814 return This
->handle
? S_OK
: MIME_E_NO_DATA
;
1817 static IMimeBodyVtbl body_vtbl
=
1819 MimeBody_QueryInterface
,
1822 MimeBody_GetClassID
,
1826 MimeBody_GetSizeMax
,
1828 MimeBody_GetPropInfo
,
1829 MimeBody_SetPropInfo
,
1832 MimeBody_AppendProp
,
1833 MimeBody_DeleteProp
,
1836 MimeBody_DeleteExcept
,
1838 MimeBody_GetCharset
,
1839 MimeBody_SetCharset
,
1840 MimeBody_GetParameters
,
1841 MimeBody_IsContentType
,
1842 MimeBody_BindToObject
,
1848 MimeBody_SetDisplayName
,
1849 MimeBody_GetDisplayName
,
1850 MimeBody_GetOffsets
,
1851 MimeBody_GetCurrentEncoding
,
1852 MimeBody_SetCurrentEncoding
,
1853 MimeBody_GetEstimatedSize
,
1854 MimeBody_GetDataHere
,
1859 MimeBody_GetTransmitInfo
,
1860 MimeBody_SaveToFile
,
1864 static HRESULT
MimeBody_set_offsets(MimeBody
*body
, const BODYOFFSETS
*offsets
)
1866 TRACE("setting offsets to %ld, %ld, %ld, %ld\n", offsets
->cbBoundaryStart
,
1867 offsets
->cbHeaderStart
, offsets
->cbBodyStart
, offsets
->cbBodyEnd
);
1869 body
->body_offsets
= *offsets
;
1873 #define FIRST_CUSTOM_PROP_ID 0x100
1875 static MimeBody
*mimebody_create(void)
1878 BODYOFFSETS body_offsets
;
1880 This
= malloc(sizeof(*This
));
1884 This
->IMimeBody_iface
.lpVtbl
= &body_vtbl
;
1886 This
->handle
= NULL
;
1887 list_init(&This
->headers
);
1888 list_init(&This
->new_props
);
1889 This
->next_prop_id
= FIRST_CUSTOM_PROP_ID
;
1890 This
->content_pri_type
= NULL
;
1891 This
->content_sub_type
= NULL
;
1892 This
->encoding
= IET_7BIT
;
1894 This
->data_iid
= IID_NULL
;
1896 body_offsets
.cbBoundaryStart
= body_offsets
.cbHeaderStart
= 0;
1897 body_offsets
.cbBodyStart
= body_offsets
.cbBodyEnd
= 0;
1898 MimeBody_set_offsets(This
, &body_offsets
);
1903 HRESULT
MimeBody_create(IUnknown
*outer
, void **ppv
)
1908 return CLASS_E_NOAGGREGATION
;
1910 if ((mb
= mimebody_create()))
1912 *ppv
= &mb
->IMimeBody_iface
;
1918 return E_OUTOFMEMORY
;
1922 typedef struct body_t
1926 MimeBody
*mime_body
;
1928 struct body_t
*parent
;
1929 struct list children
;
1932 typedef struct MimeMessage
1934 IMimeMessage IMimeMessage_iface
;
1938 struct list body_tree
;
1942 static inline MimeMessage
*impl_from_IMimeMessage(IMimeMessage
*iface
)
1944 return CONTAINING_RECORD(iface
, MimeMessage
, IMimeMessage_iface
);
1947 static HRESULT WINAPI
MimeMessage_QueryInterface(IMimeMessage
*iface
, REFIID riid
, void **ppv
)
1949 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ppv
);
1951 if (IsEqualIID(riid
, &IID_IUnknown
) ||
1952 IsEqualIID(riid
, &IID_IPersist
) ||
1953 IsEqualIID(riid
, &IID_IPersistStreamInit
) ||
1954 IsEqualIID(riid
, &IID_IMimeMessageTree
) ||
1955 IsEqualIID(riid
, &IID_IMimeMessage
))
1958 IMimeMessage_AddRef(iface
);
1962 FIXME("no interface for %s\n", debugstr_guid(riid
));
1964 return E_NOINTERFACE
;
1967 static ULONG WINAPI
MimeMessage_AddRef(IMimeMessage
*iface
)
1969 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
1970 ULONG ref
= InterlockedIncrement(&This
->ref
);
1972 TRACE("(%p) ref=%ld\n", This
, ref
);
1977 static void empty_body_list(struct list
*list
)
1979 body_t
*body
, *cursor2
;
1980 LIST_FOR_EACH_ENTRY_SAFE(body
, cursor2
, list
, body_t
, entry
)
1982 empty_body_list(&body
->children
);
1983 list_remove(&body
->entry
);
1984 IMimeBody_Release(&body
->mime_body
->IMimeBody_iface
);
1989 static ULONG WINAPI
MimeMessage_Release(IMimeMessage
*iface
)
1991 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
1992 ULONG ref
= InterlockedDecrement(&This
->ref
);
1994 TRACE("(%p) ref=%ld\n", This
, ref
);
1998 empty_body_list(&This
->body_tree
);
2000 if(This
->stream
) IStream_Release(This
->stream
);
2007 /*** IPersist methods ***/
2008 static HRESULT WINAPI
MimeMessage_GetClassID(
2009 IMimeMessage
*iface
,
2012 FIXME("(%p)->(%p)\n", iface
, pClassID
);
2016 /*** IPersistStreamInit methods ***/
2017 static HRESULT WINAPI
MimeMessage_IsDirty(
2018 IMimeMessage
*iface
)
2020 FIXME("(%p)->()\n", iface
);
2024 static body_t
*new_body_entry(MimeBody
*mime_body
, DWORD index
, body_t
*parent
)
2026 body_t
*body
= malloc(sizeof(*body
));
2029 body
->mime_body
= mime_body
;
2030 body
->index
= index
;
2031 list_init(&body
->children
);
2032 body
->parent
= parent
;
2034 mime_body
->handle
= UlongToHandle(body
->index
);
2042 BODYOFFSETS offsets
;
2045 static HRESULT
create_body_offset_list(IStream
*stm
, const char *boundary
, struct list
*body_offsets
)
2048 DWORD read
, boundary_start
;
2049 int boundary_len
= strlen(boundary
);
2050 char *buf
, *ptr
, *overlap
;
2051 DWORD start
= 0, overlap_no
;
2052 offset_entry_t
*cur_body
= NULL
;
2053 BOOL is_first_line
= TRUE
;
2057 list_init(body_offsets
);
2059 overlap_no
= boundary_len
+ 5;
2061 overlap
= buf
= malloc(overlap_no
+ PARSER_BUF_SIZE
+ 1);
2064 hr
= IStream_Seek(stm
, zero
, STREAM_SEEK_CUR
, &cur
);
2065 start
= cur
.LowPart
;
2068 hr
= IStream_Read(stm
, overlap
, PARSER_BUF_SIZE
, &read
);
2069 if(FAILED(hr
)) goto end
;
2070 if(read
== 0) break;
2071 overlap
[read
] = '\0';
2076 is_first_line
= FALSE
;
2078 ptr
= strstr(ptr
, "\r\n");
2084 boundary_start
= start
+ ptr
- buf
;
2086 if(*ptr
== '-' && *(ptr
+ 1) == '-' && !memcmp(ptr
+ 2, boundary
, boundary_len
)) {
2087 ptr
+= boundary_len
+ 2;
2089 if(*ptr
== '\r' && *(ptr
+ 1) == '\n')
2094 cur_body
->offsets
.cbBodyEnd
= boundary_start
- 2;
2095 list_add_tail(body_offsets
, &cur_body
->entry
);
2097 cur_body
= malloc(sizeof(*cur_body
));
2098 cur_body
->offsets
.cbBoundaryStart
= boundary_start
;
2099 cur_body
->offsets
.cbHeaderStart
= start
+ ptr
- buf
;
2101 else if(*ptr
== '-' && *(ptr
+ 1) == '-')
2105 cur_body
->offsets
.cbBodyEnd
= boundary_start
- 2;
2106 list_add_tail(body_offsets
, &cur_body
->entry
);
2113 if(overlap
== buf
) /* 1st iteration */
2115 memmove(buf
, buf
+ PARSER_BUF_SIZE
- overlap_no
, overlap_no
);
2116 overlap
= buf
+ overlap_no
;
2117 start
+= read
- overlap_no
;
2121 memmove(buf
, buf
+ PARSER_BUF_SIZE
, overlap_no
);
2131 static body_t
*create_sub_body(MimeMessage
*msg
, IStream
*pStm
, BODYOFFSETS
*offset
, body_t
*parent
)
2133 ULARGE_INTEGER start
, length
;
2134 MimeBody
*mime_body
;
2139 pos
.QuadPart
= offset
->cbHeaderStart
;
2140 IStream_Seek(pStm
, pos
, STREAM_SEEK_SET
, NULL
);
2142 mime_body
= mimebody_create();
2143 IMimeBody_Load(&mime_body
->IMimeBody_iface
, pStm
);
2146 hr
= IStream_Seek(pStm
, pos
, STREAM_SEEK_CUR
, &start
);
2147 offset
->cbBodyStart
= start
.QuadPart
;
2148 if (parent
) MimeBody_set_offsets(mime_body
, offset
);
2150 length
.QuadPart
= offset
->cbBodyEnd
- offset
->cbBodyStart
;
2151 create_sub_stream(pStm
, start
, length
, (IStream
**)&mime_body
->data
);
2152 mime_body
->data_iid
= IID_IStream
;
2154 body
= new_body_entry(mime_body
, msg
->next_index
++, parent
);
2156 if(IMimeBody_IsContentType(&mime_body
->IMimeBody_iface
, "multipart", NULL
) == S_OK
)
2158 MIMEPARAMINFO
*param_info
;
2160 IMimeAllocator
*alloc
;
2162 hr
= IMimeBody_GetParameters(&mime_body
->IMimeBody_iface
, "Content-Type", &count
,
2164 if(hr
!= S_OK
|| count
== 0) return body
;
2166 MimeOleGetAllocator(&alloc
);
2168 for(i
= 0; i
< count
; i
++)
2170 if(!lstrcmpiA(param_info
[i
].pszName
, "boundary"))
2172 struct list offset_list
;
2173 offset_entry_t
*cur
, *cursor2
;
2174 hr
= create_body_offset_list(pStm
, param_info
[i
].pszData
, &offset_list
);
2175 LIST_FOR_EACH_ENTRY_SAFE(cur
, cursor2
, &offset_list
, offset_entry_t
, entry
)
2179 sub_body
= create_sub_body(msg
, pStm
, &cur
->offsets
, body
);
2180 list_add_tail(&body
->children
, &sub_body
->entry
);
2181 list_remove(&cur
->entry
);
2187 IMimeAllocator_FreeParamInfoArray(alloc
, count
, param_info
, TRUE
);
2188 IMimeAllocator_Release(alloc
);
2193 static HRESULT WINAPI
MimeMessage_Load(IMimeMessage
*iface
, IStream
*pStm
)
2195 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2197 BODYOFFSETS offsets
;
2201 TRACE("(%p)->(%p)\n", iface
, pStm
);
2205 FIXME("already loaded a message\n");
2209 empty_body_list(&This
->body_tree
);
2211 IStream_AddRef(pStm
);
2212 This
->stream
= pStm
;
2213 offsets
.cbBoundaryStart
= offsets
.cbHeaderStart
= 0;
2214 offsets
.cbBodyStart
= offsets
.cbBodyEnd
= 0;
2216 root_body
= create_sub_body(This
, pStm
, &offsets
, NULL
);
2219 IStream_Seek(pStm
, zero
, STREAM_SEEK_END
, &cur
);
2220 offsets
.cbBodyEnd
= cur
.LowPart
;
2221 MimeBody_set_offsets(root_body
->mime_body
, &offsets
);
2223 list_add_head(&This
->body_tree
, &root_body
->entry
);
2228 static HRESULT WINAPI
MimeMessage_Save(IMimeMessage
*iface
, IStream
*pStm
, BOOL fClearDirty
)
2230 FIXME("(%p)->(%p, %s)\n", iface
, pStm
, fClearDirty
? "TRUE" : "FALSE");
2234 static HRESULT WINAPI
MimeMessage_GetSizeMax(
2235 IMimeMessage
*iface
,
2236 ULARGE_INTEGER
*pcbSize
)
2238 FIXME("(%p)->(%p)\n", iface
, pcbSize
);
2242 static HRESULT WINAPI
MimeMessage_InitNew(
2243 IMimeMessage
*iface
)
2245 FIXME("(%p)->()\n", iface
);
2249 /*** IMimeMessageTree methods ***/
2250 static HRESULT WINAPI
MimeMessage_GetMessageSource(IMimeMessage
*iface
, IStream
**ppStream
,
2253 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2255 FIXME("(%p)->(%p, 0x%lx)\n", iface
, ppStream
, dwFlags
);
2257 IStream_AddRef(This
->stream
);
2258 *ppStream
= This
->stream
;
2262 static HRESULT WINAPI
MimeMessage_GetMessageSize(
2263 IMimeMessage
*iface
,
2267 FIXME("(%p)->(%p, 0x%lx)\n", iface
, pcbSize
, dwFlags
);
2271 static HRESULT WINAPI
MimeMessage_LoadOffsetTable(
2272 IMimeMessage
*iface
,
2275 FIXME("(%p)->(%p)\n", iface
, pStream
);
2279 static HRESULT WINAPI
MimeMessage_SaveOffsetTable(
2280 IMimeMessage
*iface
,
2284 FIXME("(%p)->(%p, 0x%lx)\n", iface
, pStream
, dwFlags
);
2289 static HRESULT WINAPI
MimeMessage_GetFlags(
2290 IMimeMessage
*iface
,
2293 FIXME("(%p)->(%p)\n", iface
, pdwFlags
);
2297 static HRESULT WINAPI
MimeMessage_Commit(
2298 IMimeMessage
*iface
,
2301 FIXME("(%p)->(0x%lx)\n", iface
, dwFlags
);
2306 static HRESULT WINAPI
MimeMessage_HandsOffStorage(
2307 IMimeMessage
*iface
)
2309 FIXME("(%p)->()\n", iface
);
2313 static HRESULT
find_body(struct list
*list
, HBODY hbody
, body_t
**body
)
2318 if(hbody
== HBODY_ROOT
)
2320 *body
= LIST_ENTRY(list_head(list
), body_t
, entry
);
2324 LIST_FOR_EACH_ENTRY(cur
, list
, body_t
, entry
)
2326 if(cur
->index
== HandleToUlong(hbody
))
2331 hr
= find_body(&cur
->children
, hbody
, body
);
2332 if(hr
== S_OK
) return S_OK
;
2337 static HRESULT WINAPI
MimeMessage_BindToObject(IMimeMessage
*iface
, const HBODY hBody
, REFIID riid
,
2340 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2344 TRACE("(%p)->(%p, %s, %p)\n", iface
, hBody
, debugstr_guid(riid
), ppvObject
);
2346 hr
= find_body(&This
->body_tree
, hBody
, &body
);
2348 if(hr
!= S_OK
) return hr
;
2350 if(IsEqualIID(riid
, &IID_IMimeBody
))
2352 IMimeBody_AddRef(&body
->mime_body
->IMimeBody_iface
);
2353 *ppvObject
= &body
->mime_body
->IMimeBody_iface
;
2357 return E_NOINTERFACE
;
2360 static HRESULT WINAPI
MimeMessage_SaveBody(
2361 IMimeMessage
*iface
,
2366 FIXME("(%p)->(%p, 0x%lx, %p)\n", iface
, hBody
, dwFlags
, pStream
);
2370 static HRESULT
get_body(MimeMessage
*msg
, BODYLOCATION location
, HBODY pivot
, body_t
**out
)
2372 body_t
*root
= LIST_ENTRY(list_head(&msg
->body_tree
), body_t
, entry
);
2377 if(location
== IBL_ROOT
)
2383 hr
= find_body(&msg
->body_tree
, pivot
, &body
);
2391 *out
= body
->parent
;
2393 hr
= MIME_E_NOT_FOUND
;
2397 list
= list_head(&body
->children
);
2399 *out
= LIST_ENTRY(list
, body_t
, entry
);
2401 hr
= MIME_E_NOT_FOUND
;
2405 list
= list_tail(&body
->children
);
2407 *out
= LIST_ENTRY(list
, body_t
, entry
);
2409 hr
= MIME_E_NOT_FOUND
;
2413 list
= list_next(&body
->parent
->children
, &body
->entry
);
2415 *out
= LIST_ENTRY(list
, body_t
, entry
);
2417 hr
= MIME_E_NOT_FOUND
;
2421 list
= list_prev(&body
->parent
->children
, &body
->entry
);
2423 *out
= LIST_ENTRY(list
, body_t
, entry
);
2425 hr
= MIME_E_NOT_FOUND
;
2438 static HRESULT WINAPI
MimeMessage_InsertBody(
2439 IMimeMessage
*iface
,
2440 BODYLOCATION location
,
2444 FIXME("(%p)->(%d, %p, %p)\n", iface
, location
, hPivot
, phBody
);
2448 static HRESULT WINAPI
MimeMessage_GetBody(IMimeMessage
*iface
, BODYLOCATION location
, HBODY hPivot
,
2451 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2455 TRACE("(%p)->(%d, %p, %p)\n", iface
, location
, hPivot
, phBody
);
2458 return E_INVALIDARG
;
2462 hr
= get_body(This
, location
, hPivot
, &body
);
2464 if(hr
== S_OK
) *phBody
= UlongToHandle(body
->index
);
2469 static HRESULT WINAPI
MimeMessage_DeleteBody(
2470 IMimeMessage
*iface
,
2474 FIXME("(%p)->(%p, %08lx)\n", iface
, hBody
, dwFlags
);
2478 static HRESULT WINAPI
MimeMessage_MoveBody(
2479 IMimeMessage
*iface
,
2481 BODYLOCATION location
)
2483 FIXME("(%p)->(%d)\n", iface
, location
);
2487 static void count_children(body_t
*body
, boolean recurse
, ULONG
*count
)
2491 LIST_FOR_EACH_ENTRY(child
, &body
->children
, body_t
, entry
)
2494 if(recurse
) count_children(child
, recurse
, count
);
2498 static HRESULT WINAPI
MimeMessage_CountBodies(IMimeMessage
*iface
, HBODY hParent
, boolean fRecurse
,
2502 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2505 TRACE("(%p)->(%p, %s, %p)\n", iface
, hParent
, fRecurse
? "TRUE" : "FALSE", pcBodies
);
2507 hr
= find_body(&This
->body_tree
, hParent
, &body
);
2508 if(hr
!= S_OK
) return hr
;
2511 count_children(body
, fRecurse
, pcBodies
);
2516 static HRESULT
find_next(MimeMessage
*This
, body_t
*body
, FINDBODY
*find
, HBODY
*out
)
2523 if (!body
) ptr
= list_head( &This
->body_tree
);
2526 ptr
= list_head( &body
->children
);
2529 if (!body
->parent
) return MIME_E_NOT_FOUND
;
2530 if (!(ptr
= list_next( &body
->parent
->children
, &body
->entry
))) body
= body
->parent
;
2534 body
= LIST_ENTRY( ptr
, body_t
, entry
);
2535 next
= UlongToHandle( body
->index
);
2536 find
->dwReserved
= body
->index
;
2537 if (IMimeBody_IsContentType(&body
->mime_body
->IMimeBody_iface
, find
->pszPriType
,
2538 find
->pszSubType
) == S_OK
)
2544 return MIME_E_NOT_FOUND
;
2547 static HRESULT WINAPI
MimeMessage_FindFirst(IMimeMessage
*iface
, FINDBODY
*pFindBody
, HBODY
*phBody
)
2549 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2551 TRACE("(%p)->(%p, %p)\n", iface
, pFindBody
, phBody
);
2553 pFindBody
->dwReserved
= 0;
2554 return find_next(This
, NULL
, pFindBody
, phBody
);
2557 static HRESULT WINAPI
MimeMessage_FindNext(IMimeMessage
*iface
, FINDBODY
*pFindBody
, HBODY
*phBody
)
2559 MimeMessage
*This
= impl_from_IMimeMessage(iface
);
2563 TRACE("(%p)->(%p, %p)\n", iface
, pFindBody
, phBody
);
2565 hr
= find_body( &This
->body_tree
, UlongToHandle( pFindBody
->dwReserved
), &body
);
2566 if (hr
!= S_OK
) return MIME_E_NOT_FOUND
;
2567 return find_next(This
, body
, pFindBody
, phBody
);
2570 static HRESULT WINAPI
MimeMessage_ResolveURL(
2571 IMimeMessage
*iface
,
2578 FIXME("(%p)->(%p, %s, %s, 0x%lx, %p)\n", iface
, hRelated
, pszBase
, pszURL
, dwFlags
, phBody
);
2582 static HRESULT WINAPI
MimeMessage_ToMultipart(
2583 IMimeMessage
*iface
,
2586 LPHBODY phMultipart
)
2588 FIXME("(%p)->(%p, %s, %p)\n", iface
, hBody
, pszSubType
, phMultipart
);
2592 static HRESULT WINAPI
MimeMessage_GetBodyOffsets(
2593 IMimeMessage
*iface
,
2595 LPBODYOFFSETS pOffsets
)
2597 FIXME("(%p)->(%p, %p)\n", iface
, hBody
, pOffsets
);
2601 static HRESULT WINAPI
MimeMessage_GetCharset(
2602 IMimeMessage
*iface
,
2603 LPHCHARSET phCharset
)
2605 FIXME("(%p)->(%p)\n", iface
, phCharset
);
2610 static HRESULT WINAPI
MimeMessage_SetCharset(
2611 IMimeMessage
*iface
,
2613 CSETAPPLYTYPE applytype
)
2615 FIXME("(%p)->(%p, %d)\n", iface
, hCharset
, applytype
);
2619 static HRESULT WINAPI
MimeMessage_IsBodyType(
2620 IMimeMessage
*iface
,
2622 IMSGBODYTYPE bodytype
)
2625 IMimeBody
*mime_body
;
2626 TRACE("(%p)->(%p, %d)\n", iface
, hBody
, bodytype
);
2628 hr
= IMimeMessage_BindToObject(iface
, hBody
, &IID_IMimeBody
, (void**)&mime_body
);
2629 if(hr
!= S_OK
) return hr
;
2631 hr
= IMimeBody_IsType(mime_body
, bodytype
);
2632 MimeBody_Release(mime_body
);
2636 static HRESULT WINAPI
MimeMessage_IsContentType(
2637 IMimeMessage
*iface
,
2643 IMimeBody
*mime_body
;
2644 TRACE("(%p)->(%p, %s, %s)\n", iface
, hBody
, debugstr_a(pszPriType
),
2645 debugstr_a(pszSubType
));
2647 hr
= IMimeMessage_BindToObject(iface
, hBody
, &IID_IMimeBody
, (void**)&mime_body
);
2648 if(FAILED(hr
)) return hr
;
2650 hr
= IMimeBody_IsContentType(mime_body
, pszPriType
, pszSubType
);
2651 IMimeBody_Release(mime_body
);
2655 static HRESULT WINAPI
MimeMessage_QueryBodyProp(
2656 IMimeMessage
*iface
,
2661 boolean fCaseSensitive
)
2663 FIXME("(%p)->(%p, %s, %s, %s, %s)\n", iface
, hBody
, pszName
, pszCriteria
, fSubString
? "TRUE" : "FALSE", fCaseSensitive
? "TRUE" : "FALSE");
2667 static HRESULT WINAPI
MimeMessage_GetBodyProp(
2668 IMimeMessage
*iface
,
2672 LPPROPVARIANT pValue
)
2675 IMimeBody
*mime_body
;
2677 TRACE("(%p)->(%p, %s, 0x%lx, %p)\n", iface
, hBody
, pszName
, dwFlags
, pValue
);
2679 hr
= IMimeMessage_BindToObject(iface
, hBody
, &IID_IMimeBody
, (void**)&mime_body
);
2680 if(hr
!= S_OK
) return hr
;
2682 hr
= IMimeBody_GetProp(mime_body
, pszName
, dwFlags
, pValue
);
2683 IMimeBody_Release(mime_body
);
2688 static HRESULT WINAPI
MimeMessage_SetBodyProp(
2689 IMimeMessage
*iface
,
2693 LPCPROPVARIANT pValue
)
2695 FIXME("(%p)->(%p, %s, 0x%lx, %p)\n", iface
, hBody
, pszName
, dwFlags
, pValue
);
2699 static HRESULT WINAPI
MimeMessage_DeleteBodyProp(
2700 IMimeMessage
*iface
,
2704 FIXME("(%p)->(%p, %s)\n", iface
, hBody
, pszName
);
2708 static HRESULT WINAPI
MimeMessage_SetOption(
2709 IMimeMessage
*iface
,
2711 LPCPROPVARIANT pValue
)
2714 TRACE("(%p)->(%08lx, %p)\n", iface
, oid
, pValue
);
2716 /* Message ID is checked before type.
2717 * OID 0x4D -> 0x56 and 0x58 aren't defined but will filtered out later.
2719 if(TYPEDID_ID(oid
) < TYPEDID_ID(OID_ALLOW_8BIT_HEADER
) || TYPEDID_ID(oid
) > TYPEDID_ID(OID_SECURITY_2KEY_CERT_BAG_64
))
2721 WARN("oid (%08lx) out of range\n", oid
);
2722 return MIME_E_INVALID_OPTION_ID
;
2725 if(pValue
->vt
!= TYPEDID_TYPE(oid
))
2727 WARN("Called with vartype %04x and oid %08lx\n", pValue
->vt
, oid
);
2733 case OID_HIDE_TNEF_ATTACHMENTS
:
2734 FIXME("OID_HIDE_TNEF_ATTACHMENTS (value %d): ignoring\n", pValue
->boolVal
);
2736 case OID_SHOW_MACBINARY
:
2737 FIXME("OID_SHOW_MACBINARY (value %d): ignoring\n", pValue
->boolVal
);
2739 case OID_SAVEBODY_KEEPBOUNDARY
:
2740 FIXME("OID_SAVEBODY_KEEPBOUNDARY (value %d): ignoring\n", pValue
->boolVal
);
2742 case OID_CLEANUP_TREE_ON_SAVE
:
2743 FIXME("OID_CLEANUP_TREE_ON_SAVE (value %d): ignoring\n", pValue
->boolVal
);
2746 FIXME("Unhandled oid %08lx\n", oid
);
2747 hr
= MIME_E_INVALID_OPTION_ID
;
2753 static HRESULT WINAPI
MimeMessage_GetOption(
2754 IMimeMessage
*iface
,
2756 LPPROPVARIANT pValue
)
2758 FIXME("(%p)->(%08lx, %p)\n", iface
, oid
, pValue
);
2762 /*** IMimeMessage methods ***/
2763 static HRESULT WINAPI
MimeMessage_CreateWebPage(
2764 IMimeMessage
*iface
,
2766 LPWEBPAGEOPTIONS pOptions
,
2767 IMimeMessageCallback
*pCallback
,
2768 IMoniker
**ppMoniker
)
2770 FIXME("(%p)->(%p, %p, %p, %p)\n", iface
, pRootStm
, pOptions
, pCallback
, ppMoniker
);
2775 static HRESULT WINAPI
MimeMessage_GetProp(
2776 IMimeMessage
*iface
,
2779 LPPROPVARIANT pValue
)
2781 FIXME("(%p)->(%s, 0x%lx, %p)\n", iface
, pszName
, dwFlags
, pValue
);
2785 static HRESULT WINAPI
MimeMessage_SetProp(
2786 IMimeMessage
*iface
,
2789 LPCPROPVARIANT pValue
)
2791 FIXME("(%p)->(%s, 0x%lx, %p)\n", iface
, pszName
, dwFlags
, pValue
);
2795 static HRESULT WINAPI
MimeMessage_DeleteProp(
2796 IMimeMessage
*iface
,
2799 FIXME("(%p)->(%s)\n", iface
, pszName
);
2803 static HRESULT WINAPI
MimeMessage_QueryProp(
2804 IMimeMessage
*iface
,
2808 boolean fCaseSensitive
)
2810 FIXME("(%p)->(%s, %s, %s, %s)\n", iface
, pszName
, pszCriteria
, fSubString
? "TRUE" : "FALSE", fCaseSensitive
? "TRUE" : "FALSE");
2814 static HRESULT WINAPI
MimeMessage_GetTextBody(
2815 IMimeMessage
*iface
,
2817 ENCODINGTYPE ietEncoding
,
2823 FINDBODY find_struct
;
2824 IMimeBody
*mime_body
;
2825 static char text
[] = "text";
2826 static char plain
[] = "plain";
2827 static char html
[] = "html";
2829 TRACE("(%p)->(%ld, %d, %p, %p)\n", iface
, dwTxtType
, ietEncoding
, pStream
, phBody
);
2831 find_struct
.pszPriType
= text
;
2836 find_struct
.pszSubType
= plain
;
2839 find_struct
.pszSubType
= html
;
2842 return MIME_E_INVALID_TEXT_TYPE
;
2845 hr
= IMimeMessage_FindFirst(iface
, &find_struct
, &hbody
);
2848 TRACE("not found hr %08lx\n", hr
);
2853 IMimeMessage_BindToObject(iface
, hbody
, &IID_IMimeBody
, (void**)&mime_body
);
2855 IMimeBody_GetData(mime_body
, ietEncoding
, pStream
);
2857 IMimeBody_Release(mime_body
);
2861 static HRESULT WINAPI
MimeMessage_SetTextBody(
2862 IMimeMessage
*iface
,
2864 ENCODINGTYPE ietEncoding
,
2869 FIXME("(%p)->(%ld, %d, %p, %p, %p)\n", iface
, dwTxtType
, ietEncoding
, hAlternative
, pStream
, phBody
);
2873 static HRESULT WINAPI
MimeMessage_AttachObject(
2874 IMimeMessage
*iface
,
2879 FIXME("(%p)->(%s, %p, %p)\n", iface
, debugstr_guid(riid
), pvObject
, phBody
);
2883 static HRESULT WINAPI
MimeMessage_AttachFile(
2884 IMimeMessage
*iface
,
2889 FIXME("(%p)->(%s, %p, %p)\n", iface
, pszFilePath
, pstmFile
, phBody
);
2893 static HRESULT WINAPI
MimeMessage_AttachURL(
2894 IMimeMessage
*iface
,
2902 FIXME("(%p)->(%s, %s, 0x%lx, %p, %p, %p)\n", iface
, pszBase
, pszURL
, dwFlags
, pstmURL
, ppszCIDURL
, phBody
);
2906 static HRESULT WINAPI
MimeMessage_GetAttachments(
2907 IMimeMessage
*iface
,
2909 LPHBODY
*pprghAttach
)
2912 FINDBODY find_struct
;
2917 TRACE("(%p)->(%p, %p)\n", iface
, pcAttach
, pprghAttach
);
2920 array
= CoTaskMemAlloc(size
* sizeof(HBODY
));
2922 find_struct
.pszPriType
= find_struct
.pszSubType
= NULL
;
2923 hr
= IMimeMessage_FindFirst(iface
, &find_struct
, &hbody
);
2926 hr
= IMimeMessage_IsContentType(iface
, hbody
, "multipart", NULL
);
2927 TRACE("IsCT rets %08lx %ld\n", hr
, *pcAttach
);
2930 if(*pcAttach
+ 1 > size
)
2933 array
= CoTaskMemRealloc(array
, size
* sizeof(HBODY
));
2935 array
[*pcAttach
] = hbody
;
2938 hr
= IMimeMessage_FindNext(iface
, &find_struct
, &hbody
);
2941 *pprghAttach
= array
;
2945 static HRESULT WINAPI
MimeMessage_GetAddressTable(
2946 IMimeMessage
*iface
,
2947 IMimeAddressTable
**ppTable
)
2949 FIXME("(%p)->(%p)\n", iface
, ppTable
);
2953 static HRESULT WINAPI
MimeMessage_GetSender(
2954 IMimeMessage
*iface
,
2955 LPADDRESSPROPS pAddress
)
2957 FIXME("(%p)->(%p)\n", iface
, pAddress
);
2961 static HRESULT WINAPI
MimeMessage_GetAddressTypes(
2962 IMimeMessage
*iface
,
2965 LPADDRESSLIST pList
)
2967 FIXME("(%p)->(%ld, %ld, %p)\n", iface
, dwAdrTypes
, dwProps
, pList
);
2971 static HRESULT WINAPI
MimeMessage_GetAddressFormat(
2972 IMimeMessage
*iface
,
2974 ADDRESSFORMAT format
,
2977 FIXME("(%p)->(%ld, %d, %p)\n", iface
, dwAdrTypes
, format
, ppszFormat
);
2981 static HRESULT WINAPI
MimeMessage_EnumAddressTypes(
2982 IMimeMessage
*iface
,
2985 IMimeEnumAddressTypes
**ppEnum
)
2987 FIXME("(%p)->(%ld, %ld, %p)\n", iface
, dwAdrTypes
, dwProps
, ppEnum
);
2991 static HRESULT WINAPI
MimeMessage_SplitMessage(
2992 IMimeMessage
*iface
,
2994 IMimeMessageParts
**ppParts
)
2996 FIXME("(%p)->(%ld, %p)\n", iface
, cbMaxPart
, ppParts
);
3000 static HRESULT WINAPI
MimeMessage_GetRootMoniker(
3001 IMimeMessage
*iface
,
3002 IMoniker
**ppMoniker
)
3004 FIXME("(%p)->(%p)\n", iface
, ppMoniker
);
3008 static const IMimeMessageVtbl MimeMessageVtbl
=
3010 MimeMessage_QueryInterface
,
3012 MimeMessage_Release
,
3013 MimeMessage_GetClassID
,
3014 MimeMessage_IsDirty
,
3017 MimeMessage_GetSizeMax
,
3018 MimeMessage_InitNew
,
3019 MimeMessage_GetMessageSource
,
3020 MimeMessage_GetMessageSize
,
3021 MimeMessage_LoadOffsetTable
,
3022 MimeMessage_SaveOffsetTable
,
3023 MimeMessage_GetFlags
,
3025 MimeMessage_HandsOffStorage
,
3026 MimeMessage_BindToObject
,
3027 MimeMessage_SaveBody
,
3028 MimeMessage_InsertBody
,
3029 MimeMessage_GetBody
,
3030 MimeMessage_DeleteBody
,
3031 MimeMessage_MoveBody
,
3032 MimeMessage_CountBodies
,
3033 MimeMessage_FindFirst
,
3034 MimeMessage_FindNext
,
3035 MimeMessage_ResolveURL
,
3036 MimeMessage_ToMultipart
,
3037 MimeMessage_GetBodyOffsets
,
3038 MimeMessage_GetCharset
,
3039 MimeMessage_SetCharset
,
3040 MimeMessage_IsBodyType
,
3041 MimeMessage_IsContentType
,
3042 MimeMessage_QueryBodyProp
,
3043 MimeMessage_GetBodyProp
,
3044 MimeMessage_SetBodyProp
,
3045 MimeMessage_DeleteBodyProp
,
3046 MimeMessage_SetOption
,
3047 MimeMessage_GetOption
,
3048 MimeMessage_CreateWebPage
,
3049 MimeMessage_GetProp
,
3050 MimeMessage_SetProp
,
3051 MimeMessage_DeleteProp
,
3052 MimeMessage_QueryProp
,
3053 MimeMessage_GetTextBody
,
3054 MimeMessage_SetTextBody
,
3055 MimeMessage_AttachObject
,
3056 MimeMessage_AttachFile
,
3057 MimeMessage_AttachURL
,
3058 MimeMessage_GetAttachments
,
3059 MimeMessage_GetAddressTable
,
3060 MimeMessage_GetSender
,
3061 MimeMessage_GetAddressTypes
,
3062 MimeMessage_GetAddressFormat
,
3063 MimeMessage_EnumAddressTypes
,
3064 MimeMessage_SplitMessage
,
3065 MimeMessage_GetRootMoniker
,
3068 HRESULT
MimeMessage_create(IUnknown
*outer
, void **obj
)
3071 MimeBody
*mime_body
;
3074 TRACE("(%p, %p)\n", outer
, obj
);
3078 FIXME("outer unknown not supported yet\n");
3084 This
= malloc(sizeof(*This
));
3085 if (!This
) return E_OUTOFMEMORY
;
3087 This
->IMimeMessage_iface
.lpVtbl
= &MimeMessageVtbl
;
3089 This
->stream
= NULL
;
3090 list_init(&This
->body_tree
);
3091 This
->next_index
= 1;
3093 mime_body
= mimebody_create();
3094 root_body
= new_body_entry(mime_body
, This
->next_index
++, NULL
);
3095 list_add_head(&This
->body_tree
, &root_body
->entry
);
3097 *obj
= &This
->IMimeMessage_iface
;
3101 /***********************************************************************
3102 * MimeOleCreateMessage (INETCOMM.@)
3104 HRESULT WINAPI
MimeOleCreateMessage(IUnknown
*pUnkOuter
, IMimeMessage
**ppMessage
)
3106 TRACE("(%p, %p)\n", pUnkOuter
, ppMessage
);
3107 return MimeMessage_create(NULL
, (void **)ppMessage
);
3110 /***********************************************************************
3111 * MimeOleSetCompatMode (INETCOMM.@)
3113 HRESULT WINAPI
MimeOleSetCompatMode(DWORD dwMode
)
3115 FIXME("(0x%lx)\n", dwMode
);
3119 /***********************************************************************
3120 * MimeOleCreateVirtualStream (INETCOMM.@)
3122 HRESULT WINAPI
MimeOleCreateVirtualStream(IStream
**ppStream
)
3125 FIXME("(%p)\n", ppStream
);
3127 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, ppStream
);
3131 typedef struct MimeSecurity
3133 IMimeSecurity IMimeSecurity_iface
;
3137 static inline MimeSecurity
*impl_from_IMimeSecurity(IMimeSecurity
*iface
)
3139 return CONTAINING_RECORD(iface
, MimeSecurity
, IMimeSecurity_iface
);
3142 static HRESULT WINAPI
MimeSecurity_QueryInterface(IMimeSecurity
*iface
, REFIID riid
, void **ppv
)
3144 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ppv
);
3146 if (IsEqualIID(riid
, &IID_IUnknown
) ||
3147 IsEqualIID(riid
, &IID_IMimeSecurity
))
3150 IMimeSecurity_AddRef(iface
);
3154 FIXME("no interface for %s\n", debugstr_guid(riid
));
3156 return E_NOINTERFACE
;
3159 static ULONG WINAPI
MimeSecurity_AddRef(IMimeSecurity
*iface
)
3161 MimeSecurity
*This
= impl_from_IMimeSecurity(iface
);
3162 LONG ref
= InterlockedIncrement(&This
->ref
);
3164 TRACE("(%p) ref=%ld\n", This
, ref
);
3169 static ULONG WINAPI
MimeSecurity_Release(IMimeSecurity
*iface
)
3171 MimeSecurity
*This
= impl_from_IMimeSecurity(iface
);
3172 LONG ref
= InterlockedDecrement(&This
->ref
);
3174 TRACE("(%p) ref=%ld\n", This
, ref
);
3182 static HRESULT WINAPI
MimeSecurity_InitNew(
3183 IMimeSecurity
* iface
)
3185 FIXME("(%p)->(): stub\n", iface
);
3189 static HRESULT WINAPI
MimeSecurity_CheckInit(
3190 IMimeSecurity
* iface
)
3192 FIXME("(%p)->(): stub\n", iface
);
3196 static HRESULT WINAPI
MimeSecurity_EncodeMessage(
3197 IMimeSecurity
* iface
,
3198 IMimeMessageTree
* pTree
,
3201 FIXME("(%p)->(%p, %08lx): stub\n", iface
, pTree
, dwFlags
);
3205 static HRESULT WINAPI
MimeSecurity_EncodeBody(
3206 IMimeSecurity
* iface
,
3207 IMimeMessageTree
* pTree
,
3211 FIXME("(%p)->(%p, %p, %08lx): stub\n", iface
, pTree
, hEncodeRoot
, dwFlags
);
3215 static HRESULT WINAPI
MimeSecurity_DecodeMessage(
3216 IMimeSecurity
* iface
,
3217 IMimeMessageTree
* pTree
,
3220 FIXME("(%p)->(%p, %08lx): stub\n", iface
, pTree
, dwFlags
);
3224 static HRESULT WINAPI
MimeSecurity_DecodeBody(
3225 IMimeSecurity
* iface
,
3226 IMimeMessageTree
* pTree
,
3230 FIXME("(%p)->(%p, %p, %08lx): stub\n", iface
, pTree
, hDecodeRoot
, dwFlags
);
3234 static HRESULT WINAPI
MimeSecurity_EnumCertificates(
3235 IMimeSecurity
* iface
,
3241 FIXME("(%p)->(%p, %08lx, %p, %p): stub\n", iface
, hc
, dwUsage
, pPrev
, ppCert
);
3245 static HRESULT WINAPI
MimeSecurity_GetCertificateName(
3246 IMimeSecurity
* iface
,
3247 const PCX509CERT pX509Cert
,
3248 const CERTNAMETYPE cn
,
3251 FIXME("(%p)->(%p, %08x, %p): stub\n", iface
, pX509Cert
, cn
, ppszName
);
3255 static HRESULT WINAPI
MimeSecurity_GetMessageType(
3256 IMimeSecurity
* iface
,
3257 const HWND hwndParent
,
3261 FIXME("(%p)->(%p, %p, %p): stub\n", iface
, hwndParent
, pBody
, pdwSecType
);
3265 static HRESULT WINAPI
MimeSecurity_GetCertData(
3266 IMimeSecurity
* iface
,
3267 const PCX509CERT pX509Cert
,
3268 const CERTDATAID dataid
,
3269 LPPROPVARIANT pValue
)
3271 FIXME("(%p)->(%p, %x, %p): stub\n", iface
, pX509Cert
, dataid
, pValue
);
3276 static const IMimeSecurityVtbl MimeSecurityVtbl
=
3278 MimeSecurity_QueryInterface
,
3279 MimeSecurity_AddRef
,
3280 MimeSecurity_Release
,
3281 MimeSecurity_InitNew
,
3282 MimeSecurity_CheckInit
,
3283 MimeSecurity_EncodeMessage
,
3284 MimeSecurity_EncodeBody
,
3285 MimeSecurity_DecodeMessage
,
3286 MimeSecurity_DecodeBody
,
3287 MimeSecurity_EnumCertificates
,
3288 MimeSecurity_GetCertificateName
,
3289 MimeSecurity_GetMessageType
,
3290 MimeSecurity_GetCertData
3293 HRESULT
MimeSecurity_create(IUnknown
*outer
, void **obj
)
3299 if (outer
) return CLASS_E_NOAGGREGATION
;
3301 This
= malloc(sizeof(*This
));
3302 if (!This
) return E_OUTOFMEMORY
;
3304 This
->IMimeSecurity_iface
.lpVtbl
= &MimeSecurityVtbl
;
3307 *obj
= &This
->IMimeSecurity_iface
;
3311 /***********************************************************************
3312 * MimeOleCreateSecurity (INETCOMM.@)
3314 HRESULT WINAPI
MimeOleCreateSecurity(IMimeSecurity
**ppSecurity
)
3316 return MimeSecurity_create(NULL
, (void **)ppSecurity
);
3319 static HRESULT WINAPI
MimeAlloc_QueryInterface(
3320 IMimeAllocator
* iface
,
3324 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), obj
);
3326 if (IsEqualIID(riid
, &IID_IUnknown
) ||
3327 IsEqualIID(riid
, &IID_IMalloc
) ||
3328 IsEqualIID(riid
, &IID_IMimeAllocator
))
3331 IMimeAllocator_AddRef(iface
);
3335 FIXME("no interface for %s\n", debugstr_guid(riid
));
3337 return E_NOINTERFACE
;
3340 static ULONG WINAPI
MimeAlloc_AddRef(
3341 IMimeAllocator
* iface
)
3346 static ULONG WINAPI
MimeAlloc_Release(
3347 IMimeAllocator
* iface
)
3352 static LPVOID WINAPI
MimeAlloc_Alloc(
3353 IMimeAllocator
* iface
,
3356 return CoTaskMemAlloc(cb
);
3359 static LPVOID WINAPI
MimeAlloc_Realloc(
3360 IMimeAllocator
* iface
,
3364 return CoTaskMemRealloc(pv
, cb
);
3367 static void WINAPI
MimeAlloc_Free(
3368 IMimeAllocator
* iface
,
3374 static SIZE_T WINAPI
MimeAlloc_GetSize(
3375 IMimeAllocator
* iface
,
3382 static int WINAPI
MimeAlloc_DidAlloc(
3383 IMimeAllocator
* iface
,
3390 static void WINAPI
MimeAlloc_HeapMinimize(
3391 IMimeAllocator
* iface
)
3397 static HRESULT WINAPI
MimeAlloc_FreeParamInfoArray(
3398 IMimeAllocator
* iface
,
3400 LPMIMEPARAMINFO prgParam
,
3404 TRACE("(%p)->(%ld, %p, %d)\n", iface
, cParams
, prgParam
, fFreeArray
);
3406 for(i
= 0; i
< cParams
; i
++)
3408 IMimeAllocator_Free(iface
, prgParam
[i
].pszName
);
3409 IMimeAllocator_Free(iface
, prgParam
[i
].pszData
);
3411 if(fFreeArray
) IMimeAllocator_Free(iface
, prgParam
);
3415 static HRESULT WINAPI
MimeAlloc_FreeAddressList(
3416 IMimeAllocator
* iface
,
3417 LPADDRESSLIST pList
)
3423 static HRESULT WINAPI
MimeAlloc_FreeAddressProps(
3424 IMimeAllocator
* iface
,
3425 LPADDRESSPROPS pAddress
)
3431 static HRESULT WINAPI
MimeAlloc_ReleaseObjects(
3432 IMimeAllocator
* iface
,
3434 IUnknown
**prgpUnknown
,
3442 static HRESULT WINAPI
MimeAlloc_FreeEnumHeaderRowArray(
3443 IMimeAllocator
* iface
,
3445 LPENUMHEADERROW prgRow
,
3452 static HRESULT WINAPI
MimeAlloc_FreeEnumPropertyArray(
3453 IMimeAllocator
* iface
,
3455 LPENUMPROPERTY prgProp
,
3462 static HRESULT WINAPI
MimeAlloc_FreeThumbprint(
3463 IMimeAllocator
* iface
,
3464 THUMBBLOB
*pthumbprint
)
3471 static HRESULT WINAPI
MimeAlloc_PropVariantClear(
3472 IMimeAllocator
* iface
,
3473 LPPROPVARIANT pProp
)
3479 static IMimeAllocatorVtbl mime_alloc_vtbl
=
3481 MimeAlloc_QueryInterface
,
3489 MimeAlloc_HeapMinimize
,
3490 MimeAlloc_FreeParamInfoArray
,
3491 MimeAlloc_FreeAddressList
,
3492 MimeAlloc_FreeAddressProps
,
3493 MimeAlloc_ReleaseObjects
,
3494 MimeAlloc_FreeEnumHeaderRowArray
,
3495 MimeAlloc_FreeEnumPropertyArray
,
3496 MimeAlloc_FreeThumbprint
,
3497 MimeAlloc_PropVariantClear
3500 static IMimeAllocator mime_allocator
=
3505 HRESULT
MimeAllocator_create(IUnknown
*outer
, void **obj
)
3507 if(outer
) return CLASS_E_NOAGGREGATION
;
3509 *obj
= &mime_allocator
;
3513 HRESULT WINAPI
MimeOleGetAllocator(IMimeAllocator
**alloc
)
3515 return MimeAllocator_create(NULL
, (void**)alloc
);
3518 HRESULT
VirtualStream_create(IUnknown
*outer
, void **obj
)
3520 FIXME("(%p, %p)\n", outer
, obj
);
3523 if (outer
) return CLASS_E_NOAGGREGATION
;
3525 return MimeOleCreateVirtualStream((IStream
**)obj
);
3528 /* IMimePropertySchema Interface */
3529 static HRESULT WINAPI
propschema_QueryInterface(IMimePropertySchema
*iface
, REFIID riid
, void **out
)
3531 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3532 TRACE("(%p)->(%s, %p)\n", This
, debugstr_guid(riid
), out
);
3536 if (IsEqualIID(riid
, &IID_IUnknown
) ||
3537 IsEqualIID(riid
, &IID_IMimePropertySchema
))
3543 FIXME("no interface for %s\n", debugstr_guid(riid
));
3544 return E_NOINTERFACE
;
3547 IMimePropertySchema_AddRef(iface
);
3551 static ULONG WINAPI
propschema_AddRef(IMimePropertySchema
*iface
)
3553 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3554 LONG ref
= InterlockedIncrement(&This
->ref
);
3556 TRACE("(%p) ref=%ld\n", This
, ref
);
3561 static ULONG WINAPI
propschema_Release(IMimePropertySchema
*iface
)
3563 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3564 LONG ref
= InterlockedDecrement(&This
->ref
);
3566 TRACE("(%p) ref=%ld\n", This
, ref
);
3576 static HRESULT WINAPI
propschema_RegisterProperty(IMimePropertySchema
*iface
, const char *name
, DWORD flags
,
3577 DWORD rownumber
, VARTYPE vtdefault
, DWORD
*propid
)
3579 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3580 FIXME("(%p)->(%s, %lx, %ld, %d, %p) stub\n", This
, debugstr_a(name
), flags
, rownumber
, vtdefault
, propid
);
3584 static HRESULT WINAPI
propschema_ModifyProperty(IMimePropertySchema
*iface
, const char *name
, DWORD flags
,
3585 DWORD rownumber
, VARTYPE vtdefault
)
3587 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3588 FIXME("(%p)->(%s, %lx, %ld, %d) stub\n", This
, debugstr_a(name
), flags
, rownumber
, vtdefault
);
3592 static HRESULT WINAPI
propschema_GetPropertyId(IMimePropertySchema
*iface
, const char *name
, DWORD
*propid
)
3594 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3595 FIXME("(%p)->(%s, %p) stub\n", This
, debugstr_a(name
), propid
);
3599 static HRESULT WINAPI
propschema_GetPropertyName(IMimePropertySchema
*iface
, DWORD propid
, char **name
)
3601 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3602 FIXME("(%p)->(%ld, %p) stub\n", This
, propid
, name
);
3606 static HRESULT WINAPI
propschema_RegisterAddressType(IMimePropertySchema
*iface
, const char *name
, DWORD
*adrtype
)
3608 propschema
*This
= impl_from_IMimePropertySchema(iface
);
3609 FIXME("(%p)->(%s, %p) stub\n", This
, debugstr_a(name
), adrtype
);
3613 static IMimePropertySchemaVtbl prop_schema_vtbl
=
3615 propschema_QueryInterface
,
3618 propschema_RegisterProperty
,
3619 propschema_ModifyProperty
,
3620 propschema_GetPropertyId
,
3621 propschema_GetPropertyName
,
3622 propschema_RegisterAddressType
3626 HRESULT WINAPI
MimeOleGetPropertySchema(IMimePropertySchema
**schema
)
3630 TRACE("(%p) stub\n", schema
);
3632 This
= malloc(sizeof(*This
));
3634 return E_OUTOFMEMORY
;
3636 This
->IMimePropertySchema_iface
.lpVtbl
= &prop_schema_vtbl
;
3639 *schema
= &This
->IMimePropertySchema_iface
;
3644 HRESULT WINAPI
MimeGetAddressFormatW(REFIID riid
, void *object
, DWORD addr_type
,
3645 ADDRESSFORMAT addr_format
, WCHAR
**address
)
3647 FIXME("(%s, %p, %ld, %d, %p) stub\n", debugstr_guid(riid
), object
, addr_type
, addr_format
, address
);
3652 static HRESULT WINAPI
mime_obj_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppv
)
3654 FIXME("(%s %p)\n", debugstr_guid(riid
), ppv
);
3656 return E_NOINTERFACE
;
3659 static ULONG WINAPI
mime_obj_AddRef(IUnknown
*iface
)
3665 static ULONG WINAPI
mime_obj_Release(IUnknown
*iface
)
3671 static const IUnknownVtbl mime_obj_vtbl
= {
3672 mime_obj_QueryInterface
,
3677 static IUnknown mime_obj
= { &mime_obj_vtbl
};
3679 HRESULT WINAPI
MimeOleObjectFromMoniker(BINDF bindf
, IMoniker
*moniker
, IBindCtx
*binding
,
3680 REFIID riid
, void **out
, IMoniker
**moniker_new
)
3682 WCHAR
*display_name
, *mhtml_url
;
3686 WARN("(0x%08x, %p, %p, %s, %p, %p) semi-stub\n", bindf
, moniker
, binding
, debugstr_guid(riid
), out
, moniker_new
);
3688 if(!IsEqualGUID(&IID_IUnknown
, riid
)) {
3689 FIXME("Unsupported riid %s\n", debugstr_guid(riid
));
3690 return E_NOINTERFACE
;
3693 hres
= IMoniker_GetDisplayName(moniker
, NULL
, NULL
, &display_name
);
3697 TRACE("display name %s\n", debugstr_w(display_name
));
3699 len
= lstrlenW(display_name
);
3700 mhtml_url
= malloc(len
* sizeof(WCHAR
) + sizeof(L
"mhtml:"));
3702 return E_OUTOFMEMORY
;
3704 lstrcpyW(mhtml_url
, L
"mhtml:");
3705 lstrcatW(mhtml_url
, display_name
);
3706 CoTaskMemFree(display_name
);
3708 hres
= CreateURLMoniker(NULL
, mhtml_url
, moniker_new
);
3713 /* FIXME: We most likely should start binding here and return something more meaningful as mime object. */