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

dpnet: Implement IDirectPlay8Address Duplicate.

parent 0dd5cb1c
...@@ -180,8 +180,34 @@ static HRESULT WINAPI IDirectPlay8AddressImpl_Duplicate(IDirectPlay8Address *ifa ...@@ -180,8 +180,34 @@ static HRESULT WINAPI IDirectPlay8AddressImpl_Duplicate(IDirectPlay8Address *ifa
IDirectPlay8Address **ppdpaNewAddress) IDirectPlay8Address **ppdpaNewAddress)
{ {
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface); IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
TRACE("(%p, %p): stub\n", This, ppdpaNewAddress); IDirectPlay8Address *dup;
return DPN_OK; HRESULT hr;
TRACE("(%p, %p)\n", This, ppdpaNewAddress);
if(!ppdpaNewAddress)
return E_POINTER;
hr = DPNET_CreateDirectPlay8Address(NULL, NULL, &IID_IDirectPlay8Address, (LPVOID*)&dup);
if(hr == S_OK)
{
IDirectPlay8AddressImpl *DupThis = impl_from_IDirectPlay8Address(dup);
struct component *entry;
DupThis->SP_guid = This->SP_guid;
DupThis->init = This->init;
LIST_FOR_EACH_ENTRY(entry, &This->components, struct component, entry)
{
hr = IDirectPlay8Address_AddComponent(dup, entry->name, &entry->data, entry->size, entry->type);
if(hr != S_OK)
ERR("Failed to copy component: %s - 0x%08x\n", debugstr_w(entry->name), hr);
}
*ppdpaNewAddress = dup;
}
return hr;
} }
static HRESULT WINAPI IDirectPlay8AddressImpl_SetEqual(IDirectPlay8Address *iface, static HRESULT WINAPI IDirectPlay8AddressImpl_SetEqual(IDirectPlay8Address *iface,
...@@ -338,6 +364,7 @@ static HRESULT WINAPI IDirectPlay8AddressImpl_AddComponent(IDirectPlay8Address * ...@@ -338,6 +364,7 @@ static HRESULT WINAPI IDirectPlay8AddressImpl_AddComponent(IDirectPlay8Address *
list_add_tail(&This->components, &entry->entry); list_add_tail(&This->components, &entry->entry);
} }
entry->size = dwDataSize;
switch (dwDataType) switch (dwDataType)
{ {
case DPNA_DATATYPE_DWORD: case DPNA_DATATYPE_DWORD:
......
...@@ -68,6 +68,7 @@ struct component ...@@ -68,6 +68,7 @@ struct component
WCHAR *name; WCHAR *name;
DWORD type; DWORD type;
DWORD size;
union union
{ {
......
...@@ -214,6 +214,44 @@ static void address_setsp(void) ...@@ -214,6 +214,44 @@ static void address_setsp(void)
} }
} }
static void address_duplicate(void)
{
HRESULT hr;
IDirectPlay8Address *localaddr = NULL;
IDirectPlay8Address *duplicate = NULL;
DWORD components, dupcomps;
GUID guid = IID_Random;
hr = CoCreateInstance( &CLSID_DirectPlay8Address, NULL, CLSCTX_ALL, &IID_IDirectPlay8Address, (LPVOID*)&localaddr);
ok(hr == S_OK, "Failed to create IDirectPlay8Address object\n");
if(SUCCEEDED(hr))
{
hr = IDirectPlay8Address_SetSP(localaddr, &CLSID_DP8SP_TCPIP);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDirectPlay8Address_GetNumComponents(localaddr, &components);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(components == 1, "components=%d\n", components);
hr = IDirectPlay8Address_Duplicate(localaddr, &duplicate);
ok(hr == S_OK, "got 0x%08x\n", hr);
if(SUCCEEDED(hr))
{
hr = IDirectPlay8Address_GetSP(duplicate, &guid);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(IsEqualGUID(&guid, &CLSID_DP8SP_TCPIP), "wrong guid\n");
hr = IDirectPlay8Address_GetNumComponents(duplicate, &dupcomps);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(components == dupcomps, "expected %d got %d\n", components, dupcomps);
IDirectPlay8Address_Release(duplicate);
}
IDirectPlay8Address_Release(localaddr);
}
}
START_TEST(address) START_TEST(address)
{ {
HRESULT hr; HRESULT hr;
...@@ -226,6 +264,7 @@ START_TEST(address) ...@@ -226,6 +264,7 @@ START_TEST(address)
create_directplay_address(); create_directplay_address();
address_addcomponents(); address_addcomponents();
address_setsp(); address_setsp();
address_duplicate();
CoUninitialize(); CoUninitialize();
} }
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