Commit a14bb14d authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

inetcomm: Implement IMimeMessage_BindToObject.

parent 88df8e83
...@@ -1339,14 +1339,54 @@ static HRESULT WINAPI MimeMessage_HandsOffStorage( ...@@ -1339,14 +1339,54 @@ static HRESULT WINAPI MimeMessage_HandsOffStorage(
return E_NOTIMPL; 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( static HRESULT WINAPI MimeMessage_BindToObject(
IMimeMessage *iface, IMimeMessage *iface,
const HBODY hBody, const HBODY hBody,
REFIID riid, REFIID riid,
void **ppvObject) void **ppvObject)
{ {
FIXME("(%p)->(%p, %s, %p)\n", iface, hBody, debugstr_guid(riid), ppvObject); MimeMessage *This = (MimeMessage *)iface;
return E_NOTIMPL; 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( static HRESULT WINAPI MimeMessage_SaveBody(
......
...@@ -209,6 +209,8 @@ static void test_CreateMessage(void) ...@@ -209,6 +209,8 @@ static void test_CreateMessage(void)
IStream *stream; IStream *stream;
LARGE_INTEGER pos; LARGE_INTEGER pos;
LONG ref; LONG ref;
IMimeBody *body;
BODYOFFSETS offsets;
hr = MimeOleCreateMessage(NULL, &msg); hr = MimeOleCreateMessage(NULL, &msg);
ok(hr == S_OK, "ret %08x\n", hr); ok(hr == S_OK, "ret %08x\n", hr);
...@@ -221,6 +223,16 @@ static void test_CreateMessage(void) ...@@ -221,6 +223,16 @@ static void test_CreateMessage(void)
hr = IMimeMessage_Load(msg, stream); hr = IMimeMessage_Load(msg, stream);
ok(hr == S_OK, "ret %08x\n", hr); 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); IMimeMessage_Release(msg);
ref = IStream_AddRef(stream); ref = IStream_AddRef(stream);
......
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