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
33 #include "wine/debug.h"
35 #include "dpnet_private.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(dpnet
);
40 typedef struct IDirectPlay8PeerImpl
42 IDirectPlay8Peer IDirectPlay8Peer_iface
;
45 PFNDPNMESSAGEHANDLER msghandler
;
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
,
65 IDirectPlay8PeerImpl
* This
= impl_from_IDirectPlay8Peer(iface
);
67 if(IsEqualGUID(riid
, &IID_IUnknown
) ||
68 IsEqualGUID(riid
, &IID_IDirectPlay8Peer
))
70 IUnknown_AddRef(iface
);
75 WARN("(%p)->(%s,%p): not found\n", This
, debugstr_guid(riid
), ppobj
);
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
);
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
);
98 heap_free(This
->username
);
99 heap_free(This
->data
);
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
);
117 return DPNERR_INVALIDPARAM
;
119 This
->usercontext
= pvUserContext
;
120 This
->msghandler
= pfn
;
121 This
->flags
= dwFlags
;
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
[] = {'S','O','F','T','W','A','R','E','\\','M','i','c','r','o','s','o','f','t','\\',
132 'D','i','r','e','c','t','P','l','a','y','8','\\',
133 'S','e','r','v','i','c','e',' ','P','r','o','v','i','d','e','r','s',0};
134 static const WCHAR friendly
[] = {'F','r','i','e','n','d','l','y',' ','N','a','m','e',0};
135 static const WCHAR dp_adapterW
[] = {'L','o','c','a','l',' ','A','r','e','a',' ','C','o','n','n','e','c','t','i','o','n',
136 ' ','-',' ','I','P','v','4',0};
137 static const GUID adapter_guid
= {0x4ce725f6, 0xd3c0, 0xdade, {0xba, 0x6f, 0x11, 0xf9, 0x65, 0xbc, 0x42, 0x99}};
143 WCHAR provider
[MAX_PATH
];
146 if(!returned
|| !buf_size
)
153 res
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, serviceproviders
, 0, KEY_READ
, &key
);
154 if(res
== ERROR_FILE_NOT_FOUND
)
155 return DPNERR_DOESNOTEXIST
;
157 next_key
= RegEnumKeyW( key
, index
, provider
, MAX_PATH
);
158 while(next_key
== ERROR_SUCCESS
)
160 res
= RegGetValueW(key
, provider
, friendly
, RRF_RT_REG_SZ
, NULL
, NULL
, &size
);
161 if(res
== ERROR_SUCCESS
)
163 req_size
+= sizeof(DPN_SERVICE_PROVIDER_INFO
) + size
;
169 next_key
= RegEnumKeyW( key
, index
, provider
, MAX_PATH
);
173 else if(IsEqualGUID(service
, &CLSID_DP8SP_TCPIP
))
175 req_size
= sizeof(DPN_SERVICE_PROVIDER_INFO
) + sizeof(dp_adapterW
);
179 FIXME("Application requested a provider we don't handle (yet)\n");
180 return DPNERR_DOESNOTEXIST
;
183 if(*buf_size
< req_size
)
187 *buf_size
= req_size
;
188 return DPNERR_BUFFERTOOSMALL
;
195 char *infoend
= ((char *)info_buffer
+ (sizeof(DPN_SERVICE_PROVIDER_INFO
) * (*returned
)));
198 next_key
= RegEnumKeyW( key
, index
, provider
, MAX_PATH
);
199 while(next_key
== ERROR_SUCCESS
)
201 res
= RegGetValueW(key
, provider
, friendly
, RRF_RT_REG_SZ
, NULL
, NULL
, &size
);
202 if(res
== ERROR_SUCCESS
)
204 info_buffer
[count
].guid
= CLSID_DP8SP_TCPIP
;
205 info_buffer
[count
].pwszName
= (LPWSTR
)(infoend
+ offset
);
207 RegGetValueW(key
, provider
, friendly
, RRF_RT_REG_SZ
, NULL
, info_buffer
[count
].pwszName
, &size
);
214 next_key
= RegEnumKeyW(key
, index
, provider
, MAX_PATH
);
219 info_buffer
->pwszName
= (LPWSTR
)(info_buffer
+ 1);
220 lstrcpyW(info_buffer
->pwszName
, dp_adapterW
);
221 info_buffer
->guid
= adapter_guid
;
230 static HRESULT WINAPI
IDirectPlay8PeerImpl_EnumServiceProviders(IDirectPlay8Peer
*iface
,
231 const GUID
* const pguidServiceProvider
, const GUID
* const pguidApplication
,
232 DPN_SERVICE_PROVIDER_INFO
* const pSPInfoBuffer
, DWORD
* const pcbEnumData
,
233 DWORD
* const pcReturned
, const DWORD dwFlags
)
235 TRACE("(%p)->(%s,%s,%p,%p,%p,%x)\n", iface
, debugstr_guid(pguidServiceProvider
), debugstr_guid(pguidApplication
),
236 pSPInfoBuffer
, pcbEnumData
, pcReturned
, dwFlags
);
239 FIXME("Unhandled flags %x\n", dwFlags
);
242 FIXME("Application guid %s is currently being ignored\n", debugstr_guid(pguidApplication
));
244 return enum_services_providers(pguidServiceProvider
, pSPInfoBuffer
, pcbEnumData
, pcReturned
);
247 static HRESULT WINAPI
IDirectPlay8PeerImpl_CancelAsyncOperation(IDirectPlay8Peer
*iface
,
248 const DPNHANDLE hAsyncHandle
, const DWORD dwFlags
)
250 FIXME("(%p)->(%x,%x): stub\n", iface
, hAsyncHandle
, dwFlags
);
252 return DPNERR_GENERIC
;
255 static HRESULT WINAPI
IDirectPlay8PeerImpl_Connect(IDirectPlay8Peer
*iface
,
256 const DPN_APPLICATION_DESC
* const pdnAppDesc
, IDirectPlay8Address
* const pHostAddr
,
257 IDirectPlay8Address
* const pDeviceInfo
, const DPN_SECURITY_DESC
* const pdnSecurity
,
258 const DPN_SECURITY_CREDENTIALS
* const pdnCredentials
, const void * const pvUserConnectData
,
259 const DWORD dwUserConnectDataSize
, void * const pvPlayerContext
,
260 void * const pvAsyncContext
, DPNHANDLE
* const phAsyncHandle
, const DWORD dwFlags
)
262 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
);
264 return DPNERR_GENERIC
;
267 static HRESULT WINAPI
IDirectPlay8PeerImpl_SendTo(IDirectPlay8Peer
*iface
, const DPNID dpnId
,
268 const DPN_BUFFER_DESC
*pBufferDesc
, const DWORD cBufferDesc
, const DWORD dwTimeOut
,
269 void * const pvAsyncContext
, DPNHANDLE
* const phAsyncHandle
, const DWORD dwFlags
)
271 FIXME("(%p)->(%x,%p,%x,%x,%p,%p,%x): stub\n", iface
, dpnId
, pBufferDesc
, cBufferDesc
, dwTimeOut
, pvAsyncContext
, phAsyncHandle
, dwFlags
);
273 return DPNERR_GENERIC
;
276 static HRESULT WINAPI
IDirectPlay8PeerImpl_GetSendQueueInfo(IDirectPlay8Peer
*iface
,
277 const DPNID dpnid
, DWORD
* const pdwNumMsgs
, DWORD
* const pdwNumBytes
, const DWORD dwFlags
)
279 FIXME("(%p)->(%x,%p,%p,%x): stub\n", iface
, dpnid
, pdwNumMsgs
, pdwNumBytes
, dwFlags
);
281 return DPNERR_GENERIC
;
284 static HRESULT WINAPI
IDirectPlay8PeerImpl_Host(IDirectPlay8Peer
*iface
,
285 const DPN_APPLICATION_DESC
* const pdnAppDesc
, IDirectPlay8Address
** const prgpDeviceInfo
,
286 const DWORD cDeviceInfo
, const DPN_SECURITY_DESC
* const pdpSecurity
,
287 const DPN_SECURITY_CREDENTIALS
* const pdpCredentials
, void * const pvPlayerContext
,
290 FIXME("(%p)->(%p,%p,%x,%p,%p,%p,%x): stub\n", iface
, pdnAppDesc
, prgpDeviceInfo
, cDeviceInfo
, pdpSecurity
, pdpCredentials
, pvPlayerContext
, dwFlags
);
292 return DPNERR_GENERIC
;
295 static HRESULT WINAPI
IDirectPlay8PeerImpl_GetApplicationDesc(IDirectPlay8Peer
*iface
,
296 DPN_APPLICATION_DESC
* const pAppDescBuffer
, DWORD
* const pcbDataSize
, const DWORD dwFlags
)
298 FIXME("(%p)->(%p,%p,%x): stub\n", iface
, pAppDescBuffer
, pcbDataSize
, dwFlags
);
300 return DPNERR_GENERIC
;
303 static HRESULT WINAPI
IDirectPlay8PeerImpl_SetApplicationDesc(IDirectPlay8Peer
*iface
,
304 const DPN_APPLICATION_DESC
* const pad
, const DWORD dwFlags
)
306 FIXME("(%p)->(%p,%x): stub\n", iface
, pad
, dwFlags
);
308 return DPNERR_GENERIC
;
311 static HRESULT WINAPI
IDirectPlay8PeerImpl_CreateGroup(IDirectPlay8Peer
*iface
,
312 const DPN_GROUP_INFO
* const pdpnGroupInfo
, void * const pvGroupContext
,
313 void * const pvAsyncContext
, DPNHANDLE
* const phAsyncHandle
, const DWORD dwFlags
)
315 FIXME("(%p)->(%p,%p,%p,%p,%x): stub\n", iface
, pdpnGroupInfo
, pvGroupContext
, pvAsyncContext
, phAsyncHandle
, dwFlags
);
317 return DPNERR_GENERIC
;
320 static HRESULT WINAPI
IDirectPlay8PeerImpl_DestroyGroup(IDirectPlay8Peer
*iface
,
321 const DPNID idGroup
, void * const pvAsyncContext
, DPNHANDLE
* const phAsyncHandle
,
324 FIXME("(%p)->(%x,%p,%p,%x): stub\n", iface
, idGroup
, pvAsyncContext
, phAsyncHandle
, dwFlags
);
326 return DPNERR_GENERIC
;
329 static HRESULT WINAPI
IDirectPlay8PeerImpl_AddPlayerToGroup(IDirectPlay8Peer
*iface
,
330 const DPNID idGroup
, const DPNID idClient
, void * const pvAsyncContext
,
331 DPNHANDLE
* const phAsyncHandle
, const DWORD dwFlags
)
333 FIXME("(%p)->(%x,%x,%p,%p,%x): stub\n", iface
, idGroup
, idClient
, pvAsyncContext
, phAsyncHandle
, dwFlags
);
335 return DPNERR_GENERIC
;
338 static HRESULT WINAPI
IDirectPlay8PeerImpl_RemovePlayerFromGroup(IDirectPlay8Peer
*iface
,
339 const DPNID idGroup
, const DPNID idClient
, void * const pvAsyncContext
,
340 DPNHANDLE
* const phAsyncHandle
, const DWORD dwFlags
)
342 FIXME("(%p)->(%x,%x,%p,%p,%x): stub\n", iface
, idGroup
, idClient
, pvAsyncContext
, phAsyncHandle
, dwFlags
);
344 return DPNERR_GENERIC
;
347 static HRESULT WINAPI
IDirectPlay8PeerImpl_SetGroupInfo(IDirectPlay8Peer
*iface
, const DPNID dpnid
,
348 DPN_GROUP_INFO
* const pdpnGroupInfo
, void * const pvAsyncContext
,
349 DPNHANDLE
* const phAsyncHandle
, const DWORD dwFlags
)
351 FIXME("(%p)->(%x,%p,%p,%p,%x): stub\n", iface
, dpnid
, pdpnGroupInfo
, pvAsyncContext
, phAsyncHandle
, dwFlags
);
353 return DPNERR_GENERIC
;
356 static HRESULT WINAPI
IDirectPlay8PeerImpl_GetGroupInfo(IDirectPlay8Peer
*iface
, const DPNID dpnid
,
357 DPN_GROUP_INFO
* const pdpnGroupInfo
, DWORD
* const pdwSize
, const DWORD dwFlags
)
359 FIXME("(%p)->(%x,%p,%p,%x): stub\n", iface
, dpnid
, pdpnGroupInfo
, pdwSize
, dwFlags
);
361 return DPNERR_GENERIC
;
364 static HRESULT WINAPI
IDirectPlay8PeerImpl_EnumPlayersAndGroups(IDirectPlay8Peer
*iface
,
365 DPNID
* const prgdpnid
, DWORD
* const pcdpnid
, const DWORD dwFlags
)
367 FIXME("(%p)->(%p,%p,%x): stub\n", iface
, prgdpnid
, pcdpnid
, dwFlags
);
369 return DPNERR_GENERIC
;
372 static HRESULT WINAPI
IDirectPlay8PeerImpl_EnumGroupMembers(IDirectPlay8Peer
*iface
,
373 const DPNID dpnid
, DPNID
* const prgdpnid
, DWORD
* const pcdpnid
, const DWORD dwFlags
)
375 FIXME("(%p)->(%x,%p,%p,%x): stub\n", iface
, dpnid
, prgdpnid
, pcdpnid
, dwFlags
);
377 return DPNERR_GENERIC
;
380 static HRESULT WINAPI
IDirectPlay8PeerImpl_SetPeerInfo(IDirectPlay8Peer
*iface
,
381 const DPN_PLAYER_INFO
* const pdpnPlayerInfo
, void * const pvAsyncContext
,
382 DPNHANDLE
* const phAsyncHandle
, const DWORD dwFlags
)
384 IDirectPlay8PeerImpl
* This
= impl_from_IDirectPlay8Peer(iface
);
386 FIXME("(%p)->(%p,%p,%p,%x) Semi-stub.\n", This
, pdpnPlayerInfo
, pvAsyncContext
, phAsyncHandle
, dwFlags
);
392 FIXME("Async handle currently not supported.\n");
394 if (pdpnPlayerInfo
->dwInfoFlags
& DPNINFO_NAME
)
396 heap_free(This
->username
);
397 This
->username
= NULL
;
399 if(pdpnPlayerInfo
->pwszName
)
401 This
->username
= heap_strdupW(pdpnPlayerInfo
->pwszName
);
403 return E_OUTOFMEMORY
;
407 if (pdpnPlayerInfo
->dwInfoFlags
& DPNINFO_DATA
)
409 heap_free(This
->data
);
411 This
->datasize
= pdpnPlayerInfo
->dwDataSize
;
412 This
->data
= heap_alloc(pdpnPlayerInfo
->dwDataSize
);
414 return E_OUTOFMEMORY
;
416 memcpy(This
->data
, pdpnPlayerInfo
->pvData
, pdpnPlayerInfo
->dwDataSize
);
422 static HRESULT WINAPI
IDirectPlay8PeerImpl_GetPeerInfo(IDirectPlay8Peer
*iface
, const DPNID dpnid
,
423 DPN_PLAYER_INFO
* const pdpnPlayerInfo
, DWORD
* const pdwSize
, const DWORD dwFlags
)
425 FIXME("(%p)->(%x,%p,%p,%x): stub\n", iface
, dpnid
, pdpnPlayerInfo
, pdwSize
, dwFlags
);
427 return DPNERR_GENERIC
;
430 static HRESULT WINAPI
IDirectPlay8PeerImpl_GetPeerAddress(IDirectPlay8Peer
*iface
,
431 const DPNID dpnid
, IDirectPlay8Address
** const pAddress
, const DWORD dwFlags
)
433 FIXME("(%p)->(%x,%p,%x): stub\n", iface
, dpnid
, pAddress
, dwFlags
);
435 return DPNERR_GENERIC
;
438 static HRESULT WINAPI
IDirectPlay8PeerImpl_GetLocalHostAddresses(IDirectPlay8Peer
*iface
,
439 IDirectPlay8Address
** const prgpAddress
, DWORD
* const pcAddress
, const DWORD dwFlags
)
441 FIXME("(%p)->(%p,%p,%x): stub\n", iface
, prgpAddress
, pcAddress
, dwFlags
);
443 return DPNERR_GENERIC
;
446 static HRESULT WINAPI
IDirectPlay8PeerImpl_Close(IDirectPlay8Peer
*iface
, const DWORD dwFlags
)
448 FIXME("(%p)->(%x): stub\n", iface
, dwFlags
);
453 static HRESULT WINAPI
IDirectPlay8PeerImpl_EnumHosts(IDirectPlay8Peer
*iface
,
454 PDPN_APPLICATION_DESC
const pApplicationDesc
, IDirectPlay8Address
* const pAddrHost
,
455 IDirectPlay8Address
* const pDeviceInfo
, void * const pUserEnumData
,
456 const DWORD dwUserEnumDataSize
, const DWORD dwEnumCount
, const DWORD dwRetryInterval
,
457 const DWORD dwTimeOut
, void * const pvUserContext
, DPNHANDLE
* const pAsyncHandle
, const DWORD dwFlags
)
459 IDirectPlay8PeerImpl
* This
= impl_from_IDirectPlay8Peer(iface
);
461 FIXME("(%p)->(%p,%p,%p,%p,%x,%x,%x,%x,%p,%p,%x): stub\n",
462 This
, pApplicationDesc
, pAddrHost
, pDeviceInfo
, pUserEnumData
, dwUserEnumDataSize
, dwEnumCount
,
463 dwRetryInterval
, dwTimeOut
, pvUserContext
, pAsyncHandle
, dwFlags
);
465 if(!This
->msghandler
)
466 return DPNERR_UNINITIALIZED
;
468 if((dwFlags
& DPNENUMHOSTS_SYNC
) && pAsyncHandle
)
469 return DPNERR_INVALIDPARAM
;
471 if(dwUserEnumDataSize
> This
->spcaps
.dwMaxEnumPayloadSize
)
472 return DPNERR_ENUMQUERYTOOLARGE
;
474 return (dwFlags
& DPNENUMHOSTS_SYNC
) ? DPN_OK
: DPNSUCCESS_PENDING
;
477 static HRESULT WINAPI
IDirectPlay8PeerImpl_DestroyPeer(IDirectPlay8Peer
*iface
, const DPNID dpnidClient
,
478 const void * const pvDestroyData
, const DWORD dwDestroyDataSize
, const DWORD dwFlags
)
480 FIXME("(%p)->(%x,%p,%x,%x): stub\n", iface
, dpnidClient
, pvDestroyData
, dwDestroyDataSize
, dwFlags
);
482 return DPNERR_GENERIC
;
485 static HRESULT WINAPI
IDirectPlay8PeerImpl_ReturnBuffer(IDirectPlay8Peer
*iface
, const DPNHANDLE hBufferHandle
,
488 FIXME("(%p)->(%x,%x): stub\n", iface
, hBufferHandle
, dwFlags
);
490 return DPNERR_GENERIC
;
493 static HRESULT WINAPI
IDirectPlay8PeerImpl_GetPlayerContext(IDirectPlay8Peer
*iface
, const DPNID dpnid
,
494 void ** const ppvPlayerContext
, const DWORD dwFlags
)
496 FIXME("(%p)->(%x,%p,%x): stub\n", iface
, dpnid
, ppvPlayerContext
, dwFlags
);
498 return DPNERR_GENERIC
;
501 static HRESULT WINAPI
IDirectPlay8PeerImpl_GetGroupContext(IDirectPlay8Peer
*iface
, const DPNID dpnid
,
502 void ** const ppvGroupContext
, const DWORD dwFlags
)
504 FIXME("(%p)->(%x,%p,%x): stub\n", iface
, dpnid
, ppvGroupContext
, dwFlags
);
506 return DPNERR_GENERIC
;
509 static HRESULT WINAPI
IDirectPlay8PeerImpl_GetCaps(IDirectPlay8Peer
*iface
, DPN_CAPS
* const pdpCaps
,
512 FIXME("(%p)->(%p,%x): stub\n", iface
, pdpCaps
, dwFlags
);
514 return DPNERR_GENERIC
;
517 static HRESULT WINAPI
IDirectPlay8PeerImpl_SetCaps(IDirectPlay8Peer
*iface
, const DPN_CAPS
* const pdpCaps
,
520 FIXME("(%p)->(%p,%x): stub\n", iface
, pdpCaps
, dwFlags
);
522 return DPNERR_GENERIC
;
525 static HRESULT WINAPI
IDirectPlay8PeerImpl_SetSPCaps(IDirectPlay8Peer
*iface
, const GUID
* const pguidSP
,
526 const DPN_SP_CAPS
* const pdpspCaps
, const DWORD dwFlags
)
528 IDirectPlay8PeerImpl
* This
= impl_from_IDirectPlay8Peer(iface
);
530 TRACE("(%p)->(%p,%p,%x): stub\n", iface
, pguidSP
, pdpspCaps
, dwFlags
);
532 if(!This
->msghandler
|| pdpspCaps
->dwSize
!= sizeof(DPN_SP_CAPS
))
533 return DPNERR_INVALIDPARAM
;
535 /* Only dwSystemBufferSize is set by this call. */
536 This
->spcaps
.dwSystemBufferSize
= pdpspCaps
->dwSystemBufferSize
;
541 static HRESULT WINAPI
IDirectPlay8PeerImpl_GetSPCaps(IDirectPlay8Peer
*iface
, const GUID
* const pguidSP
,
542 DPN_SP_CAPS
* const pdpspCaps
, const DWORD dwFlags
)
544 IDirectPlay8PeerImpl
* This
= impl_from_IDirectPlay8Peer(iface
);
546 TRACE("(%p)->(%p,%p,%x)\n", This
, pguidSP
, pdpspCaps
, dwFlags
);
548 if(!This
->msghandler
)
549 return DPNERR_UNINITIALIZED
;
551 if(pdpspCaps
->dwSize
!= sizeof(DPN_SP_CAPS
))
553 return DPNERR_INVALIDPARAM
;
556 *pdpspCaps
= This
->spcaps
;
561 static HRESULT WINAPI
IDirectPlay8PeerImpl_GetConnectionInfo(IDirectPlay8Peer
*iface
, const DPNID dpnid
,
562 DPN_CONNECTION_INFO
* const pdpConnectionInfo
, const DWORD dwFlags
)
564 FIXME("(%p)->(%x,%p,%x): stub\n", iface
, dpnid
, pdpConnectionInfo
, dwFlags
);
566 return DPNERR_GENERIC
;
569 static HRESULT WINAPI
IDirectPlay8PeerImpl_RegisterLobby(IDirectPlay8Peer
*iface
, const DPNHANDLE dpnHandle
,
570 struct IDirectPlay8LobbiedApplication
* const pIDP8LobbiedApplication
, const DWORD dwFlags
)
572 FIXME("(%p)->(%x,%p,%x): stub\n", iface
, dpnHandle
, pIDP8LobbiedApplication
, dwFlags
);
574 return DPNERR_GENERIC
;
577 static HRESULT WINAPI
IDirectPlay8PeerImpl_TerminateSession(IDirectPlay8Peer
*iface
, void * const pvTerminateData
,
578 const DWORD dwTerminateDataSize
, const DWORD dwFlags
)
580 FIXME("(%p)->(%p,%x,%x): stub\n", iface
, pvTerminateData
, dwTerminateDataSize
, dwFlags
);
582 return DPNERR_GENERIC
;
585 static const IDirectPlay8PeerVtbl DirectPlay8Peer_Vtbl
=
587 IDirectPlay8PeerImpl_QueryInterface
,
588 IDirectPlay8PeerImpl_AddRef
,
589 IDirectPlay8PeerImpl_Release
,
590 IDirectPlay8PeerImpl_Initialize
,
591 IDirectPlay8PeerImpl_EnumServiceProviders
,
592 IDirectPlay8PeerImpl_CancelAsyncOperation
,
593 IDirectPlay8PeerImpl_Connect
,
594 IDirectPlay8PeerImpl_SendTo
,
595 IDirectPlay8PeerImpl_GetSendQueueInfo
,
596 IDirectPlay8PeerImpl_Host
,
597 IDirectPlay8PeerImpl_GetApplicationDesc
,
598 IDirectPlay8PeerImpl_SetApplicationDesc
,
599 IDirectPlay8PeerImpl_CreateGroup
,
600 IDirectPlay8PeerImpl_DestroyGroup
,
601 IDirectPlay8PeerImpl_AddPlayerToGroup
,
602 IDirectPlay8PeerImpl_RemovePlayerFromGroup
,
603 IDirectPlay8PeerImpl_SetGroupInfo
,
604 IDirectPlay8PeerImpl_GetGroupInfo
,
605 IDirectPlay8PeerImpl_EnumPlayersAndGroups
,
606 IDirectPlay8PeerImpl_EnumGroupMembers
,
607 IDirectPlay8PeerImpl_SetPeerInfo
,
608 IDirectPlay8PeerImpl_GetPeerInfo
,
609 IDirectPlay8PeerImpl_GetPeerAddress
,
610 IDirectPlay8PeerImpl_GetLocalHostAddresses
,
611 IDirectPlay8PeerImpl_Close
,
612 IDirectPlay8PeerImpl_EnumHosts
,
613 IDirectPlay8PeerImpl_DestroyPeer
,
614 IDirectPlay8PeerImpl_ReturnBuffer
,
615 IDirectPlay8PeerImpl_GetPlayerContext
,
616 IDirectPlay8PeerImpl_GetGroupContext
,
617 IDirectPlay8PeerImpl_GetCaps
,
618 IDirectPlay8PeerImpl_SetCaps
,
619 IDirectPlay8PeerImpl_SetSPCaps
,
620 IDirectPlay8PeerImpl_GetSPCaps
,
621 IDirectPlay8PeerImpl_GetConnectionInfo
,
622 IDirectPlay8PeerImpl_RegisterLobby
,
623 IDirectPlay8PeerImpl_TerminateSession
626 void init_dpn_sp_caps(DPN_SP_CAPS
*dpnspcaps
)
628 dpnspcaps
->dwSize
= sizeof(DPN_SP_CAPS
);
629 dpnspcaps
->dwFlags
= DPNSPCAPS_SUPPORTSDPNSRV
| DPNSPCAPS_SUPPORTSBROADCAST
|
630 DPNSPCAPS_SUPPORTSALLADAPTERS
| DPNSPCAPS_SUPPORTSTHREADPOOL
;
631 dpnspcaps
->dwNumThreads
= 3;
632 dpnspcaps
->dwDefaultEnumCount
= 5;
633 dpnspcaps
->dwDefaultEnumRetryInterval
= 1500;
634 dpnspcaps
->dwDefaultEnumTimeout
= 1500;
635 dpnspcaps
->dwMaxEnumPayloadSize
= 983;
636 dpnspcaps
->dwBuffersPerThread
= 1;
637 dpnspcaps
->dwSystemBufferSize
= 0x10000;
640 HRESULT
DPNET_CreateDirectPlay8Peer(IClassFactory
*iface
, IUnknown
*pUnkOuter
, REFIID riid
, LPVOID
*ppobj
)
642 IDirectPlay8PeerImpl
* Client
;
645 Client
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectPlay8PeerImpl
));
651 WARN("Not enough memory\n");
652 return E_OUTOFMEMORY
;
655 Client
->IDirectPlay8Peer_iface
.lpVtbl
= &DirectPlay8Peer_Vtbl
;
657 Client
->usercontext
= NULL
;
658 Client
->msghandler
= NULL
;
661 init_dpn_sp_caps(&Client
->spcaps
);
663 ret
= IDirectPlay8Peer_QueryInterface(&Client
->IDirectPlay8Peer_iface
, riid
, ppobj
);
664 IDirectPlay8Peer_Release(&Client
->IDirectPlay8Peer_iface
);