inetcomm: Added missing initialization.
[wine/winequartzdrv.git] / dlls / inetcomm / mimeole.c
blob0e4a6113e400cf73da81c50a5a4a65288f5c2c8c
1 /*
2 * MIME OLE Interfaces
4 * Copyright 2006 Robert Shearman for CodeWeavers
5 * Copyright 2007 Huw Davies for CodeWeavers
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define COBJMACROS
23 #define NONAMELESSUNION
25 #include <stdarg.h>
26 #include <stdio.h>
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winuser.h"
31 #include "objbase.h"
32 #include "ole2.h"
33 #include "mimeole.h"
35 #include "wine/list.h"
36 #include "wine/debug.h"
38 #include "inetcomm_private.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(inetcomm);
42 typedef struct
44 LPCSTR name;
45 DWORD id;
46 DWORD flags; /* MIMEPROPFLAGS */
47 VARTYPE default_vt;
48 } property_t;
50 typedef struct
52 struct list entry;
53 property_t prop;
54 } property_list_entry_t;
56 static const property_t default_props[] =
58 {"References", PID_HDR_REFS, 0, VT_LPSTR},
59 {"Subject", PID_HDR_SUBJECT, 0, VT_LPSTR},
60 {"From", PID_HDR_FROM, MPF_ADDRESS, VT_LPSTR},
61 {"Message-ID", PID_HDR_MESSAGEID, 0, VT_LPSTR},
62 {"Return-Path", PID_HDR_RETURNPATH, MPF_ADDRESS, VT_LPSTR},
63 {"Date", PID_HDR_DATE, 0, VT_LPSTR},
64 {"Received", PID_HDR_RECEIVED, 0, VT_LPSTR},
65 {"Reply-To", PID_HDR_REPLYTO, MPF_ADDRESS, VT_LPSTR},
66 {"X-Mailer", PID_HDR_XMAILER, 0, VT_LPSTR},
67 {"Bcc", PID_HDR_BCC, MPF_ADDRESS, VT_LPSTR},
68 {"MIME-Version", PID_HDR_MIMEVER, MPF_MIME, VT_LPSTR},
69 {"Content-Type", PID_HDR_CNTTYPE, MPF_MIME | MPF_HASPARAMS, VT_LPSTR},
70 {"Content-Transfer-Encoding", PID_HDR_CNTXFER, MPF_MIME, VT_LPSTR},
71 {"Content-ID", PID_HDR_CNTID, MPF_MIME, VT_LPSTR},
72 {"Content-Disposition", PID_HDR_CNTDISP, MPF_MIME, VT_LPSTR},
73 {"To", PID_HDR_TO, MPF_ADDRESS, VT_LPSTR},
74 {"Cc", PID_HDR_CC, MPF_ADDRESS, VT_LPSTR},
75 {"Sender", PID_HDR_SENDER, MPF_ADDRESS, VT_LPSTR},
76 {"In-Reply-To", PID_HDR_INREPLYTO, 0, VT_LPSTR},
77 {NULL, 0, 0, 0}
80 typedef struct
82 struct list entry;
83 char *name;
84 char *value;
85 } param_t;
87 typedef struct
89 struct list entry;
90 const property_t *prop;
91 PROPVARIANT value;
92 struct list params;
93 } header_t;
95 typedef struct MimeBody
97 const IMimeBodyVtbl *lpVtbl;
98 LONG refs;
100 HBODY handle;
102 struct list headers;
103 struct list new_props; /* FIXME: This should be in a PropertySchema */
104 DWORD next_prop_id;
105 char *content_pri_type;
106 char *content_sub_type;
107 ENCODINGTYPE encoding;
108 void *data;
109 IID data_iid;
110 BODYOFFSETS body_offsets;
111 } MimeBody;
113 static inline MimeBody *impl_from_IMimeBody( IMimeBody *iface )
115 return (MimeBody *)((char*)iface - FIELD_OFFSET(MimeBody, lpVtbl));
118 static LPSTR strdupA(LPCSTR str)
120 char *ret;
121 int len = strlen(str);
122 ret = HeapAlloc(GetProcessHeap(), 0, len + 1);
123 memcpy(ret, str, len + 1);
124 return ret;
127 #define PARSER_BUF_SIZE 1024
129 /*****************************************************
130 * copy_headers_to_buf [internal]
132 * Copies the headers into a '\0' terminated memory block and leave
133 * the stream's current position set to after the blank line.
135 static HRESULT copy_headers_to_buf(IStream *stm, char **ptr)
137 char *buf = NULL;
138 DWORD size = PARSER_BUF_SIZE, offset = 0, last_end = 0;
139 HRESULT hr;
140 int done = 0;
142 *ptr = NULL;
146 char *end;
147 DWORD read;
149 if(!buf)
150 buf = HeapAlloc(GetProcessHeap(), 0, size + 1);
151 else
153 size *= 2;
154 buf = HeapReAlloc(GetProcessHeap(), 0, buf, size + 1);
156 if(!buf)
158 hr = E_OUTOFMEMORY;
159 goto fail;
162 hr = IStream_Read(stm, buf + offset, size - offset, &read);
163 if(FAILED(hr)) goto fail;
165 offset += read;
166 buf[offset] = '\0';
168 if(read == 0) done = 1;
170 while(!done && (end = strstr(buf + last_end, "\r\n")))
172 DWORD new_end = end - buf + 2;
173 if(new_end - last_end == 2)
175 LARGE_INTEGER off;
176 off.QuadPart = new_end;
177 IStream_Seek(stm, off, STREAM_SEEK_SET, NULL);
178 buf[new_end] = '\0';
179 done = 1;
181 else
182 last_end = new_end;
184 } while(!done);
186 *ptr = buf;
187 return S_OK;
189 fail:
190 HeapFree(GetProcessHeap(), 0, buf);
191 return hr;
194 static header_t *read_prop(MimeBody *body, char **ptr)
196 char *colon = strchr(*ptr, ':');
197 const property_t *prop;
198 header_t *ret;
200 if(!colon) return NULL;
202 *colon = '\0';
204 for(prop = default_props; prop->name; prop++)
206 if(!strcasecmp(*ptr, prop->name))
208 TRACE("%s: found match with default property id %d\n", *ptr, prop->id);
209 break;
213 if(!prop->name)
215 property_list_entry_t *prop_entry;
216 LIST_FOR_EACH_ENTRY(prop_entry, &body->new_props, property_list_entry_t, entry)
218 if(!strcasecmp(*ptr, prop_entry->prop.name))
220 TRACE("%s: found match with already added new property id %d\n", *ptr, prop_entry->prop.id);
221 prop = &prop_entry->prop;
222 break;
225 if(!prop->name)
227 prop_entry = HeapAlloc(GetProcessHeap(), 0, sizeof(*prop_entry));
228 prop_entry->prop.name = strdupA(*ptr);
229 prop_entry->prop.id = body->next_prop_id++;
230 prop_entry->prop.flags = 0;
231 prop_entry->prop.default_vt = VT_LPSTR;
232 list_add_tail(&body->new_props, &prop_entry->entry);
233 prop = &prop_entry->prop;
234 TRACE("%s: allocating new prop id %d\n", *ptr, prop_entry->prop.id);
238 ret = HeapAlloc(GetProcessHeap(), 0, sizeof(*ret));
239 ret->prop = prop;
240 PropVariantInit(&ret->value);
241 list_init(&ret->params);
242 *ptr = colon + 1;
244 return ret;
247 static void unfold_header(char *header, int len)
249 char *start = header, *cp = header;
251 do {
252 while(*cp == ' ' || *cp == '\t')
254 cp++;
255 len--;
257 if(cp != start)
258 memmove(start, cp, len + 1);
260 cp = strstr(start, "\r\n");
261 len -= (cp - start);
262 start = cp;
263 *start = ' ';
264 start++;
265 len--;
266 cp += 2;
267 } while(*cp == ' ' || *cp == '\t');
269 *(start - 1) = '\0';
272 static char *unquote_string(const char *str)
274 int quoted = 0;
275 char *ret, *cp;
277 while(*str == ' ' || *str == '\t') str++;
279 if(*str == '"')
281 quoted = 1;
282 str++;
284 ret = strdupA(str);
285 for(cp = ret; *cp; cp++)
287 if(*cp == '\\')
288 memmove(cp, cp + 1, strlen(cp + 1) + 1);
289 else if(*cp == '"')
291 if(!quoted)
293 WARN("quote in unquoted string\n");
295 else
297 *cp = '\0';
298 break;
302 return ret;
305 static void add_param(header_t *header, const char *p)
307 const char *key = p, *value, *cp = p;
308 param_t *param;
309 char *name;
311 TRACE("got param %s\n", p);
313 while (*key == ' ' || *key == '\t' ) key++;
315 cp = strchr(key, '=');
316 if(!cp)
318 WARN("malformed parameter - skipping\n");
319 return;
322 name = HeapAlloc(GetProcessHeap(), 0, cp - key + 1);
323 memcpy(name, key, cp - key);
324 name[cp - key] = '\0';
326 value = cp + 1;
328 param = HeapAlloc(GetProcessHeap(), 0, sizeof(*param));
329 param->name = name;
330 param->value = unquote_string(value);
331 list_add_tail(&header->params, &param->entry);
334 static void split_params(header_t *header, char *value)
336 char *cp = value, *start = value;
337 int in_quote = 0;
338 int done_value = 0;
340 while(*cp)
342 if(!in_quote && *cp == ';')
344 *cp = '\0';
345 if(done_value) add_param(header, start);
346 done_value = 1;
347 start = cp + 1;
349 else if(*cp == '"')
350 in_quote = !in_quote;
351 cp++;
353 if(done_value) add_param(header, start);
356 static void read_value(header_t *header, char **cur)
358 char *end = *cur, *value;
359 DWORD len;
361 do {
362 end = strstr(end, "\r\n");
363 end += 2;
364 } while(*end == ' ' || *end == '\t');
366 len = end - *cur;
367 value = HeapAlloc(GetProcessHeap(), 0, len + 1);
368 memcpy(value, *cur, len);
369 value[len] = '\0';
371 unfold_header(value, len);
372 TRACE("value %s\n", debugstr_a(value));
374 if(header->prop->flags & MPF_HASPARAMS)
376 split_params(header, value);
377 TRACE("value w/o params %s\n", debugstr_a(value));
380 header->value.vt = VT_LPSTR;
381 header->value.u.pszVal = value;
383 *cur = end;
386 static void init_content_type(MimeBody *body, header_t *header)
388 char *slash;
389 DWORD len;
391 if(header->prop->id != PID_HDR_CNTTYPE)
393 ERR("called with header %s\n", header->prop->name);
394 return;
397 slash = strchr(header->value.u.pszVal, '/');
398 if(!slash)
400 WARN("malformed context type value\n");
401 return;
403 len = slash - header->value.u.pszVal;
404 body->content_pri_type = HeapAlloc(GetProcessHeap(), 0, len + 1);
405 memcpy(body->content_pri_type, header->value.u.pszVal, len);
406 body->content_pri_type[len] = '\0';
407 body->content_sub_type = strdupA(slash + 1);
410 static HRESULT parse_headers(MimeBody *body, IStream *stm)
412 char *header_buf, *cur_header_ptr;
413 HRESULT hr;
414 header_t *header;
416 hr = copy_headers_to_buf(stm, &header_buf);
417 if(FAILED(hr)) return hr;
419 cur_header_ptr = header_buf;
420 while((header = read_prop(body, &cur_header_ptr)))
422 read_value(header, &cur_header_ptr);
423 list_add_tail(&body->headers, &header->entry);
425 if(header->prop->id == PID_HDR_CNTTYPE)
426 init_content_type(body, header);
429 HeapFree(GetProcessHeap(), 0, header_buf);
430 return hr;
433 static void empty_param_list(struct list *list)
435 param_t *param, *cursor2;
437 LIST_FOR_EACH_ENTRY_SAFE(param, cursor2, list, param_t, entry)
439 list_remove(&param->entry);
440 HeapFree(GetProcessHeap(), 0, param->name);
441 HeapFree(GetProcessHeap(), 0, param->value);
442 HeapFree(GetProcessHeap(), 0, param);
446 static void empty_header_list(struct list *list)
448 header_t *header, *cursor2;
450 LIST_FOR_EACH_ENTRY_SAFE(header, cursor2, list, header_t, entry)
452 list_remove(&header->entry);
453 PropVariantClear(&header->value);
454 empty_param_list(&header->params);
455 HeapFree(GetProcessHeap(), 0, header);
459 static void empty_new_prop_list(struct list *list)
461 property_list_entry_t *prop, *cursor2;
463 LIST_FOR_EACH_ENTRY_SAFE(prop, cursor2, list, property_list_entry_t, entry)
465 list_remove(&prop->entry);
466 HeapFree(GetProcessHeap(), 0, (char *)prop->prop.name);
467 HeapFree(GetProcessHeap(), 0, prop);
471 static void release_data(REFIID riid, void *data)
473 if(!data) return;
475 if(IsEqualIID(riid, &IID_IStream))
476 IStream_Release((IStream *)data);
477 else
478 FIXME("Unhandled data format %s\n", debugstr_guid(riid));
481 static HRESULT find_prop(MimeBody *body, const char *name, header_t **prop)
483 header_t *header;
485 *prop = NULL;
487 LIST_FOR_EACH_ENTRY(header, &body->headers, header_t, entry)
489 if(!strcasecmp(name, header->prop->name))
491 *prop = header;
492 return S_OK;
496 return MIME_E_NOT_FOUND;
499 static HRESULT WINAPI MimeBody_QueryInterface(IMimeBody* iface,
500 REFIID riid,
501 void** ppvObject)
503 TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppvObject);
505 *ppvObject = NULL;
507 if (IsEqualIID(riid, &IID_IUnknown) ||
508 IsEqualIID(riid, &IID_IPersist) ||
509 IsEqualIID(riid, &IID_IPersistStreamInit) ||
510 IsEqualIID(riid, &IID_IMimePropertySet) ||
511 IsEqualIID(riid, &IID_IMimeBody))
513 *ppvObject = iface;
516 if(*ppvObject)
518 IUnknown_AddRef((IUnknown*)*ppvObject);
519 return S_OK;
522 FIXME("no interface for %s\n", debugstr_guid(riid));
523 return E_NOINTERFACE;
526 static ULONG WINAPI MimeBody_AddRef(IMimeBody* iface)
528 MimeBody *This = impl_from_IMimeBody(iface);
529 TRACE("(%p)->()\n", iface);
530 return InterlockedIncrement(&This->refs);
533 static ULONG WINAPI MimeBody_Release(IMimeBody* iface)
535 MimeBody *This = impl_from_IMimeBody(iface);
536 ULONG refs;
538 TRACE("(%p)->()\n", iface);
540 refs = InterlockedDecrement(&This->refs);
541 if (!refs)
543 empty_header_list(&This->headers);
544 empty_new_prop_list(&This->new_props);
546 HeapFree(GetProcessHeap(), 0, This->content_pri_type);
547 HeapFree(GetProcessHeap(), 0, This->content_sub_type);
549 release_data(&This->data_iid, This->data);
551 HeapFree(GetProcessHeap(), 0, This);
554 return refs;
557 static HRESULT WINAPI MimeBody_GetClassID(
558 IMimeBody* iface,
559 CLSID* pClassID)
561 FIXME("stub\n");
562 return E_NOTIMPL;
566 static HRESULT WINAPI MimeBody_IsDirty(
567 IMimeBody* iface)
569 FIXME("stub\n");
570 return E_NOTIMPL;
573 static HRESULT WINAPI MimeBody_Load(
574 IMimeBody* iface,
575 LPSTREAM pStm)
577 MimeBody *This = impl_from_IMimeBody(iface);
578 TRACE("(%p)->(%p)\n", iface, pStm);
579 return parse_headers(This, pStm);
582 static HRESULT WINAPI MimeBody_Save(
583 IMimeBody* iface,
584 LPSTREAM pStm,
585 BOOL fClearDirty)
587 FIXME("stub\n");
588 return E_NOTIMPL;
591 static HRESULT WINAPI MimeBody_GetSizeMax(
592 IMimeBody* iface,
593 ULARGE_INTEGER* pcbSize)
595 FIXME("stub\n");
596 return E_NOTIMPL;
599 static HRESULT WINAPI MimeBody_InitNew(
600 IMimeBody* iface)
602 TRACE("%p->()\n", iface);
603 return S_OK;
606 static HRESULT WINAPI MimeBody_GetPropInfo(
607 IMimeBody* iface,
608 LPCSTR pszName,
609 LPMIMEPROPINFO pInfo)
611 FIXME("stub\n");
612 return E_NOTIMPL;
615 static HRESULT WINAPI MimeBody_SetPropInfo(
616 IMimeBody* iface,
617 LPCSTR pszName,
618 LPCMIMEPROPINFO pInfo)
620 FIXME("stub\n");
621 return E_NOTIMPL;
624 static HRESULT WINAPI MimeBody_GetProp(
625 IMimeBody* iface,
626 LPCSTR pszName,
627 DWORD dwFlags,
628 LPPROPVARIANT pValue)
630 FIXME("stub\n");
631 return E_NOTIMPL;
634 static HRESULT WINAPI MimeBody_SetProp(
635 IMimeBody* iface,
636 LPCSTR pszName,
637 DWORD dwFlags,
638 LPCPROPVARIANT pValue)
640 FIXME("stub\n");
641 return E_NOTIMPL;
644 static HRESULT WINAPI MimeBody_AppendProp(
645 IMimeBody* iface,
646 LPCSTR pszName,
647 DWORD dwFlags,
648 LPPROPVARIANT pValue)
650 FIXME("stub\n");
651 return E_NOTIMPL;
654 static HRESULT WINAPI MimeBody_DeleteProp(
655 IMimeBody* iface,
656 LPCSTR pszName)
658 FIXME("stub\n");
659 return E_NOTIMPL;
662 static HRESULT WINAPI MimeBody_CopyProps(
663 IMimeBody* iface,
664 ULONG cNames,
665 LPCSTR* prgszName,
666 IMimePropertySet* pPropertySet)
668 FIXME("stub\n");
669 return E_NOTIMPL;
672 static HRESULT WINAPI MimeBody_MoveProps(
673 IMimeBody* iface,
674 ULONG cNames,
675 LPCSTR* prgszName,
676 IMimePropertySet* pPropertySet)
678 FIXME("stub\n");
679 return E_NOTIMPL;
682 static HRESULT WINAPI MimeBody_DeleteExcept(
683 IMimeBody* iface,
684 ULONG cNames,
685 LPCSTR* prgszName)
687 FIXME("stub\n");
688 return E_NOTIMPL;
691 static HRESULT WINAPI MimeBody_QueryProp(
692 IMimeBody* iface,
693 LPCSTR pszName,
694 LPCSTR pszCriteria,
695 boolean fSubString,
696 boolean fCaseSensitive)
698 FIXME("stub\n");
699 return E_NOTIMPL;
702 static HRESULT WINAPI MimeBody_GetCharset(
703 IMimeBody* iface,
704 LPHCHARSET phCharset)
706 FIXME("stub\n");
707 return E_NOTIMPL;
710 static HRESULT WINAPI MimeBody_SetCharset(
711 IMimeBody* iface,
712 HCHARSET hCharset,
713 CSETAPPLYTYPE applytype)
715 FIXME("stub\n");
716 return E_NOTIMPL;
719 static HRESULT WINAPI MimeBody_GetParameters(
720 IMimeBody* iface,
721 LPCSTR pszName,
722 ULONG* pcParams,
723 LPMIMEPARAMINFO* pprgParam)
725 MimeBody *This = impl_from_IMimeBody(iface);
726 HRESULT hr;
727 header_t *header;
729 TRACE("(%p)->(%s, %p, %p)\n", iface, debugstr_a(pszName), pcParams, pprgParam);
731 *pprgParam = NULL;
732 *pcParams = 0;
734 hr = find_prop(This, pszName, &header);
735 if(hr != S_OK) return hr;
737 *pcParams = list_count(&header->params);
738 if(*pcParams)
740 IMimeAllocator *alloc;
741 param_t *param;
742 MIMEPARAMINFO *info;
744 MimeOleGetAllocator(&alloc);
746 *pprgParam = info = IMimeAllocator_Alloc(alloc, *pcParams * sizeof(**pprgParam));
747 LIST_FOR_EACH_ENTRY(param, &header->params, param_t, entry)
749 int len;
751 len = strlen(param->name) + 1;
752 info->pszName = IMimeAllocator_Alloc(alloc, len);
753 memcpy(info->pszName, param->name, len);
754 len = strlen(param->value) + 1;
755 info->pszData = IMimeAllocator_Alloc(alloc, len);
756 memcpy(info->pszData, param->value, len);
757 info++;
759 IMimeAllocator_Release(alloc);
761 return S_OK;
764 static HRESULT WINAPI MimeBody_IsContentType(
765 IMimeBody* iface,
766 LPCSTR pszPriType,
767 LPCSTR pszSubType)
769 MimeBody *This = impl_from_IMimeBody(iface);
771 TRACE("(%p)->(%s, %s)\n", This, debugstr_a(pszPriType), debugstr_a(pszSubType));
772 if(pszPriType)
774 const char *pri = This->content_pri_type;
775 if(!pri) pri = "text";
776 if(strcasecmp(pri, pszPriType)) return S_FALSE;
779 if(pszSubType)
781 const char *sub = This->content_sub_type;
782 if(!sub) sub = "plain";
783 if(strcasecmp(sub, pszSubType)) return S_FALSE;
786 return S_OK;
789 static HRESULT WINAPI MimeBody_BindToObject(
790 IMimeBody* iface,
791 REFIID riid,
792 void** ppvObject)
794 FIXME("stub\n");
795 return E_NOTIMPL;
798 static HRESULT WINAPI MimeBody_Clone(
799 IMimeBody* iface,
800 IMimePropertySet** ppPropertySet)
802 FIXME("stub\n");
803 return E_NOTIMPL;
806 static HRESULT WINAPI MimeBody_SetOption(
807 IMimeBody* iface,
808 const TYPEDID oid,
809 LPCPROPVARIANT pValue)
811 FIXME("stub\n");
812 return E_NOTIMPL;
815 static HRESULT WINAPI MimeBody_GetOption(
816 IMimeBody* iface,
817 const TYPEDID oid,
818 LPPROPVARIANT pValue)
820 FIXME("stub\n");
821 return E_NOTIMPL;
824 static HRESULT WINAPI MimeBody_EnumProps(
825 IMimeBody* iface,
826 DWORD dwFlags,
827 IMimeEnumProperties** ppEnum)
829 FIXME("stub\n");
830 return E_NOTIMPL;
833 static HRESULT WINAPI MimeBody_IsType(
834 IMimeBody* iface,
835 IMSGBODYTYPE bodytype)
837 FIXME("stub\n");
838 return E_NOTIMPL;
841 static HRESULT WINAPI MimeBody_SetDisplayName(
842 IMimeBody* iface,
843 LPCSTR pszDisplay)
845 FIXME("stub\n");
846 return E_NOTIMPL;
849 static HRESULT WINAPI MimeBody_GetDisplayName(
850 IMimeBody* iface,
851 LPSTR* ppszDisplay)
853 FIXME("stub\n");
854 return E_NOTIMPL;
857 static HRESULT WINAPI MimeBody_GetOffsets(
858 IMimeBody* iface,
859 LPBODYOFFSETS pOffsets)
861 MimeBody *This = impl_from_IMimeBody(iface);
862 TRACE("(%p)->(%p)\n", This, pOffsets);
864 *pOffsets = This->body_offsets;
866 if(This->body_offsets.cbBodyEnd == 0) return MIME_E_NO_DATA;
867 return S_OK;
870 static HRESULT WINAPI MimeBody_GetCurrentEncoding(
871 IMimeBody* iface,
872 ENCODINGTYPE* pietEncoding)
874 MimeBody *This = impl_from_IMimeBody(iface);
876 TRACE("(%p)->(%p)\n", This, pietEncoding);
878 *pietEncoding = This->encoding;
879 return S_OK;
882 static HRESULT WINAPI MimeBody_SetCurrentEncoding(
883 IMimeBody* iface,
884 ENCODINGTYPE ietEncoding)
886 MimeBody *This = impl_from_IMimeBody(iface);
888 TRACE("(%p)->(%d)\n", This, ietEncoding);
890 This->encoding = ietEncoding;
891 return S_OK;
894 static HRESULT WINAPI MimeBody_GetEstimatedSize(
895 IMimeBody* iface,
896 ENCODINGTYPE ietEncoding,
897 ULONG* pcbSize)
899 FIXME("stub\n");
900 return E_NOTIMPL;
903 static HRESULT WINAPI MimeBody_GetDataHere(
904 IMimeBody* iface,
905 ENCODINGTYPE ietEncoding,
906 IStream* pStream)
908 FIXME("stub\n");
909 return E_NOTIMPL;
912 static HRESULT WINAPI MimeBody_GetData(
913 IMimeBody* iface,
914 ENCODINGTYPE ietEncoding,
915 IStream** ppStream)
917 MimeBody *This = impl_from_IMimeBody(iface);
918 FIXME("(%p)->(%d, %p). Ignoring encoding type.\n", This, ietEncoding, ppStream);
920 *ppStream = This->data;
921 IStream_AddRef(*ppStream);
922 return S_OK;
925 static HRESULT WINAPI MimeBody_SetData(
926 IMimeBody* iface,
927 ENCODINGTYPE ietEncoding,
928 LPCSTR pszPriType,
929 LPCSTR pszSubType,
930 REFIID riid,
931 LPVOID pvObject)
933 MimeBody *This = impl_from_IMimeBody(iface);
934 TRACE("(%p)->(%d, %s, %s, %s %p)\n", This, ietEncoding, debugstr_a(pszPriType), debugstr_a(pszSubType),
935 debugstr_guid(riid), pvObject);
937 if(IsEqualIID(riid, &IID_IStream))
938 IStream_AddRef((IStream *)pvObject);
939 else
941 FIXME("Unhandled object type %s\n", debugstr_guid(riid));
942 return E_INVALIDARG;
945 if(This->data)
946 FIXME("release old data\n");
948 This->data_iid = *riid;
949 This->data = pvObject;
951 IMimeBody_SetCurrentEncoding(iface, ietEncoding);
953 /* FIXME: Update the content type.
954 If pszPriType == NULL use 'application'
955 If pszSubType == NULL use 'octet-stream' */
957 return S_OK;
960 static HRESULT WINAPI MimeBody_EmptyData(
961 IMimeBody* iface)
963 FIXME("stub\n");
964 return E_NOTIMPL;
967 static HRESULT WINAPI MimeBody_CopyTo(
968 IMimeBody* iface,
969 IMimeBody* pBody)
971 FIXME("stub\n");
972 return E_NOTIMPL;
975 static HRESULT WINAPI MimeBody_GetTransmitInfo(
976 IMimeBody* iface,
977 LPTRANSMITINFO pTransmitInfo)
979 FIXME("stub\n");
980 return E_NOTIMPL;
983 static HRESULT WINAPI MimeBody_SaveToFile(
984 IMimeBody* iface,
985 ENCODINGTYPE ietEncoding,
986 LPCSTR pszFilePath)
988 FIXME("stub\n");
989 return E_NOTIMPL;
992 static HRESULT WINAPI MimeBody_GetHandle(
993 IMimeBody* iface,
994 LPHBODY phBody)
996 MimeBody *This = impl_from_IMimeBody(iface);
997 TRACE("(%p)->(%p)\n", iface, phBody);
999 *phBody = This->handle;
1000 return This->handle ? S_OK : MIME_E_NO_DATA;
1003 static IMimeBodyVtbl body_vtbl =
1005 MimeBody_QueryInterface,
1006 MimeBody_AddRef,
1007 MimeBody_Release,
1008 MimeBody_GetClassID,
1009 MimeBody_IsDirty,
1010 MimeBody_Load,
1011 MimeBody_Save,
1012 MimeBody_GetSizeMax,
1013 MimeBody_InitNew,
1014 MimeBody_GetPropInfo,
1015 MimeBody_SetPropInfo,
1016 MimeBody_GetProp,
1017 MimeBody_SetProp,
1018 MimeBody_AppendProp,
1019 MimeBody_DeleteProp,
1020 MimeBody_CopyProps,
1021 MimeBody_MoveProps,
1022 MimeBody_DeleteExcept,
1023 MimeBody_QueryProp,
1024 MimeBody_GetCharset,
1025 MimeBody_SetCharset,
1026 MimeBody_GetParameters,
1027 MimeBody_IsContentType,
1028 MimeBody_BindToObject,
1029 MimeBody_Clone,
1030 MimeBody_SetOption,
1031 MimeBody_GetOption,
1032 MimeBody_EnumProps,
1033 MimeBody_IsType,
1034 MimeBody_SetDisplayName,
1035 MimeBody_GetDisplayName,
1036 MimeBody_GetOffsets,
1037 MimeBody_GetCurrentEncoding,
1038 MimeBody_SetCurrentEncoding,
1039 MimeBody_GetEstimatedSize,
1040 MimeBody_GetDataHere,
1041 MimeBody_GetData,
1042 MimeBody_SetData,
1043 MimeBody_EmptyData,
1044 MimeBody_CopyTo,
1045 MimeBody_GetTransmitInfo,
1046 MimeBody_SaveToFile,
1047 MimeBody_GetHandle
1050 static HRESULT MimeBody_set_offsets(MimeBody *body, const BODYOFFSETS *offsets)
1052 TRACE("setting offsets to %d, %d, %d, %d\n", offsets->cbBoundaryStart,
1053 offsets->cbHeaderStart, offsets->cbBodyStart, offsets->cbBodyEnd);
1055 body->body_offsets = *offsets;
1056 return S_OK;
1059 #define FIRST_CUSTOM_PROP_ID 0x100
1061 HRESULT MimeBody_create(IUnknown *outer, void **obj)
1063 MimeBody *This;
1064 BODYOFFSETS body_offsets;
1066 *obj = NULL;
1068 if(outer) return CLASS_E_NOAGGREGATION;
1070 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
1071 if (!This) return E_OUTOFMEMORY;
1073 This->lpVtbl = &body_vtbl;
1074 This->refs = 1;
1075 This->handle = NULL;
1076 list_init(&This->headers);
1077 list_init(&This->new_props);
1078 This->next_prop_id = FIRST_CUSTOM_PROP_ID;
1079 This->content_pri_type = NULL;
1080 This->content_sub_type = NULL;
1081 This->encoding = IET_7BIT;
1082 This->data = NULL;
1083 This->data_iid = IID_NULL;
1085 body_offsets.cbBoundaryStart = body_offsets.cbHeaderStart = 0;
1086 body_offsets.cbBodyStart = body_offsets.cbBodyEnd = 0;
1087 MimeBody_set_offsets(This, &body_offsets);
1089 *obj = (IMimeBody *)&This->lpVtbl;
1090 return S_OK;
1093 typedef struct body_t
1095 struct list entry;
1096 HBODY hbody;
1097 IMimeBody *mime_body;
1099 struct body_t *parent;
1100 struct list children;
1101 } body_t;
1103 typedef struct MimeMessage
1105 const IMimeMessageVtbl *lpVtbl;
1107 LONG refs;
1108 IStream *stream;
1110 struct list body_tree;
1111 HBODY next_hbody;
1112 } MimeMessage;
1114 static HRESULT WINAPI MimeMessage_QueryInterface(IMimeMessage *iface, REFIID riid, void **ppv)
1116 TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppv);
1118 if (IsEqualIID(riid, &IID_IUnknown) ||
1119 IsEqualIID(riid, &IID_IPersist) ||
1120 IsEqualIID(riid, &IID_IPersistStreamInit) ||
1121 IsEqualIID(riid, &IID_IMimeMessageTree) ||
1122 IsEqualIID(riid, &IID_IMimeMessage))
1124 *ppv = iface;
1125 IUnknown_AddRef(iface);
1126 return S_OK;
1129 FIXME("no interface for %s\n", debugstr_guid(riid));
1130 *ppv = NULL;
1131 return E_NOINTERFACE;
1134 static ULONG WINAPI MimeMessage_AddRef(IMimeMessage *iface)
1136 MimeMessage *This = (MimeMessage *)iface;
1137 TRACE("(%p)->()\n", iface);
1138 return InterlockedIncrement(&This->refs);
1141 static void empty_body_list(struct list *list)
1143 body_t *body, *cursor2;
1144 LIST_FOR_EACH_ENTRY_SAFE(body, cursor2, list, body_t, entry)
1146 empty_body_list(&body->children);
1147 list_remove(&body->entry);
1148 IMimeBody_Release(body->mime_body);
1149 HeapFree(GetProcessHeap(), 0, body);
1153 static ULONG WINAPI MimeMessage_Release(IMimeMessage *iface)
1155 MimeMessage *This = (MimeMessage *)iface;
1156 ULONG refs;
1158 TRACE("(%p)->()\n", iface);
1160 refs = InterlockedDecrement(&This->refs);
1161 if (!refs)
1163 empty_body_list(&This->body_tree);
1165 if(This->stream) IStream_Release(This->stream);
1166 HeapFree(GetProcessHeap(), 0, This);
1169 return refs;
1172 /*** IPersist methods ***/
1173 static HRESULT WINAPI MimeMessage_GetClassID(
1174 IMimeMessage *iface,
1175 CLSID *pClassID)
1177 FIXME("(%p)->(%p)\n", iface, pClassID);
1178 return E_NOTIMPL;
1181 /*** IPersistStreamInit methods ***/
1182 static HRESULT WINAPI MimeMessage_IsDirty(
1183 IMimeMessage *iface)
1185 FIXME("(%p)->()\n", iface);
1186 return E_NOTIMPL;
1189 static body_t *new_body_entry(IMimeBody *mime_body, HBODY hbody, body_t *parent)
1191 body_t *body = HeapAlloc(GetProcessHeap(), 0, sizeof(*body));
1192 if(body)
1194 body->mime_body = mime_body;
1195 body->hbody = hbody;
1196 list_init(&body->children);
1197 body->parent = parent;
1199 return body;
1202 static body_t *create_sub_body(MimeMessage *msg, IStream *pStm, BODYOFFSETS *offset, body_t *parent)
1204 IMimeBody *mime_body;
1205 HRESULT hr;
1206 body_t *body;
1207 ULARGE_INTEGER cur;
1208 LARGE_INTEGER zero;
1210 MimeBody_create(NULL, (void**)&mime_body);
1211 IMimeBody_Load(mime_body, pStm);
1212 zero.QuadPart = 0;
1213 hr = IStream_Seek(pStm, zero, STREAM_SEEK_CUR, &cur);
1214 offset->cbBodyStart = cur.LowPart;
1215 IMimeBody_SetData(mime_body, IET_BINARY, NULL, NULL, &IID_IStream, pStm);
1216 body = new_body_entry(mime_body, msg->next_hbody, parent);
1217 msg->next_hbody = (HBODY)((DWORD)msg->next_hbody + 1);
1219 return body;
1222 static HRESULT WINAPI MimeMessage_Load(
1223 IMimeMessage *iface,
1224 LPSTREAM pStm)
1226 MimeMessage *This = (MimeMessage *)iface;
1227 body_t *root_body;
1228 BODYOFFSETS offsets;
1229 ULARGE_INTEGER cur;
1230 LARGE_INTEGER zero;
1232 TRACE("(%p)->(%p)\n", iface, pStm);
1234 if(This->stream)
1236 FIXME("already loaded a message\n");
1237 return E_FAIL;
1240 IStream_AddRef(pStm);
1241 This->stream = pStm;
1242 offsets.cbBoundaryStart = offsets.cbHeaderStart = 0;
1243 offsets.cbBodyStart = offsets.cbBodyEnd = 0;
1245 root_body = create_sub_body(This, pStm, &offsets, NULL);
1247 zero.QuadPart = 0;
1248 IStream_Seek(pStm, zero, STREAM_SEEK_END, &cur);
1249 offsets.cbBodyEnd = cur.LowPart;
1250 MimeBody_set_offsets(impl_from_IMimeBody(root_body->mime_body), &offsets);
1252 list_add_head(&This->body_tree, &root_body->entry);
1254 return S_OK;
1257 static HRESULT WINAPI MimeMessage_Save(
1258 IMimeMessage *iface,
1259 LPSTREAM pStm,
1260 BOOL fClearDirty)
1262 FIXME("(%p)->(%p, %s)\n", iface, pStm, fClearDirty ? "TRUE" : "FALSE");
1263 return E_NOTIMPL;
1266 static HRESULT WINAPI MimeMessage_GetSizeMax(
1267 IMimeMessage *iface,
1268 ULARGE_INTEGER *pcbSize)
1270 FIXME("(%p)->(%p)\n", iface, pcbSize);
1271 return E_NOTIMPL;
1274 static HRESULT WINAPI MimeMessage_InitNew(
1275 IMimeMessage *iface)
1277 FIXME("(%p)->()\n", iface);
1278 return E_NOTIMPL;
1281 /*** IMimeMessageTree methods ***/
1282 static HRESULT WINAPI MimeMessage_GetMessageSource(
1283 IMimeMessage *iface,
1284 IStream **ppStream,
1285 DWORD dwFlags)
1287 FIXME("(%p)->(%p, 0x%x)\n", iface, ppStream, dwFlags);
1288 return E_NOTIMPL;
1291 static HRESULT WINAPI MimeMessage_GetMessageSize(
1292 IMimeMessage *iface,
1293 ULONG *pcbSize,
1294 DWORD dwFlags)
1296 FIXME("(%p)->(%p, 0x%x)\n", iface, pcbSize, dwFlags);
1297 return E_NOTIMPL;
1300 static HRESULT WINAPI MimeMessage_LoadOffsetTable(
1301 IMimeMessage *iface,
1302 IStream *pStream)
1304 FIXME("(%p)->(%p)\n", iface, pStream);
1305 return E_NOTIMPL;
1308 static HRESULT WINAPI MimeMessage_SaveOffsetTable(
1309 IMimeMessage *iface,
1310 IStream *pStream,
1311 DWORD dwFlags)
1313 FIXME("(%p)->(%p, 0x%x)\n", iface, pStream, dwFlags);
1314 return E_NOTIMPL;
1318 static HRESULT WINAPI MimeMessage_GetFlags(
1319 IMimeMessage *iface,
1320 DWORD *pdwFlags)
1322 FIXME("(%p)->(%p)\n", iface, pdwFlags);
1323 return E_NOTIMPL;
1326 static HRESULT WINAPI MimeMessage_Commit(
1327 IMimeMessage *iface,
1328 DWORD dwFlags)
1330 FIXME("(%p)->(0x%x)\n", iface, dwFlags);
1331 return E_NOTIMPL;
1335 static HRESULT WINAPI MimeMessage_HandsOffStorage(
1336 IMimeMessage *iface)
1338 FIXME("(%p)->()\n", iface);
1339 return E_NOTIMPL;
1342 static HRESULT find_body(struct list *list, HBODY hbody, body_t **body)
1344 body_t *cur;
1345 HRESULT hr;
1347 if(hbody == HBODY_ROOT)
1349 *body = LIST_ENTRY(list_head(list), body_t, entry);
1350 return S_OK;
1353 LIST_FOR_EACH_ENTRY(cur, list, body_t, entry)
1355 if(cur->hbody == hbody)
1357 *body = cur;
1358 return S_OK;
1360 hr = find_body(&cur->children, hbody, body);
1361 if(hr == S_OK) return S_OK;
1363 return S_FALSE;
1366 static HRESULT WINAPI MimeMessage_BindToObject(
1367 IMimeMessage *iface,
1368 const HBODY hBody,
1369 REFIID riid,
1370 void **ppvObject)
1372 MimeMessage *This = (MimeMessage *)iface;
1373 HRESULT hr;
1374 body_t *body;
1376 TRACE("(%p)->(%p, %s, %p)\n", iface, hBody, debugstr_guid(riid), ppvObject);
1378 hr = find_body(&This->body_tree, hBody, &body);
1380 if(hr != S_OK) return hr;
1382 if(IsEqualIID(riid, &IID_IMimeBody))
1384 IMimeBody_AddRef(body->mime_body);
1385 *ppvObject = body->mime_body;
1386 return S_OK;
1389 return E_NOINTERFACE;
1392 static HRESULT WINAPI MimeMessage_SaveBody(
1393 IMimeMessage *iface,
1394 HBODY hBody,
1395 DWORD dwFlags,
1396 IStream *pStream)
1398 FIXME("(%p)->(%p, 0x%x, %p)\n", iface, hBody, dwFlags, pStream);
1399 return E_NOTIMPL;
1402 static HRESULT WINAPI MimeMessage_InsertBody(
1403 IMimeMessage *iface,
1404 BODYLOCATION location,
1405 HBODY hPivot,
1406 LPHBODY phBody)
1408 FIXME("(%p)->(%d, %p, %p)\n", iface, location, hPivot, phBody);
1409 return E_NOTIMPL;
1412 static HRESULT WINAPI MimeMessage_GetBody(
1413 IMimeMessage *iface,
1414 BODYLOCATION location,
1415 HBODY hPivot,
1416 LPHBODY phBody)
1418 FIXME("(%p)->(%d, %p, %p)\n", iface, location, hPivot, phBody);
1419 return E_NOTIMPL;
1422 static HRESULT WINAPI MimeMessage_DeleteBody(
1423 IMimeMessage *iface,
1424 HBODY hBody,
1425 DWORD dwFlags)
1427 FIXME("(%p)->(%p, %08x)\n", iface, hBody, dwFlags);
1428 return E_NOTIMPL;
1431 static HRESULT WINAPI MimeMessage_MoveBody(
1432 IMimeMessage *iface,
1433 HBODY hBody,
1434 BODYLOCATION location)
1436 FIXME("(%p)->(%d)\n", iface, location);
1437 return E_NOTIMPL;
1440 static HRESULT WINAPI MimeMessage_CountBodies(
1441 IMimeMessage *iface,
1442 HBODY hParent,
1443 boolean fRecurse,
1444 ULONG *pcBodies)
1446 FIXME("(%p)->(%p, %s, %p)\n", iface, hParent, fRecurse ? "TRUE" : "FALSE", pcBodies);
1447 return E_NOTIMPL;
1450 static HRESULT WINAPI MimeMessage_FindFirst(
1451 IMimeMessage *iface,
1452 LPFINDBODY pFindBody,
1453 LPHBODY phBody)
1455 FIXME("(%p)->(%p, %p)\n", iface, pFindBody, phBody);
1456 return E_NOTIMPL;
1459 static HRESULT WINAPI MimeMessage_FindNext(
1460 IMimeMessage *iface,
1461 LPFINDBODY pFindBody,
1462 LPHBODY phBody)
1464 FIXME("(%p)->(%p, %p)\n", iface, pFindBody, phBody);
1465 return E_NOTIMPL;
1468 static HRESULT WINAPI MimeMessage_ResolveURL(
1469 IMimeMessage *iface,
1470 HBODY hRelated,
1471 LPCSTR pszBase,
1472 LPCSTR pszURL,
1473 DWORD dwFlags,
1474 LPHBODY phBody)
1476 FIXME("(%p)->(%p, %s, %s, 0x%x, %p)\n", iface, hRelated, pszBase, pszURL, dwFlags, phBody);
1477 return E_NOTIMPL;
1480 static HRESULT WINAPI MimeMessage_ToMultipart(
1481 IMimeMessage *iface,
1482 HBODY hBody,
1483 LPCSTR pszSubType,
1484 LPHBODY phMultipart)
1486 FIXME("(%p)->(%p, %s, %p)\n", iface, hBody, pszSubType, phMultipart);
1487 return E_NOTIMPL;
1490 static HRESULT WINAPI MimeMessage_GetBodyOffsets(
1491 IMimeMessage *iface,
1492 HBODY hBody,
1493 LPBODYOFFSETS pOffsets)
1495 FIXME("(%p)->(%p, %p)\n", iface, hBody, pOffsets);
1496 return E_NOTIMPL;
1499 static HRESULT WINAPI MimeMessage_GetCharset(
1500 IMimeMessage *iface,
1501 LPHCHARSET phCharset)
1503 FIXME("(%p)->(%p)\n", iface, phCharset);
1504 return E_NOTIMPL;
1507 static HRESULT WINAPI MimeMessage_SetCharset(
1508 IMimeMessage *iface,
1509 HCHARSET hCharset,
1510 CSETAPPLYTYPE applytype)
1512 FIXME("(%p)->(%p, %d)\n", iface, hCharset, applytype);
1513 return E_NOTIMPL;
1516 static HRESULT WINAPI MimeMessage_IsBodyType(
1517 IMimeMessage *iface,
1518 HBODY hBody,
1519 IMSGBODYTYPE bodytype)
1521 FIXME("(%p)->(%p, %d)\n", iface, hBody, bodytype);
1522 return E_NOTIMPL;
1525 static HRESULT WINAPI MimeMessage_IsContentType(
1526 IMimeMessage *iface,
1527 HBODY hBody,
1528 LPCSTR pszPriType,
1529 LPCSTR pszSubType)
1531 FIXME("(%p)->(%p, %s, %s)\n", iface, hBody, pszPriType, pszSubType);
1532 return E_NOTIMPL;
1535 static HRESULT WINAPI MimeMessage_QueryBodyProp(
1536 IMimeMessage *iface,
1537 HBODY hBody,
1538 LPCSTR pszName,
1539 LPCSTR pszCriteria,
1540 boolean fSubString,
1541 boolean fCaseSensitive)
1543 FIXME("(%p)->(%p, %s, %s, %s, %s)\n", iface, hBody, pszName, pszCriteria, fSubString ? "TRUE" : "FALSE", fCaseSensitive ? "TRUE" : "FALSE");
1544 return E_NOTIMPL;
1547 static HRESULT WINAPI MimeMessage_GetBodyProp(
1548 IMimeMessage *iface,
1549 HBODY hBody,
1550 LPCSTR pszName,
1551 DWORD dwFlags,
1552 LPPROPVARIANT pValue)
1554 FIXME("(%p)->(%p, %s, 0x%x, %p)\n", iface, hBody, pszName, dwFlags, pValue);
1555 return E_NOTIMPL;
1558 static HRESULT WINAPI MimeMessage_SetBodyProp(
1559 IMimeMessage *iface,
1560 HBODY hBody,
1561 LPCSTR pszName,
1562 DWORD dwFlags,
1563 LPCPROPVARIANT pValue)
1565 FIXME("(%p)->(%p, %s, 0x%x, %p)\n", iface, hBody, pszName, dwFlags, pValue);
1566 return E_NOTIMPL;
1569 static HRESULT WINAPI MimeMessage_DeleteBodyProp(
1570 IMimeMessage *iface,
1571 HBODY hBody,
1572 LPCSTR pszName)
1574 FIXME("(%p)->(%p, %s)\n", iface, hBody, pszName);
1575 return E_NOTIMPL;
1578 static HRESULT WINAPI MimeMessage_SetOption(
1579 IMimeMessage *iface,
1580 const TYPEDID oid,
1581 LPCPROPVARIANT pValue)
1583 FIXME("(%p)->(%d, %p)\n", iface, oid, pValue);
1584 return E_NOTIMPL;
1587 static HRESULT WINAPI MimeMessage_GetOption(
1588 IMimeMessage *iface,
1589 const TYPEDID oid,
1590 LPPROPVARIANT pValue)
1592 FIXME("(%p)->(%d, %p)\n", iface, oid, pValue);
1593 return E_NOTIMPL;
1596 /*** IMimeMessage methods ***/
1597 static HRESULT WINAPI MimeMessage_CreateWebPage(
1598 IMimeMessage *iface,
1599 IStream *pRootStm,
1600 LPWEBPAGEOPTIONS pOptions,
1601 IMimeMessageCallback *pCallback,
1602 IMoniker **ppMoniker)
1604 FIXME("(%p)->(%p, %p, %p, %p)\n", iface, pRootStm, pOptions, pCallback, ppMoniker);
1605 *ppMoniker = NULL;
1606 return E_NOTIMPL;
1609 static HRESULT WINAPI MimeMessage_GetProp(
1610 IMimeMessage *iface,
1611 LPCSTR pszName,
1612 DWORD dwFlags,
1613 LPPROPVARIANT pValue)
1615 FIXME("(%p)->(%s, 0x%x, %p)\n", iface, pszName, dwFlags, pValue);
1616 return E_NOTIMPL;
1619 static HRESULT WINAPI MimeMessage_SetProp(
1620 IMimeMessage *iface,
1621 LPCSTR pszName,
1622 DWORD dwFlags,
1623 LPCPROPVARIANT pValue)
1625 FIXME("(%p)->(%s, 0x%x, %p)\n", iface, pszName, dwFlags, pValue);
1626 return E_NOTIMPL;
1629 static HRESULT WINAPI MimeMessage_DeleteProp(
1630 IMimeMessage *iface,
1631 LPCSTR pszName)
1633 FIXME("(%p)->(%s)\n", iface, pszName);
1634 return E_NOTIMPL;
1637 static HRESULT WINAPI MimeMessage_QueryProp(
1638 IMimeMessage *iface,
1639 LPCSTR pszName,
1640 LPCSTR pszCriteria,
1641 boolean fSubString,
1642 boolean fCaseSensitive)
1644 FIXME("(%p)->(%s, %s, %s, %s)\n", iface, pszName, pszCriteria, fSubString ? "TRUE" : "FALSE", fCaseSensitive ? "TRUE" : "FALSE");
1645 return E_NOTIMPL;
1648 static HRESULT WINAPI MimeMessage_GetTextBody(
1649 IMimeMessage *iface,
1650 DWORD dwTxtType,
1651 ENCODINGTYPE ietEncoding,
1652 IStream **pStream,
1653 LPHBODY phBody)
1655 FIXME("(%p)->(%d, %d, %p, %p)\n", iface, dwTxtType, ietEncoding, pStream, phBody);
1656 return E_NOTIMPL;
1659 static HRESULT WINAPI MimeMessage_SetTextBody(
1660 IMimeMessage *iface,
1661 DWORD dwTxtType,
1662 ENCODINGTYPE ietEncoding,
1663 HBODY hAlternative,
1664 IStream *pStream,
1665 LPHBODY phBody)
1667 FIXME("(%p)->(%d, %d, %p, %p, %p)\n", iface, dwTxtType, ietEncoding, hAlternative, pStream, phBody);
1668 return E_NOTIMPL;
1671 static HRESULT WINAPI MimeMessage_AttachObject(
1672 IMimeMessage *iface,
1673 REFIID riid,
1674 void *pvObject,
1675 LPHBODY phBody)
1677 FIXME("(%p)->(%s, %p, %p)\n", iface, debugstr_guid(riid), pvObject, phBody);
1678 return E_NOTIMPL;
1681 static HRESULT WINAPI MimeMessage_AttachFile(
1682 IMimeMessage *iface,
1683 LPCSTR pszFilePath,
1684 IStream *pstmFile,
1685 LPHBODY phBody)
1687 FIXME("(%p)->(%s, %p, %p)\n", iface, pszFilePath, pstmFile, phBody);
1688 return E_NOTIMPL;
1691 static HRESULT WINAPI MimeMessage_AttachURL(
1692 IMimeMessage *iface,
1693 LPCSTR pszBase,
1694 LPCSTR pszURL,
1695 DWORD dwFlags,
1696 IStream *pstmURL,
1697 LPSTR *ppszCIDURL,
1698 LPHBODY phBody)
1700 FIXME("(%p)->(%s, %s, 0x%x, %p, %p, %p)\n", iface, pszBase, pszURL, dwFlags, pstmURL, ppszCIDURL, phBody);
1701 return E_NOTIMPL;
1704 static HRESULT WINAPI MimeMessage_GetAttachments(
1705 IMimeMessage *iface,
1706 ULONG *pcAttach,
1707 LPHBODY *pprghAttach)
1709 FIXME("(%p)->(%p, %p)\n", iface, pcAttach, pprghAttach);
1710 return E_NOTIMPL;
1713 static HRESULT WINAPI MimeMessage_GetAddressTable(
1714 IMimeMessage *iface,
1715 IMimeAddressTable **ppTable)
1717 FIXME("(%p)->(%p)\n", iface, ppTable);
1718 return E_NOTIMPL;
1721 static HRESULT WINAPI MimeMessage_GetSender(
1722 IMimeMessage *iface,
1723 LPADDRESSPROPS pAddress)
1725 FIXME("(%p)->(%p)\n", iface, pAddress);
1726 return E_NOTIMPL;
1729 static HRESULT WINAPI MimeMessage_GetAddressTypes(
1730 IMimeMessage *iface,
1731 DWORD dwAdrTypes,
1732 DWORD dwProps,
1733 LPADDRESSLIST pList)
1735 FIXME("(%p)->(%d, %d, %p)\n", iface, dwAdrTypes, dwProps, pList);
1736 return E_NOTIMPL;
1739 static HRESULT WINAPI MimeMessage_GetAddressFormat(
1740 IMimeMessage *iface,
1741 DWORD dwAdrTypes,
1742 ADDRESSFORMAT format,
1743 LPSTR *ppszFormat)
1745 FIXME("(%p)->(%d, %d, %p)\n", iface, dwAdrTypes, format, ppszFormat);
1746 return E_NOTIMPL;
1749 static HRESULT WINAPI MimeMessage_EnumAddressTypes(
1750 IMimeMessage *iface,
1751 DWORD dwAdrTypes,
1752 DWORD dwProps,
1753 IMimeEnumAddressTypes **ppEnum)
1755 FIXME("(%p)->(%d, %d, %p)\n", iface, dwAdrTypes, dwProps, ppEnum);
1756 return E_NOTIMPL;
1759 static HRESULT WINAPI MimeMessage_SplitMessage(
1760 IMimeMessage *iface,
1761 ULONG cbMaxPart,
1762 IMimeMessageParts **ppParts)
1764 FIXME("(%p)->(%d, %p)\n", iface, cbMaxPart, ppParts);
1765 return E_NOTIMPL;
1768 static HRESULT WINAPI MimeMessage_GetRootMoniker(
1769 IMimeMessage *iface,
1770 IMoniker **ppMoniker)
1772 FIXME("(%p)->(%p)\n", iface, ppMoniker);
1773 return E_NOTIMPL;
1776 static const IMimeMessageVtbl MimeMessageVtbl =
1778 MimeMessage_QueryInterface,
1779 MimeMessage_AddRef,
1780 MimeMessage_Release,
1781 MimeMessage_GetClassID,
1782 MimeMessage_IsDirty,
1783 MimeMessage_Load,
1784 MimeMessage_Save,
1785 MimeMessage_GetSizeMax,
1786 MimeMessage_InitNew,
1787 MimeMessage_GetMessageSource,
1788 MimeMessage_GetMessageSize,
1789 MimeMessage_LoadOffsetTable,
1790 MimeMessage_SaveOffsetTable,
1791 MimeMessage_GetFlags,
1792 MimeMessage_Commit,
1793 MimeMessage_HandsOffStorage,
1794 MimeMessage_BindToObject,
1795 MimeMessage_SaveBody,
1796 MimeMessage_InsertBody,
1797 MimeMessage_GetBody,
1798 MimeMessage_DeleteBody,
1799 MimeMessage_MoveBody,
1800 MimeMessage_CountBodies,
1801 MimeMessage_FindFirst,
1802 MimeMessage_FindNext,
1803 MimeMessage_ResolveURL,
1804 MimeMessage_ToMultipart,
1805 MimeMessage_GetBodyOffsets,
1806 MimeMessage_GetCharset,
1807 MimeMessage_SetCharset,
1808 MimeMessage_IsBodyType,
1809 MimeMessage_IsContentType,
1810 MimeMessage_QueryBodyProp,
1811 MimeMessage_GetBodyProp,
1812 MimeMessage_SetBodyProp,
1813 MimeMessage_DeleteBodyProp,
1814 MimeMessage_SetOption,
1815 MimeMessage_GetOption,
1816 MimeMessage_CreateWebPage,
1817 MimeMessage_GetProp,
1818 MimeMessage_SetProp,
1819 MimeMessage_DeleteProp,
1820 MimeMessage_QueryProp,
1821 MimeMessage_GetTextBody,
1822 MimeMessage_SetTextBody,
1823 MimeMessage_AttachObject,
1824 MimeMessage_AttachFile,
1825 MimeMessage_AttachURL,
1826 MimeMessage_GetAttachments,
1827 MimeMessage_GetAddressTable,
1828 MimeMessage_GetSender,
1829 MimeMessage_GetAddressTypes,
1830 MimeMessage_GetAddressFormat,
1831 MimeMessage_EnumAddressTypes,
1832 MimeMessage_SplitMessage,
1833 MimeMessage_GetRootMoniker,
1836 /***********************************************************************
1837 * MimeOleCreateMessage (INETCOMM.@)
1839 HRESULT WINAPI MimeOleCreateMessage(IUnknown *pUnkOuter, IMimeMessage **ppMessage)
1841 MimeMessage *This;
1843 TRACE("(%p, %p)\n", pUnkOuter, ppMessage);
1845 if (pUnkOuter)
1847 FIXME("outer unknown not supported yet\n");
1848 return E_NOTIMPL;
1851 *ppMessage = NULL;
1853 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
1854 if (!This) return E_OUTOFMEMORY;
1856 This->lpVtbl = &MimeMessageVtbl;
1857 This->refs = 1;
1858 This->stream = NULL;
1859 list_init(&This->body_tree);
1860 This->next_hbody = (HBODY)1;
1862 *ppMessage = (IMimeMessage *)&This->lpVtbl;
1863 return S_OK;
1866 /***********************************************************************
1867 * MimeOleSetCompatMode (INETCOMM.@)
1869 HRESULT WINAPI MimeOleSetCompatMode(DWORD dwMode)
1871 FIXME("(0x%x)\n", dwMode);
1872 return S_OK;
1875 /***********************************************************************
1876 * MimeOleCreateVirtualStream (INETCOMM.@)
1878 HRESULT WINAPI MimeOleCreateVirtualStream(IStream **ppStream)
1880 HRESULT hr;
1881 FIXME("(%p)\n", ppStream);
1883 hr = CreateStreamOnHGlobal(NULL, TRUE, ppStream);
1884 return hr;
1887 typedef struct MimeSecurity
1889 const IMimeSecurityVtbl *lpVtbl;
1891 LONG refs;
1892 } MimeSecurity;
1894 static HRESULT WINAPI MimeSecurity_QueryInterface(
1895 IMimeSecurity* iface,
1896 REFIID riid,
1897 void** obj)
1899 TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), obj);
1901 if (IsEqualIID(riid, &IID_IUnknown) ||
1902 IsEqualIID(riid, &IID_IMimeSecurity))
1904 *obj = iface;
1905 IUnknown_AddRef(iface);
1906 return S_OK;
1909 FIXME("no interface for %s\n", debugstr_guid(riid));
1910 *obj = NULL;
1911 return E_NOINTERFACE;
1914 static ULONG WINAPI MimeSecurity_AddRef(
1915 IMimeSecurity* iface)
1917 MimeSecurity *This = (MimeSecurity *)iface;
1918 TRACE("(%p)->()\n", iface);
1919 return InterlockedIncrement(&This->refs);
1922 static ULONG WINAPI MimeSecurity_Release(
1923 IMimeSecurity* iface)
1925 MimeSecurity *This = (MimeSecurity *)iface;
1926 ULONG refs;
1928 TRACE("(%p)->()\n", iface);
1930 refs = InterlockedDecrement(&This->refs);
1931 if (!refs)
1933 HeapFree(GetProcessHeap(), 0, This);
1936 return refs;
1939 static HRESULT WINAPI MimeSecurity_InitNew(
1940 IMimeSecurity* iface)
1942 FIXME("(%p)->(): stub\n", iface);
1943 return S_OK;
1946 static HRESULT WINAPI MimeSecurity_CheckInit(
1947 IMimeSecurity* iface)
1949 FIXME("(%p)->(): stub\n", iface);
1950 return E_NOTIMPL;
1953 static HRESULT WINAPI MimeSecurity_EncodeMessage(
1954 IMimeSecurity* iface,
1955 IMimeMessageTree* pTree,
1956 DWORD dwFlags)
1958 FIXME("(%p)->(%p, %08x): stub\n", iface, pTree, dwFlags);
1959 return E_NOTIMPL;
1962 static HRESULT WINAPI MimeSecurity_EncodeBody(
1963 IMimeSecurity* iface,
1964 IMimeMessageTree* pTree,
1965 HBODY hEncodeRoot,
1966 DWORD dwFlags)
1968 FIXME("(%p)->(%p, %p, %08x): stub\n", iface, pTree, hEncodeRoot, dwFlags);
1969 return E_NOTIMPL;
1972 static HRESULT WINAPI MimeSecurity_DecodeMessage(
1973 IMimeSecurity* iface,
1974 IMimeMessageTree* pTree,
1975 DWORD dwFlags)
1977 FIXME("(%p)->(%p, %08x): stub\n", iface, pTree, dwFlags);
1978 return E_NOTIMPL;
1981 static HRESULT WINAPI MimeSecurity_DecodeBody(
1982 IMimeSecurity* iface,
1983 IMimeMessageTree* pTree,
1984 HBODY hDecodeRoot,
1985 DWORD dwFlags)
1987 FIXME("(%p)->(%p, %p, %08x): stub\n", iface, pTree, hDecodeRoot, dwFlags);
1988 return E_NOTIMPL;
1991 static HRESULT WINAPI MimeSecurity_EnumCertificates(
1992 IMimeSecurity* iface,
1993 HCAPICERTSTORE hc,
1994 DWORD dwUsage,
1995 PCX509CERT pPrev,
1996 PCX509CERT* ppCert)
1998 FIXME("(%p)->(%p, %08x, %p, %p): stub\n", iface, hc, dwUsage, pPrev, ppCert);
1999 return E_NOTIMPL;
2002 static HRESULT WINAPI MimeSecurity_GetCertificateName(
2003 IMimeSecurity* iface,
2004 const PCX509CERT pX509Cert,
2005 const CERTNAMETYPE cn,
2006 LPSTR* ppszName)
2008 FIXME("(%p)->(%p, %08x, %p): stub\n", iface, pX509Cert, cn, ppszName);
2009 return E_NOTIMPL;
2012 static HRESULT WINAPI MimeSecurity_GetMessageType(
2013 IMimeSecurity* iface,
2014 const HWND hwndParent,
2015 IMimeBody* pBody,
2016 DWORD* pdwSecType)
2018 FIXME("(%p)->(%p, %p, %p): stub\n", iface, hwndParent, pBody, pdwSecType);
2019 return E_NOTIMPL;
2022 static HRESULT WINAPI MimeSecurity_GetCertData(
2023 IMimeSecurity* iface,
2024 const PCX509CERT pX509Cert,
2025 const CERTDATAID dataid,
2026 LPPROPVARIANT pValue)
2028 FIXME("(%p)->(%p, %x, %p): stub\n", iface, pX509Cert, dataid, pValue);
2029 return E_NOTIMPL;
2033 static const IMimeSecurityVtbl MimeSecurityVtbl =
2035 MimeSecurity_QueryInterface,
2036 MimeSecurity_AddRef,
2037 MimeSecurity_Release,
2038 MimeSecurity_InitNew,
2039 MimeSecurity_CheckInit,
2040 MimeSecurity_EncodeMessage,
2041 MimeSecurity_EncodeBody,
2042 MimeSecurity_DecodeMessage,
2043 MimeSecurity_DecodeBody,
2044 MimeSecurity_EnumCertificates,
2045 MimeSecurity_GetCertificateName,
2046 MimeSecurity_GetMessageType,
2047 MimeSecurity_GetCertData
2050 /***********************************************************************
2051 * MimeOleCreateSecurity (INETCOMM.@)
2053 HRESULT WINAPI MimeOleCreateSecurity(IMimeSecurity **ppSecurity)
2055 MimeSecurity *This;
2057 TRACE("(%p)\n", ppSecurity);
2059 *ppSecurity = NULL;
2061 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
2062 if (!This) return E_OUTOFMEMORY;
2064 This->lpVtbl = &MimeSecurityVtbl;
2065 This->refs = 1;
2067 *ppSecurity = (IMimeSecurity *)&This->lpVtbl;
2068 return S_OK;
2072 typedef struct
2074 IMimeAllocatorVtbl *lpVtbl;
2075 } MimeAllocator;
2077 static HRESULT WINAPI MimeAlloc_QueryInterface(
2078 IMimeAllocator* iface,
2079 REFIID riid,
2080 void **obj)
2082 TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), obj);
2084 if (IsEqualIID(riid, &IID_IUnknown) ||
2085 IsEqualIID(riid, &IID_IMalloc) ||
2086 IsEqualIID(riid, &IID_IMimeAllocator))
2088 *obj = iface;
2089 IUnknown_AddRef(iface);
2090 return S_OK;
2093 FIXME("no interface for %s\n", debugstr_guid(riid));
2094 *obj = NULL;
2095 return E_NOINTERFACE;
2098 static ULONG WINAPI MimeAlloc_AddRef(
2099 IMimeAllocator* iface)
2101 return 2;
2104 static ULONG WINAPI MimeAlloc_Release(
2105 IMimeAllocator* iface)
2107 return 1;
2110 static LPVOID WINAPI MimeAlloc_Alloc(
2111 IMimeAllocator* iface,
2112 ULONG cb)
2114 return CoTaskMemAlloc(cb);
2117 static LPVOID WINAPI MimeAlloc_Realloc(
2118 IMimeAllocator* iface,
2119 LPVOID pv,
2120 ULONG cb)
2122 return CoTaskMemRealloc(pv, cb);
2125 static void WINAPI MimeAlloc_Free(
2126 IMimeAllocator* iface,
2127 LPVOID pv)
2129 return CoTaskMemFree(pv);
2132 static ULONG WINAPI MimeAlloc_GetSize(
2133 IMimeAllocator* iface,
2134 LPVOID pv)
2136 FIXME("stub\n");
2137 return 0;
2140 static int WINAPI MimeAlloc_DidAlloc(
2141 IMimeAllocator* iface,
2142 LPVOID pv)
2144 FIXME("stub\n");
2145 return 0;
2148 static void WINAPI MimeAlloc_HeapMinimize(
2149 IMimeAllocator* iface)
2151 FIXME("stub\n");
2152 return;
2155 static HRESULT WINAPI MimeAlloc_FreeParamInfoArray(
2156 IMimeAllocator* iface,
2157 ULONG cParams,
2158 LPMIMEPARAMINFO prgParam,
2159 boolean fFreeArray)
2161 ULONG i;
2162 TRACE("(%p)->(%d, %p, %d)\n", iface, cParams, prgParam, fFreeArray);
2164 for(i = 0; i < cParams; i++)
2166 IMimeAllocator_Free(iface, prgParam[i].pszName);
2167 IMimeAllocator_Free(iface, prgParam[i].pszData);
2169 if(fFreeArray) IMimeAllocator_Free(iface, prgParam);
2170 return S_OK;
2173 static HRESULT WINAPI MimeAlloc_FreeAddressList(
2174 IMimeAllocator* iface,
2175 LPADDRESSLIST pList)
2177 FIXME("stub\n");
2178 return E_NOTIMPL;
2181 static HRESULT WINAPI MimeAlloc_FreeAddressProps(
2182 IMimeAllocator* iface,
2183 LPADDRESSPROPS pAddress)
2185 FIXME("stub\n");
2186 return E_NOTIMPL;
2189 static HRESULT WINAPI MimeAlloc_ReleaseObjects(
2190 IMimeAllocator* iface,
2191 ULONG cObjects,
2192 IUnknown **prgpUnknown,
2193 boolean fFreeArray)
2195 FIXME("stub\n");
2196 return E_NOTIMPL;
2200 static HRESULT WINAPI MimeAlloc_FreeEnumHeaderRowArray(
2201 IMimeAllocator* iface,
2202 ULONG cRows,
2203 LPENUMHEADERROW prgRow,
2204 boolean fFreeArray)
2206 FIXME("stub\n");
2207 return E_NOTIMPL;
2210 static HRESULT WINAPI MimeAlloc_FreeEnumPropertyArray(
2211 IMimeAllocator* iface,
2212 ULONG cProps,
2213 LPENUMPROPERTY prgProp,
2214 boolean fFreeArray)
2216 FIXME("stub\n");
2217 return E_NOTIMPL;
2220 static HRESULT WINAPI MimeAlloc_FreeThumbprint(
2221 IMimeAllocator* iface,
2222 THUMBBLOB *pthumbprint)
2224 FIXME("stub\n");
2225 return E_NOTIMPL;
2229 static HRESULT WINAPI MimeAlloc_PropVariantClear(
2230 IMimeAllocator* iface,
2231 LPPROPVARIANT pProp)
2233 FIXME("stub\n");
2234 return E_NOTIMPL;
2237 static IMimeAllocatorVtbl mime_alloc_vtbl =
2239 MimeAlloc_QueryInterface,
2240 MimeAlloc_AddRef,
2241 MimeAlloc_Release,
2242 MimeAlloc_Alloc,
2243 MimeAlloc_Realloc,
2244 MimeAlloc_Free,
2245 MimeAlloc_GetSize,
2246 MimeAlloc_DidAlloc,
2247 MimeAlloc_HeapMinimize,
2248 MimeAlloc_FreeParamInfoArray,
2249 MimeAlloc_FreeAddressList,
2250 MimeAlloc_FreeAddressProps,
2251 MimeAlloc_ReleaseObjects,
2252 MimeAlloc_FreeEnumHeaderRowArray,
2253 MimeAlloc_FreeEnumPropertyArray,
2254 MimeAlloc_FreeThumbprint,
2255 MimeAlloc_PropVariantClear
2258 static MimeAllocator mime_allocator =
2260 &mime_alloc_vtbl
2263 HRESULT MimeAllocator_create(IUnknown *outer, void **obj)
2265 if(outer) return CLASS_E_NOAGGREGATION;
2267 *obj = &mime_allocator;
2268 return S_OK;
2271 HRESULT WINAPI MimeOleGetAllocator(IMimeAllocator **alloc)
2273 return MimeAllocator_create(NULL, (void**)alloc);