user32/tests: Test pending redraw state with owner-drawn list box.
[wine.git] / dlls / dpnet / peer.c
blob329d9b3a828cb66a1f1faa1ed6eea1d49de6ca3c
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 **ppobj)
65 IDirectPlay8PeerImpl* This = impl_from_IDirectPlay8Peer(iface);
67 if(IsEqualGUID(riid, &IID_IUnknown) ||
68 IsEqualGUID(riid, &IID_IDirectPlay8Peer))
70 IUnknown_AddRef(iface);
71 *ppobj = This;
72 return DPN_OK;
75 WARN("(%p)->(%s,%p): not found\n", This, debugstr_guid(riid), ppobj);
76 return E_NOINTERFACE;
79 static ULONG WINAPI IDirectPlay8PeerImpl_AddRef(IDirectPlay8Peer *iface)
81 IDirectPlay8PeerImpl* This = impl_from_IDirectPlay8Peer(iface);
82 ULONG RefCount = InterlockedIncrement(&This->ref);
84 TRACE("(%p) ref=%d\n", This, RefCount);
86 return RefCount;
89 static ULONG WINAPI IDirectPlay8PeerImpl_Release(IDirectPlay8Peer *iface)
91 IDirectPlay8PeerImpl* This = impl_from_IDirectPlay8Peer(iface);
92 ULONG RefCount = InterlockedDecrement(&This->ref);
94 TRACE("(%p) ref=%d\n", This, RefCount);
96 if(!RefCount)
98 heap_free(This->username);
99 heap_free(This->data);
101 heap_free(This);
104 return RefCount;
107 /* IDirectPlay8Peer interface follows */
109 static HRESULT WINAPI IDirectPlay8PeerImpl_Initialize(IDirectPlay8Peer *iface,
110 void * const pvUserContext, const PFNDPNMESSAGEHANDLER pfn, const DWORD dwFlags)
112 IDirectPlay8PeerImpl* This = impl_from_IDirectPlay8Peer(iface);
114 TRACE("(%p)->(%p,%p,%x): stub\n", iface, pvUserContext, pfn, dwFlags);
116 if(!pfn)
117 return DPNERR_INVALIDPARAM;
119 This->usercontext = pvUserContext;
120 This->msghandler = pfn;
121 This->flags = dwFlags;
123 init_winsock();
125 return DPN_OK;
128 HRESULT enum_services_providers(const GUID * const service, DPN_SERVICE_PROVIDER_INFO * const info_buffer,
129 DWORD * const buf_size, DWORD * const returned)
131 static const WCHAR serviceproviders[] = L"SOFTWARE\\Microsoft\\DirectPlay8\\Service Providers";
132 static const WCHAR friendly[] = L"Friendly Name";
133 static const WCHAR dp_adapterW[] = L"Local Area Connection - IPv4";
134 static const GUID adapter_guid = {0x4ce725f6, 0xd3c0, 0xdade, {0xba, 0x6f, 0x11, 0xf9, 0x65, 0xbc, 0x42, 0x99}};
135 DWORD req_size = 0;
136 LONG res;
137 HKEY key = NULL;
138 LONG next_key;
139 DWORD index = 0;
140 WCHAR provider[MAX_PATH];
141 DWORD size;
143 if(!returned || !buf_size)
144 return E_POINTER;
146 if(!service)
148 *returned = 0;
150 res = RegOpenKeyExW(HKEY_LOCAL_MACHINE, serviceproviders, 0, KEY_READ, &key);
151 if(res == ERROR_FILE_NOT_FOUND)
152 return DPNERR_DOESNOTEXIST;
154 next_key = RegEnumKeyW( key, index, provider, MAX_PATH);
155 while(next_key == ERROR_SUCCESS)
157 size = 0;
158 res = RegGetValueW(key, provider, friendly, RRF_RT_REG_SZ, NULL, NULL, &size);
159 if(res == ERROR_SUCCESS)
161 req_size += sizeof(DPN_SERVICE_PROVIDER_INFO) + size;
163 (*returned)++;
166 index++;
167 next_key = RegEnumKeyW( key, index, provider, MAX_PATH );
171 else if(IsEqualGUID(service, &CLSID_DP8SP_TCPIP))
173 req_size = sizeof(DPN_SERVICE_PROVIDER_INFO) + sizeof(dp_adapterW);
175 else
177 FIXME("Application requested a provider we don't handle (yet)\n");
178 return DPNERR_DOESNOTEXIST;
181 if(*buf_size < req_size)
183 RegCloseKey(key);
185 *buf_size = req_size;
186 return DPNERR_BUFFERTOOSMALL;
189 if(!service)
191 int offset = 0;
192 int count = 0;
193 char *infoend = ((char *)info_buffer + (sizeof(DPN_SERVICE_PROVIDER_INFO) * (*returned)));
195 index = 0;
196 next_key = RegEnumKeyW( key, index, provider, MAX_PATH);
197 while(next_key == ERROR_SUCCESS)
199 size = 0;
200 res = RegGetValueW(key, provider, friendly, RRF_RT_REG_SZ, NULL, NULL, &size);
201 if(res == ERROR_SUCCESS)
203 info_buffer[count].guid = CLSID_DP8SP_TCPIP;
204 info_buffer[count].pwszName = (LPWSTR)(infoend + offset);
206 RegGetValueW(key, provider, friendly, RRF_RT_REG_SZ, NULL, info_buffer[count].pwszName, &size);
208 offset += size;
209 count++;
212 index++;
213 next_key = RegEnumKeyW(key, index, provider, MAX_PATH);
216 else
218 info_buffer->pwszName = (LPWSTR)(info_buffer + 1);
219 lstrcpyW(info_buffer->pwszName, dp_adapterW);
220 info_buffer->guid = adapter_guid;
221 *returned = 1;
224 RegCloseKey(key);
226 return DPN_OK;
229 static HRESULT WINAPI IDirectPlay8PeerImpl_EnumServiceProviders(IDirectPlay8Peer *iface,
230 const GUID * const pguidServiceProvider, const GUID * const pguidApplication,
231 DPN_SERVICE_PROVIDER_INFO * const pSPInfoBuffer, DWORD * const pcbEnumData,
232 DWORD * const pcReturned, const DWORD dwFlags)
234 TRACE("(%p)->(%s,%s,%p,%p,%p,%x)\n", iface, debugstr_guid(pguidServiceProvider), debugstr_guid(pguidApplication),
235 pSPInfoBuffer, pcbEnumData, pcReturned, dwFlags);
237 if(dwFlags)
238 FIXME("Unhandled flags %x\n", dwFlags);
240 if(pguidApplication)
241 FIXME("Application guid %s is currently being ignored\n", debugstr_guid(pguidApplication));
243 return enum_services_providers(pguidServiceProvider, pSPInfoBuffer, pcbEnumData, pcReturned);
246 static HRESULT WINAPI IDirectPlay8PeerImpl_CancelAsyncOperation(IDirectPlay8Peer *iface,
247 const DPNHANDLE hAsyncHandle, const DWORD dwFlags)
249 FIXME("(%p)->(%x,%x): stub\n", iface, hAsyncHandle, dwFlags);
251 return DPNERR_GENERIC;
254 static HRESULT WINAPI IDirectPlay8PeerImpl_Connect(IDirectPlay8Peer *iface,
255 const DPN_APPLICATION_DESC * const pdnAppDesc, IDirectPlay8Address * const pHostAddr,
256 IDirectPlay8Address * const pDeviceInfo, const DPN_SECURITY_DESC * const pdnSecurity,
257 const DPN_SECURITY_CREDENTIALS * const pdnCredentials, const void * const pvUserConnectData,
258 const DWORD dwUserConnectDataSize, void * const pvPlayerContext,
259 void * const pvAsyncContext, DPNHANDLE * const phAsyncHandle, const DWORD dwFlags)
261 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);
263 return DPNERR_GENERIC;
266 static HRESULT WINAPI IDirectPlay8PeerImpl_SendTo(IDirectPlay8Peer *iface, const DPNID dpnId,
267 const DPN_BUFFER_DESC *pBufferDesc, const DWORD cBufferDesc, const DWORD dwTimeOut,
268 void * const pvAsyncContext, DPNHANDLE * const phAsyncHandle, const DWORD dwFlags)
270 FIXME("(%p)->(%x,%p,%x,%x,%p,%p,%x): stub\n", iface, dpnId, pBufferDesc, cBufferDesc, dwTimeOut, pvAsyncContext, phAsyncHandle, dwFlags);
272 return DPNERR_GENERIC;
275 static HRESULT WINAPI IDirectPlay8PeerImpl_GetSendQueueInfo(IDirectPlay8Peer *iface,
276 const DPNID dpnid, DWORD * const pdwNumMsgs, DWORD * const pdwNumBytes, const DWORD dwFlags)
278 FIXME("(%p)->(%x,%p,%p,%x): stub\n", iface, dpnid, pdwNumMsgs, pdwNumBytes, dwFlags);
280 return DPNERR_GENERIC;
283 static HRESULT WINAPI IDirectPlay8PeerImpl_Host(IDirectPlay8Peer *iface,
284 const DPN_APPLICATION_DESC * const pdnAppDesc, IDirectPlay8Address ** const prgpDeviceInfo,
285 const DWORD cDeviceInfo, const DPN_SECURITY_DESC * const pdpSecurity,
286 const DPN_SECURITY_CREDENTIALS * const pdpCredentials, void * const pvPlayerContext,
287 const DWORD dwFlags)
289 FIXME("(%p)->(%p,%p,%x,%p,%p,%p,%x): stub\n", iface, pdnAppDesc, prgpDeviceInfo, cDeviceInfo, pdpSecurity, pdpCredentials, pvPlayerContext, dwFlags);
291 return DPNERR_GENERIC;
294 static HRESULT WINAPI IDirectPlay8PeerImpl_GetApplicationDesc(IDirectPlay8Peer *iface,
295 DPN_APPLICATION_DESC * const pAppDescBuffer, DWORD * const pcbDataSize, const DWORD dwFlags)
297 FIXME("(%p)->(%p,%p,%x): stub\n", iface, pAppDescBuffer, pcbDataSize, dwFlags);
299 return DPNERR_GENERIC;
302 static HRESULT WINAPI IDirectPlay8PeerImpl_SetApplicationDesc(IDirectPlay8Peer *iface,
303 const DPN_APPLICATION_DESC * const pad, const DWORD dwFlags)
305 FIXME("(%p)->(%p,%x): stub\n", iface, pad, dwFlags);
307 return DPNERR_GENERIC;
310 static HRESULT WINAPI IDirectPlay8PeerImpl_CreateGroup(IDirectPlay8Peer *iface,
311 const DPN_GROUP_INFO * const pdpnGroupInfo, void * const pvGroupContext,
312 void * const pvAsyncContext, DPNHANDLE * const phAsyncHandle, const DWORD dwFlags)
314 FIXME("(%p)->(%p,%p,%p,%p,%x): stub\n", iface, pdpnGroupInfo, pvGroupContext, pvAsyncContext, phAsyncHandle, dwFlags);
316 return DPNERR_GENERIC;
319 static HRESULT WINAPI IDirectPlay8PeerImpl_DestroyGroup(IDirectPlay8Peer *iface,
320 const DPNID idGroup, void * const pvAsyncContext, DPNHANDLE * const phAsyncHandle,
321 const DWORD dwFlags)
323 FIXME("(%p)->(%x,%p,%p,%x): stub\n", iface, idGroup, pvAsyncContext, phAsyncHandle, dwFlags);
325 return DPNERR_GENERIC;
328 static HRESULT WINAPI IDirectPlay8PeerImpl_AddPlayerToGroup(IDirectPlay8Peer *iface,
329 const DPNID idGroup, const DPNID idClient, void * const pvAsyncContext,
330 DPNHANDLE * const phAsyncHandle, const DWORD dwFlags)
332 FIXME("(%p)->(%x,%x,%p,%p,%x): stub\n", iface, idGroup, idClient, pvAsyncContext, phAsyncHandle, dwFlags);
334 return DPNERR_GENERIC;
337 static HRESULT WINAPI IDirectPlay8PeerImpl_RemovePlayerFromGroup(IDirectPlay8Peer *iface,
338 const DPNID idGroup, const DPNID idClient, void * const pvAsyncContext,
339 DPNHANDLE * const phAsyncHandle, const DWORD dwFlags)
341 FIXME("(%p)->(%x,%x,%p,%p,%x): stub\n", iface, idGroup, idClient, pvAsyncContext, phAsyncHandle, dwFlags);
343 return DPNERR_GENERIC;
346 static HRESULT WINAPI IDirectPlay8PeerImpl_SetGroupInfo(IDirectPlay8Peer *iface, const DPNID dpnid,
347 DPN_GROUP_INFO * const pdpnGroupInfo, void * const pvAsyncContext,
348 DPNHANDLE * const phAsyncHandle, const DWORD dwFlags)
350 FIXME("(%p)->(%x,%p,%p,%p,%x): stub\n", iface, dpnid, pdpnGroupInfo, pvAsyncContext, phAsyncHandle, dwFlags);
352 return DPNERR_GENERIC;
355 static HRESULT WINAPI IDirectPlay8PeerImpl_GetGroupInfo(IDirectPlay8Peer *iface, const DPNID dpnid,
356 DPN_GROUP_INFO * const pdpnGroupInfo, DWORD * const pdwSize, const DWORD dwFlags)
358 FIXME("(%p)->(%x,%p,%p,%x): stub\n", iface, dpnid, pdpnGroupInfo, pdwSize, dwFlags);
360 return DPNERR_GENERIC;
363 static HRESULT WINAPI IDirectPlay8PeerImpl_EnumPlayersAndGroups(IDirectPlay8Peer *iface,
364 DPNID * const prgdpnid, DWORD * const pcdpnid, const DWORD dwFlags)
366 FIXME("(%p)->(%p,%p,%x): stub\n", iface, prgdpnid, pcdpnid, dwFlags);
368 return DPNERR_GENERIC;
371 static HRESULT WINAPI IDirectPlay8PeerImpl_EnumGroupMembers(IDirectPlay8Peer *iface,
372 const DPNID dpnid, DPNID * const prgdpnid, DWORD * const pcdpnid, const DWORD dwFlags)
374 FIXME("(%p)->(%x,%p,%p,%x): stub\n", iface, dpnid, prgdpnid, pcdpnid, dwFlags);
376 return DPNERR_GENERIC;
379 static HRESULT WINAPI IDirectPlay8PeerImpl_SetPeerInfo(IDirectPlay8Peer *iface,
380 const DPN_PLAYER_INFO * const pdpnPlayerInfo, void * const pvAsyncContext,
381 DPNHANDLE * const phAsyncHandle, const DWORD dwFlags)
383 IDirectPlay8PeerImpl* This = impl_from_IDirectPlay8Peer(iface);
385 FIXME("(%p)->(%p,%p,%p,%x) Semi-stub.\n", This, pdpnPlayerInfo, pvAsyncContext, phAsyncHandle, dwFlags);
387 if(!pdpnPlayerInfo)
388 return E_POINTER;
390 if(phAsyncHandle)
391 FIXME("Async handle currently not supported.\n");
393 if (pdpnPlayerInfo->dwInfoFlags & DPNINFO_NAME)
395 heap_free(This->username);
396 This->username = NULL;
398 if(pdpnPlayerInfo->pwszName)
400 This->username = heap_strdupW(pdpnPlayerInfo->pwszName);
401 if (!This->username)
402 return E_OUTOFMEMORY;
406 if (pdpnPlayerInfo->dwInfoFlags & DPNINFO_DATA)
408 heap_free(This->data);
410 This->datasize = pdpnPlayerInfo->dwDataSize;
411 This->data = heap_alloc(pdpnPlayerInfo->dwDataSize);
412 if (!This->data)
413 return E_OUTOFMEMORY;
415 memcpy(This->data, pdpnPlayerInfo->pvData, pdpnPlayerInfo->dwDataSize);
418 return S_OK;
421 static HRESULT WINAPI IDirectPlay8PeerImpl_GetPeerInfo(IDirectPlay8Peer *iface, const DPNID dpnid,
422 DPN_PLAYER_INFO * const pdpnPlayerInfo, DWORD * const pdwSize, const DWORD dwFlags)
424 FIXME("(%p)->(%x,%p,%p,%x): stub\n", iface, dpnid, pdpnPlayerInfo, pdwSize, dwFlags);
426 return DPNERR_GENERIC;
429 static HRESULT WINAPI IDirectPlay8PeerImpl_GetPeerAddress(IDirectPlay8Peer *iface,
430 const DPNID dpnid, IDirectPlay8Address ** const pAddress, const DWORD dwFlags)
432 FIXME("(%p)->(%x,%p,%x): stub\n", iface, dpnid, pAddress, dwFlags);
434 return DPNERR_GENERIC;
437 static HRESULT WINAPI IDirectPlay8PeerImpl_GetLocalHostAddresses(IDirectPlay8Peer *iface,
438 IDirectPlay8Address ** const prgpAddress, DWORD * const pcAddress, const DWORD dwFlags)
440 FIXME("(%p)->(%p,%p,%x): stub\n", iface, prgpAddress, pcAddress, dwFlags);
442 return DPNERR_GENERIC;
445 static HRESULT WINAPI IDirectPlay8PeerImpl_Close(IDirectPlay8Peer *iface, const DWORD dwFlags)
447 FIXME("(%p)->(%x): stub\n", iface, dwFlags);
449 return DPN_OK;
452 static HRESULT WINAPI IDirectPlay8PeerImpl_EnumHosts(IDirectPlay8Peer *iface,
453 PDPN_APPLICATION_DESC const pApplicationDesc, IDirectPlay8Address * const pAddrHost,
454 IDirectPlay8Address * const pDeviceInfo, void * const pUserEnumData,
455 const DWORD dwUserEnumDataSize, const DWORD dwEnumCount, const DWORD dwRetryInterval,
456 const DWORD dwTimeOut, void * const pvUserContext, DPNHANDLE * const pAsyncHandle, const DWORD dwFlags)
458 IDirectPlay8PeerImpl* This = impl_from_IDirectPlay8Peer(iface);
460 FIXME("(%p)->(%p,%p,%p,%p,%x,%x,%x,%x,%p,%p,%x): stub\n",
461 This, pApplicationDesc, pAddrHost, pDeviceInfo, pUserEnumData, dwUserEnumDataSize, dwEnumCount,
462 dwRetryInterval, dwTimeOut, pvUserContext, pAsyncHandle, dwFlags);
464 if(!This->msghandler)
465 return DPNERR_UNINITIALIZED;
467 if((dwFlags & DPNENUMHOSTS_SYNC) && pAsyncHandle)
468 return DPNERR_INVALIDPARAM;
470 if(dwUserEnumDataSize > This->spcaps.dwMaxEnumPayloadSize)
471 return DPNERR_ENUMQUERYTOOLARGE;
473 return (dwFlags & DPNENUMHOSTS_SYNC) ? DPN_OK : DPNSUCCESS_PENDING;
476 static HRESULT WINAPI IDirectPlay8PeerImpl_DestroyPeer(IDirectPlay8Peer *iface, const DPNID dpnidClient,
477 const void * const pvDestroyData, const DWORD dwDestroyDataSize, const DWORD dwFlags)
479 FIXME("(%p)->(%x,%p,%x,%x): stub\n", iface, dpnidClient, pvDestroyData, dwDestroyDataSize, dwFlags);
481 return DPNERR_GENERIC;
484 static HRESULT WINAPI IDirectPlay8PeerImpl_ReturnBuffer(IDirectPlay8Peer *iface, const DPNHANDLE hBufferHandle,
485 const DWORD dwFlags)
487 FIXME("(%p)->(%x,%x): stub\n", iface, hBufferHandle, dwFlags);
489 return DPNERR_GENERIC;
492 static HRESULT WINAPI IDirectPlay8PeerImpl_GetPlayerContext(IDirectPlay8Peer *iface, const DPNID dpnid,
493 void ** const ppvPlayerContext, const DWORD dwFlags)
495 FIXME("(%p)->(%x,%p,%x): stub\n", iface, dpnid, ppvPlayerContext, dwFlags);
497 return DPNERR_GENERIC;
500 static HRESULT WINAPI IDirectPlay8PeerImpl_GetGroupContext(IDirectPlay8Peer *iface, const DPNID dpnid,
501 void ** const ppvGroupContext, const DWORD dwFlags)
503 FIXME("(%p)->(%x,%p,%x): stub\n", iface, dpnid, ppvGroupContext, dwFlags);
505 return DPNERR_GENERIC;
508 static HRESULT WINAPI IDirectPlay8PeerImpl_GetCaps(IDirectPlay8Peer *iface, DPN_CAPS * const pdpCaps,
509 const DWORD dwFlags)
511 FIXME("(%p)->(%p,%x): stub\n", iface, pdpCaps, dwFlags);
513 return DPNERR_GENERIC;
516 static HRESULT WINAPI IDirectPlay8PeerImpl_SetCaps(IDirectPlay8Peer *iface, const DPN_CAPS * const pdpCaps,
517 const DWORD dwFlags)
519 FIXME("(%p)->(%p,%x): stub\n", iface, pdpCaps, dwFlags);
521 return DPNERR_GENERIC;
524 static HRESULT WINAPI IDirectPlay8PeerImpl_SetSPCaps(IDirectPlay8Peer *iface, const GUID * const pguidSP,
525 const DPN_SP_CAPS * const pdpspCaps, const DWORD dwFlags )
527 IDirectPlay8PeerImpl* This = impl_from_IDirectPlay8Peer(iface);
529 TRACE("(%p)->(%p,%p,%x): stub\n", iface, pguidSP, pdpspCaps, dwFlags);
531 if(!This->msghandler || pdpspCaps->dwSize != sizeof(DPN_SP_CAPS))
532 return DPNERR_INVALIDPARAM;
534 /* Only dwSystemBufferSize is set by this call. */
535 This->spcaps.dwSystemBufferSize = pdpspCaps->dwSystemBufferSize;
537 return DPN_OK;
540 static HRESULT WINAPI IDirectPlay8PeerImpl_GetSPCaps(IDirectPlay8Peer *iface, const GUID * const pguidSP,
541 DPN_SP_CAPS * const pdpspCaps, const DWORD dwFlags)
543 IDirectPlay8PeerImpl* This = impl_from_IDirectPlay8Peer(iface);
545 TRACE("(%p)->(%p,%p,%x)\n", This, pguidSP, pdpspCaps, dwFlags);
547 if(!This->msghandler)
548 return DPNERR_UNINITIALIZED;
550 if(pdpspCaps->dwSize != sizeof(DPN_SP_CAPS))
552 return DPNERR_INVALIDPARAM;
555 *pdpspCaps = This->spcaps;
557 return DPN_OK;
560 static HRESULT WINAPI IDirectPlay8PeerImpl_GetConnectionInfo(IDirectPlay8Peer *iface, const DPNID dpnid,
561 DPN_CONNECTION_INFO * const pdpConnectionInfo, const DWORD dwFlags)
563 FIXME("(%p)->(%x,%p,%x): stub\n", iface, dpnid, pdpConnectionInfo, dwFlags);
565 return DPNERR_GENERIC;
568 static HRESULT WINAPI IDirectPlay8PeerImpl_RegisterLobby(IDirectPlay8Peer *iface, const DPNHANDLE dpnHandle,
569 struct IDirectPlay8LobbiedApplication * const pIDP8LobbiedApplication, const DWORD dwFlags)
571 FIXME("(%p)->(%x,%p,%x): stub\n", iface, dpnHandle, pIDP8LobbiedApplication, dwFlags);
573 return DPNERR_GENERIC;
576 static HRESULT WINAPI IDirectPlay8PeerImpl_TerminateSession(IDirectPlay8Peer *iface, void * const pvTerminateData,
577 const DWORD dwTerminateDataSize, const DWORD dwFlags)
579 FIXME("(%p)->(%p,%x,%x): stub\n", iface, pvTerminateData, dwTerminateDataSize, dwFlags);
581 return DPNERR_GENERIC;
584 static const IDirectPlay8PeerVtbl DirectPlay8Peer_Vtbl =
586 IDirectPlay8PeerImpl_QueryInterface,
587 IDirectPlay8PeerImpl_AddRef,
588 IDirectPlay8PeerImpl_Release,
589 IDirectPlay8PeerImpl_Initialize,
590 IDirectPlay8PeerImpl_EnumServiceProviders,
591 IDirectPlay8PeerImpl_CancelAsyncOperation,
592 IDirectPlay8PeerImpl_Connect,
593 IDirectPlay8PeerImpl_SendTo,
594 IDirectPlay8PeerImpl_GetSendQueueInfo,
595 IDirectPlay8PeerImpl_Host,
596 IDirectPlay8PeerImpl_GetApplicationDesc,
597 IDirectPlay8PeerImpl_SetApplicationDesc,
598 IDirectPlay8PeerImpl_CreateGroup,
599 IDirectPlay8PeerImpl_DestroyGroup,
600 IDirectPlay8PeerImpl_AddPlayerToGroup,
601 IDirectPlay8PeerImpl_RemovePlayerFromGroup,
602 IDirectPlay8PeerImpl_SetGroupInfo,
603 IDirectPlay8PeerImpl_GetGroupInfo,
604 IDirectPlay8PeerImpl_EnumPlayersAndGroups,
605 IDirectPlay8PeerImpl_EnumGroupMembers,
606 IDirectPlay8PeerImpl_SetPeerInfo,
607 IDirectPlay8PeerImpl_GetPeerInfo,
608 IDirectPlay8PeerImpl_GetPeerAddress,
609 IDirectPlay8PeerImpl_GetLocalHostAddresses,
610 IDirectPlay8PeerImpl_Close,
611 IDirectPlay8PeerImpl_EnumHosts,
612 IDirectPlay8PeerImpl_DestroyPeer,
613 IDirectPlay8PeerImpl_ReturnBuffer,
614 IDirectPlay8PeerImpl_GetPlayerContext,
615 IDirectPlay8PeerImpl_GetGroupContext,
616 IDirectPlay8PeerImpl_GetCaps,
617 IDirectPlay8PeerImpl_SetCaps,
618 IDirectPlay8PeerImpl_SetSPCaps,
619 IDirectPlay8PeerImpl_GetSPCaps,
620 IDirectPlay8PeerImpl_GetConnectionInfo,
621 IDirectPlay8PeerImpl_RegisterLobby,
622 IDirectPlay8PeerImpl_TerminateSession
625 void init_dpn_sp_caps(DPN_SP_CAPS *dpnspcaps)
627 dpnspcaps->dwSize = sizeof(DPN_SP_CAPS);
628 dpnspcaps->dwFlags = DPNSPCAPS_SUPPORTSDPNSRV | DPNSPCAPS_SUPPORTSBROADCAST |
629 DPNSPCAPS_SUPPORTSALLADAPTERS | DPNSPCAPS_SUPPORTSTHREADPOOL;
630 dpnspcaps->dwNumThreads = 3;
631 dpnspcaps->dwDefaultEnumCount = 5;
632 dpnspcaps->dwDefaultEnumRetryInterval = 1500;
633 dpnspcaps->dwDefaultEnumTimeout = 1500;
634 dpnspcaps->dwMaxEnumPayloadSize = 983;
635 dpnspcaps->dwBuffersPerThread = 1;
636 dpnspcaps->dwSystemBufferSize = 0x10000;
639 HRESULT DPNET_CreateDirectPlay8Peer(IClassFactory *iface, IUnknown *pUnkOuter, REFIID riid, LPVOID *ppobj)
641 IDirectPlay8PeerImpl* Client;
642 HRESULT ret;
644 Client = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8PeerImpl));
646 *ppobj = NULL;
648 if(Client == NULL)
650 WARN("Not enough memory\n");
651 return E_OUTOFMEMORY;
654 Client->IDirectPlay8Peer_iface.lpVtbl = &DirectPlay8Peer_Vtbl;
655 Client->ref = 1;
656 Client->usercontext = NULL;
657 Client->msghandler = NULL;
658 Client->flags = 0;
660 init_dpn_sp_caps(&Client->spcaps);
662 ret = IDirectPlay8Peer_QueryInterface(&Client->IDirectPlay8Peer_iface, riid, ppobj);
663 IDirectPlay8Peer_Release(&Client->IDirectPlay8Peer_iface);
665 return ret;