Huw Davies : inetcomm: Implement IMimeMessage_GetBody.

Alexandre Julliard julliard at winehq.org
Wed Feb 13 10:40:06 CST 2008


Module: wine
Branch: master
Commit: e15ff2ef86c4913e6f463896edfcf98a64642c06
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e15ff2ef86c4913e6f463896edfcf98a64642c06

Author: Huw Davies <huw at codeweavers.com>
Date:   Tue Feb 12 11:49:47 2008 +0000

inetcomm: Implement IMimeMessage_GetBody.

---

 dlls/inetcomm/mimeole.c       |   78 +++++++++++++++++++++++++++++++++++++++-
 dlls/inetcomm/tests/mimeole.c |   27 ++++++++++++++
 2 files changed, 103 insertions(+), 2 deletions(-)

diff --git a/dlls/inetcomm/mimeole.c b/dlls/inetcomm/mimeole.c
index bdce35b..099d2b6 100644
--- a/dlls/inetcomm/mimeole.c
+++ b/dlls/inetcomm/mimeole.c
@@ -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(
diff --git a/dlls/inetcomm/tests/mimeole.c b/dlls/inetcomm/tests/mimeole.c
index 5f5fa0c..3d49e61 100644
--- a/dlls/inetcomm/tests/mimeole.c
+++ b/dlls/inetcomm/tests/mimeole.c
@@ -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);




More information about the wine-cvs mailing list