inetcomm: Implement IMimeMessage_CountBodies.

This commit is contained in:
Huw Davies 2008-02-12 11:59:36 +00:00 committed by Alexandre Julliard
parent e15ff2ef86
commit 8be6df3434
2 changed files with 33 additions and 2 deletions

View File

@ -1889,14 +1889,36 @@ static HRESULT WINAPI MimeMessage_MoveBody(
return E_NOTIMPL;
}
static void count_children(body_t *body, boolean recurse, ULONG *count)
{
body_t *child;
LIST_FOR_EACH_ENTRY(child, &body->children, body_t, entry)
{
(*count)++;
if(recurse) count_children(child, recurse, count);
}
}
static HRESULT WINAPI MimeMessage_CountBodies(
IMimeMessage *iface,
HBODY hParent,
boolean fRecurse,
ULONG *pcBodies)
{
FIXME("(%p)->(%p, %s, %p)\n", iface, hParent, fRecurse ? "TRUE" : "FALSE", pcBodies);
return E_NOTIMPL;
HRESULT hr;
MimeMessage *This = (MimeMessage *)iface;
body_t *body;
TRACE("(%p)->(%p, %s, %p)\n", iface, hParent, fRecurse ? "TRUE" : "FALSE", pcBodies);
hr = find_body(&This->body_tree, hParent, &body);
if(hr != S_OK) return hr;
*pcBodies = 1;
count_children(body, fRecurse, pcBodies);
return S_OK;
}
static HRESULT WINAPI MimeMessage_FindFirst(

View File

@ -212,6 +212,7 @@ static void test_CreateMessage(void)
HBODY hbody;
IMimeBody *body;
BODYOFFSETS offsets;
ULONG count;
hr = MimeOleCreateMessage(NULL, &msg);
ok(hr == S_OK, "ret %08x\n", hr);
@ -224,6 +225,14 @@ static void test_CreateMessage(void)
hr = IMimeMessage_Load(msg, stream);
ok(hr == S_OK, "ret %08x\n", hr);
hr = IMimeMessage_CountBodies(msg, HBODY_ROOT, TRUE, &count);
ok(hr == S_OK, "ret %08x\n", hr);
ok(count == 3, "got %d\n", count);
hr = IMimeMessage_CountBodies(msg, HBODY_ROOT, FALSE, &count);
ok(hr == S_OK, "ret %08x\n", hr);
ok(count == 3, "got %d\n", count);
hr = IMimeMessage_BindToObject(msg, HBODY_ROOT, &IID_IMimeBody, (void**)&body);
ok(hr == S_OK, "ret %08x\n", hr);
hr = IMimeBody_GetOffsets(body, &offsets);