From e446351d4cd932a0eb753ef8a0d406d2fee5a4de Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Tue, 18 Dec 2007 15:26:32 +0000 Subject: [PATCH] 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 0b5e29099d6..38dd46b4444 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 97fe6e62f34..c36502e2bee 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, ¶m_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, ¶m_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, ¶m_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); }