4 * Copyright 2004 Raphael Junqueira
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.
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.
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
32 #include "wine/debug.h"
35 #include "dpnet_private.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(dpnet
);
39 typedef struct IDirectPlay8LobbyClientImpl
41 IDirectPlay8LobbyClient IDirectPlay8LobbyClient_iface
;
43 } IDirectPlay8LobbyClientImpl
;
45 static inline IDirectPlay8LobbyClientImpl
*impl_from_IDirectPlay8LobbyClient(IDirectPlay8LobbyClient
*iface
)
47 return CONTAINING_RECORD(iface
, IDirectPlay8LobbyClientImpl
, IDirectPlay8LobbyClient_iface
);
50 static inline IDirectPlay8ClientImpl
*impl_from_IDirectPlay8Client(IDirectPlay8Client
*iface
)
52 return CONTAINING_RECORD(iface
, IDirectPlay8ClientImpl
, IDirectPlay8Client_iface
);
55 /* IDirectPlay8Client IUnknown parts follow: */
56 static HRESULT WINAPI
IDirectPlay8ClientImpl_QueryInterface(IDirectPlay8Client
*iface
, REFIID riid
,
59 IDirectPlay8ClientImpl
*This
= impl_from_IDirectPlay8Client(iface
);
61 if (IsEqualGUID(riid
, &IID_IUnknown
)
62 || IsEqualGUID(riid
, &IID_IDirectPlay8Client
)) {
63 IUnknown_AddRef(iface
);
68 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
72 static ULONG WINAPI
IDirectPlay8ClientImpl_AddRef(IDirectPlay8Client
*iface
)
74 IDirectPlay8ClientImpl
*This
= impl_from_IDirectPlay8Client(iface
);
75 ULONG ref
= InterlockedIncrement(&This
->ref
);
77 TRACE("(%p) ref=%u\n", This
, ref
);
82 static ULONG WINAPI
IDirectPlay8ClientImpl_Release(IDirectPlay8Client
*iface
)
84 IDirectPlay8ClientImpl
*This
= impl_from_IDirectPlay8Client(iface
);
85 ULONG ref
= InterlockedDecrement(&This
->ref
);
87 TRACE("(%p) ref=%u\n", This
, ref
);
90 HeapFree(GetProcessHeap(), 0, This
);
95 /* IDirectPlay8Client Interface follow: */
97 static HRESULT WINAPI
IDirectPlay8ClientImpl_Initialize(IDirectPlay8Client
*iface
,
98 void * const pvUserContext
, const PFNDPNMESSAGEHANDLER pfn
, const DWORD dwFlags
)
100 IDirectPlay8ClientImpl
*This
= impl_from_IDirectPlay8Client(iface
);
102 TRACE("(%p):(%p,%p,%x)\n", This
, pvUserContext
, pfn
, dwFlags
);
105 return DPNERR_INVALIDPARAM
;
107 This
->usercontext
= pvUserContext
;
108 This
->msghandler
= pfn
;
109 This
->flags
= dwFlags
;
114 static HRESULT WINAPI
IDirectPlay8ClientImpl_EnumServiceProviders(IDirectPlay8Client
*iface
,
115 const GUID
* const pguidServiceProvider
, const GUID
* const pguidApplication
,
116 DPN_SERVICE_PROVIDER_INFO
* const pSPInfoBuffer
, PDWORD
const pcbEnumData
,
117 PDWORD
const pcReturned
, const DWORD dwFlags
)
119 IDirectPlay8ClientImpl
*This
= impl_from_IDirectPlay8Client(iface
);
120 FIXME("(%p):(%x): Stub\n", This
, dwFlags
);
124 static HRESULT WINAPI
IDirectPlay8ClientImpl_EnumHosts(IDirectPlay8Client
*iface
,
125 PDPN_APPLICATION_DESC
const pApplicationDesc
, IDirectPlay8Address
* const pAddrHost
,
126 IDirectPlay8Address
* const pDeviceInfo
, void * const pUserEnumData
,
127 const DWORD dwUserEnumDataSize
, const DWORD dwEnumCount
, const DWORD dwRetryInterval
,
128 const DWORD dwTimeOut
, void * const pvUserContext
, DPNHANDLE
* const pAsyncHandle
,
131 IDirectPlay8ClientImpl
*This
= impl_from_IDirectPlay8Client(iface
);
132 FIXME("(%p):(%p,%p,%x): Stub\n", This
, pvUserContext
, pAsyncHandle
, dwFlags
);
136 static HRESULT WINAPI
IDirectPlay8ClientImpl_CancelAsyncOperation(IDirectPlay8Client
*iface
,
137 const DPNHANDLE hAsyncHandle
, const DWORD dwFlags
)
139 IDirectPlay8ClientImpl
*This
= impl_from_IDirectPlay8Client(iface
);
140 FIXME("(%p):(%u,%x): Stub\n", This
, hAsyncHandle
, dwFlags
);
144 static HRESULT WINAPI
IDirectPlay8ClientImpl_Connect(IDirectPlay8Client
*iface
,
145 const DPN_APPLICATION_DESC
* const pdnAppDesc
, IDirectPlay8Address
* const pHostAddr
,
146 IDirectPlay8Address
* const pDeviceInfo
, const DPN_SECURITY_DESC
* const pdnSecurity
,
147 const DPN_SECURITY_CREDENTIALS
* const pdnCredentials
, const void * const pvUserConnectData
,
148 const DWORD dwUserConnectDataSize
, void * const pvAsyncContext
,
149 DPNHANDLE
* const phAsyncHandle
, const DWORD dwFlags
)
151 IDirectPlay8ClientImpl
*This
= impl_from_IDirectPlay8Client(iface
);
152 FIXME("(%p):(%p,%p,%x): Stub\n", This
, pvAsyncContext
, phAsyncHandle
, dwFlags
);
156 static HRESULT WINAPI
IDirectPlay8ClientImpl_Send(IDirectPlay8Client
*iface
,
157 const DPN_BUFFER_DESC
* const prgBufferDesc
, const DWORD cBufferDesc
, const DWORD dwTimeOut
,
158 void * const pvAsyncContext
, DPNHANDLE
* const phAsyncHandle
, const DWORD dwFlags
)
160 IDirectPlay8ClientImpl
*This
= impl_from_IDirectPlay8Client(iface
);
161 FIXME("(%p):(%p,%p,%x): Stub\n", This
, pvAsyncContext
, phAsyncHandle
, dwFlags
);
165 static HRESULT WINAPI
IDirectPlay8ClientImpl_GetSendQueueInfo(IDirectPlay8Client
*iface
,
166 DWORD
* const pdwNumMsgs
, DWORD
* const pdwNumBytes
, const DWORD dwFlags
)
168 IDirectPlay8ClientImpl
*This
= impl_from_IDirectPlay8Client(iface
);
169 FIXME("(%p):(%x): Stub\n", This
, dwFlags
);
173 static HRESULT WINAPI
IDirectPlay8ClientImpl_GetApplicationDesc(IDirectPlay8Client
*iface
,
174 DPN_APPLICATION_DESC
* const pAppDescBuffer
, DWORD
* const pcbDataSize
, const DWORD dwFlags
)
176 IDirectPlay8ClientImpl
*This
= impl_from_IDirectPlay8Client(iface
);
177 FIXME("(%p):(%x): Stub\n", This
, dwFlags
);
181 static HRESULT WINAPI
IDirectPlay8ClientImpl_SetClientInfo(IDirectPlay8Client
*iface
,
182 const DPN_PLAYER_INFO
* const pdpnPlayerInfo
, void * const pvAsyncContext
,
183 DPNHANDLE
* const phAsyncHandle
, const DWORD dwFlags
)
185 IDirectPlay8ClientImpl
*This
= impl_from_IDirectPlay8Client(iface
);
186 FIXME("(%p):(%p,%p,%x): Stub\n", This
, pvAsyncContext
, phAsyncHandle
, dwFlags
);
190 static HRESULT WINAPI
IDirectPlay8ClientImpl_GetServerInfo(IDirectPlay8Client
*iface
,
191 DPN_PLAYER_INFO
* const pdpnPlayerInfo
, DWORD
* const pdwSize
, const DWORD dwFlags
)
193 IDirectPlay8ClientImpl
*This
= impl_from_IDirectPlay8Client(iface
);
194 FIXME("(%p):(%x): Stub\n", This
, dwFlags
);
198 static HRESULT WINAPI
IDirectPlay8ClientImpl_GetServerAddress(IDirectPlay8Client
*iface
,
199 IDirectPlay8Address
** const pAddress
, const DWORD dwFlags
)
201 IDirectPlay8ClientImpl
*This
= impl_from_IDirectPlay8Client(iface
);
202 FIXME("(%p):(%x): Stub\n", This
, dwFlags
);
206 static HRESULT WINAPI
IDirectPlay8ClientImpl_Close(IDirectPlay8Client
*iface
, const DWORD dwFlags
)
208 IDirectPlay8ClientImpl
*This
= impl_from_IDirectPlay8Client(iface
);
209 FIXME("(%p):(%x): Stub\n", This
, dwFlags
);
213 static HRESULT WINAPI
IDirectPlay8ClientImpl_ReturnBuffer(IDirectPlay8Client
*iface
,
214 const DPNHANDLE hBufferHandle
, const DWORD dwFlags
)
216 IDirectPlay8ClientImpl
*This
= impl_from_IDirectPlay8Client(iface
);
217 FIXME("(%p):(%x): Stub\n", This
, dwFlags
);
221 static HRESULT WINAPI
IDirectPlay8ClientImpl_GetCaps(IDirectPlay8Client
*iface
,
222 DPN_CAPS
* const pdpCaps
, const DWORD dwFlags
)
224 IDirectPlay8ClientImpl
*This
= impl_from_IDirectPlay8Client(iface
);
225 FIXME("(%p):(%x): Stub\n", This
, dwFlags
);
229 static HRESULT WINAPI
IDirectPlay8ClientImpl_SetCaps(IDirectPlay8Client
*iface
,
230 const DPN_CAPS
* const pdpCaps
, const DWORD dwFlags
)
232 IDirectPlay8ClientImpl
*This
= impl_from_IDirectPlay8Client(iface
);
233 FIXME("(%p):(%x): Stub\n", This
, dwFlags
);
237 static HRESULT WINAPI
IDirectPlay8ClientImpl_SetSPCaps(IDirectPlay8Client
*iface
,
238 const GUID
* const pguidSP
, const DPN_SP_CAPS
* const pdpspCaps
, const DWORD dwFlags
)
240 IDirectPlay8ClientImpl
*This
= impl_from_IDirectPlay8Client(iface
);
241 FIXME("(%p):(%x): Stub\n", This
, dwFlags
);
245 static HRESULT WINAPI
IDirectPlay8ClientImpl_GetSPCaps(IDirectPlay8Client
*iface
,
246 const GUID
* const pguidSP
, DPN_SP_CAPS
* const pdpspCaps
, const DWORD dwFlags
)
248 IDirectPlay8ClientImpl
*This
= impl_from_IDirectPlay8Client(iface
);
250 TRACE("(%p)->(%p,%p,%x)\n", This
, pguidSP
, pdpspCaps
, dwFlags
);
252 if(!This
->msghandler
)
253 return DPNERR_UNINITIALIZED
;
255 if(pdpspCaps
->dwSize
!= sizeof(DPN_SP_CAPS
))
257 return DPNERR_INVALIDPARAM
;
260 *pdpspCaps
= This
->spcaps
;
265 static HRESULT WINAPI
IDirectPlay8ClientImpl_GetConnectionInfo(IDirectPlay8Client
*iface
,
266 DPN_CONNECTION_INFO
* const pdpConnectionInfo
, const DWORD dwFlags
)
268 IDirectPlay8ClientImpl
*This
= impl_from_IDirectPlay8Client(iface
);
269 FIXME("(%p):(%x): Stub\n", This
, dwFlags
);
273 static HRESULT WINAPI
IDirectPlay8ClientImpl_RegisterLobby(IDirectPlay8Client
*iface
,
274 const DPNHANDLE dpnHandle
,
275 struct IDirectPlay8LobbiedApplication
* const pIDP8LobbiedApplication
, const DWORD dwFlags
)
277 IDirectPlay8ClientImpl
*This
= impl_from_IDirectPlay8Client(iface
);
278 FIXME("(%p):(%x): Stub\n", This
, dwFlags
);
282 static const IDirectPlay8ClientVtbl DirectPlay8Client_Vtbl
=
284 IDirectPlay8ClientImpl_QueryInterface
,
285 IDirectPlay8ClientImpl_AddRef
,
286 IDirectPlay8ClientImpl_Release
,
287 IDirectPlay8ClientImpl_Initialize
,
288 IDirectPlay8ClientImpl_EnumServiceProviders
,
289 IDirectPlay8ClientImpl_EnumHosts
,
290 IDirectPlay8ClientImpl_CancelAsyncOperation
,
291 IDirectPlay8ClientImpl_Connect
,
292 IDirectPlay8ClientImpl_Send
,
293 IDirectPlay8ClientImpl_GetSendQueueInfo
,
294 IDirectPlay8ClientImpl_GetApplicationDesc
,
295 IDirectPlay8ClientImpl_SetClientInfo
,
296 IDirectPlay8ClientImpl_GetServerInfo
,
297 IDirectPlay8ClientImpl_GetServerAddress
,
298 IDirectPlay8ClientImpl_Close
,
299 IDirectPlay8ClientImpl_ReturnBuffer
,
300 IDirectPlay8ClientImpl_GetCaps
,
301 IDirectPlay8ClientImpl_SetCaps
,
302 IDirectPlay8ClientImpl_SetSPCaps
,
303 IDirectPlay8ClientImpl_GetSPCaps
,
304 IDirectPlay8ClientImpl_GetConnectionInfo
,
305 IDirectPlay8ClientImpl_RegisterLobby
308 HRESULT
DPNET_CreateDirectPlay8Client(IClassFactory
*iface
, IUnknown
*pUnkOuter
, REFIID riid
, void **ppv
)
310 IDirectPlay8ClientImpl
* client
;
313 TRACE("(%p, %s, %p)\n", pUnkOuter
, debugstr_guid(riid
), ppv
);
318 return CLASS_E_NOAGGREGATION
;
320 client
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectPlay8ClientImpl
));
322 return E_OUTOFMEMORY
;
324 client
->IDirectPlay8Client_iface
.lpVtbl
= &DirectPlay8Client_Vtbl
;
327 init_dpn_sp_caps(&client
->spcaps
);
329 hr
= IDirectPlay8ClientImpl_QueryInterface(&client
->IDirectPlay8Client_iface
, riid
, ppv
);
330 IDirectPlay8ClientImpl_Release(&client
->IDirectPlay8Client_iface
);
335 static HRESULT WINAPI
lobbyclient_QueryInterface(IDirectPlay8LobbyClient
*iface
, REFIID riid
, void **obj
)
337 IDirectPlay8LobbyClientImpl
*This
= impl_from_IDirectPlay8LobbyClient(iface
);
339 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), obj
);
343 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
344 IsEqualGUID(riid
, &IID_IDirectPlay8LobbyClient
))
346 *obj
= &This
->IDirectPlay8LobbyClient_iface
;
347 IUnknown_AddRef( (IUnknown
*)*obj
);
352 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),obj
);
353 return E_NOINTERFACE
;
356 static ULONG WINAPI
lobbyclient_AddRef(IDirectPlay8LobbyClient
*iface
)
358 IDirectPlay8LobbyClientImpl
*This
= impl_from_IDirectPlay8LobbyClient(iface
);
359 ULONG ref
= InterlockedIncrement(&This
->ref
);
361 TRACE("(%p) ref=%u\n", This
, ref
);
366 static ULONG WINAPI
lobbyclient_Release(IDirectPlay8LobbyClient
*iface
)
368 IDirectPlay8LobbyClientImpl
*This
= impl_from_IDirectPlay8LobbyClient(iface
);
369 ULONG ref
= InterlockedDecrement(&This
->ref
);
371 TRACE("(%p) ref=%u\n", This
, ref
);
375 HeapFree(GetProcessHeap(), 0, This
);
381 static HRESULT WINAPI
lobbyclient_Initialize(IDirectPlay8LobbyClient
*iface
, void *context
,
382 PFNDPNMESSAGEHANDLER msghandler
, DWORD flags
)
384 IDirectPlay8LobbyClientImpl
*This
= impl_from_IDirectPlay8LobbyClient(iface
);
386 FIXME("(%p)->(%p %p 0x%08x)\n", This
, context
, msghandler
, flags
);
391 static HRESULT WINAPI
lobbyclient_EnumLocalPrograms(IDirectPlay8LobbyClient
*iface
, GUID
* guidapplication
,
392 BYTE
*enumdata
, DWORD
*enumDataSize
, DWORD
*items
, DWORD flags
)
394 IDirectPlay8LobbyClientImpl
*This
= impl_from_IDirectPlay8LobbyClient(iface
);
396 FIXME("(%p)->(%p %p %p %p 0x%08x)\n", This
, guidapplication
, enumdata
, enumDataSize
, items
, flags
);
401 static HRESULT WINAPI
lobbyclient_ConnectApplication(IDirectPlay8LobbyClient
*iface
, DPL_CONNECT_INFO
*connectioninfo
,
402 void *connectioncontext
, DPNHANDLE
*application
, DWORD timeout
,
405 IDirectPlay8LobbyClientImpl
*This
= impl_from_IDirectPlay8LobbyClient(iface
);
407 FIXME("(%p)->(%p %p %p %u 0x%08x)\n", This
, connectioninfo
, connectioncontext
, application
, timeout
, flags
);
412 static HRESULT WINAPI
lobbyclient_Send(IDirectPlay8LobbyClient
*iface
, DPNHANDLE connection
, BYTE
*buffer
, DWORD buffersize
, DWORD flags
)
414 IDirectPlay8LobbyClientImpl
*This
= impl_from_IDirectPlay8LobbyClient(iface
);
416 FIXME("(%p)->(%u %p %u 0x%08x)\n", This
, connection
, buffer
, buffersize
, flags
);
421 static HRESULT WINAPI
lobbyclient_ReleaseApplication(IDirectPlay8LobbyClient
*iface
, DPNHANDLE connection
, DWORD flags
)
423 IDirectPlay8LobbyClientImpl
*This
= impl_from_IDirectPlay8LobbyClient(iface
);
425 FIXME("(%p)->(%u 0x%08x)\n", This
, connection
, flags
);
430 static HRESULT WINAPI
lobbyclient_Close(IDirectPlay8LobbyClient
*iface
, DWORD flags
)
432 IDirectPlay8LobbyClientImpl
*This
= impl_from_IDirectPlay8LobbyClient(iface
);
434 FIXME("(%p)->(0x%08x)\n", This
, flags
);
439 static HRESULT WINAPI
lobbyclient_GetConnectionSettings(IDirectPlay8LobbyClient
*iface
, DPNHANDLE connection
, DPL_CONNECTION_SETTINGS
*sessioninfo
, DWORD
*infosize
, DWORD flags
)
441 IDirectPlay8LobbyClientImpl
*This
= impl_from_IDirectPlay8LobbyClient(iface
);
443 FIXME("(%p)->(%u %p %p 0x%08x)\n", This
, connection
, sessioninfo
, infosize
, flags
);
448 static HRESULT WINAPI
lobbyclient_SetConnectionSettings(IDirectPlay8LobbyClient
*iface
, DPNHANDLE connection
, const DPL_CONNECTION_SETTINGS
*sessioninfo
, DWORD flags
)
450 IDirectPlay8LobbyClientImpl
*This
= impl_from_IDirectPlay8LobbyClient(iface
);
452 FIXME("(%p)->(%u %p 0x%08x)\n", This
, connection
, sessioninfo
, flags
);
457 static const IDirectPlay8LobbyClientVtbl DirectPlay8LobbiedClient_Vtbl
=
459 lobbyclient_QueryInterface
,
462 lobbyclient_Initialize
,
463 lobbyclient_EnumLocalPrograms
,
464 lobbyclient_ConnectApplication
,
466 lobbyclient_ReleaseApplication
,
468 lobbyclient_GetConnectionSettings
,
469 lobbyclient_SetConnectionSettings
472 HRESULT
DPNET_CreateDirectPlay8LobbyClient(IClassFactory
*iface
, IUnknown
*outer
, REFIID riid
, void **obj
)
474 IDirectPlay8LobbyClientImpl
*client
;
477 TRACE("%p (%p, %s, %p)\n", iface
, outer
, debugstr_guid(riid
), obj
);
479 client
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*client
));
483 return E_OUTOFMEMORY
;
486 client
->IDirectPlay8LobbyClient_iface
.lpVtbl
= &DirectPlay8LobbiedClient_Vtbl
;
489 ret
= lobbyclient_QueryInterface(&client
->IDirectPlay8LobbyClient_iface
, riid
, obj
);
490 lobbyclient_Release(&client
->IDirectPlay8LobbyClient_iface
);