inetcomm: Implement IMimeBody_GetParameters.

This commit is contained in:
Huw Davies 2007-12-18 15:26:32 +00:00 committed by Alexandre Julliard
parent 1cb7df8a98
commit e446351d4c
2 changed files with 82 additions and 2 deletions

View File

@ -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(

View File

@ -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);
}