Huw Davies : inetcomm: Implement IMimeBody_GetParameters.

Alexandre Julliard julliard at winehq.org
Tue Dec 18 13:08:16 CST 2007


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

Author: Huw Davies <huw at codeweavers.com>
Date:   Tue Dec 18 15:26:32 2007 +0000

inetcomm: Implement IMimeBody_GetParameters.

---

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

diff --git a/dlls/inetcomm/mimeole.c b/dlls/inetcomm/mimeole.c
index 0b5e290..38dd46b 100644
--- a/dlls/inetcomm/mimeole.c
+++ b/dlls/inetcomm/mimeole.c
@@ -444,6 +444,24 @@ static void release_data(REFIID riid, void *data)
         FIXME("Unhandled data format %s\n", debugstr_guid(riid));
 }
 
+static HRESULT find_prop(MimeBody *body, const char *name, header_t **prop)
+{
+    header_t *header;
+
+    *prop = NULL;
+
+    LIST_FOR_EACH_ENTRY(header, &body->headers, header_t, entry)
+    {
+        if(!strcasecmp(name, header->prop->name))
+        {
+            *prop = header;
+            return S_OK;
+        }
+    }
+
+    return MIME_E_NOT_FOUND;
+}
+
 static HRESULT WINAPI MimeBody_QueryInterface(IMimeBody* iface,
                                      REFIID riid,
                                      void** ppvObject)
@@ -670,8 +688,43 @@ static HRESULT WINAPI MimeBody_GetParameters(
                                     ULONG* pcParams,
                                     LPMIMEPARAMINFO* pprgParam)
 {
-    FIXME("stub\n");
-    return E_NOTIMPL;
+    MimeBody *This = impl_from_IMimeBody(iface);
+    HRESULT hr;
+    header_t *header;
+
+    TRACE("(%p)->(%s, %p, %p)\n", iface, debugstr_a(pszName), pcParams, pprgParam);
+
+    *pprgParam = NULL;
+    *pcParams = 0;
+
+    hr = find_prop(This, pszName, &header);
+    if(hr != S_OK) return hr;
+
+    *pcParams = list_count(&header->params);
+    if(*pcParams)
+    {
+        IMimeAllocator *alloc;
+        param_t *param;
+        MIMEPARAMINFO *info;
+
+        MimeOleGetAllocator(&alloc);
+
+        *pprgParam = info = IMimeAllocator_Alloc(alloc, *pcParams * sizeof(**pprgParam));
+        LIST_FOR_EACH_ENTRY(param, &header->params, param_t, entry)
+        {
+            int len;
+
+            len = strlen(param->name) + 1;
+            info->pszName = IMimeAllocator_Alloc(alloc, len);
+            memcpy(info->pszName, param->name, len);
+            len = strlen(param->value) + 1;
+            info->pszData = IMimeAllocator_Alloc(alloc, len);
+            memcpy(info->pszData, param->value, len);
+            info++;
+        }
+        IMimeAllocator_Release(alloc);
+    }
+    return S_OK;
 }
 
 static HRESULT WINAPI MimeBody_IsContentType(
diff --git a/dlls/inetcomm/tests/mimeole.c b/dlls/inetcomm/tests/mimeole.c
index 97fe6e6..c36502e 100644
--- a/dlls/inetcomm/tests/mimeole.c
+++ b/dlls/inetcomm/tests/mimeole.c
@@ -90,6 +90,9 @@ static void test_CreateBody(void)
     LARGE_INTEGER off;
     ULARGE_INTEGER pos;
     ENCODINGTYPE enc;
+    ULONG count;
+    MIMEPARAMINFO *param_info;
+    IMimeAllocator *alloc;
 
     hr = CoCreateInstance(&CLSID_IMimeBody, NULL, CLSCTX_INPROC_SERVER, &IID_IMimeBody, (void**)&body);
     ok(hr == S_OK, "ret %08x\n", hr);
@@ -134,6 +137,30 @@ static void test_CreateBody(void)
     ok(hr == S_OK, "ret %08x\n", hr);
     ok(enc == IET_8BIT, "encoding %d\n", enc);
 
+    hr = MimeOleGetAllocator(&alloc);
+    ok(hr == S_OK, "ret %08x\n", hr);
+
+    hr = IMimeBody_GetParameters(body, "nothere", &count, &param_info);
+    ok(hr == MIME_E_NOT_FOUND, "ret %08x\n", hr);
+    ok(count == 0, "got %d\n", count);
+    ok(!param_info, "got %p\n", param_info);
+
+    hr = IMimeBody_GetParameters(body, "bar", &count, &param_info);
+    ok(hr == S_OK, "ret %08x\n", hr);
+    ok(count == 0, "got %d\n", count);
+    ok(!param_info, "got %p\n", param_info);
+
+    hr = IMimeBody_GetParameters(body, "Content-Type", &count, &param_info);
+    ok(hr == S_OK, "ret %08x\n", hr);
+    todo_wine  /* native adds a charset parameter */
+        ok(count == 3, "got %d\n", count);
+    ok(param_info != NULL, "got %p\n", param_info);
+
+    hr = IMimeAllocator_FreeParamInfoArray(alloc, count, param_info, TRUE);
+    ok(hr == S_OK, "ret %08x\n", hr);
+    IMimeAllocator_Release(alloc);
+
+    IStream_Release(in);
     IMimeBody_Release(body);
 }
 




More information about the wine-cvs mailing list