inetcomm: Implement IMimeMessage_GetAttachments.

This commit is contained in:
Huw Davies 2008-02-12 13:49:28 +00:00 committed by Alexandre Julliard
parent 869b10b430
commit 02ceeef288
2 changed files with 38 additions and 2 deletions

View File

@ -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(

View File

@ -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);