Module: wine Branch: master Commit: a14bb14dc506b6e7d6377d0f022c7af9fdcb7123 URL: http://source.winehq.org/git/wine.git/?a=commit;h=a14bb14dc506b6e7d6377d0f02...
Author: Huw Davies huw@codeweavers.com Date: Mon Feb 11 12:04:49 2008 +0000
inetcomm: Implement IMimeMessage_BindToObject.
---
dlls/inetcomm/mimeole.c | 44 +++++++++++++++++++++++++++++++++++++++- dlls/inetcomm/tests/mimeole.c | 12 +++++++++++ 2 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/dlls/inetcomm/mimeole.c b/dlls/inetcomm/mimeole.c index 6c34e1d..ab68090 100644 --- a/dlls/inetcomm/mimeole.c +++ b/dlls/inetcomm/mimeole.c @@ -1339,14 +1339,54 @@ static HRESULT WINAPI MimeMessage_HandsOffStorage( return E_NOTIMPL; }
+static HRESULT find_body(struct list *list, HBODY hbody, body_t **body) +{ + body_t *cur; + HRESULT hr; + + if(hbody == HBODY_ROOT) + { + *body = LIST_ENTRY(list_head(list), body_t, entry); + return S_OK; + } + + LIST_FOR_EACH_ENTRY(cur, list, body_t, entry) + { + if(cur->hbody == hbody) + { + *body = cur; + return S_OK; + } + hr = find_body(&cur->children, hbody, body); + if(hr == S_OK) return S_OK; + } + return S_FALSE; +} + static HRESULT WINAPI MimeMessage_BindToObject( IMimeMessage *iface, const HBODY hBody, REFIID riid, void **ppvObject) { - FIXME("(%p)->(%p, %s, %p)\n", iface, hBody, debugstr_guid(riid), ppvObject); - return E_NOTIMPL; + MimeMessage *This = (MimeMessage *)iface; + HRESULT hr; + body_t *body; + + TRACE("(%p)->(%p, %s, %p)\n", iface, hBody, debugstr_guid(riid), ppvObject); + + hr = find_body(&This->body_tree, hBody, &body); + + if(hr != S_OK) return hr; + + if(IsEqualIID(riid, &IID_IMimeBody)) + { + IMimeBody_AddRef(body->mime_body); + *ppvObject = body->mime_body; + return S_OK; + } + + return E_NOINTERFACE; }
static HRESULT WINAPI MimeMessage_SaveBody( diff --git a/dlls/inetcomm/tests/mimeole.c b/dlls/inetcomm/tests/mimeole.c index 1f542cf..5f5fa0c 100644 --- a/dlls/inetcomm/tests/mimeole.c +++ b/dlls/inetcomm/tests/mimeole.c @@ -209,6 +209,8 @@ static void test_CreateMessage(void) IStream *stream; LARGE_INTEGER pos; LONG ref; + IMimeBody *body; + BODYOFFSETS offsets;
hr = MimeOleCreateMessage(NULL, &msg); ok(hr == S_OK, "ret %08x\n", hr); @@ -221,6 +223,16 @@ static void test_CreateMessage(void) hr = IMimeMessage_Load(msg, stream); ok(hr == S_OK, "ret %08x\n", hr);
+ hr = IMimeMessage_BindToObject(msg, HBODY_ROOT, &IID_IMimeBody, (void**)&body); + ok(hr == S_OK, "ret %08x\n", hr); + hr = IMimeBody_GetOffsets(body, &offsets); + ok(hr == S_OK, "ret %08x\n", hr); + ok(offsets.cbBoundaryStart == 0, "got %d\n", offsets.cbBoundaryStart); + ok(offsets.cbHeaderStart == 0, "got %d\n", offsets.cbHeaderStart); + ok(offsets.cbBodyStart == 359, "got %d\n", offsets.cbBodyStart); + ok(offsets.cbBodyEnd == 666, "got %d\n", offsets.cbBodyEnd); + IMimeBody_Release(body); + IMimeMessage_Release(msg);
ref = IStream_AddRef(stream);