Commit ed9a8a22 authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

inetcomm: Implement IMimeBody SetProp.

parent 912d7474
......@@ -663,8 +663,60 @@ static HRESULT WINAPI MimeBody_SetProp(
LPCPROPVARIANT pValue)
{
MimeBody *This = impl_from_IMimeBody(iface);
FIXME("(%p)->(%s, 0x%x, %p) stub\n", This, debugstr_a(pszName), dwFlags, pValue);
return E_NOTIMPL;
header_t *header;
HRESULT hr;
TRACE("(%p)->(%s, 0x%x, %p)\n", This, debugstr_a(pszName), dwFlags, pValue);
if(!pszName || !pValue)
return E_INVALIDARG;
hr = find_prop(This, pszName, &header);
if(hr != S_OK)
{
property_list_entry_t *prop_entry;
const property_t *prop = NULL;
LIST_FOR_EACH_ENTRY(prop_entry, &This->new_props, property_list_entry_t, entry)
{
if(!strcasecmp(pszName, prop_entry->prop.name))
{
TRACE("Found match with already added new property id %d\n", prop_entry->prop.id);
prop = &prop_entry->prop;
break;
}
}
header = HeapAlloc(GetProcessHeap(), 0, sizeof(*header));
if(!header)
return E_OUTOFMEMORY;
if(!prop)
{
prop_entry = HeapAlloc(GetProcessHeap(), 0, sizeof(*prop_entry));
if(!prop_entry)
{
HeapFree(GetProcessHeap(), 0, header);
return E_OUTOFMEMORY;
}
prop_entry->prop.name = strdupA(pszName);
prop_entry->prop.id = This->next_prop_id++;
prop_entry->prop.flags = 0;
prop_entry->prop.default_vt = pValue->vt;
list_add_tail(&This->new_props, &prop_entry->entry);
prop = &prop_entry->prop;
TRACE("Allocating new prop id %d\n", prop_entry->prop.id);
}
header->prop = prop;
PropVariantInit(&header->value);
list_init(&header->params);
list_add_tail(&This->headers, &header->entry);
}
PropVariantCopy(&header->value, pValue);
return S_OK;
}
static HRESULT WINAPI MimeBody_AppendProp(
......
......@@ -332,6 +332,48 @@ static void test_CreateMessage(void)
IStream_Release(stream);
}
static void test_MessageSetProp(void)
{
static const char topic[] = "wine topic";
HRESULT hr;
IMimeMessage *msg;
IMimeBody *body;
PROPVARIANT prop;
hr = MimeOleCreateMessage(NULL, &msg);
ok(hr == S_OK, "ret %08x\n", hr);
PropVariantInit(&prop);
hr = IMimeMessage_BindToObject(msg, HBODY_ROOT, &IID_IMimeBody, (void**)&body);
ok(hr == S_OK, "ret %08x\n", hr);
hr = IMimeBody_SetProp(body, NULL, 0, &prop);
ok(hr == E_INVALIDARG, "ret %08x\n", hr);
hr = IMimeBody_SetProp(body, "Thread-Topic", 0, NULL);
ok(hr == E_INVALIDARG, "ret %08x\n", hr);
prop.vt = VT_LPSTR;
prop.u.pszVal = CoTaskMemAlloc(strlen(topic)+1);
strcpy(prop.u.pszVal, topic);
hr = IMimeBody_SetProp(body, "Thread-Topic", 0, &prop);
ok(hr == S_OK, "ret %08x\n", hr);
PropVariantClear(&prop);
hr = IMimeBody_GetProp(body, "Thread-Topic", 0, &prop);
todo_wine ok(hr == S_OK, "ret %08x\n", hr);
if(hr == S_OK)
{
todo_wine ok(prop.vt == VT_LPSTR, "type %d\n", prop.vt);
todo_wine ok(!strcmp(prop.u.pszVal, topic), "got %s\n", prop.u.pszVal);
PropVariantClear(&prop);
}
IMimeBody_Release(body);
IMimeMessage_Release(msg);
}
static void test_MessageOptions(void)
{
static const char string[] = "XXXXX";
......@@ -434,6 +476,7 @@ START_TEST(mimeole)
test_CreateBody();
test_Allocator();
test_CreateMessage();
test_MessageSetProp();
test_MessageOptions();
test_BindToObject();
test_MimeOleGetPropertySchema();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment