quartz: On flushing, always signal blocked event handle.
[wine] / dlls / dpnet / lobbiedapp.c
1 /*
2  * DirectPlay8 LobbiedApplication
3  *
4  * Copyright 2007 Jason Edmeades
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  *
20  */
21
22 #include "config.h"
23
24 #include <stdarg.h>
25
26 #define COBJMACROS
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wingdi.h"
30 #include "winuser.h"
31 #include "objbase.h"
32 #include "wine/debug.h"
33
34 #include "dplay8.h"
35 #include "dplobby8.h"
36 #include "dpnet_private.h"
37
38 WINE_DEFAULT_DEBUG_CHANNEL(dpnet);
39
40 /* IDirectPlay8LobbiedApplication IUnknown parts follow: */
41 static HRESULT WINAPI IDirectPlay8LobbiedApplicationImpl_QueryInterface(
42                                   PDIRECTPLAY8LOBBIEDAPPLICATION iface,
43                                   REFIID riid,
44                                   LPVOID *ppobj) {
45     IDirectPlay8LobbiedApplicationImpl *This = (IDirectPlay8LobbiedApplicationImpl *)iface;
46
47     if (IsEqualGUID(riid, &IID_IUnknown)
48         || IsEqualGUID(riid, &IID_IDirectPlay8LobbiedApplication)) {
49         IUnknown_AddRef(iface);
50         *ppobj = This;
51         return DPN_OK;
52     }
53
54     WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
55     return E_NOINTERFACE;
56 }
57
58 static ULONG WINAPI IDirectPlay8LobbiedApplicationImpl_AddRef(
59                                 PDIRECTPLAY8LOBBIEDAPPLICATION iface) {
60     IDirectPlay8LobbiedApplicationImpl *This = (IDirectPlay8LobbiedApplicationImpl *)iface;
61     ULONG refCount = InterlockedIncrement(&This->ref);
62
63     TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
64
65     return refCount;
66 }
67
68 static ULONG WINAPI IDirectPlay8LobbiedApplicationImpl_Release(
69                                 PDIRECTPLAY8LOBBIEDAPPLICATION iface) {
70     IDirectPlay8LobbiedApplicationImpl *This = (IDirectPlay8LobbiedApplicationImpl *)iface;
71     ULONG refCount = InterlockedDecrement(&This->ref);
72
73     TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
74
75     if (!refCount) {
76         HeapFree(GetProcessHeap(), 0, This);
77     }
78     return refCount;
79 }
80
81 /* IDirectPlay8LobbiedApplication Interface follow: */
82
83 static HRESULT WINAPI IDirectPlay8LobbiedApplicationImpl_Initialize(PDIRECTPLAY8LOBBIEDAPPLICATION iface,
84                                                                 CONST PVOID pvUserContext,
85                                                                 CONST PFNDPNMESSAGEHANDLER pfn,
86                                                                 DPNHANDLE* CONST pdpnhConnection,
87                                                                 CONST DWORD dwFlags) {
88   IDirectPlay8LobbiedApplicationImpl *This = (IDirectPlay8LobbiedApplicationImpl *)iface;
89   FIXME("(%p): stub\n", This);
90   return DPN_OK;
91 }
92
93 static HRESULT WINAPI IDirectPlay8LobbiedApplicationImpl_RegisterProgram(PDIRECTPLAY8LOBBIEDAPPLICATION iface,
94                                                                 PDPL_PROGRAM_DESC pdplProgramDesc,
95                                                                 CONST DWORD dwFlags) {
96   IDirectPlay8LobbiedApplicationImpl *This = (IDirectPlay8LobbiedApplicationImpl *)iface;
97   FIXME("(%p): stub\n", This);
98   return DPN_OK;
99 }
100
101 static HRESULT WINAPI IDirectPlay8LobbiedApplicationImpl_UnRegisterProgram(PDIRECTPLAY8LOBBIEDAPPLICATION iface,
102                                                                 GUID* pguidApplication,
103                                                                 CONST DWORD dwFlags) {
104   IDirectPlay8LobbiedApplicationImpl *This = (IDirectPlay8LobbiedApplicationImpl *)iface;
105   FIXME("(%p): stub\n", This);
106   return DPN_OK;
107 }
108
109 static HRESULT WINAPI IDirectPlay8LobbiedApplicationImpl_Send(PDIRECTPLAY8LOBBIEDAPPLICATION iface,
110                                                           CONST DPNHANDLE hConnection,
111                                                           BYTE* CONST pBuffer,
112                                                           CONST DWORD pBufferSize,
113                                                           CONST DWORD dwFlags) {
114   IDirectPlay8LobbiedApplicationImpl *This = (IDirectPlay8LobbiedApplicationImpl *)iface;
115   FIXME("(%p): stub\n", This);
116   return DPN_OK;
117 }
118
119 static HRESULT WINAPI IDirectPlay8LobbiedApplicationImpl_SetAppAvailable(PDIRECTPLAY8LOBBIEDAPPLICATION iface,
120                                                           CONST BOOL fAvailable,
121                                                           CONST DWORD dwFlags) {
122   IDirectPlay8LobbiedApplicationImpl *This = (IDirectPlay8LobbiedApplicationImpl *)iface;
123   FIXME("(%p): stub\n", This);
124   return DPN_OK;
125 }
126
127 static HRESULT WINAPI IDirectPlay8LobbiedApplicationImpl_UpdateStatus(PDIRECTPLAY8LOBBIEDAPPLICATION iface,
128                                                           CONST DPNHANDLE hConnection,
129                                                           CONST DWORD dwStatus,
130                                                           CONST DWORD dwFlags) {
131   IDirectPlay8LobbiedApplicationImpl *This = (IDirectPlay8LobbiedApplicationImpl *)iface;
132   FIXME("(%p): stub\n", This);
133   return DPN_OK;
134 }
135
136 static HRESULT WINAPI IDirectPlay8LobbiedApplicationImpl_Close(PDIRECTPLAY8LOBBIEDAPPLICATION iface,
137                                                           CONST DWORD dwFlags) {
138   IDirectPlay8LobbiedApplicationImpl *This = (IDirectPlay8LobbiedApplicationImpl *)iface;
139   FIXME("(%p): stub\n", This);
140   return DPN_OK;
141 }
142
143 static HRESULT WINAPI IDirectPlay8LobbiedApplicationImpl_GetConnectionSettings(PDIRECTPLAY8LOBBIEDAPPLICATION iface,
144                                                           CONST DPNHANDLE hConnection,
145                                                           DPL_CONNECTION_SETTINGS* CONST pdplSessionInfo,
146                                                           DWORD* pdwInfoSize,
147                                                           CONST DWORD dwFlags) {
148   IDirectPlay8LobbiedApplicationImpl *This = (IDirectPlay8LobbiedApplicationImpl *)iface;
149   FIXME("(%p): stub\n", This);
150   return DPN_OK;
151 }
152
153 static HRESULT WINAPI IDirectPlay8LobbiedApplicationImpl_SetConnectionSettings(PDIRECTPLAY8LOBBIEDAPPLICATION iface,
154                                                           CONST DPNHANDLE hConnection,
155                                                           CONST DPL_CONNECTION_SETTINGS* CONST pdplSessionInfo,
156                                                           CONST DWORD dwFlags) {
157   IDirectPlay8LobbiedApplicationImpl *This = (IDirectPlay8LobbiedApplicationImpl *)iface;
158   FIXME("(%p): stub\n", This);
159   return DPN_OK;
160 }
161
162 static const IDirectPlay8LobbiedApplicationVtbl DirectPlay8LobbiedApplication_Vtbl =
163 {
164     IDirectPlay8LobbiedApplicationImpl_QueryInterface,
165     IDirectPlay8LobbiedApplicationImpl_AddRef,
166     IDirectPlay8LobbiedApplicationImpl_Release,
167     IDirectPlay8LobbiedApplicationImpl_Initialize,
168     IDirectPlay8LobbiedApplicationImpl_RegisterProgram,
169     IDirectPlay8LobbiedApplicationImpl_UnRegisterProgram,
170     IDirectPlay8LobbiedApplicationImpl_Send,
171     IDirectPlay8LobbiedApplicationImpl_SetAppAvailable,
172     IDirectPlay8LobbiedApplicationImpl_UpdateStatus,
173     IDirectPlay8LobbiedApplicationImpl_Close,
174     IDirectPlay8LobbiedApplicationImpl_GetConnectionSettings,
175     IDirectPlay8LobbiedApplicationImpl_SetConnectionSettings
176 };
177
178
179
180 HRESULT DPNET_CreateDirectPlay8LobbiedApp(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj) {
181   IDirectPlay8LobbiedApplicationImpl* app;
182
183   TRACE("(%p, %s, %p)\n", punkOuter, debugstr_guid(riid), ppobj);
184
185   app = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8LobbiedApplicationImpl));
186   if (NULL == app) {
187     *ppobj = NULL;
188     return E_OUTOFMEMORY;
189   }
190   app->lpVtbl = &DirectPlay8LobbiedApplication_Vtbl;
191   app->ref = 0; /* will be inited with QueryInterface */
192   return IDirectPlay8LobbiedApplicationImpl_QueryInterface ((PDIRECTPLAY8LOBBIEDAPPLICATION)app, riid, ppobj);
193 }