dpnet: Stub interface IDirectPlay8LobbyClient (try 2)

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Wed May 14 01:46:49 CDT 2014


Hi,
FIX L*JUNk macros.
Correctly register interface as well.

Changelog:
     dpnet: Stub interface IDirectPlay8LobbyClient


Best Regards
  Alistair Leslie-Hughes
-------------- next part --------------
>From bfeddb862c4d73f03fad5068589d796ae478c73d Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Mon, 12 May 2014 15:19:03 +1000
Subject: [PATCH] Stub interface IDirectPlay8LobbyClient
To: wine-patches <wine-patches at winehq.org>

---
 dlls/dpnet/Makefile.in         |   1 +
 dlls/dpnet/dpnet.idl           |   7 ++
 dlls/dpnet/dpnet_main.c        |   1 +
 dlls/dpnet/dpnet_private.h     |   1 +
 dlls/dpnet/lobbyclient.c       | 201 +++++++++++++++++++++++++++++++++++++++++
 dlls/dpnet/tests/Makefile.in   |   1 +
 dlls/dpnet/tests/lobbyclient.c |  65 +++++++++++++
 7 files changed, 277 insertions(+)
 create mode 100644 dlls/dpnet/lobbyclient.c
 create mode 100644 dlls/dpnet/tests/lobbyclient.c

diff --git a/dlls/dpnet/Makefile.in b/dlls/dpnet/Makefile.in
index 541e104..70ccef0 100644
--- a/dlls/dpnet/Makefile.in
+++ b/dlls/dpnet/Makefile.in
@@ -7,6 +7,7 @@ C_SRCS = \
 	client.c \
 	dpnet_main.c \
 	lobbiedapp.c \
+	lobbyclient.c \
 	peer.c \
 	server.c \
 	threadpool.c
diff --git a/dlls/dpnet/dpnet.idl b/dlls/dpnet/dpnet.idl
index de20bdd..3389973 100644
--- a/dlls/dpnet/dpnet.idl
+++ b/dlls/dpnet/dpnet.idl
@@ -56,6 +56,13 @@ coclass DirectPlay8Address { interface IDirectPlay8Address; }
 coclass DirectPlay8LobbiedApplication { interface IDirectPlay8LobbiedApplication; }
 
 [
+    helpstring("DirectPlay8LobbyClient Object"),
+    threading(both),
+    uuid(3B2B6775-70B6-45AF-8DEA-A209C69559F3)
+]
+coclass DirectPlay8LobbyClient { interface IDirectPlay8LobbyClient; }
+
+[
     helpstring("DirectPlay8 Thread Pool Object"),
     threading(both),
     uuid(fc47060e-6153-4b34-b975-8e4121eb7f3c)
diff --git a/dlls/dpnet/dpnet_main.c b/dlls/dpnet/dpnet_main.c
index 29cbb79..042b95a 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 6b4b35d..d6f572b 100644
--- a/dlls/dpnet/dpnet_private.h
+++ b/dlls/dpnet/dpnet_private.h
@@ -127,6 +127,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/lobbyclient.c b/dlls/dpnet/lobbyclient.c
new file mode 100644
index 0000000..d0c2488
--- /dev/null
+++ b/dlls/dpnet/lobbyclient.c
@@ -0,0 +1,201 @@
+/*
+ * Direct Play Lobby Client
+ *
+ * Copyright 2014 Alistair Leslie-Hughes
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ *
+ */
+#include "config.h"
+
+#include <stdarg.h>
+
+#define COBJMACROS
+#include "windef.h"
+#include "winbase.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "objbase.h"
+#include "wine/debug.h"
+
+#include "dplay8.h"
+#include "dplobby8.h"
+#include "dpnet_private.h"
+
+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 HRESULT WINAPI lobbyclient_QueryInterface(IDirectPlay8LobbyClient *iface, REFIID riid, void **ppobj)
+{
+    IDirectPlay8LobbyClientImpl *This = impl_from_IDirectPlay8LobbyClient(iface);
+
+    if (IsEqualGUID(riid, &IID_IUnknown) ||
+        IsEqualGUID(riid, &IID_IDirectPlay8LobbyClient))
+    {
+        IUnknown_AddRef(iface);
+        *ppobj = This;
+        return DPN_OK;
+    }
+
+    WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
+    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 pfn, DWORD flags)
+{
+    IDirectPlay8LobbyClientImpl *This = impl_from_IDirectPlay8LobbyClient(iface);
+
+    FIXME("(%p)->(%p %p %x)\n", This, context, pfn, flags);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI lobbyclient_EnumLocalPrograms(IDirectPlay8LobbyClient *iface, GUID* pGuidApplication, BYTE* pEnumData, DWORD* pdwEnumData, DWORD* pdwItems, DWORD flags)
+{
+    IDirectPlay8LobbyClientImpl *This = impl_from_IDirectPlay8LobbyClient(iface);
+
+    FIXME("(%p)->(%p %p %p %p %x)\n", This, pGuidApplication, pEnumData, pdwEnumData, pdwItems, flags);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI lobbyclient_ConnectApplication(IDirectPlay8LobbyClient *iface, DPL_CONNECT_INFO* pdplConnectionInfo, PVOID pvConnectionContext, DPNHANDLE* hApplication, DWORD dwTimeOut, DWORD flags)
+{
+    IDirectPlay8LobbyClientImpl *This = impl_from_IDirectPlay8LobbyClient(iface);
+
+    FIXME("(%p)->(%p %p %p %d %x)\n", This, pdplConnectionInfo, pvConnectionContext, hApplication, dwTimeOut, flags);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI lobbyclient_Send(IDirectPlay8LobbyClient *iface, DPNHANDLE hConnection, BYTE* pBuffer, DWORD pBufferSize, DWORD flags)
+{
+    IDirectPlay8LobbyClientImpl *This = impl_from_IDirectPlay8LobbyClient(iface);
+
+    FIXME("(%p)->(%d %p %p %d %x)\n", This, hConnection, pBuffer, pBuffer, pBufferSize, flags);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI lobbyclient_ReleaseApplication(IDirectPlay8LobbyClient *iface, DPNHANDLE hConnection, DWORD flags)
+{
+    IDirectPlay8LobbyClientImpl *This = impl_from_IDirectPlay8LobbyClient(iface);
+
+    FIXME("(%p)->(%d %x)\n", This, hConnection, flags);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI lobbyclient_Close(IDirectPlay8LobbyClient *iface, DWORD flags)
+{
+    IDirectPlay8LobbyClientImpl *This = impl_from_IDirectPlay8LobbyClient(iface);
+
+    FIXME("(%p)->(%x)\n", This, flags);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI lobbyclient_GetConnectionSettings(IDirectPlay8LobbyClient *iface, DPNHANDLE hConnection, DPL_CONNECTION_SETTINGS* pdplSessionInfo, DWORD* pdwInfoSize, DWORD flags)
+{
+    IDirectPlay8LobbyClientImpl *This = impl_from_IDirectPlay8LobbyClient(iface);
+
+    FIXME("(%p)->(%d %p %p %x)\n", This, hConnection, pdplSessionInfo, pdwInfoSize, flags);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI lobbyclient_SetConnectionSettings(IDirectPlay8LobbyClient *iface, DPNHANDLE hConnection, const DPL_CONNECTION_SETTINGS* pdplSessionInfo, DWORD flags)
+{
+    IDirectPlay8LobbyClientImpl *This = impl_from_IDirectPlay8LobbyClient(iface);
+
+    FIXME("(%p)->(%d %p %x)\n", This, hConnection, pdplSessionInfo, 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 *app;
+    HRESULT ret;
+
+    TRACE("(%p, %s, %p)\n", outer, debugstr_guid(riid), obj);
+
+    app = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8LobbyClientImpl));
+    if (!app)
+    {
+        *obj = NULL;
+        return E_OUTOFMEMORY;
+    }
+
+    app->IDirectPlay8LobbyClient_iface.lpVtbl = &DirectPlay8LobbiedClient_Vtbl;
+    app->ref = 1;
+
+    ret = lobbyclient_QueryInterface(&app->IDirectPlay8LobbyClient_iface, riid, obj);
+    lobbyclient_Release(&app->IDirectPlay8LobbyClient_iface);
+
+    return ret;
+}
diff --git a/dlls/dpnet/tests/Makefile.in b/dlls/dpnet/tests/Makefile.in
index f6e45ea..5b97aa1 100644
--- a/dlls/dpnet/tests/Makefile.in
+++ b/dlls/dpnet/tests/Makefile.in
@@ -4,5 +4,6 @@ IMPORTS   = dxguid uuid dpnet ole32
 C_SRCS = \
 	address.c \
 	client.c \
+	lobbyclient.c \
 	peer.c \
 	server.c
diff --git a/dlls/dpnet/tests/lobbyclient.c b/dlls/dpnet/tests/lobbyclient.c
new file mode 100644
index 0000000..28c4248
--- /dev/null
+++ b/dlls/dpnet/tests/lobbyclient.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2014 Alistair Leslie-Hughes
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define WIN32_LEAN_AND_MEAN
+#include <stdio.h>
+
+#include <dplay8.h>
+#include <dplobby8.h>
+
+#include "wine/test.h"
+
+static HRESULT WINAPI DirectPlayLobbyMessageHandler(PVOID context, DWORD message_id, PVOID buffer)
+{
+    trace("DirectPlayLobbyMessageHandler: 0x%08x\n", message_id);
+    return S_OK;
+}
+
+void create_lobbyclient(void)
+{
+    HRESULT hr;
+    IDirectPlay8LobbyClient *client = NULL;
+
+    hr = CoCreateInstance( &CLSID_DirectPlay8LobbyClient, NULL, CLSCTX_ALL, &IID_IDirectPlay8LobbyClient, (LPVOID*)&client);
+    ok(hr == S_OK, "Failed to create object\n");
+    if(SUCCEEDED(hr))
+    {
+        hr = IDirectPlay8LobbyClient_Initialize(client, NULL, DirectPlayLobbyMessageHandler, 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);
+    }
+}
+
+
+START_TEST(lobbyclient)
+{
+    HRESULT hr;
+
+    hr = CoInitialize(0);
+    ok(hr == S_OK, "failed to init com\n");
+    if(hr != S_OK)
+        return;
+
+    create_lobbyclient();
+
+    CoUninitialize();
+}
-- 
1.9.1



More information about the wine-patches mailing list