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

dpnet: Semi-stub IDirectPlay8Client SetClientInfo.

parent ac5418b1
...@@ -86,8 +86,11 @@ static ULONG WINAPI IDirectPlay8ClientImpl_Release(IDirectPlay8Client *iface) ...@@ -86,8 +86,11 @@ static ULONG WINAPI IDirectPlay8ClientImpl_Release(IDirectPlay8Client *iface)
TRACE("(%p) ref=%u\n", This, ref); TRACE("(%p) ref=%u\n", This, ref);
if (!ref) { if (!ref)
HeapFree(GetProcessHeap(), 0, This); {
heap_free(This->username);
heap_free(This->data);
heap_free(This);
} }
return ref; return ref;
} }
...@@ -182,9 +185,50 @@ static HRESULT WINAPI IDirectPlay8ClientImpl_SetClientInfo(IDirectPlay8Client *i ...@@ -182,9 +185,50 @@ static HRESULT WINAPI IDirectPlay8ClientImpl_SetClientInfo(IDirectPlay8Client *i
const DPN_PLAYER_INFO * const pdpnPlayerInfo, void * const pvAsyncContext, const DPN_PLAYER_INFO * const pdpnPlayerInfo, void * const pvAsyncContext,
DPNHANDLE * const phAsyncHandle, const DWORD dwFlags) DPNHANDLE * const phAsyncHandle, const DWORD dwFlags)
{ {
IDirectPlay8ClientImpl *This = impl_from_IDirectPlay8Client(iface); IDirectPlay8ClientImpl *This = impl_from_IDirectPlay8Client(iface);
FIXME("(%p):(%p,%p,%x): Stub\n", This, pvAsyncContext, phAsyncHandle, dwFlags); FIXME("(%p):(%p,%p,%x): Semi-stub.\n", This, pvAsyncContext, phAsyncHandle, dwFlags);
return DPN_OK;
if(!pdpnPlayerInfo)
return E_POINTER;
if(phAsyncHandle)
FIXME("Async handle currently not supported.\n");
if (pdpnPlayerInfo->dwInfoFlags & DPNINFO_NAME)
{
heap_free(This->username);
This->username = NULL;
if(pdpnPlayerInfo->pwszName)
{
This->username = heap_strdupW(pdpnPlayerInfo->pwszName);
if (!This->username)
return E_OUTOFMEMORY;
}
}
if (pdpnPlayerInfo->dwInfoFlags & DPNINFO_DATA)
{
heap_free(This->data);
This->data = NULL;
This->datasize = 0;
if(!pdpnPlayerInfo->pvData && pdpnPlayerInfo->dwDataSize)
return E_POINTER;
if(pdpnPlayerInfo->dwDataSize && pdpnPlayerInfo->pvData)
{
This->data = heap_alloc(pdpnPlayerInfo->dwDataSize);
if (!This->data)
return E_OUTOFMEMORY;
This->datasize = pdpnPlayerInfo->dwDataSize;
memcpy(This->data, pdpnPlayerInfo->pvData, pdpnPlayerInfo->dwDataSize);
}
}
return DPN_OK;
} }
static HRESULT WINAPI IDirectPlay8ClientImpl_GetServerInfo(IDirectPlay8Client *iface, static HRESULT WINAPI IDirectPlay8ClientImpl_GetServerInfo(IDirectPlay8Client *iface,
......
...@@ -56,6 +56,9 @@ struct IDirectPlay8ClientImpl ...@@ -56,6 +56,9 @@ struct IDirectPlay8ClientImpl
PFNDPNMESSAGEHANDLER msghandler; PFNDPNMESSAGEHANDLER msghandler;
DWORD flags; DWORD flags;
void *usercontext; void *usercontext;
WCHAR *username;
void *data;
DWORD datasize;
DPN_SP_CAPS spcaps; DPN_SP_CAPS spcaps;
}; };
......
...@@ -230,6 +230,71 @@ static void test_lobbyclient(void) ...@@ -230,6 +230,71 @@ static void test_lobbyclient(void)
} }
} }
static void test_player_info(void)
{
HRESULT hr;
DPN_PLAYER_INFO info;
WCHAR name[] = {'w','i','n','e',0};
WCHAR name2[] = {'w','i','n','e','2',0};
WCHAR data[] = {'X','X','X','X',0};
ZeroMemory( &info, sizeof(DPN_PLAYER_INFO) );
info.dwSize = sizeof(DPN_PLAYER_INFO);
info.dwInfoFlags = DPNINFO_NAME;
hr = IDirectPlay8Client_SetClientInfo(client, NULL, NULL, NULL, DPNSETCLIENTINFO_SYNC);
ok(hr == E_POINTER, "got %x\n", hr);
info.pwszName = NULL;
hr = IDirectPlay8Client_SetClientInfo(client, &info, NULL, NULL, DPNSETCLIENTINFO_SYNC);
ok(hr == S_OK, "got %x\n", hr);
info.pwszName = name;
hr = IDirectPlay8Client_SetClientInfo(client, &info, NULL, NULL, DPNSETCLIENTINFO_SYNC);
ok(hr == S_OK, "got %x\n", hr);
info.dwInfoFlags = DPNINFO_NAME;
info.pwszName = name2;
hr = IDirectPlay8Client_SetClientInfo(client, &info, NULL, NULL, DPNSETCLIENTINFO_SYNC);
ok(hr == S_OK, "got %x\n", hr);
info.dwInfoFlags = DPNINFO_DATA;
info.pwszName = NULL;
info.pvData = NULL;
info.dwDataSize = sizeof(data);
hr = IDirectPlay8Client_SetClientInfo(client, &info, NULL, NULL, DPNSETCLIENTINFO_SYNC);
ok(hr == E_POINTER, "got %x\n", hr);
info.dwInfoFlags = DPNINFO_DATA;
info.pwszName = NULL;
info.pvData = data;
info.dwDataSize = 0;
hr = IDirectPlay8Client_SetClientInfo(client, &info, NULL, NULL, DPNSETCLIENTINFO_SYNC);
ok(hr == S_OK, "got %x\n", hr);
info.dwInfoFlags = DPNINFO_DATA;
info.pwszName = NULL;
info.pvData = data;
info.dwDataSize = sizeof(data);
hr = IDirectPlay8Client_SetClientInfo(client, &info, NULL, NULL, DPNSETCLIENTINFO_SYNC);
ok(hr == S_OK, "got %x\n", hr);
info.dwInfoFlags = DPNINFO_DATA | DPNINFO_NAME;
info.pwszName = name;
info.pvData = data;
info.dwDataSize = sizeof(data);
hr = IDirectPlay8Client_SetClientInfo(client, &info, NULL, NULL, DPNSETCLIENTINFO_SYNC);
ok(hr == S_OK, "got %x\n", hr);
/* Leave ClientInfo with only the name set. */
info.dwInfoFlags = DPNINFO_DATA | DPNINFO_NAME;
info.pwszName = name;
info.pvData = NULL;
info.dwDataSize = 0;
hr = IDirectPlay8Client_SetClientInfo(client, &info, NULL, NULL, DPNSETCLIENTINFO_SYNC);
ok(hr == S_OK, "got %x\n", hr);
}
static void test_cleanup_dp(void) static void test_cleanup_dp(void)
{ {
HRESULT hr; HRESULT hr;
...@@ -258,6 +323,7 @@ START_TEST(client) ...@@ -258,6 +323,7 @@ START_TEST(client)
test_enum_service_providers(); test_enum_service_providers();
test_enum_hosts(); test_enum_hosts();
test_get_sp_caps(); test_get_sp_caps();
test_player_info();
test_lobbyclient(); test_lobbyclient();
test_cleanup_dp(); test_cleanup_dp();
} }
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