Commit 8be6df34 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

inetcomm: Implement IMimeMessage_CountBodies.

parent e15ff2ef
......@@ -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(
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment