dwmapi: Clear DWM_TIMING_INFO structure before returning.
[wine.git] / dlls / dpnet / peer.c
blobbbcda6a72c240496c82f6ce39095ae16130655b9
1 /*
2 * DirectPlay8 Peer
3 *
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
25 #include <stdarg.h>
27 #define COBJMACROS
28 #include "windef.h"
29 #include "winbase.h"
30 #include "wingdi.h"
31 #include "winuser.h"
32 #include "objbase.h"
33 #include "wine/debug.h"
35 #include "dpnet_private.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(dpnet);
40 typedef struct IDirectPlay8PeerImpl
42 IDirectPlay8Peer IDirectPlay8Peer_iface;
43 LONG ref;
45 PFNDPNMESSAGEHANDLER msghandler;
46 DWORD flags;
47 void *usercontext;
49 WCHAR *username;
50 void *data;
51 DWORD datasize;
53 DPN_SP_CAPS spcaps;
54 } IDirectPlay8PeerImpl;
56 static inline IDirectPlay8PeerImpl *impl_from_IDirectPlay8Peer(IDirectPlay8Peer *iface)
58 return CONTAINING_RECORD(iface, IDirectPlay8PeerImpl, IDirectPlay8Peer_iface);
61 /* IUnknown interface follows */
62 static HRESULT WINAPI IDirectPlay8PeerImpl_QueryInterface(IDirectPlay8Peer *iface, REFIID riid,
63 void **ret_iface)
65 if(IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectPlay8Peer))
67 IDirectPlay8Peer_AddRef(iface);
68 *ret_iface = iface;
69 return S_OK;
72 WARN("(%p)->(%s,%p): not found\n", iface, debugstr_guid(riid), ret_iface);
73 return E_NOINTERFACE;
76 static ULONG WINAPI IDirectPlay8PeerImpl_AddRef(IDirectPlay8Peer *iface)
78 IDirectPlay8PeerImpl* This = impl_from_IDirectPlay8Peer(iface);
79 ULONG RefCount = InterlockedIncrement(&This->ref);
81 TRACE("(%p) ref=%ld\n", This, RefCount);
83 return RefCount;
86 static ULONG WINAPI IDirectPlay8PeerImpl_Release(IDirectPlay8Peer *iface)
88 IDirectPlay8PeerImpl* This = impl_from_IDirectPlay8Peer(iface);
89 ULONG RefCount = InterlockedDecrement(&This->ref);
91 TRACE("(%p) ref=%ld\n", This, RefCount);
93 if(!RefCount)
95 heap_free(This->username);
96 heap_free(This->data);
98 heap_free(This);
101 return RefCount;
104 /* IDirectPlay8Peer interface follows */
106 static HRESULT WINAPI IDirectPlay8PeerImpl_Initialize(IDirectPlay8Peer *iface,
107 void * const pvUserContext, const PFNDPNMESSAGEHANDLER pfn, const DWORD dwFlags)
109 IDirectPlay8PeerImpl* This = impl_from_IDirectPlay8Peer(iface);
111 TRACE("(%p)->(%p,%p,%lx): stub\n", iface, pvUserContext, pfn, dwFlags);
113 if(!pfn)
114 return DPNERR_INVALIDPARAM;
116 This->usercontext = pvUserContext;
117 This->msghandler = pfn;
118 This->flags = dwFlags;
120 init_winsock();
122 return DPN_OK;
125 HRESULT enum_services_providers(const GUID * const service, DPN_SERVICE_PROVIDER_INFO * const info_buffer,
126 DWORD * const buf_size, DWORD * const returned)
128 static const WCHAR serviceproviders[] = L"SOFTWARE\\Microsoft\\DirectPlay8\\Service Providers";
129 static const WCHAR friendly[] = L"Friendly Name";
130 static const WCHAR dp_adapterW[] = L"Local Area Connection - IPv4";
131 static const GUID adapter_guid = {0x4ce725f6, 0xd3c0, 0xdade, {0xba, 0x6f, 0x11, 0xf9, 0x65, 0xbc, 0x42, 0x99}};
132 DWORD req_size = 0;
133 LONG res;
134 HKEY key = NULL;
135 LONG next_key;
136 DWORD index = 0;
137 WCHAR provider[MAX_PATH];
138 DWORD size;
140 if(!returned || !buf_size)
141 return E_POINTER;
143 if(!service)
145 *returned = 0;
147 res = RegOpenKeyExW(HKEY_LOCAL_MACHINE, serviceproviders, 0, KEY_READ, &key);
148 if(res == ERROR_FILE_NOT_FOUND)
149 return DPNERR_DOESNOTEXIST;
151 next_key = RegEnumKeyW( key, index, provider, MAX_PATH);
152 while(next_key == ERROR_SUCCESS)
154 size = 0;
155 res = RegGetValueW(key, provider, friendly, RRF_RT_REG_SZ, NULL, NULL, &size);
156 if(res == ERROR_SUCCESS)
158 req_size += sizeof(DPN_SERVICE_PROVIDER_INFO) + size;
160 (*returned)++;
163 index++;
164 next_key = RegEnumKeyW( key, index, provider, MAX_PATH );
168 else if(IsEqualGUID(service, &CLSID_DP8SP_TCPIP))
170 req_size = sizeof(DPN_SERVICE_PROVIDER_INFO) + sizeof(dp_adapterW);
172 else
174 FIXME("Application requested a provider we don't handle (yet)\n");
175 return DPNERR_DOESNOTEXIST;
178 if(*buf_size < req_size)
180 RegCloseKey(key);
182 *buf_size = req_size;
183 return DPNERR_BUFFERTOOSMALL;
186 if(!service)
188 int offset = 0;
189 int count = 0;
190 char *infoend = ((char *)info_buffer + (sizeof(DPN_SERVICE_PROVIDER_INFO) * (*returned)));
192 index = 0;
193 next_key = RegEnumKeyW( key, index, provider, MAX_PATH);
194 while(next_key == ERROR_SUCCESS)
196 size = 0;
197 res = RegGetValueW(key, provider, friendly, RRF_RT_REG_SZ, NULL, NULL, &size);
198 if(res == ERROR_SUCCESS)
200 info_buffer[count].guid = CLSID_DP8SP_TCPIP;
201 info_buffer[count].pwszName = (LPWSTR)(infoend + offset);
203 RegGetValueW(key, provider, friendly, RRF_RT_REG_SZ, NULL, info_buffer[count].pwszName, &size);
205 offset += size;
206 count++;
209 index++;
210 next_key = RegEnumKeyW(key, index, provider, MAX_PATH);
213 else
215 info_buffer->pwszName = (LPWSTR)(info_buffer + 1);
216 lstrcpyW(info_buffer->pwszName, dp_adapterW);
217 info_buffer->guid = adapter_guid;
218 *returned = 1;
221 RegCloseKey(key);
223 return DPN_OK;
226 static HRESULT WINAPI IDirectPlay8PeerImpl_EnumServiceProviders(IDirectPlay8Peer *iface,
227 const GUID * const pguidServiceProvider, const GUID * const pguidApplication,
228 DPN_SERVICE_PROVIDER_INFO * const pSPInfoBuffer, DWORD * const pcbEnumData,
229 DWORD * const pcReturned, const DWORD dwFlags)
231 TRACE("(%p)->(%s,%s,%p,%p,%p,%lx)\n", iface, debugstr_guid(pguidServiceProvider), debugstr_guid(pguidApplication),
232 pSPInfoBuffer, pcbEnumData, pcReturned, dwFlags);
234 if(dwFlags)
235 FIXME("Unhandled flags %lx\n", dwFlags);
237 if(pguidApplication)
238 FIXME("Application guid %s is currently being ignored\n", debugstr_guid(pguidApplication));
240 return enum_services_providers(pguidServiceProvider, pSPInfoBuffer, pcbEnumData, pcReturned);
243 static HRESULT WINAPI IDirectPlay8PeerImpl_CancelAsyncOperation(IDirectPlay8Peer *iface,
244 const DPNHANDLE hAsyncHandle, const DWORD dwFlags)
246 FIXME("(%p)->(%lx,%lx): stub\n", iface, hAsyncHandle, dwFlags);
248 return DPNERR_GENERIC;
251 static HRESULT WINAPI IDirectPlay8PeerImpl_Connect(IDirectPlay8Peer *iface,
252 const DPN_APPLICATION_DESC * const pdnAppDesc, IDirectPlay8Address * const pHostAddr,
253 IDirectPlay8Address * const pDeviceInfo, const DPN_SECURITY_DESC * const pdnSecurity,
254 const DPN_SECURITY_CREDENTIALS * const pdnCredentials, const void * const pvUserConnectData,
255 const DWORD dwUserConnectDataSize, void * const pvPlayerContext,
256 void * const pvAsyncContext, DPNHANDLE * const phAsyncHandle, const DWORD dwFlags)
258 FIXME("(%p)->(%p,%p,%p,%p,%p,%p,%lx,%p,%p,%p,%lx): stub\n", iface, pdnAppDesc, pHostAddr, pDeviceInfo, pdnSecurity, pdnCredentials, pvUserConnectData, dwUserConnectDataSize, pvPlayerContext, pvAsyncContext, phAsyncHandle, dwFlags);
260 return DPNERR_GENERIC;
263 static HRESULT WINAPI IDirectPlay8PeerImpl_SendTo(IDirectPlay8Peer *iface, const DPNID dpnId,
264 const DPN_BUFFER_DESC *pBufferDesc, const DWORD cBufferDesc, const DWORD dwTimeOut,
265 void * const pvAsyncContext, DPNHANDLE * const phAsyncHandle, const DWORD dwFlags)
267 FIXME("(%p)->(%lx,%p,%lx,%lx,%p,%p,%lx): stub\n", iface, dpnId, pBufferDesc, cBufferDesc, dwTimeOut, pvAsyncContext, phAsyncHandle, dwFlags);
269 return DPNERR_GENERIC;
272 static HRESULT WINAPI IDirectPlay8PeerImpl_GetSendQueueInfo(IDirectPlay8Peer *iface,
273 const DPNID dpnid, DWORD * const pdwNumMsgs, DWORD * const pdwNumBytes, const DWORD dwFlags)
275 FIXME("(%p)->(%lx,%p,%p,%lx): stub\n", iface, dpnid, pdwNumMsgs, pdwNumBytes, dwFlags);
277 return DPNERR_GENERIC;
280 static HRESULT WINAPI IDirectPlay8PeerImpl_Host(IDirectPlay8Peer *iface,
281 const DPN_APPLICATION_DESC * const pdnAppDesc, IDirectPlay8Address ** const prgpDeviceInfo,
282 const DWORD cDeviceInfo, const DPN_SECURITY_DESC * const pdpSecurity,
283 const DPN_SECURITY_CREDENTIALS * const pdpCredentials, void * const pvPlayerContext,
284 const DWORD dwFlags)
286 FIXME("(%p)->(%p,%p,%lx,%p,%p,%p,%lx): stub\n", iface, pdnAppDesc, prgpDeviceInfo, cDeviceInfo, pdpSecurity, pdpCredentials, pvPlayerContext, dwFlags);
288 return DPNERR_GENERIC;
291 static HRESULT WINAPI IDirectPlay8PeerImpl_GetApplicationDesc(IDirectPlay8Peer *iface,
292 DPN_APPLICATION_DESC * const pAppDescBuffer, DWORD * const pcbDataSize, const DWORD dwFlags)
294 FIXME("(%p)->(%p,%p,%lx): stub\n", iface, pAppDescBuffer, pcbDataSize, dwFlags);
296 return DPNERR_GENERIC;
299 static HRESULT WINAPI IDirectPlay8PeerImpl_SetApplicationDesc(IDirectPlay8Peer *iface,
300 const DPN_APPLICATION_DESC * const pad, const DWORD dwFlags)
302 FIXME("(%p)->(%p,%lx): stub\n", iface, pad, dwFlags);
304 return DPNERR_GENERIC;
307 static HRESULT WINAPI IDirectPlay8PeerImpl_CreateGroup(IDirectPlay8Peer *iface,
308 const DPN_GROUP_INFO * const pdpnGroupInfo, void * const pvGroupContext,
309 void * const pvAsyncContext, DPNHANDLE * const phAsyncHandle, const DWORD dwFlags)
311 FIXME("(%p)->(%p,%p,%p,%p,%lx): stub\n", iface, pdpnGroupInfo, pvGroupContext, pvAsyncContext, phAsyncHandle, dwFlags);
313 return DPNERR_GENERIC;
316 static HRESULT WINAPI IDirectPlay8PeerImpl_DestroyGroup(IDirectPlay8Peer *iface,
317 const DPNID idGroup, void * const pvAsyncContext, DPNHANDLE * const phAsyncHandle,
318 const DWORD dwFlags)
320 FIXME("(%p)->(%lx,%p,%p,%lx): stub\n", iface, idGroup, pvAsyncContext, phAsyncHandle, dwFlags);
322 return DPNERR_GENERIC;
325 static HRESULT WINAPI IDirectPlay8PeerImpl_AddPlayerToGroup(IDirectPlay8Peer *iface,
326 const DPNID idGroup, const DPNID idClient, void * const pvAsyncContext,
327 DPNHANDLE * const phAsyncHandle, const DWORD dwFlags)
329 FIXME("(%p)->(%lx,%lx,%p,%p,%lx): stub\n", iface, idGroup, idClient, pvAsyncContext, phAsyncHandle, dwFlags);
331 return DPNERR_GENERIC;
334 static HRESULT WINAPI IDirectPlay8PeerImpl_RemovePlayerFromGroup(IDirectPlay8Peer *iface,
335 const DPNID idGroup, const DPNID idClient, void * const pvAsyncContext,
336 DPNHANDLE * const phAsyncHandle, const DWORD dwFlags)
338 FIXME("(%p)->(%lx,%lx,%p,%p,%lx): stub\n", iface, idGroup, idClient, pvAsyncContext, phAsyncHandle, dwFlags);
340 return DPNERR_GENERIC;
343 static HRESULT WINAPI IDirectPlay8PeerImpl_SetGroupInfo(IDirectPlay8Peer *iface, const DPNID dpnid,
344 DPN_GROUP_INFO * const pdpnGroupInfo, void * const pvAsyncContext,
345 DPNHANDLE * const phAsyncHandle, const DWORD dwFlags)
347 FIXME("(%p)->(%lx,%p,%p,%p,%lx): stub\n", iface, dpnid, pdpnGroupInfo, pvAsyncContext, phAsyncHandle, dwFlags);
349 return DPNERR_GENERIC;
352 static HRESULT WINAPI IDirectPlay8PeerImpl_GetGroupInfo(IDirectPlay8Peer *iface, const DPNID dpnid,
353 DPN_GROUP_INFO * const pdpnGroupInfo, DWORD * const pdwSize, const DWORD dwFlags)
355 FIXME("(%p)->(%lx,%p,%p,%lx): stub\n", iface, dpnid, pdpnGroupInfo, pdwSize, dwFlags);
357 return DPNERR_GENERIC;
360 static HRESULT WINAPI IDirectPlay8PeerImpl_EnumPlayersAndGroups(IDirectPlay8Peer *iface,
361 DPNID * const prgdpnid, DWORD * const pcdpnid, const DWORD dwFlags)
363 FIXME("(%p)->(%p,%p,%lx): stub\n", iface, prgdpnid, pcdpnid, dwFlags);
365 return DPNERR_GENERIC;
368 static HRESULT WINAPI IDirectPlay8PeerImpl_EnumGroupMembers(IDirectPlay8Peer *iface,
369 const DPNID dpnid, DPNID * const prgdpnid, DWORD * const pcdpnid, const DWORD dwFlags)
371 FIXME("(%p)->(%lx,%p,%p,%lx): stub\n", iface, dpnid, prgdpnid, pcdpnid, dwFlags);
373 return DPNERR_GENERIC;
376 static HRESULT WINAPI IDirectPlay8PeerImpl_SetPeerInfo(IDirectPlay8Peer *iface,
377 const DPN_PLAYER_INFO * const pdpnPlayerInfo, void * const pvAsyncContext,
378 DPNHANDLE * const phAsyncHandle, const DWORD dwFlags)
380 IDirectPlay8PeerImpl* This = impl_from_IDirectPlay8Peer(iface);
382 FIXME("(%p)->(%p,%p,%p,%lx) Semi-stub.\n", This, pdpnPlayerInfo, pvAsyncContext, phAsyncHandle, dwFlags);
384 if(!pdpnPlayerInfo)
385 return E_POINTER;
387 if(phAsyncHandle)
388 FIXME("Async handle currently not supported.\n");
390 if (pdpnPlayerInfo->dwInfoFlags & DPNINFO_NAME)
392 heap_free(This->username);
393 This->username = NULL;
395 if(pdpnPlayerInfo->pwszName)
397 This->username = heap_strdupW(pdpnPlayerInfo->pwszName);
398 if (!This->username)
399 return E_OUTOFMEMORY;
403 if (pdpnPlayerInfo->dwInfoFlags & DPNINFO_DATA)
405 heap_free(This->data);
407 This->datasize = pdpnPlayerInfo->dwDataSize;
408 This->data = heap_alloc(pdpnPlayerInfo->dwDataSize);
409 if (!This->data)
410 return E_OUTOFMEMORY;
412 memcpy(This->data, pdpnPlayerInfo->pvData, pdpnPlayerInfo->dwDataSize);
415 return S_OK;
418 static HRESULT WINAPI IDirectPlay8PeerImpl_GetPeerInfo(IDirectPlay8Peer *iface, const DPNID dpnid,
419 DPN_PLAYER_INFO * const pdpnPlayerInfo, DWORD * const pdwSize, const DWORD dwFlags)
421 FIXME("(%p)->(%lx,%p,%p,%lx): stub\n", iface, dpnid, pdpnPlayerInfo, pdwSize, dwFlags);
423 return DPNERR_GENERIC;
426 static HRESULT WINAPI IDirectPlay8PeerImpl_GetPeerAddress(IDirectPlay8Peer *iface,
427 const DPNID dpnid, IDirectPlay8Address ** const pAddress, const DWORD dwFlags)
429 FIXME("(%p)->(%lx,%p,%lx): stub\n", iface, dpnid, pAddress, dwFlags);
431 return DPNERR_GENERIC;
434 static HRESULT WINAPI IDirectPlay8PeerImpl_GetLocalHostAddresses(IDirectPlay8Peer *iface,
435 IDirectPlay8Address ** const prgpAddress, DWORD * const pcAddress, const DWORD dwFlags)
437 FIXME("(%p)->(%p,%p,%lx): stub\n", iface, prgpAddress, pcAddress, dwFlags);
439 return DPNERR_GENERIC;
442 static HRESULT WINAPI IDirectPlay8PeerImpl_Close(IDirectPlay8Peer *iface, const DWORD dwFlags)
444 FIXME("(%p)->(%lx): stub\n", iface, dwFlags);
446 return DPN_OK;
449 static HRESULT WINAPI IDirectPlay8PeerImpl_EnumHosts(IDirectPlay8Peer *iface,
450 PDPN_APPLICATION_DESC const pApplicationDesc, IDirectPlay8Address * const pAddrHost,
451 IDirectPlay8Address * const pDeviceInfo, void * const pUserEnumData,
452 const DWORD dwUserEnumDataSize, const DWORD dwEnumCount, const DWORD dwRetryInterval,
453 const DWORD dwTimeOut, void * const pvUserContext, DPNHANDLE * const pAsyncHandle, const DWORD dwFlags)
455 IDirectPlay8PeerImpl* This = impl_from_IDirectPlay8Peer(iface);
457 FIXME("(%p)->(%p,%p,%p,%p,%lx,%lx,%lx,%lx,%p,%p,%lx): stub\n",
458 This, pApplicationDesc, pAddrHost, pDeviceInfo, pUserEnumData, dwUserEnumDataSize, dwEnumCount,
459 dwRetryInterval, dwTimeOut, pvUserContext, pAsyncHandle, dwFlags);
461 if(!This->msghandler)
462 return DPNERR_UNINITIALIZED;
464 if((dwFlags & DPNENUMHOSTS_SYNC) && pAsyncHandle)
465 return DPNERR_INVALIDPARAM;
467 if(dwUserEnumDataSize > This->spcaps.dwMaxEnumPayloadSize)
468 return DPNERR_ENUMQUERYTOOLARGE;
470 return (dwFlags & DPNENUMHOSTS_SYNC) ? DPN_OK : DPNSUCCESS_PENDING;
473 static HRESULT WINAPI IDirectPlay8PeerImpl_DestroyPeer(IDirectPlay8Peer *iface, const DPNID dpnidClient,
474 const void * const pvDestroyData, const DWORD dwDestroyDataSize, const DWORD dwFlags)
476 FIXME("(%p)->(%lx,%p,%lx,%lx): stub\n", iface, dpnidClient, pvDestroyData, dwDestroyDataSize, dwFlags);
478 return DPNERR_GENERIC;
481 static HRESULT WINAPI IDirectPlay8PeerImpl_ReturnBuffer(IDirectPlay8Peer *iface, const DPNHANDLE hBufferHandle,
482 const DWORD dwFlags)
484 FIXME("(%p)->(%lx,%lx): stub\n", iface, hBufferHandle, dwFlags);
486 return DPNERR_GENERIC;
489 static HRESULT WINAPI IDirectPlay8PeerImpl_GetPlayerContext(IDirectPlay8Peer *iface, const DPNID dpnid,
490 void ** const ppvPlayerContext, const DWORD dwFlags)
492 FIXME("(%p)->(%lx,%p,%lx): stub\n", iface, dpnid, ppvPlayerContext, dwFlags);
494 return DPNERR_GENERIC;
497 static HRESULT WINAPI IDirectPlay8PeerImpl_GetGroupContext(IDirectPlay8Peer *iface, const DPNID dpnid,
498 void ** const ppvGroupContext, const DWORD dwFlags)
500 FIXME("(%p)->(%lx,%p,%lx): stub\n", iface, dpnid, ppvGroupContext, dwFlags);
502 return DPNERR_GENERIC;
505 static HRESULT WINAPI IDirectPlay8PeerImpl_GetCaps(IDirectPlay8Peer *iface, DPN_CAPS * const pdpCaps,
506 const DWORD dwFlags)
508 FIXME("(%p)->(%p,%lx): stub\n", iface, pdpCaps, dwFlags);
510 return DPNERR_GENERIC;
513 static HRESULT WINAPI IDirectPlay8PeerImpl_SetCaps(IDirectPlay8Peer *iface, const DPN_CAPS * const pdpCaps,
514 const DWORD dwFlags)
516 FIXME("(%p)->(%p,%lx): stub\n", iface, pdpCaps, dwFlags);
518 return DPNERR_GENERIC;
521 static HRESULT WINAPI IDirectPlay8PeerImpl_SetSPCaps(IDirectPlay8Peer *iface, const GUID * const pguidSP,
522 const DPN_SP_CAPS * const pdpspCaps, const DWORD dwFlags )
524 IDirectPlay8PeerImpl* This = impl_from_IDirectPlay8Peer(iface);
526 TRACE("(%p)->(%p,%p,%lx): stub\n", iface, pguidSP, pdpspCaps, dwFlags);
528 if(!This->msghandler || pdpspCaps->dwSize != sizeof(DPN_SP_CAPS))
529 return DPNERR_INVALIDPARAM;
531 /* Only dwSystemBufferSize is set by this call. */
532 This->spcaps.dwSystemBufferSize = pdpspCaps->dwSystemBufferSize;
534 return DPN_OK;
537 static HRESULT WINAPI IDirectPlay8PeerImpl_GetSPCaps(IDirectPlay8Peer *iface, const GUID * const pguidSP,
538 DPN_SP_CAPS * const pdpspCaps, const DWORD dwFlags)
540 IDirectPlay8PeerImpl* This = impl_from_IDirectPlay8Peer(iface);
542 TRACE("(%p)->(%p,%p,%lx)\n", This, pguidSP, pdpspCaps, dwFlags);
544 if(!This->msghandler)
545 return DPNERR_UNINITIALIZED;
547 if(pdpspCaps->dwSize != sizeof(DPN_SP_CAPS))
549 return DPNERR_INVALIDPARAM;
552 *pdpspCaps = This->spcaps;
554 return DPN_OK;
557 static HRESULT WINAPI IDirectPlay8PeerImpl_GetConnectionInfo(IDirectPlay8Peer *iface, const DPNID dpnid,
558 DPN_CONNECTION_INFO * const pdpConnectionInfo, const DWORD dwFlags)
560 FIXME("(%p)->(%lx,%p,%lx): stub\n", iface, dpnid, pdpConnectionInfo, dwFlags);
562 return DPNERR_GENERIC;
565 static HRESULT WINAPI IDirectPlay8PeerImpl_RegisterLobby(IDirectPlay8Peer *iface, const DPNHANDLE dpnHandle,
566 struct IDirectPlay8LobbiedApplication * const pIDP8LobbiedApplication, const DWORD dwFlags)
568 FIXME("(%p)->(%lx,%p,%lx): stub\n", iface, dpnHandle, pIDP8LobbiedApplication, dwFlags);
570 return DPNERR_GENERIC;
573 static HRESULT WINAPI IDirectPlay8PeerImpl_TerminateSession(IDirectPlay8Peer *iface, void * const pvTerminateData,
574 const DWORD dwTerminateDataSize, const DWORD dwFlags)
576 FIXME("(%p)->(%p,%lx,%lx): stub\n", iface, pvTerminateData, dwTerminateDataSize, dwFlags);
578 return DPNERR_GENERIC;
581 static const IDirectPlay8PeerVtbl DirectPlay8Peer_Vtbl =
583 IDirectPlay8PeerImpl_QueryInterface,
584 IDirectPlay8PeerImpl_AddRef,
585 IDirectPlay8PeerImpl_Release,
586 IDirectPlay8PeerImpl_Initialize,
587 IDirectPlay8PeerImpl_EnumServiceProviders,
588 IDirectPlay8PeerImpl_CancelAsyncOperation,
589 IDirectPlay8PeerImpl_Connect,
590 IDirectPlay8PeerImpl_SendTo,
591 IDirectPlay8PeerImpl_GetSendQueueInfo,
592 IDirectPlay8PeerImpl_Host,
593 IDirectPlay8PeerImpl_GetApplicationDesc,
594 IDirectPlay8PeerImpl_SetApplicationDesc,
595 IDirectPlay8PeerImpl_CreateGroup,
596 IDirectPlay8PeerImpl_DestroyGroup,
597 IDirectPlay8PeerImpl_AddPlayerToGroup,
598 IDirectPlay8PeerImpl_RemovePlayerFromGroup,
599 IDirectPlay8PeerImpl_SetGroupInfo,
600 IDirectPlay8PeerImpl_GetGroupInfo,
601 IDirectPlay8PeerImpl_EnumPlayersAndGroups,
602 IDirectPlay8PeerImpl_EnumGroupMembers,
603 IDirectPlay8PeerImpl_SetPeerInfo,
604 IDirectPlay8PeerImpl_GetPeerInfo,
605 IDirectPlay8PeerImpl_GetPeerAddress,
606 IDirectPlay8PeerImpl_GetLocalHostAddresses,
607 IDirectPlay8PeerImpl_Close,
608 IDirectPlay8PeerImpl_EnumHosts,
609 IDirectPlay8PeerImpl_DestroyPeer,
610 IDirectPlay8PeerImpl_ReturnBuffer,
611 IDirectPlay8PeerImpl_GetPlayerContext,
612 IDirectPlay8PeerImpl_GetGroupContext,
613 IDirectPlay8PeerImpl_GetCaps,
614 IDirectPlay8PeerImpl_SetCaps,
615 IDirectPlay8PeerImpl_SetSPCaps,
616 IDirectPlay8PeerImpl_GetSPCaps,
617 IDirectPlay8PeerImpl_GetConnectionInfo,
618 IDirectPlay8PeerImpl_RegisterLobby,
619 IDirectPlay8PeerImpl_TerminateSession
622 void init_dpn_sp_caps(DPN_SP_CAPS *dpnspcaps)
624 dpnspcaps->dwSize = sizeof(DPN_SP_CAPS);
625 dpnspcaps->dwFlags = DPNSPCAPS_SUPPORTSDPNSRV | DPNSPCAPS_SUPPORTSBROADCAST |
626 DPNSPCAPS_SUPPORTSALLADAPTERS | DPNSPCAPS_SUPPORTSTHREADPOOL;
627 dpnspcaps->dwNumThreads = 3;
628 dpnspcaps->dwDefaultEnumCount = 5;
629 dpnspcaps->dwDefaultEnumRetryInterval = 1500;
630 dpnspcaps->dwDefaultEnumTimeout = 1500;
631 dpnspcaps->dwMaxEnumPayloadSize = 983;
632 dpnspcaps->dwBuffersPerThread = 1;
633 dpnspcaps->dwSystemBufferSize = 0x10000;
636 HRESULT DPNET_CreateDirectPlay8Peer(IClassFactory *iface, IUnknown *pUnkOuter, REFIID riid, LPVOID *ppobj)
638 IDirectPlay8PeerImpl* Client;
639 HRESULT ret;
641 Client = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8PeerImpl));
643 *ppobj = NULL;
645 if(Client == NULL)
647 WARN("Not enough memory\n");
648 return E_OUTOFMEMORY;
651 Client->IDirectPlay8Peer_iface.lpVtbl = &DirectPlay8Peer_Vtbl;
652 Client->ref = 1;
653 Client->usercontext = NULL;
654 Client->msghandler = NULL;
655 Client->flags = 0;
657 init_dpn_sp_caps(&Client->spcaps);
659 ret = IDirectPlay8Peer_QueryInterface(&Client->IDirectPlay8Peer_iface, riid, ppobj);
660 IDirectPlay8Peer_Release(&Client->IDirectPlay8Peer_iface);
662 return ret;