Huw Davies : inetcomm: Implement IMimeMessage_CountBodies.
Alexandre Julliard
julliard at winehq.org
Wed Feb 13 10:40:06 CST 2008
Module: wine
Branch: master
Commit: 8be6df34347ad0c986fdb9e34cc320f4035dce6b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8be6df34347ad0c986fdb9e34cc320f4035dce6b
Author: Huw Davies <huw at codeweavers.com>
Date: Tue Feb 12 11:59:36 2008 +0000
inetcomm: Implement IMimeMessage_CountBodies.
---
dlls/inetcomm/mimeole.c | 26 ++++++++++++++++++++++++--
dlls/inetcomm/tests/mimeole.c | 9 +++++++++
2 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/dlls/inetcomm/mimeole.c b/dlls/inetcomm/mimeole.c
index 099d2b6..d6b4274 100644
--- a/dlls/inetcomm/mimeole.c
+++ b/dlls/inetcomm/mimeole.c
@@ -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(
diff --git a/dlls/inetcomm/tests/mimeole.c b/dlls/inetcomm/tests/mimeole.c
index 3d49e61..c40952f 100644
--- a/dlls/inetcomm/tests/mimeole.c
+++ b/dlls/inetcomm/tests/mimeole.c
@@ -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);
More information about the wine-cvs
mailing list