wsdapi: Implement Get/SetLocalAddress.

Signed-off-by: Owen Rudge <orudge@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Owen Rudge 2017-06-26 22:35:41 +01:00 committed by Alexandre Julliard
parent 524c632a82
commit 9ce9d73414
2 changed files with 49 additions and 11 deletions

View File

@ -32,6 +32,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(wsdapi);
typedef struct IWSDMessageParametersImpl {
IWSDMessageParameters IWSDMessageParameters_iface;
LONG ref;
IWSDAddress *localAddress;
} IWSDMessageParametersImpl;
typedef struct IWSDUdpMessageParametersImpl {
@ -68,6 +69,11 @@ static ULONG WINAPI IWSDMessageParametersImpl_Release(IWSDMessageParameters *ifa
if (ref == 0)
{
if (This->localAddress != NULL)
{
IWSDAddress_Release(This->localAddress);
}
HeapFree(GetProcessHeap(), 0, This);
}
@ -76,14 +82,46 @@ static ULONG WINAPI IWSDMessageParametersImpl_Release(IWSDMessageParameters *ifa
static HRESULT WINAPI IWSDMessageParametersImpl_GetLocalAddress(IWSDMessageParameters *This, IWSDAddress **ppAddress)
{
FIXME("(%p, %p)\n", This, ppAddress);
return E_NOTIMPL;
IWSDMessageParametersImpl *impl = impl_from_IWSDMessageParameters(This);
TRACE("(%p, %p)\n", impl, ppAddress);
if (ppAddress == NULL)
{
return E_POINTER;
}
if (impl->localAddress == NULL)
{
return E_ABORT;
}
*ppAddress = impl->localAddress;
IWSDAddress_AddRef(*ppAddress);
return S_OK;
}
static HRESULT WINAPI IWSDMessageParametersImpl_SetLocalAddress(IWSDMessageParameters *This, IWSDAddress *pAddress)
{
FIXME("(%p, %p)\n", This, pAddress);
return E_NOTIMPL;
IWSDMessageParametersImpl *impl = impl_from_IWSDMessageParameters(This);
TRACE("(%p, %p)\n", impl, pAddress);
if (pAddress == NULL)
{
return E_POINTER;
}
if (impl->localAddress != NULL)
{
IWSDAddress_Release(impl->localAddress);
}
impl->localAddress = pAddress;
IWSDAddress_AddRef(pAddress);
return S_OK;
}
static HRESULT WINAPI IWSDMessageParametersImpl_GetRemoteAddress(IWSDMessageParameters *This, IWSDAddress **ppAddress)
@ -215,7 +253,7 @@ HRESULT WINAPI WSDCreateUdpMessageParameters(IWSDUdpMessageParameters **ppTxPara
*ppTxParams = NULL;
obj = HeapAlloc(GetProcessHeap(), 0, sizeof(*obj));
obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*obj));
if (!obj) return E_OUTOFMEMORY;
obj->base.IWSDMessageParameters_iface.lpVtbl = (IWSDMessageParametersVtbl *)&udpMsgParamsVtbl;

View File

@ -84,11 +84,11 @@ static void LocalAddress_tests(void)
ok(udpMessageParams != NULL, "WSDCreateUdpMessageParameters(NULL, &udpMessageParams) failed: udpMessageParams == NULL\n");
rc = IWSDUdpMessageParameters_GetLocalAddress(udpMessageParams, NULL);
todo_wine ok(rc == E_POINTER, "GetLocalAddress failed: %08x\n", rc);
ok(rc == E_POINTER, "GetLocalAddress failed: %08x\n", rc);
ok(returnedAddress == NULL, "GetLocalAddress returned %p\n", returnedAddress);
rc = IWSDUdpMessageParameters_GetLocalAddress(udpMessageParams, &returnedAddress);
todo_wine ok(rc == E_ABORT, "GetLocalAddress failed: %08x\n", rc);
ok(rc == E_ABORT, "GetLocalAddress failed: %08x\n", rc);
ok(returnedAddress == NULL, "GetLocalAddress returned %p\n", returnedAddress);
rc = WSDCreateUdpAddress(&origUdpAddress);
@ -99,14 +99,14 @@ static void LocalAddress_tests(void)
todo_wine ok(rc == S_OK, "SetTransportAddress failed: %08x\n", rc);
rc = IWSDUdpMessageParameters_SetLocalAddress(udpMessageParams, (IWSDAddress *)origUdpAddress);
todo_wine ok(rc == S_OK, "SetLocalAddress failed: %08x\n", rc);
ok(rc == S_OK, "SetLocalAddress failed: %08x\n", rc);
rc = IWSDUdpMessageParameters_GetLocalAddress(udpMessageParams, &returnedAddress);
todo_wine ok(rc == S_OK, "GetLocalAddress failed: %08x\n", rc);
todo_wine ok(returnedAddress != NULL, "GetLocalAddress returned NULL\n");
ok(rc == S_OK, "GetLocalAddress failed: %08x\n", rc);
ok(returnedAddress != NULL, "GetLocalAddress returned NULL\n");
/* Check if GetLocalAddress returns the same object */
todo_wine ok(returnedAddress == (IWSDAddress *)origUdpAddress, "returnedAddress != origUdpAddress\n");
ok(returnedAddress == (IWSDAddress *)origUdpAddress, "returnedAddress != origUdpAddress\n");
ret = IWSDUdpMessageParameters_Release(udpMessageParams);
ok(ret == 0, "IWSDUdpMessageParameters_Release() has %d references, should have 0\n", ret);