diff --git a/dlls/dpnet/client.c b/dlls/dpnet/client.c index abcc5f7dd7a..bf2b8d2c465 100644 --- a/dlls/dpnet/client.c +++ b/dlls/dpnet/client.c @@ -36,6 +36,17 @@ WINE_DEFAULT_DEBUG_CHANNEL(dpnet); +typedef struct IDirectPlay8LobbyClientImpl +{ + IDirectPlay8LobbyClient IDirectPlay8LobbyClient_iface; + LONG ref; +} IDirectPlay8LobbyClientImpl; + +static inline IDirectPlay8LobbyClientImpl *impl_from_IDirectPlay8LobbyClient(IDirectPlay8LobbyClient *iface) +{ + return CONTAINING_RECORD(iface, IDirectPlay8LobbyClientImpl, IDirectPlay8LobbyClient_iface); +} + static inline IDirectPlay8ClientImpl *impl_from_IDirectPlay8Client(IDirectPlay8Client *iface) { return CONTAINING_RECORD(iface, IDirectPlay8ClientImpl, IDirectPlay8Client_iface); @@ -320,3 +331,163 @@ HRESULT DPNET_CreateDirectPlay8Client(IClassFactory *iface, IUnknown *pUnkOuter, return hr; } + +static HRESULT WINAPI lobbyclient_QueryInterface(IDirectPlay8LobbyClient *iface, REFIID riid, void **obj) +{ + IDirectPlay8LobbyClientImpl *This = impl_from_IDirectPlay8LobbyClient(iface); + + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj); + + *obj = NULL; + + if (IsEqualGUID(riid, &IID_IUnknown) || + IsEqualGUID(riid, &IID_IDirectPlay8LobbyClient)) + { + *obj = &This->IDirectPlay8LobbyClient_iface; + IUnknown_AddRef( (IUnknown*)*obj); + + return DPN_OK; + } + + WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),obj); + return E_NOINTERFACE; +} + +static ULONG WINAPI lobbyclient_AddRef(IDirectPlay8LobbyClient *iface) +{ + IDirectPlay8LobbyClientImpl *This = impl_from_IDirectPlay8LobbyClient(iface); + ULONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p) ref=%u\n", This, ref); + + return ref; +} + +static ULONG WINAPI lobbyclient_Release(IDirectPlay8LobbyClient *iface) +{ + IDirectPlay8LobbyClientImpl *This = impl_from_IDirectPlay8LobbyClient(iface); + ULONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p) ref=%u\n", This, ref); + + if (!ref) + { + HeapFree(GetProcessHeap(), 0, This); + } + + return ref; +} + +static HRESULT WINAPI lobbyclient_Initialize(IDirectPlay8LobbyClient *iface, void *context, + PFNDPNMESSAGEHANDLER msghandler, DWORD flags) +{ + IDirectPlay8LobbyClientImpl *This = impl_from_IDirectPlay8LobbyClient(iface); + + FIXME("(%p)->(%p %p 0x%08x)\n", This, context, msghandler, flags); + + return E_NOTIMPL; +} + +static HRESULT WINAPI lobbyclient_EnumLocalPrograms(IDirectPlay8LobbyClient *iface, GUID* guidapplication, + BYTE *enumdata, DWORD *enumDataSize, DWORD *items, DWORD flags) +{ + IDirectPlay8LobbyClientImpl *This = impl_from_IDirectPlay8LobbyClient(iface); + + FIXME("(%p)->(%p %p %p %p 0x%08x)\n", This, guidapplication, enumdata, enumDataSize, items, flags); + + return E_NOTIMPL; +} + +static HRESULT WINAPI lobbyclient_ConnectApplication(IDirectPlay8LobbyClient *iface, DPL_CONNECT_INFO *connectioninfo, + void *connectioncontext, DPNHANDLE *application, DWORD timeout, + DWORD flags) +{ + IDirectPlay8LobbyClientImpl *This = impl_from_IDirectPlay8LobbyClient(iface); + + FIXME("(%p)->(%p %p %p %u 0x%08x)\n", This, connectioninfo, connectioncontext, application, timeout, flags); + + return E_NOTIMPL; +} + +static HRESULT WINAPI lobbyclient_Send(IDirectPlay8LobbyClient *iface, DPNHANDLE connection, BYTE *buffer, DWORD buffersize, DWORD flags) +{ + IDirectPlay8LobbyClientImpl *This = impl_from_IDirectPlay8LobbyClient(iface); + + FIXME("(%p)->(%u %p %u 0x%08x)\n", This, connection, buffer, buffersize, flags); + + return E_NOTIMPL; +} + +static HRESULT WINAPI lobbyclient_ReleaseApplication(IDirectPlay8LobbyClient *iface, DPNHANDLE connection, DWORD flags) +{ + IDirectPlay8LobbyClientImpl *This = impl_from_IDirectPlay8LobbyClient(iface); + + FIXME("(%p)->(%u 0x%08x)\n", This, connection, flags); + + return E_NOTIMPL; +} + +static HRESULT WINAPI lobbyclient_Close(IDirectPlay8LobbyClient *iface, DWORD flags) +{ + IDirectPlay8LobbyClientImpl *This = impl_from_IDirectPlay8LobbyClient(iface); + + FIXME("(%p)->(0x%08x)\n", This, flags); + + return E_NOTIMPL; +} + +static HRESULT WINAPI lobbyclient_GetConnectionSettings(IDirectPlay8LobbyClient *iface, DPNHANDLE connection, DPL_CONNECTION_SETTINGS *sessioninfo, DWORD *infosize, DWORD flags) +{ + IDirectPlay8LobbyClientImpl *This = impl_from_IDirectPlay8LobbyClient(iface); + + FIXME("(%p)->(%u %p %p 0x%08x)\n", This, connection, sessioninfo, infosize, flags); + + return E_NOTIMPL; +} + +static HRESULT WINAPI lobbyclient_SetConnectionSettings(IDirectPlay8LobbyClient *iface, DPNHANDLE connection, const DPL_CONNECTION_SETTINGS *sessioninfo, DWORD flags) +{ + IDirectPlay8LobbyClientImpl *This = impl_from_IDirectPlay8LobbyClient(iface); + + FIXME("(%p)->(%u %p 0x%08x)\n", This, connection, sessioninfo, flags); + + return E_NOTIMPL; +} + +static const IDirectPlay8LobbyClientVtbl DirectPlay8LobbiedClient_Vtbl = +{ + lobbyclient_QueryInterface, + lobbyclient_AddRef, + lobbyclient_Release, + lobbyclient_Initialize, + lobbyclient_EnumLocalPrograms, + lobbyclient_ConnectApplication, + lobbyclient_Send, + lobbyclient_ReleaseApplication, + lobbyclient_Close, + lobbyclient_GetConnectionSettings, + lobbyclient_SetConnectionSettings +}; + +HRESULT DPNET_CreateDirectPlay8LobbyClient(IClassFactory *iface, IUnknown *outer, REFIID riid, void **obj) +{ + IDirectPlay8LobbyClientImpl *client; + HRESULT ret; + + TRACE("%p (%p, %s, %p)\n", iface, outer, debugstr_guid(riid), obj); + + client = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*client)); + if (!client) + { + *obj = NULL; + return E_OUTOFMEMORY; + } + + client->IDirectPlay8LobbyClient_iface.lpVtbl = &DirectPlay8LobbiedClient_Vtbl; + client->ref = 1; + + ret = lobbyclient_QueryInterface(&client->IDirectPlay8LobbyClient_iface, riid, obj); + lobbyclient_Release(&client->IDirectPlay8LobbyClient_iface); + + return ret; +} diff --git a/dlls/dpnet/dpnet_main.c b/dlls/dpnet/dpnet_main.c index 29cbb79b75f..042b95a515e 100644 --- a/dlls/dpnet/dpnet_main.c +++ b/dlls/dpnet/dpnet_main.c @@ -122,6 +122,7 @@ static IClassFactoryImpl DPNET_CFS[] = { { { &DICF_Vtbl }, 1, &CLSID_DirectPlay8Peer, DPNET_CreateDirectPlay8Peer }, { { &DICF_Vtbl }, 1, &CLSID_DirectPlay8Address, DPNET_CreateDirectPlay8Address }, { { &DICF_Vtbl }, 1, &CLSID_DirectPlay8LobbiedApplication, DPNET_CreateDirectPlay8LobbiedApp }, + { { &DICF_Vtbl }, 1, &CLSID_DirectPlay8LobbyClient, DPNET_CreateDirectPlay8LobbyClient }, { { &DICF_Vtbl }, 1, &CLSID_DirectPlay8ThreadPool, DPNET_CreateDirectPlay8ThreadPool}, { { NULL }, 0, NULL, NULL } }; diff --git a/dlls/dpnet/dpnet_private.h b/dlls/dpnet/dpnet_private.h index 8fd04d60e03..0c284912d7f 100644 --- a/dlls/dpnet/dpnet_private.h +++ b/dlls/dpnet/dpnet_private.h @@ -105,6 +105,7 @@ extern HRESULT DPNET_CreateDirectPlay8Peer(LPCLASSFACTORY iface, LPUNKNOWN punkO extern HRESULT DPNET_CreateDirectPlay8Address(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN; extern HRESULT DPNET_CreateDirectPlay8LobbiedApp(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN; extern HRESULT DPNET_CreateDirectPlay8ThreadPool(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN; +extern HRESULT DPNET_CreateDirectPlay8LobbyClient(IClassFactory *iface, IUnknown *pUnkOuter, REFIID riid, void **ppobj) DECLSPEC_HIDDEN; extern void init_dpn_sp_caps(DPN_SP_CAPS *dpnspcaps) DECLSPEC_HIDDEN; diff --git a/dlls/dpnet/tests/client.c b/dlls/dpnet/tests/client.c index 92bed5524ca..7f10439cd1c 100644 --- a/dlls/dpnet/tests/client.c +++ b/dlls/dpnet/tests/client.c @@ -41,6 +41,12 @@ static HRESULT WINAPI DirectPlayLobbyMessageHandler(PVOID context, DWORD message return S_OK; } +static HRESULT WINAPI DirectPlayLobbyClientMessageHandler(void *context, DWORD message_id, void* buffer) +{ + trace("DirectPlayLobbyClientMessageHandler: 0x%08x\n", message_id); + return S_OK; +} + static BOOL test_init_dp(void) { HRESULT hr; @@ -205,6 +211,25 @@ static void test_get_sp_caps(void) "expected 0x10000, got 0x%x\n", caps.dwSystemBufferSize); } +void test_lobbyclient(void) +{ + HRESULT hr; + IDirectPlay8LobbyClient *client = NULL; + + hr = CoCreateInstance( &CLSID_DirectPlay8LobbyClient, NULL, CLSCTX_ALL, &IID_IDirectPlay8LobbyClient, (void**)&client); + ok(hr == S_OK, "Failed to create object\n"); + if(SUCCEEDED(hr)) + { + hr = IDirectPlay8LobbyClient_Initialize(client, NULL, DirectPlayLobbyClientMessageHandler, 0); + todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = IDirectPlay8LobbyClient_Close(client, 0); + todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); + + IDirectPlay8LobbyClient_Release(client); + } +} + static void test_cleanup_dp(void) { HRESULT hr; @@ -233,5 +258,6 @@ START_TEST(client) test_enum_service_providers(); test_enum_hosts(); test_get_sp_caps(); + test_lobbyclient(); test_cleanup_dp(); }