Module: wine Branch: master Commit: 02ceeef2886a701998a1b46c6147302da14f7920 URL: http://source.winehq.org/git/wine.git/?a=commit;h=02ceeef2886a701998a1b46c61...
Author: Huw Davies huw@codeweavers.com Date: Tue Feb 12 13:49:28 2008 +0000
inetcomm: Implement IMimeMessage_GetAttachments.
---
dlls/inetcomm/mimeole.c | 34 ++++++++++++++++++++++++++++++++-- dlls/inetcomm/tests/mimeole.c | 6 ++++++ 2 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/dlls/inetcomm/mimeole.c b/dlls/inetcomm/mimeole.c index b794f5d..cf0e85b 100644 --- a/dlls/inetcomm/mimeole.c +++ b/dlls/inetcomm/mimeole.c @@ -2279,8 +2279,38 @@ static HRESULT WINAPI MimeMessage_GetAttachments( ULONG *pcAttach, LPHBODY *pprghAttach) { - FIXME("(%p)->(%p, %p)\n", iface, pcAttach, pprghAttach); - return E_NOTIMPL; + HRESULT hr; + FINDBODY find_struct; + HBODY hbody; + LPHBODY array; + ULONG size = 10; + + TRACE("(%p)->(%p, %p)\n", iface, pcAttach, pprghAttach); + + *pcAttach = 0; + array = CoTaskMemAlloc(size * sizeof(HBODY)); + + find_struct.pszPriType = find_struct.pszSubType = NULL; + hr = IMimeMessage_FindFirst(iface, &find_struct, &hbody); + while(hr == S_OK) + { + hr = IMimeMessage_IsContentType(iface, hbody, "multipart", NULL); + TRACE("IsCT rets %08x %d\n", hr, *pcAttach); + if(hr != S_OK) + { + if(*pcAttach + 1 > size) + { + size *= 2; + array = CoTaskMemRealloc(array, size * sizeof(HBODY)); + } + array[*pcAttach] = hbody; + (*pcAttach)++; + } + hr = IMimeMessage_FindNext(iface, &find_struct, &hbody); + } + + *pprghAttach = array; + return S_OK; }
static HRESULT WINAPI MimeMessage_GetAddressTable( diff --git a/dlls/inetcomm/tests/mimeole.c b/dlls/inetcomm/tests/mimeole.c index ee53d15..f5f8a90 100644 --- a/dlls/inetcomm/tests/mimeole.c +++ b/dlls/inetcomm/tests/mimeole.c @@ -215,6 +215,7 @@ static void test_CreateMessage(void) ULONG count; FINDBODY find_struct; char text[] = "text"; + HBODY *body_list;
hr = MimeOleCreateMessage(NULL, &msg); ok(hr == S_OK, "ret %08x\n", hr); @@ -282,6 +283,11 @@ static void test_CreateMessage(void) hr = IMimeMessage_FindNext(msg, &find_struct, &hbody); ok(hr == MIME_E_NOT_FOUND, "ret %08x\n", hr);
+ hr = IMimeMessage_GetAttachments(msg, &count, &body_list); + ok(hr == S_OK, "ret %08x\n", hr); + ok(count == 2, "got %d\n", count); + CoTaskMemFree(body_list); + IMimeMessage_Release(msg);
ref = IStream_AddRef(stream);