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"
34 #include "dpnet_private.h"
36 typedef struct IDirectPlay8ServerImpl
38 IDirectPlay8Server IDirectPlay8Server_iface
;
41 PFNDPNMESSAGEHANDLER msghandler
;
48 } IDirectPlay8ServerImpl
;
50 WINE_DEFAULT_DEBUG_CHANNEL(dpnet
);
52 static inline IDirectPlay8ServerImpl
*impl_from_IDirectPlay8Server(IDirectPlay8Server
*iface
)
54 return CONTAINING_RECORD(iface
, IDirectPlay8ServerImpl
, IDirectPlay8Server_iface
);
57 static HRESULT WINAPI
IDirectPlay8ServerImpl_QueryInterface(IDirectPlay8Server
*iface
, REFIID riid
, void **ppv
)
59 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
61 TRACE("%p %s %p\n", This
, debugstr_guid(riid
), ppv
);
63 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
64 IsEqualGUID(riid
, &IID_IDirectPlay8Server
))
66 TRACE("(%p)->(IID_IDirectPlay8Server %p)\n", This
, ppv
);
67 *ppv
= &This
->IDirectPlay8Server_iface
;
70 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
75 IUnknown_AddRef((IUnknown
*)*ppv
);
79 static ULONG WINAPI
IDirectPlay8ServerImpl_AddRef(IDirectPlay8Server
*iface
)
81 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
82 ULONG ref
= InterlockedIncrement(&This
->ref
);
84 TRACE("(%p) ref=%d\n", This
, ref
);
89 static ULONG WINAPI
IDirectPlay8ServerImpl_Release(IDirectPlay8Server
*iface
)
91 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
92 ULONG ref
= InterlockedDecrement(&This
->ref
);
94 TRACE("(%p) ref=%d\n", This
, ref
);
98 heap_free(This
->servername
);
99 heap_free(This
->data
);
106 static HRESULT WINAPI
IDirectPlay8ServerImpl_Initialize(IDirectPlay8Server
*iface
, PVOID pvUserContext
,
107 PFNDPNMESSAGEHANDLER pfn
, DWORD dwFlags
)
109 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
110 TRACE("(%p)->(%p %p %d)\n", This
, pvUserContext
, pfn
, dwFlags
);
113 return DPNERR_INVALIDPARAM
;
115 This
->usercontext
= pvUserContext
;
116 This
->msghandler
= pfn
;
117 This
->flags
= dwFlags
;
124 static HRESULT WINAPI
IDirectPlay8ServerImpl_EnumServiceProviders(IDirectPlay8Server
*iface
, const GUID
*pguidServiceProvider
,
125 const GUID
*pguidApplication
, DPN_SERVICE_PROVIDER_INFO
*pSPInfoBuffer
, PDWORD pcbEnumData
,
126 PDWORD pcReturned
, DWORD dwFlags
)
128 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
129 FIXME("(%p)->(%s %s %p %p %p %d)\n", This
, debugstr_guid(pguidServiceProvider
), debugstr_guid(pguidApplication
),
130 pSPInfoBuffer
, pcbEnumData
, pcReturned
, dwFlags
);
134 static HRESULT WINAPI
IDirectPlay8ServerImpl_CancelAsyncOperation(IDirectPlay8Server
*iface
, DPNHANDLE hAsyncHandle
, DWORD dwFlags
)
136 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
137 FIXME("(%p)->(%d %d)\n", This
, hAsyncHandle
, dwFlags
);
141 static HRESULT WINAPI
IDirectPlay8ServerImpl_GetSendQueueInfo(IDirectPlay8Server
*iface
, DPNID dpnid
, DWORD
*pdwNumMsgs
,
142 DWORD
*pdwNumBytes
, DWORD dwFlags
)
144 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
145 FIXME("(%p)->(%d %p %p %d)\n", This
, dpnid
, pdwNumMsgs
, pdwNumBytes
, dwFlags
);
149 static HRESULT WINAPI
IDirectPlay8ServerImpl_GetApplicationDesc(IDirectPlay8Server
*iface
, DPN_APPLICATION_DESC
*pAppDescBuffer
,
150 DWORD
*pcbDataSize
, DWORD dwFlags
)
152 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
153 FIXME("(%p)->(%p %p %d)\n", This
, pAppDescBuffer
, pcbDataSize
, dwFlags
);
157 static HRESULT WINAPI
IDirectPlay8ServerImpl_SetServerInfo(IDirectPlay8Server
*iface
, const DPN_PLAYER_INFO
*pdpnPlayerInfo
,
158 PVOID pvAsyncContext
, DPNHANDLE
*phAsyncHandle
, DWORD dwFlags
)
160 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
162 FIXME("(%p)->(%p %p %p %x) Semi-stub\n", This
, pdpnPlayerInfo
, pvAsyncContext
, phAsyncHandle
, dwFlags
);
167 if(!This
->msghandler
)
168 return DPNERR_UNINITIALIZED
;
171 FIXME("Async handle currently not supported.\n");
173 if (pdpnPlayerInfo
->dwInfoFlags
& DPNINFO_NAME
)
175 heap_free(This
->servername
);
176 This
->servername
= NULL
;
178 if(pdpnPlayerInfo
->pwszName
)
180 This
->servername
= heap_strdupW(pdpnPlayerInfo
->pwszName
);
181 if (!This
->servername
)
182 return E_OUTOFMEMORY
;
186 if (pdpnPlayerInfo
->dwInfoFlags
& DPNINFO_DATA
)
188 heap_free(This
->data
);
192 if(!pdpnPlayerInfo
->pvData
&& pdpnPlayerInfo
->dwDataSize
)
195 if(pdpnPlayerInfo
->dwDataSize
&& pdpnPlayerInfo
->pvData
)
197 This
->data
= heap_alloc(pdpnPlayerInfo
->dwDataSize
);
199 return E_OUTOFMEMORY
;
201 This
->datasize
= pdpnPlayerInfo
->dwDataSize
;
203 memcpy(This
->data
, pdpnPlayerInfo
->pvData
, pdpnPlayerInfo
->dwDataSize
);
207 /* TODO: Send DPN_MSGID_SERVER_INFO message to all players. */
211 static HRESULT WINAPI
IDirectPlay8ServerImpl_GetClientInfo(IDirectPlay8Server
*iface
, DPNID dpnid
, DPN_PLAYER_INFO
*pdpnPlayerInfo
,
212 DWORD
*pdwSize
, DWORD dwFlags
)
214 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
215 FIXME("(%p)->(%d %p %p %d)\n", This
, dpnid
, pdpnPlayerInfo
, pdwSize
, dwFlags
);
219 static HRESULT WINAPI
IDirectPlay8ServerImpl_GetClientAddress(IDirectPlay8Server
*iface
, DPNID dpnid
, IDirectPlay8Address
**pAddress
,
222 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
223 FIXME("(%p)->(%d %p %d)\n", This
, dpnid
, pAddress
, dwFlags
);
227 static HRESULT WINAPI
IDirectPlay8ServerImpl_GetLocalHostAddresses(IDirectPlay8Server
*iface
, IDirectPlay8Address
**prgpAddress
,
228 DWORD
*pcAddress
, DWORD dwFlags
)
230 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
231 FIXME("(%p)->(%p %p %d)\n", This
, prgpAddress
, pcAddress
, dwFlags
);
235 static HRESULT WINAPI
IDirectPlay8ServerImpl_SetApplicationDesc(IDirectPlay8Server
*iface
, const DPN_APPLICATION_DESC
*pad
, DWORD dwFlags
)
237 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
238 FIXME("(%p)->(%p %d)\n", This
, pad
, dwFlags
);
242 static HRESULT WINAPI
IDirectPlay8ServerImpl_Host(IDirectPlay8Server
*iface
, const DPN_APPLICATION_DESC
*pdnAppDesc
,
243 IDirectPlay8Address
**prgpDeviceInfo
, DWORD cDeviceInfo
, const DPN_SECURITY_DESC
*pdnSecurity
,
244 const DPN_SECURITY_CREDENTIALS
*pdnCredentials
, void *pvPlayerContext
, DWORD dwFlags
)
246 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
247 FIXME("(%p)->(%p %p %d %p %p %p %d)\n", This
, pdnAppDesc
, prgpDeviceInfo
, cDeviceInfo
, pdnSecurity
, pdnCredentials
,
248 pvPlayerContext
, dwFlags
);
252 static HRESULT WINAPI
IDirectPlay8ServerImpl_SendTo(IDirectPlay8Server
*iface
, DPNID dpnid
, const DPN_BUFFER_DESC
*prgBufferDesc
,
253 DWORD cBufferDesc
, DWORD dwTimeOut
, void *pvAsyncContext
, DPNHANDLE
*phAsyncHandle
, DWORD dwFlags
)
255 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
256 FIXME("(%p)->(%d %p %d %d %p %p %d)\n", This
, dpnid
, prgBufferDesc
, cBufferDesc
, dwTimeOut
, pvAsyncContext
, phAsyncHandle
,
261 static HRESULT WINAPI
IDirectPlay8ServerImpl_CreateGroup(IDirectPlay8Server
*iface
, const DPN_GROUP_INFO
*pdpnGroupInfo
,
262 void *pvGroupContext
, void *pvAsyncContext
, DPNHANDLE
*phAsyncHandle
, DWORD dwFlags
)
264 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
265 FIXME("(%p)->(%p %p %p %p %d)\n", This
, pdpnGroupInfo
, pvGroupContext
, pvAsyncContext
, phAsyncHandle
, dwFlags
);
269 static HRESULT WINAPI
IDirectPlay8ServerImpl_DestroyGroup(IDirectPlay8Server
*iface
, DPNID idGroup
, PVOID pvAsyncContext
,
270 DPNHANDLE
*phAsyncHandle
, DWORD dwFlags
)
272 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
273 FIXME("(%p)->(%d %p %p %d)\n", This
, idGroup
, pvAsyncContext
, phAsyncHandle
, dwFlags
);
277 static HRESULT WINAPI
IDirectPlay8ServerImpl_AddPlayerToGroup(IDirectPlay8Server
*iface
, DPNID idGroup
, DPNID idClient
,
278 PVOID pvAsyncContext
, DPNHANDLE
*phAsyncHandle
, DWORD dwFlags
)
280 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
281 FIXME("(%p)->(%d %d %p %p %d)\n", This
, idGroup
, idClient
, pvAsyncContext
, phAsyncHandle
, dwFlags
);
285 static HRESULT WINAPI
IDirectPlay8ServerImpl_RemovePlayerFromGroup(IDirectPlay8Server
*iface
, DPNID idGroup
, DPNID idClient
,
286 PVOID pvAsyncContext
, DPNHANDLE
*phAsyncHandle
, DWORD dwFlags
)
288 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
289 FIXME("(%p)->(%d %d %p %p %d)\n", This
, idGroup
, idClient
, pvAsyncContext
, phAsyncHandle
, dwFlags
);
293 static HRESULT WINAPI
IDirectPlay8ServerImpl_SetGroupInfo(IDirectPlay8Server
*iface
, DPNID dpnid
, DPN_GROUP_INFO
*pdpnGroupInfo
,
294 PVOID pvAsyncContext
, DPNHANDLE
*phAsyncHandle
, DWORD dwFlags
)
296 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
297 FIXME("(%p)->(%d %p %p %p %d)\n", This
, dpnid
, pdpnGroupInfo
, pvAsyncContext
, phAsyncHandle
, dwFlags
);
301 static HRESULT WINAPI
IDirectPlay8ServerImpl_GetGroupInfo(IDirectPlay8Server
*iface
, DPNID dpnid
, DPN_GROUP_INFO
*pdpnGroupInfo
,
302 DWORD
*pdwSize
, DWORD dwFlags
)
304 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
305 FIXME("(%p)->(%d %p %p %d)\n", This
, dpnid
, pdpnGroupInfo
, pdwSize
, dwFlags
);
309 static HRESULT WINAPI
IDirectPlay8ServerImpl_EnumPlayersAndGroups(IDirectPlay8Server
*iface
, DPNID
*prgdpnid
, DWORD
*pcdpnid
, DWORD dwFlags
)
311 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
312 FIXME("(%p)->(%p %p %d)\n", This
, prgdpnid
, pcdpnid
, dwFlags
);
316 static HRESULT WINAPI
IDirectPlay8ServerImpl_EnumGroupMembers(IDirectPlay8Server
*iface
, DPNID dpnid
, DPNID
*prgdpnid
, DWORD
*pcdpnid
, DWORD dwFlags
)
318 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
319 FIXME("(%p)->(%d %p %p %d)\n", This
, dpnid
, prgdpnid
, pcdpnid
, dwFlags
);
323 static HRESULT WINAPI
IDirectPlay8ServerImpl_Close(IDirectPlay8Server
*iface
, DWORD dwFlags
)
325 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
326 FIXME("(%p)->(%d)\n", This
, dwFlags
);
330 static HRESULT WINAPI
IDirectPlay8ServerImpl_DestroyClient(IDirectPlay8Server
*iface
, DPNID dpnidClient
, const void *pvDestroyData
,
331 DWORD dwDestroyDataSize
, DWORD dwFlags
)
333 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
334 FIXME("(%p)->(%d %p %d %d)\n", This
, dpnidClient
, pvDestroyData
, dwDestroyDataSize
, dwFlags
);
338 static HRESULT WINAPI
IDirectPlay8ServerImpl_ReturnBuffer(IDirectPlay8Server
*iface
, DPNHANDLE hBufferHandle
, DWORD dwFlags
)
340 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
341 FIXME("(%p)->(%d %d)\n", This
, hBufferHandle
, dwFlags
);
345 static HRESULT WINAPI
IDirectPlay8ServerImpl_GetPlayerContext(IDirectPlay8Server
*iface
, DPNID dpnid
, PVOID
*ppvPlayerContext
, DWORD dwFlags
)
347 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
348 FIXME("(%p)->(%d %p %d)\n", This
, dpnid
, ppvPlayerContext
, dwFlags
);
352 static HRESULT WINAPI
IDirectPlay8ServerImpl_GetGroupContext(IDirectPlay8Server
*iface
, DPNID dpnid
, PVOID
*ppvGroupContext
, DWORD dwFlags
)
354 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
355 FIXME("(%p)->(%d %p %d)\n", This
, dpnid
, ppvGroupContext
, dwFlags
);
359 static HRESULT WINAPI
IDirectPlay8ServerImpl_GetCaps(IDirectPlay8Server
*iface
, DPN_CAPS
*pdpCaps
, DWORD dwFlags
)
361 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
362 FIXME("(%p)->(%p %d)\n", This
, pdpCaps
, dwFlags
);
366 static HRESULT WINAPI
IDirectPlay8ServerImpl_SetCaps(IDirectPlay8Server
*iface
, const DPN_CAPS
*pdpCaps
, DWORD dwFlags
)
368 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
369 FIXME("(%p)->(%p %d)\n", This
, pdpCaps
, dwFlags
);
373 static HRESULT WINAPI
IDirectPlay8ServerImpl_SetSPCaps(IDirectPlay8Server
*iface
, const GUID
*pguidSP
, const DPN_SP_CAPS
*pdpspCaps
, DWORD dwFlags
)
375 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
376 FIXME("(%p)->(%p %p %d)\n", This
, pguidSP
, pdpspCaps
, dwFlags
);
380 static HRESULT WINAPI
IDirectPlay8ServerImpl_GetSPCaps(IDirectPlay8Server
*iface
, const GUID
*pguidSP
, DPN_SP_CAPS
*pdpspCaps
, DWORD dwFlags
)
382 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
383 FIXME("(%p)->(%p %p %d)\n", This
, pguidSP
, pdpspCaps
, dwFlags
);
387 static HRESULT WINAPI
IDirectPlay8ServerImpl_GetConnectionInfo(IDirectPlay8Server
*iface
, DPNID dpnid
,
388 DPN_CONNECTION_INFO
*pdpConnectionInfo
, DWORD dwFlags
)
390 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
391 FIXME("(%p)->(%d %p %d)\n", This
, dpnid
, pdpConnectionInfo
, dwFlags
);
395 static HRESULT WINAPI
IDirectPlay8ServerImpl_RegisterLobby(IDirectPlay8Server
*iface
, DPNHANDLE dpnHandle
,
396 struct IDirectPlay8LobbiedApplication
*pIDP8LobbiedApplication
, DWORD dwFlags
)
398 IDirectPlay8ServerImpl
*This
= impl_from_IDirectPlay8Server(iface
);
399 FIXME("(%p)->(%d %p %d)\n", This
, dpnHandle
, pIDP8LobbiedApplication
, dwFlags
);
403 static const IDirectPlay8ServerVtbl DirectPlay8ServerVtbl
=
405 IDirectPlay8ServerImpl_QueryInterface
,
406 IDirectPlay8ServerImpl_AddRef
,
407 IDirectPlay8ServerImpl_Release
,
408 IDirectPlay8ServerImpl_Initialize
,
409 IDirectPlay8ServerImpl_EnumServiceProviders
,
410 IDirectPlay8ServerImpl_CancelAsyncOperation
,
411 IDirectPlay8ServerImpl_GetSendQueueInfo
,
412 IDirectPlay8ServerImpl_GetApplicationDesc
,
413 IDirectPlay8ServerImpl_SetServerInfo
,
414 IDirectPlay8ServerImpl_GetClientInfo
,
415 IDirectPlay8ServerImpl_GetClientAddress
,
416 IDirectPlay8ServerImpl_GetLocalHostAddresses
,
417 IDirectPlay8ServerImpl_SetApplicationDesc
,
418 IDirectPlay8ServerImpl_Host
,
419 IDirectPlay8ServerImpl_SendTo
,
420 IDirectPlay8ServerImpl_CreateGroup
,
421 IDirectPlay8ServerImpl_DestroyGroup
,
422 IDirectPlay8ServerImpl_AddPlayerToGroup
,
423 IDirectPlay8ServerImpl_RemovePlayerFromGroup
,
424 IDirectPlay8ServerImpl_SetGroupInfo
,
425 IDirectPlay8ServerImpl_GetGroupInfo
,
426 IDirectPlay8ServerImpl_EnumPlayersAndGroups
,
427 IDirectPlay8ServerImpl_EnumGroupMembers
,
428 IDirectPlay8ServerImpl_Close
,
429 IDirectPlay8ServerImpl_DestroyClient
,
430 IDirectPlay8ServerImpl_ReturnBuffer
,
431 IDirectPlay8ServerImpl_GetPlayerContext
,
432 IDirectPlay8ServerImpl_GetGroupContext
,
433 IDirectPlay8ServerImpl_GetCaps
,
434 IDirectPlay8ServerImpl_SetCaps
,
435 IDirectPlay8ServerImpl_SetSPCaps
,
436 IDirectPlay8ServerImpl_GetSPCaps
,
437 IDirectPlay8ServerImpl_GetConnectionInfo
,
438 IDirectPlay8ServerImpl_RegisterLobby
441 HRESULT
DPNET_CreateDirectPlay8Server(IClassFactory
*iface
, IUnknown
*pUnkOuter
, REFIID riid
, void **ppv
)
443 IDirectPlay8ServerImpl
*server
;
446 TRACE("(%p, %s, %p)\n", pUnkOuter
, debugstr_guid(riid
), ppv
);
451 return CLASS_E_NOAGGREGATION
;
453 server
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectPlay8ServerImpl
));
455 return E_OUTOFMEMORY
;
457 server
->IDirectPlay8Server_iface
.lpVtbl
= &DirectPlay8ServerVtbl
;
459 server
->usercontext
= NULL
;
460 server
->msghandler
= NULL
;
463 hr
= IDirectPlay8Server_QueryInterface(&server
->IDirectPlay8Server_iface
, riid
, ppv
);
464 IDirectPlay8Server_Release(&server
->IDirectPlay8Server_iface
);