Module: wine Branch: master Commit: 7dcfb9d3e55bab5a3422c85e85221e5279689d09 URL: http://source.winehq.org/git/wine.git/?a=commit;h=7dcfb9d3e55bab5a3422c85e85...
Author: Alistair Leslie-Hughes leslie_alistair@hotmail.com Date: Tue May 13 12:57:47 2014 +1000
dpnet: Implement IDirectPlay8Address Duplicate.
---
dlls/dpnet/address.c | 33 ++++++++++++++++++++++++++++++--- dlls/dpnet/dpnet_private.h | 1 + dlls/dpnet/tests/address.c | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 3 deletions(-)
diff --git a/dlls/dpnet/address.c b/dlls/dpnet/address.c index 2cea1ea..7df7ad6 100644 --- a/dlls/dpnet/address.c +++ b/dlls/dpnet/address.c @@ -179,9 +179,35 @@ static HRESULT WINAPI IDirectPlay8AddressImpl_BuildFromURLA(IDirectPlay8Address static HRESULT WINAPI IDirectPlay8AddressImpl_Duplicate(IDirectPlay8Address *iface, IDirectPlay8Address **ppdpaNewAddress) { - IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface); - TRACE("(%p, %p): stub\n", This, ppdpaNewAddress); - return DPN_OK; + IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface); + IDirectPlay8Address *dup; + 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, @@ -338,6 +364,7 @@ static HRESULT WINAPI IDirectPlay8AddressImpl_AddComponent(IDirectPlay8Address * list_add_tail(&This->components, &entry->entry); }
+ entry->size = dwDataSize; switch (dwDataType) { case DPNA_DATATYPE_DWORD: diff --git a/dlls/dpnet/dpnet_private.h b/dlls/dpnet/dpnet_private.h index 61e2200..1ed4f25 100644 --- a/dlls/dpnet/dpnet_private.h +++ b/dlls/dpnet/dpnet_private.h @@ -68,6 +68,7 @@ struct component
WCHAR *name; DWORD type; + DWORD size;
union { diff --git a/dlls/dpnet/tests/address.c b/dlls/dpnet/tests/address.c index 0f0b8ce..ad35954 100644 --- a/dlls/dpnet/tests/address.c +++ b/dlls/dpnet/tests/address.c @@ -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) { HRESULT hr; @@ -226,6 +264,7 @@ START_TEST(address) create_directplay_address(); address_addcomponents(); address_setsp(); + address_duplicate();
CoUninitialize(); }