4 * Copyright 2004 Raphael Junqueira
5 * Copyright 2008 Alexander N. Sørnes <alex@thehandofagony.com>
6 * Copyright 2011 Louis Lenders
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
34 #include "wine/debug.h"
37 #include "dpnet_private.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(dpnet);
41 static inline IDirectPlay8PeerImpl *impl_from_IDirectPlay8Peer(IDirectPlay8Peer *iface)
43 return CONTAINING_RECORD(iface, IDirectPlay8PeerImpl, IDirectPlay8Peer_iface);
46 /* IUnknown interface follows */
47 static HRESULT WINAPI IDirectPlay8PeerImpl_QueryInterface(IDirectPlay8Peer *iface, REFIID riid,
50 IDirectPlay8PeerImpl* This = impl_from_IDirectPlay8Peer(iface);
52 if(IsEqualGUID(riid, &IID_IUnknown) ||
53 IsEqualGUID(riid, &IID_IDirectPlay8Peer))
55 IUnknown_AddRef(iface);
60 WARN("(%p)->(%s,%p): not found\n", This, debugstr_guid(riid), ppobj);
64 static ULONG WINAPI IDirectPlay8PeerImpl_AddRef(IDirectPlay8Peer *iface)
66 IDirectPlay8PeerImpl* This = impl_from_IDirectPlay8Peer(iface);
67 ULONG RefCount = InterlockedIncrement(&This->ref);
72 static ULONG WINAPI IDirectPlay8PeerImpl_Release(IDirectPlay8Peer *iface)
74 IDirectPlay8PeerImpl* This = impl_from_IDirectPlay8Peer(iface);
75 ULONG RefCount = InterlockedDecrement(&This->ref);
78 HeapFree(GetProcessHeap(), 0, This);
83 /* IDirectPlay8Peer interface follows */
85 static HRESULT WINAPI IDirectPlay8PeerImpl_Initialize(IDirectPlay8Peer *iface,
86 void * const pvUserContext, const PFNDPNMESSAGEHANDLER pfn, const DWORD dwFlags)
88 TRACE("(%p)->(%p,%p,%x): stub\n", iface, pvUserContext, pfn, dwFlags);
93 static HRESULT WINAPI IDirectPlay8PeerImpl_EnumServiceProviders(IDirectPlay8Peer *iface,
94 const GUID * const pguidServiceProvider, const GUID * const pguidApplication,
95 DPN_SERVICE_PROVIDER_INFO * const pSPInfoBuffer, DWORD * const pcbEnumData,
96 DWORD * const pcReturned, const DWORD dwFlags)
98 static const WCHAR dp_providerW[] = {'D','i','r','e','c','t','P','l','a','y','8',' ','T','C','P','/','I','P',' ',
99 'S','e','r','v','i','c','e',' ','P','r','o','v','i','d','e','r','\0'};
100 static const WCHAR dp_adapterW[] = {'L','o','c','a','l',' ','A','r','e','a',' ','C','o','n','n','e','c','t','i','o','n',
101 ' ','-',' ','I','P','v','4','\0'};
103 static const GUID adapter_guid = {0x4ce725f6, 0xd3c0, 0xdade, {0xba, 0x6f, 0x11, 0xf9, 0x65, 0xbc, 0x42, 0x99}};
106 TRACE("(%p)->(%p,%p,%p,%p,%p,%x): stub\n", iface, pguidServiceProvider, pguidApplication, pSPInfoBuffer,
107 pcbEnumData, pcReturned, dwFlags);
109 if(!pguidServiceProvider)
111 req_size = sizeof(DPN_SERVICE_PROVIDER_INFO) + sizeof(dp_providerW);
113 else if(IsEqualGUID(pguidServiceProvider, &CLSID_DP8SP_TCPIP))
115 req_size = sizeof(DPN_SERVICE_PROVIDER_INFO) + sizeof(dp_adapterW);
119 FIXME("Application requested a provider we don't handle (yet)\n");
121 return DPNERR_DOESNOTEXIST;
124 if(*pcbEnumData < req_size)
126 *pcbEnumData = req_size;
127 return DPNERR_BUFFERTOOSMALL;
130 pSPInfoBuffer->pwszName = (LPWSTR)(pSPInfoBuffer + 1);
132 if(!pguidServiceProvider)
134 lstrcpyW(pSPInfoBuffer->pwszName, dp_providerW);
135 pSPInfoBuffer->guid = CLSID_DP8SP_TCPIP;
139 lstrcpyW(pSPInfoBuffer->pwszName, dp_adapterW);
140 pSPInfoBuffer->guid = adapter_guid;
147 static HRESULT WINAPI IDirectPlay8PeerImpl_CancelAsyncOperation(IDirectPlay8Peer *iface,
148 const DPNHANDLE hAsyncHandle, const DWORD dwFlags)
150 FIXME("(%p)->(%x,%x): stub\n", iface, hAsyncHandle, dwFlags);
152 return DPNERR_GENERIC;
155 static HRESULT WINAPI IDirectPlay8PeerImpl_Connect(IDirectPlay8Peer *iface,
156 const DPN_APPLICATION_DESC * const pdnAppDesc, IDirectPlay8Address * const pHostAddr,
157 IDirectPlay8Address * const pDeviceInfo, const DPN_SECURITY_DESC * const pdnSecurity,
158 const DPN_SECURITY_CREDENTIALS * const pdnCredentials, const void * const pvUserConnectData,
159 const DWORD dwUserConnectDataSize, void * const pvPlayerContext,
160 void * const pvAsyncContext, DPNHANDLE * const phAsyncHandle, const DWORD dwFlags)
162 FIXME("(%p)->(%p,%p,%p,%p,%p,%p,%x,%p,%p,%p,%x): stub\n", iface, pdnAppDesc, pHostAddr, pDeviceInfo, pdnSecurity, pdnCredentials, pvUserConnectData, dwUserConnectDataSize, pvPlayerContext, pvAsyncContext, phAsyncHandle, dwFlags);
164 return DPNERR_GENERIC;
167 static HRESULT WINAPI IDirectPlay8PeerImpl_SendTo(IDirectPlay8Peer *iface, const DPNID dpnId,
168 const DPN_BUFFER_DESC *pBufferDesc, const DWORD cBufferDesc, const DWORD dwTimeOut,
169 void * const pvAsyncContext, DPNHANDLE * const phAsyncHandle, const DWORD dwFlags)
171 FIXME("(%p)->(%x,%p,%x,%x,%p,%p,%x): stub\n", iface, dpnId, pBufferDesc, cBufferDesc, dwTimeOut, pvAsyncContext, phAsyncHandle, dwFlags);
173 return DPNERR_GENERIC;
176 static HRESULT WINAPI IDirectPlay8PeerImpl_GetSendQueueInfo(IDirectPlay8Peer *iface,
177 const DPNID dpnid, DWORD * const pdwNumMsgs, DWORD * const pdwNumBytes, const DWORD dwFlags)
179 FIXME("(%p)->(%x,%p,%p,%x): stub\n", iface, dpnid, pdwNumMsgs, pdwNumBytes, dwFlags);
181 return DPNERR_GENERIC;
184 static HRESULT WINAPI IDirectPlay8PeerImpl_Host(IDirectPlay8Peer *iface,
185 const DPN_APPLICATION_DESC * const pdnAppDesc, IDirectPlay8Address ** const prgpDeviceInfo,
186 const DWORD cDeviceInfo, const DPN_SECURITY_DESC * const pdpSecurity,
187 const DPN_SECURITY_CREDENTIALS * const pdpCredentials, void * const pvPlayerContext,
190 FIXME("(%p)->(%p,%p,%x,%p,%p,%p,%x): stub\n", iface, pdnAppDesc, prgpDeviceInfo, cDeviceInfo, pdpSecurity, pdpCredentials, pvPlayerContext, dwFlags);
192 return DPNERR_GENERIC;
195 static HRESULT WINAPI IDirectPlay8PeerImpl_GetApplicationDesc(IDirectPlay8Peer *iface,
196 DPN_APPLICATION_DESC * const pAppDescBuffer, DWORD * const pcbDataSize, const DWORD dwFlags)
198 FIXME("(%p)->(%p,%p,%x): stub\n", iface, pAppDescBuffer, pcbDataSize, dwFlags);
200 return DPNERR_GENERIC;
203 static HRESULT WINAPI IDirectPlay8PeerImpl_SetApplicationDesc(IDirectPlay8Peer *iface,
204 const DPN_APPLICATION_DESC * const pad, const DWORD dwFlags)
206 FIXME("(%p)->(%p,%x): stub\n", iface, pad, dwFlags);
208 return DPNERR_GENERIC;
211 static HRESULT WINAPI IDirectPlay8PeerImpl_CreateGroup(IDirectPlay8Peer *iface,
212 const DPN_GROUP_INFO * const pdpnGroupInfo, void * const pvGroupContext,
213 void * const pvAsyncContext, DPNHANDLE * const phAsyncHandle, const DWORD dwFlags)
215 FIXME("(%p)->(%p,%p,%p,%p,%x): stub\n", iface, pdpnGroupInfo, pvGroupContext, pvAsyncContext, phAsyncHandle, dwFlags);
217 return DPNERR_GENERIC;
220 static HRESULT WINAPI IDirectPlay8PeerImpl_DestroyGroup(IDirectPlay8Peer *iface,
221 const DPNID idGroup, void * const pvAsyncContext, DPNHANDLE * const phAsyncHandle,
224 FIXME("(%p)->(%x,%p,%p,%x): stub\n", iface, idGroup, pvAsyncContext, phAsyncHandle, dwFlags);
226 return DPNERR_GENERIC;
229 static HRESULT WINAPI IDirectPlay8PeerImpl_AddPlayerToGroup(IDirectPlay8Peer *iface,
230 const DPNID idGroup, const DPNID idClient, void * const pvAsyncContext,
231 DPNHANDLE * const phAsyncHandle, const DWORD dwFlags)
233 FIXME("(%p)->(%x,%x,%p,%p,%x): stub\n", iface, idGroup, idClient, pvAsyncContext, phAsyncHandle, dwFlags);
235 return DPNERR_GENERIC;
238 static HRESULT WINAPI IDirectPlay8PeerImpl_RemovePlayerFromGroup(IDirectPlay8Peer *iface,
239 const DPNID idGroup, const DPNID idClient, void * const pvAsyncContext,
240 DPNHANDLE * const phAsyncHandle, const DWORD dwFlags)
242 FIXME("(%p)->(%x,%x,%p,%p,%x): stub\n", iface, idGroup, idClient, pvAsyncContext, phAsyncHandle, dwFlags);
244 return DPNERR_GENERIC;
247 static HRESULT WINAPI IDirectPlay8PeerImpl_SetGroupInfo(IDirectPlay8Peer *iface, const DPNID dpnid,
248 DPN_GROUP_INFO * const pdpnGroupInfo, void * const pvAsyncContext,
249 DPNHANDLE * const phAsyncHandle, const DWORD dwFlags)
251 FIXME("(%p)->(%x,%p,%p,%p,%x): stub\n", iface, dpnid, pdpnGroupInfo, pvAsyncContext, phAsyncHandle, dwFlags);
253 return DPNERR_GENERIC;
256 static HRESULT WINAPI IDirectPlay8PeerImpl_GetGroupInfo(IDirectPlay8Peer *iface, const DPNID dpnid,
257 DPN_GROUP_INFO * const pdpnGroupInfo, DWORD * const pdwSize, const DWORD dwFlags)
259 FIXME("(%p)->(%x,%p,%p,%x): stub\n", iface, dpnid, pdpnGroupInfo, pdwSize, dwFlags);
261 return DPNERR_GENERIC;
264 static HRESULT WINAPI IDirectPlay8PeerImpl_EnumPlayersAndGroups(IDirectPlay8Peer *iface,
265 DPNID * const prgdpnid, DWORD * const pcdpnid, const DWORD dwFlags)
267 FIXME("(%p)->(%p,%p,%x): stub\n", iface, prgdpnid, pcdpnid, dwFlags);
269 return DPNERR_GENERIC;
272 static HRESULT WINAPI IDirectPlay8PeerImpl_EnumGroupMembers(IDirectPlay8Peer *iface,
273 const DPNID dpnid, DPNID * const prgdpnid, DWORD * const pcdpnid, const DWORD dwFlags)
275 FIXME("(%p)->(%x,%p,%p,%x): stub\n", iface, dpnid, prgdpnid, pcdpnid, dwFlags);
277 return DPNERR_GENERIC;
280 static HRESULT WINAPI IDirectPlay8PeerImpl_SetPeerInfo(IDirectPlay8Peer *iface,
281 const DPN_PLAYER_INFO * const pdpnPlayerInfo, void * const pvAsyncContext,
282 DPNHANDLE * const phAsyncHandle, const DWORD dwFlags)
284 FIXME("(%p)->(%p,%p,%p,%x): stub\n", iface, pdpnPlayerInfo, pvAsyncContext, phAsyncHandle, dwFlags);
286 return DPNERR_GENERIC;
289 static HRESULT WINAPI IDirectPlay8PeerImpl_GetPeerInfo(IDirectPlay8Peer *iface, const DPNID dpnid,
290 DPN_PLAYER_INFO * const pdpnPlayerInfo, DWORD * const pdwSize, const DWORD dwFlags)
292 FIXME("(%p)->(%x,%p,%p,%x): stub\n", iface, dpnid, pdpnPlayerInfo, pdwSize, dwFlags);
294 return DPNERR_GENERIC;
297 static HRESULT WINAPI IDirectPlay8PeerImpl_GetPeerAddress(IDirectPlay8Peer *iface,
298 const DPNID dpnid, IDirectPlay8Address ** const pAddress, const DWORD dwFlags)
300 FIXME("(%p)->(%x,%p,%x): stub\n", iface, dpnid, pAddress, dwFlags);
302 return DPNERR_GENERIC;
305 static HRESULT WINAPI IDirectPlay8PeerImpl_GetLocalHostAddresses(IDirectPlay8Peer *iface,
306 IDirectPlay8Address ** const prgpAddress, DWORD * const pcAddress, const DWORD dwFlags)
308 FIXME("(%p)->(%p,%p,%x): stub\n", iface, prgpAddress, pcAddress, dwFlags);
310 return DPNERR_GENERIC;
313 static HRESULT WINAPI IDirectPlay8PeerImpl_Close(IDirectPlay8Peer *iface, const DWORD dwFlags)
315 FIXME("(%p)->(%x): stub\n", iface, dwFlags);
320 static HRESULT WINAPI IDirectPlay8PeerImpl_EnumHosts(IDirectPlay8Peer *iface,
321 PDPN_APPLICATION_DESC const pApplicationDesc, IDirectPlay8Address * const pAddrHost,
322 IDirectPlay8Address * const pDeviceInfo, void * const pUserEnumData,
323 const DWORD dwUserEnumDataSize, const DWORD dwEnumCount, const DWORD dwRetryInterval,
324 const DWORD dwTimeOut, void * const pvUserContext, DPNHANDLE * const pAsyncHandle, const DWORD dwFlags)
326 FIXME("(%p)->(%p,%p,%p,%p,%x,%x,%x,%x,%p,%p,%x): stub\n",
327 iface, pApplicationDesc, pAddrHost, pDeviceInfo, pUserEnumData, dwUserEnumDataSize, dwEnumCount,
328 dwRetryInterval, dwTimeOut, pvUserContext, pAsyncHandle, dwFlags);
330 return DPNERR_GENERIC;
333 static HRESULT WINAPI IDirectPlay8PeerImpl_DestroyPeer(IDirectPlay8Peer *iface, const DPNID dpnidClient,
334 const void * const pvDestroyData, const DWORD dwDestroyDataSize, const DWORD dwFlags)
336 FIXME("(%p)->(%x,%p,%x,%x): stub\n", iface, dpnidClient, pvDestroyData, dwDestroyDataSize, dwFlags);
338 return DPNERR_GENERIC;
341 static HRESULT WINAPI IDirectPlay8PeerImpl_ReturnBuffer(IDirectPlay8Peer *iface, const DPNHANDLE hBufferHandle,
344 FIXME("(%p)->(%x,%x): stub\n", iface, hBufferHandle, dwFlags);
346 return DPNERR_GENERIC;
349 static HRESULT WINAPI IDirectPlay8PeerImpl_GetPlayerContext(IDirectPlay8Peer *iface, const DPNID dpnid,
350 void ** const ppvPlayerContext, const DWORD dwFlags)
352 FIXME("(%p)->(%x,%p,%x): stub\n", iface, dpnid, ppvPlayerContext, dwFlags);
354 return DPNERR_GENERIC;
357 static HRESULT WINAPI IDirectPlay8PeerImpl_GetGroupContext(IDirectPlay8Peer *iface, const DPNID dpnid,
358 void ** const ppvGroupContext, const DWORD dwFlags)
360 FIXME("(%p)->(%x,%p,%x): stub\n", iface, dpnid, ppvGroupContext, dwFlags);
362 return DPNERR_GENERIC;
365 static HRESULT WINAPI IDirectPlay8PeerImpl_GetCaps(IDirectPlay8Peer *iface, DPN_CAPS * const pdpCaps,
368 FIXME("(%p)->(%p,%x): stub\n", iface, pdpCaps, dwFlags);
370 return DPNERR_GENERIC;
373 static HRESULT WINAPI IDirectPlay8PeerImpl_SetCaps(IDirectPlay8Peer *iface, const DPN_CAPS * const pdpCaps,
376 FIXME("(%p)->(%p,%x): stub\n", iface, pdpCaps, dwFlags);
378 return DPNERR_GENERIC;
381 static HRESULT WINAPI IDirectPlay8PeerImpl_SetSPCaps(IDirectPlay8Peer *iface, const GUID * const pguidSP,
382 const DPN_SP_CAPS * const pdpspCaps, const DWORD dwFlags )
384 FIXME("(%p)->(%p,%p,%x): stub\n", iface, pguidSP, pdpspCaps, dwFlags);
386 return DPNERR_GENERIC;
389 static HRESULT WINAPI IDirectPlay8PeerImpl_GetSPCaps(IDirectPlay8Peer *iface, const GUID * const pguidSP,
390 DPN_SP_CAPS * const pdpspCaps, const DWORD dwFlags)
392 TRACE("(%p)->(%p,%p,%x)\n", iface, pguidSP, pdpspCaps, dwFlags);
394 if(pdpspCaps->dwSize != sizeof(DPN_SP_CAPS))
396 return DPNERR_INVALIDPARAM;
399 pdpspCaps->dwFlags = DPNSPCAPS_SUPPORTSDPNSRV | DPNSPCAPS_SUPPORTSBROADCAST |
400 DPNSPCAPS_SUPPORTSALLADAPTERS | DPNSPCAPS_SUPPORTSTHREADPOOL;
401 pdpspCaps->dwNumThreads = 3;
402 pdpspCaps->dwDefaultEnumCount = 5;
403 pdpspCaps->dwDefaultEnumRetryInterval = 1500;
404 pdpspCaps->dwDefaultEnumTimeout = 1500;
405 pdpspCaps->dwMaxEnumPayloadSize = 983;
406 pdpspCaps->dwBuffersPerThread = 1;
407 pdpspCaps->dwSystemBufferSize = 8192;
412 static HRESULT WINAPI IDirectPlay8PeerImpl_GetConnectionInfo(IDirectPlay8Peer *iface, const DPNID dpnid,
413 DPN_CONNECTION_INFO * const pdpConnectionInfo, const DWORD dwFlags)
415 FIXME("(%p)->(%x,%p,%x): stub\n", iface, dpnid, pdpConnectionInfo, dwFlags);
417 return DPNERR_GENERIC;
420 static HRESULT WINAPI IDirectPlay8PeerImpl_RegisterLobby(IDirectPlay8Peer *iface, const DPNHANDLE dpnHandle,
421 struct IDirectPlay8LobbiedApplication * const pIDP8LobbiedApplication, const DWORD dwFlags)
423 FIXME("(%p)->(%x,%p,%x): stub\n", iface, dpnHandle, pIDP8LobbiedApplication, dwFlags);
425 return DPNERR_GENERIC;
428 static HRESULT WINAPI IDirectPlay8PeerImpl_TerminateSession(IDirectPlay8Peer *iface, void * const pvTerminateData,
429 const DWORD dwTerminateDataSize, const DWORD dwFlags)
431 FIXME("(%p)->(%p,%x,%x): stub\n", iface, pvTerminateData, dwTerminateDataSize, dwFlags);
433 return DPNERR_GENERIC;
436 static const IDirectPlay8PeerVtbl DirectPlay8Peer_Vtbl =
438 IDirectPlay8PeerImpl_QueryInterface,
439 IDirectPlay8PeerImpl_AddRef,
440 IDirectPlay8PeerImpl_Release,
441 IDirectPlay8PeerImpl_Initialize,
442 IDirectPlay8PeerImpl_EnumServiceProviders,
443 IDirectPlay8PeerImpl_CancelAsyncOperation,
444 IDirectPlay8PeerImpl_Connect,
445 IDirectPlay8PeerImpl_SendTo,
446 IDirectPlay8PeerImpl_GetSendQueueInfo,
447 IDirectPlay8PeerImpl_Host,
448 IDirectPlay8PeerImpl_GetApplicationDesc,
449 IDirectPlay8PeerImpl_SetApplicationDesc,
450 IDirectPlay8PeerImpl_CreateGroup,
451 IDirectPlay8PeerImpl_DestroyGroup,
452 IDirectPlay8PeerImpl_AddPlayerToGroup,
453 IDirectPlay8PeerImpl_RemovePlayerFromGroup,
454 IDirectPlay8PeerImpl_SetGroupInfo,
455 IDirectPlay8PeerImpl_GetGroupInfo,
456 IDirectPlay8PeerImpl_EnumPlayersAndGroups,
457 IDirectPlay8PeerImpl_EnumGroupMembers,
458 IDirectPlay8PeerImpl_SetPeerInfo,
459 IDirectPlay8PeerImpl_GetPeerInfo,
460 IDirectPlay8PeerImpl_GetPeerAddress,
461 IDirectPlay8PeerImpl_GetLocalHostAddresses,
462 IDirectPlay8PeerImpl_Close,
463 IDirectPlay8PeerImpl_EnumHosts,
464 IDirectPlay8PeerImpl_DestroyPeer,
465 IDirectPlay8PeerImpl_ReturnBuffer,
466 IDirectPlay8PeerImpl_GetPlayerContext,
467 IDirectPlay8PeerImpl_GetGroupContext,
468 IDirectPlay8PeerImpl_GetCaps,
469 IDirectPlay8PeerImpl_SetCaps,
470 IDirectPlay8PeerImpl_SetSPCaps,
471 IDirectPlay8PeerImpl_GetSPCaps,
472 IDirectPlay8PeerImpl_GetConnectionInfo,
473 IDirectPlay8PeerImpl_RegisterLobby,
474 IDirectPlay8PeerImpl_TerminateSession
477 HRESULT DPNET_CreateDirectPlay8Peer(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj) {
478 IDirectPlay8PeerImpl* Client;
481 Client = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8PeerImpl));
486 WARN("Not enough memory\n");
487 return E_OUTOFMEMORY;
490 Client->IDirectPlay8Peer_iface.lpVtbl = &DirectPlay8Peer_Vtbl;
491 ret = IDirectPlay8PeerImpl_QueryInterface(&Client->IDirectPlay8Peer_iface, riid, ppobj);
493 HeapFree(GetProcessHeap(), 0, Client);