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

dpnet: Implement IDirectPlay8Address GetComponentByName.

parent 3cd145f6
......@@ -316,9 +316,53 @@ static HRESULT WINAPI IDirectPlay8AddressImpl_GetNumComponents(IDirectPlay8Addre
static HRESULT WINAPI IDirectPlay8AddressImpl_GetComponentByName(IDirectPlay8Address *iface,
const WCHAR *const pwszName, void *pvBuffer, DWORD *pdwBufferSize, DWORD *pdwDataType)
{
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
TRACE("(%p): stub\n", This);
return DPN_OK;
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
struct component *entry;
TRACE("(%p)->(%p %p %p %p)\n", This, pwszName, pvBuffer, pdwBufferSize, pdwDataType);
if(!pwszName || !pdwBufferSize || !pdwDataType || (!pvBuffer && pdwBufferSize))
return E_POINTER;
LIST_FOR_EACH_ENTRY(entry, &This->components, struct component, entry)
{
if (lstrcmpW(pwszName, entry->name) == 0)
{
TRACE("Found %s\n", debugstr_w(pwszName));
if(*pdwBufferSize < entry->size)
{
*pdwBufferSize = entry->size;
return DPNERR_BUFFERTOOSMALL;
}
*pdwBufferSize = entry->size;
*pdwDataType = entry->type;
switch (entry->type)
{
case DPNA_DATATYPE_DWORD:
memcpy(pvBuffer, &entry->data.value, sizeof(DWORD));
break;
case DPNA_DATATYPE_GUID:
memcpy(pvBuffer, &entry->data.guid, sizeof(GUID));
break;
case DPNA_DATATYPE_STRING:
memcpy(pvBuffer, &entry->data.string, entry->size);
break;
case DPNA_DATATYPE_STRING_ANSI:
memcpy(pvBuffer, &entry->data.ansi, entry->size);
break;
case DPNA_DATATYPE_BINARY:
memcpy(pvBuffer, &entry->data.binary, entry->size);
break;
}
return S_OK;
}
}
return DPNERR_DOESNOTEXIST;
}
static HRESULT WINAPI IDirectPlay8AddressImpl_GetComponentByIndex(IDirectPlay8Address *iface,
......@@ -364,7 +408,6 @@ static HRESULT WINAPI IDirectPlay8AddressImpl_AddComponent(IDirectPlay8Address *
list_add_tail(&This->components, &entry->entry);
}
entry->size = dwDataSize;
switch (dwDataType)
{
case DPNA_DATATYPE_DWORD:
......@@ -402,6 +445,8 @@ static HRESULT WINAPI IDirectPlay8AddressImpl_AddComponent(IDirectPlay8Address *
break;
}
entry->size = dwDataSize;
return DPN_OK;
}
......
......@@ -102,11 +102,28 @@ static void address_addcomponents(void)
hr = IDirectPlay8Address_AddComponent(localaddr, DPNA_KEY_PORT, &port, sizeof(DWORD), DPNA_DATATYPE_DWORD);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDirectPlay8Address_GetComponentByName(localaddr, NULL, &compguid, &size, &type);
ok(hr == E_POINTER, "got 0x%08x\n", hr);
hr = IDirectPlay8Address_GetComponentByName(localaddr, UNKNOWN, NULL, &size, &type);
ok(hr == E_POINTER, "got 0x%08x\n", hr);
hr = IDirectPlay8Address_GetComponentByName(localaddr, UNKNOWN, &compguid, NULL, &type);
ok(hr == E_POINTER, "got 0x%08x\n", hr);
hr = IDirectPlay8Address_GetComponentByName(localaddr, UNKNOWN, &compguid, &size, NULL);
ok(hr == E_POINTER, "got 0x%08x\n", hr);
size = sizeof(GUID)-1;
hr = IDirectPlay8Address_GetComponentByName(localaddr, UNKNOWN, &compguid, &size, &type);
ok(hr == DPNERR_BUFFERTOOSMALL, "got 0x%08x\n", hr);
ok(size == sizeof(GUID), "got %d\n", size);
size = sizeof(GUID);
hr = IDirectPlay8Address_GetComponentByName(localaddr, UNKNOWN, &compguid, &size, &type);
todo_wine ok(IsEqualGUID(&compguid, &IID_Random), "incorrect guid\n");
ok(size == sizeof(GUID), "incorrect size\n");
todo_wine ok(type == DPNA_DATATYPE_GUID, "incorrect type\n");
ok(IsEqualGUID(&compguid, &IID_Random), "incorrect guid\n");
ok(size == sizeof(GUID), "incorrect size got %d\n", size);
ok(type == DPNA_DATATYPE_GUID, "incorrect type\n");
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDirectPlay8Address_GetNumComponents(localaddr, NULL);
......
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