inetcomm: Implement IMimeMessage_GetBody.
This commit is contained in:
parent
db4881cfb6
commit
e15ff2ef86
|
@ -1777,6 +1777,71 @@ static HRESULT WINAPI MimeMessage_SaveBody(
|
|||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT get_body(MimeMessage *msg, BODYLOCATION location, HBODY pivot, body_t **out)
|
||||
{
|
||||
body_t *root = LIST_ENTRY(list_head(&msg->body_tree), body_t, entry);
|
||||
body_t *body;
|
||||
HRESULT hr;
|
||||
struct list *list;
|
||||
|
||||
if(location == IBL_ROOT)
|
||||
{
|
||||
*out = root;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
hr = find_body(&msg->body_tree, pivot, &body);
|
||||
|
||||
if(hr == S_OK)
|
||||
{
|
||||
switch(location)
|
||||
{
|
||||
case IBL_PARENT:
|
||||
*out = body->parent;
|
||||
break;
|
||||
|
||||
case IBL_FIRST:
|
||||
list = list_head(&body->children);
|
||||
if(list)
|
||||
*out = LIST_ENTRY(list, body_t, entry);
|
||||
else
|
||||
hr = MIME_E_NOT_FOUND;
|
||||
break;
|
||||
|
||||
case IBL_LAST:
|
||||
list = list_tail(&body->children);
|
||||
if(list)
|
||||
*out = LIST_ENTRY(list, body_t, entry);
|
||||
else
|
||||
hr = MIME_E_NOT_FOUND;
|
||||
break;
|
||||
|
||||
case IBL_NEXT:
|
||||
list = list_next(&body->parent->children, &body->entry);
|
||||
if(list)
|
||||
*out = LIST_ENTRY(list, body_t, entry);
|
||||
else
|
||||
hr = MIME_E_NOT_FOUND;
|
||||
break;
|
||||
|
||||
case IBL_PREVIOUS:
|
||||
list = list_prev(&body->parent->children, &body->entry);
|
||||
if(list)
|
||||
*out = LIST_ENTRY(list, body_t, entry);
|
||||
else
|
||||
hr = MIME_E_NOT_FOUND;
|
||||
break;
|
||||
|
||||
default:
|
||||
hr = E_FAIL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
static HRESULT WINAPI MimeMessage_InsertBody(
|
||||
IMimeMessage *iface,
|
||||
BODYLOCATION location,
|
||||
|
@ -1793,8 +1858,17 @@ static HRESULT WINAPI MimeMessage_GetBody(
|
|||
HBODY hPivot,
|
||||
LPHBODY phBody)
|
||||
{
|
||||
FIXME("(%p)->(%d, %p, %p)\n", iface, location, hPivot, phBody);
|
||||
return E_NOTIMPL;
|
||||
MimeMessage *This = (MimeMessage *)iface;
|
||||
body_t *body;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%p)->(%d, %p, %p)\n", iface, location, hPivot, phBody);
|
||||
|
||||
hr = get_body(This, location, hPivot, &body);
|
||||
|
||||
if(hr == S_OK) *phBody = body->hbody;
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI MimeMessage_DeleteBody(
|
||||
|
|
|
@ -209,6 +209,7 @@ static void test_CreateMessage(void)
|
|||
IStream *stream;
|
||||
LARGE_INTEGER pos;
|
||||
LONG ref;
|
||||
HBODY hbody;
|
||||
IMimeBody *body;
|
||||
BODYOFFSETS offsets;
|
||||
|
||||
|
@ -233,6 +234,32 @@ static void test_CreateMessage(void)
|
|||
ok(offsets.cbBodyEnd == 666, "got %d\n", offsets.cbBodyEnd);
|
||||
IMimeBody_Release(body);
|
||||
|
||||
hr = IMimeMessage_GetBody(msg, IBL_ROOT, NULL, &hbody);
|
||||
hr = IMimeMessage_GetBody(msg, IBL_FIRST, hbody, &hbody);
|
||||
ok(hr == S_OK, "ret %08x\n", hr);
|
||||
hr = IMimeMessage_BindToObject(msg, hbody, &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 == 405, "got %d\n", offsets.cbBoundaryStart);
|
||||
ok(offsets.cbHeaderStart == 428, "got %d\n", offsets.cbHeaderStart);
|
||||
ok(offsets.cbBodyStart == 518, "got %d\n", offsets.cbBodyStart);
|
||||
ok(offsets.cbBodyEnd == 523, "got %d\n", offsets.cbBodyEnd);
|
||||
IMimeBody_Release(body);
|
||||
|
||||
hr = IMimeMessage_GetBody(msg, IBL_NEXT, hbody, &hbody);
|
||||
ok(hr == S_OK, "ret %08x\n", hr);
|
||||
hr = IMimeMessage_BindToObject(msg, hbody, &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 == 525, "got %d\n", offsets.cbBoundaryStart);
|
||||
ok(offsets.cbHeaderStart == 548, "got %d\n", offsets.cbHeaderStart);
|
||||
ok(offsets.cbBodyStart == 629, "got %d\n", offsets.cbBodyStart);
|
||||
ok(offsets.cbBodyEnd == 639, "got %d\n", offsets.cbBodyEnd);
|
||||
IMimeBody_Release(body);
|
||||
|
||||
|
||||
IMimeMessage_Release(msg);
|
||||
|
||||
ref = IStream_AddRef(stream);
|
||||
|
|
Loading…
Reference in New Issue