oleaut32/tests: Test more return values.
[wine.git] / dlls / dpnet / server.c
blob46d5fe2183d6bbd859c982f221f970574cc9b18c
1 /*
2 * DirectPlay8 Server
3 *
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
22 #include "config.h"
24 #include <stdarg.h>
26 #define COBJMACROS
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wingdi.h"
30 #include "winuser.h"
31 #include "objbase.h"
32 #include "ocidl.h"
33 #include "wine/debug.h"
35 #include "dpnet_private.h"
37 typedef struct IDirectPlay8ServerImpl
39 IDirectPlay8Server IDirectPlay8Server_iface;
40 LONG ref;
42 PFNDPNMESSAGEHANDLER msghandler;
43 DWORD flags;
44 void *usercontext;
46 WCHAR *servername;
47 void *data;
48 DWORD datasize;
49 } IDirectPlay8ServerImpl;
51 WINE_DEFAULT_DEBUG_CHANNEL(dpnet);
53 static inline IDirectPlay8ServerImpl *impl_from_IDirectPlay8Server(IDirectPlay8Server *iface)
55 return CONTAINING_RECORD(iface, IDirectPlay8ServerImpl, IDirectPlay8Server_iface);
58 static HRESULT WINAPI IDirectPlay8ServerImpl_QueryInterface(IDirectPlay8Server *iface, REFIID riid, void **ppv)
60 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
62 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppv);
64 if (IsEqualGUID(riid, &IID_IUnknown) ||
65 IsEqualGUID(riid, &IID_IDirectPlay8Server))
67 TRACE("(%p)->(IID_IDirectPlay8Server %p)\n", This, ppv);
68 *ppv = &This->IDirectPlay8Server_iface;
70 else {
71 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
72 *ppv = NULL;
73 return E_NOINTERFACE;
76 IUnknown_AddRef((IUnknown*)*ppv);
77 return S_OK;
80 static ULONG WINAPI IDirectPlay8ServerImpl_AddRef(IDirectPlay8Server *iface)
82 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
83 ULONG ref = InterlockedIncrement(&This->ref);
85 TRACE("(%p) ref=%d\n", This, ref);
87 return ref;
90 static ULONG WINAPI IDirectPlay8ServerImpl_Release(IDirectPlay8Server *iface)
92 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
93 ULONG ref = InterlockedDecrement(&This->ref);
95 TRACE("(%p) ref=%d\n", This, ref);
97 if (!ref)
99 heap_free(This->servername);
100 heap_free(This->data);
101 heap_free(This);
104 return ref;
107 static HRESULT WINAPI IDirectPlay8ServerImpl_Initialize(IDirectPlay8Server *iface, PVOID pvUserContext,
108 PFNDPNMESSAGEHANDLER pfn, DWORD dwFlags)
110 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
111 TRACE("(%p)->(%p %p %d)\n", This, 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 static HRESULT WINAPI IDirectPlay8ServerImpl_EnumServiceProviders(IDirectPlay8Server *iface, const GUID *pguidServiceProvider,
126 const GUID *pguidApplication, DPN_SERVICE_PROVIDER_INFO *pSPInfoBuffer, PDWORD pcbEnumData,
127 PDWORD pcReturned, DWORD dwFlags)
129 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
130 FIXME("(%p)->(%s %s %p %p %p %d)\n", This, debugstr_guid(pguidServiceProvider), debugstr_guid(pguidApplication),
131 pSPInfoBuffer, pcbEnumData, pcReturned, dwFlags);
132 return E_NOTIMPL;
135 static HRESULT WINAPI IDirectPlay8ServerImpl_CancelAsyncOperation(IDirectPlay8Server *iface, DPNHANDLE hAsyncHandle, DWORD dwFlags)
137 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
138 FIXME("(%p)->(%d %d)\n", This, hAsyncHandle, dwFlags);
139 return E_NOTIMPL;
142 static HRESULT WINAPI IDirectPlay8ServerImpl_GetSendQueueInfo(IDirectPlay8Server *iface, DPNID dpnid, DWORD *pdwNumMsgs,
143 DWORD *pdwNumBytes, DWORD dwFlags)
145 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
146 FIXME("(%p)->(%d %p %p %d)\n", This, dpnid, pdwNumMsgs, pdwNumBytes, dwFlags);
147 return E_NOTIMPL;
150 static HRESULT WINAPI IDirectPlay8ServerImpl_GetApplicationDesc(IDirectPlay8Server *iface, DPN_APPLICATION_DESC *pAppDescBuffer,
151 DWORD *pcbDataSize, DWORD dwFlags)
153 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
154 FIXME("(%p)->(%p %p %d)\n", This, pAppDescBuffer, pcbDataSize, dwFlags);
155 return E_NOTIMPL;
158 static HRESULT WINAPI IDirectPlay8ServerImpl_SetServerInfo(IDirectPlay8Server *iface, const DPN_PLAYER_INFO *pdpnPlayerInfo,
159 PVOID pvAsyncContext, DPNHANDLE *phAsyncHandle, DWORD dwFlags)
161 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
163 FIXME("(%p)->(%p %p %p %x) Semi-stub\n", This, pdpnPlayerInfo, pvAsyncContext, phAsyncHandle, dwFlags);
165 if(!pdpnPlayerInfo)
166 return E_POINTER;
168 if(!This->msghandler)
169 return DPNERR_UNINITIALIZED;
171 if(phAsyncHandle)
172 FIXME("Async handle currently not supported.\n");
174 if (pdpnPlayerInfo->dwInfoFlags & DPNINFO_NAME)
176 heap_free(This->servername);
177 This->servername = NULL;
179 if(pdpnPlayerInfo->pwszName)
181 This->servername = heap_strdupW(pdpnPlayerInfo->pwszName);
182 if (!This->servername)
183 return E_OUTOFMEMORY;
187 if (pdpnPlayerInfo->dwInfoFlags & DPNINFO_DATA)
189 heap_free(This->data);
190 This->data = NULL;
191 This->datasize = 0;
193 if(!pdpnPlayerInfo->pvData && pdpnPlayerInfo->dwDataSize)
194 return E_POINTER;
196 if(pdpnPlayerInfo->dwDataSize && pdpnPlayerInfo->pvData)
198 This->data = heap_alloc(pdpnPlayerInfo->dwDataSize);
199 if (!This->data)
200 return E_OUTOFMEMORY;
202 This->datasize = pdpnPlayerInfo->dwDataSize;
204 memcpy(This->data, pdpnPlayerInfo->pvData, pdpnPlayerInfo->dwDataSize);
208 /* TODO: Send DPN_MSGID_SERVER_INFO message to all players. */
209 return S_OK;
212 static HRESULT WINAPI IDirectPlay8ServerImpl_GetClientInfo(IDirectPlay8Server *iface, DPNID dpnid, DPN_PLAYER_INFO *pdpnPlayerInfo,
213 DWORD *pdwSize, DWORD dwFlags)
215 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
216 FIXME("(%p)->(%d %p %p %d)\n", This, dpnid, pdpnPlayerInfo, pdwSize, dwFlags);
217 return E_NOTIMPL;
220 static HRESULT WINAPI IDirectPlay8ServerImpl_GetClientAddress(IDirectPlay8Server *iface, DPNID dpnid, IDirectPlay8Address **pAddress,
221 DWORD dwFlags)
223 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
224 FIXME("(%p)->(%d %p %d)\n", This, dpnid, pAddress, dwFlags);
225 return E_NOTIMPL;
228 static HRESULT WINAPI IDirectPlay8ServerImpl_GetLocalHostAddresses(IDirectPlay8Server *iface, IDirectPlay8Address **prgpAddress,
229 DWORD *pcAddress, DWORD dwFlags)
231 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
232 FIXME("(%p)->(%p %p %d)\n", This, prgpAddress, pcAddress, dwFlags);
233 return E_NOTIMPL;
236 static HRESULT WINAPI IDirectPlay8ServerImpl_SetApplicationDesc(IDirectPlay8Server *iface, const DPN_APPLICATION_DESC *pad, DWORD dwFlags)
238 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
239 FIXME("(%p)->(%p %d)\n", This, pad, dwFlags);
240 return E_NOTIMPL;
243 static HRESULT WINAPI IDirectPlay8ServerImpl_Host(IDirectPlay8Server *iface, const DPN_APPLICATION_DESC *pdnAppDesc,
244 IDirectPlay8Address **prgpDeviceInfo, DWORD cDeviceInfo, const DPN_SECURITY_DESC *pdnSecurity,
245 const DPN_SECURITY_CREDENTIALS *pdnCredentials, void *pvPlayerContext, DWORD dwFlags)
247 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
248 FIXME("(%p)->(%p %p %d %p %p %p %d)\n", This, pdnAppDesc, prgpDeviceInfo, cDeviceInfo, pdnSecurity, pdnCredentials,
249 pvPlayerContext, dwFlags);
250 return E_NOTIMPL;
253 static HRESULT WINAPI IDirectPlay8ServerImpl_SendTo(IDirectPlay8Server *iface, DPNID dpnid, const DPN_BUFFER_DESC *prgBufferDesc,
254 DWORD cBufferDesc, DWORD dwTimeOut, void *pvAsyncContext, DPNHANDLE *phAsyncHandle, DWORD dwFlags)
256 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
257 FIXME("(%p)->(%d %p %d %d %p %p %d)\n", This, dpnid, prgBufferDesc, cBufferDesc, dwTimeOut, pvAsyncContext, phAsyncHandle,
258 dwFlags);
259 return E_NOTIMPL;
262 static HRESULT WINAPI IDirectPlay8ServerImpl_CreateGroup(IDirectPlay8Server *iface, const DPN_GROUP_INFO *pdpnGroupInfo,
263 void *pvGroupContext, void *pvAsyncContext, DPNHANDLE *phAsyncHandle, DWORD dwFlags)
265 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
266 FIXME("(%p)->(%p %p %p %p %d)\n", This, pdpnGroupInfo, pvGroupContext, pvAsyncContext, phAsyncHandle, dwFlags);
267 return E_NOTIMPL;
270 static HRESULT WINAPI IDirectPlay8ServerImpl_DestroyGroup(IDirectPlay8Server *iface, DPNID idGroup, PVOID pvAsyncContext,
271 DPNHANDLE *phAsyncHandle, DWORD dwFlags)
273 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
274 FIXME("(%p)->(%d %p %p %d)\n", This, idGroup, pvAsyncContext, phAsyncHandle, dwFlags);
275 return E_NOTIMPL;
278 static HRESULT WINAPI IDirectPlay8ServerImpl_AddPlayerToGroup(IDirectPlay8Server *iface, DPNID idGroup, DPNID idClient,
279 PVOID pvAsyncContext, DPNHANDLE *phAsyncHandle, DWORD dwFlags)
281 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
282 FIXME("(%p)->(%d %d %p %p %d)\n", This, idGroup, idClient, pvAsyncContext, phAsyncHandle, dwFlags);
283 return E_NOTIMPL;
286 static HRESULT WINAPI IDirectPlay8ServerImpl_RemovePlayerFromGroup(IDirectPlay8Server *iface, DPNID idGroup, DPNID idClient,
287 PVOID pvAsyncContext, DPNHANDLE *phAsyncHandle, DWORD dwFlags)
289 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
290 FIXME("(%p)->(%d %d %p %p %d)\n", This, idGroup, idClient, pvAsyncContext, phAsyncHandle, dwFlags);
291 return E_NOTIMPL;
294 static HRESULT WINAPI IDirectPlay8ServerImpl_SetGroupInfo(IDirectPlay8Server *iface, DPNID dpnid, DPN_GROUP_INFO *pdpnGroupInfo,
295 PVOID pvAsyncContext, DPNHANDLE *phAsyncHandle, DWORD dwFlags)
297 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
298 FIXME("(%p)->(%d %p %p %p %d)\n", This, dpnid, pdpnGroupInfo, pvAsyncContext, phAsyncHandle, dwFlags);
299 return E_NOTIMPL;
302 static HRESULT WINAPI IDirectPlay8ServerImpl_GetGroupInfo(IDirectPlay8Server *iface, DPNID dpnid, DPN_GROUP_INFO *pdpnGroupInfo,
303 DWORD *pdwSize, DWORD dwFlags)
305 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
306 FIXME("(%p)->(%d %p %p %d)\n", This, dpnid, pdpnGroupInfo, pdwSize, dwFlags);
307 return E_NOTIMPL;
310 static HRESULT WINAPI IDirectPlay8ServerImpl_EnumPlayersAndGroups(IDirectPlay8Server *iface, DPNID *prgdpnid, DWORD *pcdpnid, DWORD dwFlags)
312 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
313 FIXME("(%p)->(%p %p %d)\n", This, prgdpnid, pcdpnid, dwFlags);
314 return E_NOTIMPL;
317 static HRESULT WINAPI IDirectPlay8ServerImpl_EnumGroupMembers(IDirectPlay8Server *iface, DPNID dpnid, DPNID *prgdpnid, DWORD *pcdpnid, DWORD dwFlags)
319 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
320 FIXME("(%p)->(%d %p %p %d)\n", This, dpnid, prgdpnid, pcdpnid, dwFlags);
321 return E_NOTIMPL;
324 static HRESULT WINAPI IDirectPlay8ServerImpl_Close(IDirectPlay8Server *iface, DWORD dwFlags)
326 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
327 FIXME("(%p)->(%d)\n", This, dwFlags);
328 return E_NOTIMPL;
331 static HRESULT WINAPI IDirectPlay8ServerImpl_DestroyClient(IDirectPlay8Server *iface, DPNID dpnidClient, const void *pvDestroyData,
332 DWORD dwDestroyDataSize, DWORD dwFlags)
334 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
335 FIXME("(%p)->(%d %p %d %d)\n", This, dpnidClient, pvDestroyData, dwDestroyDataSize, dwFlags);
336 return E_NOTIMPL;
339 static HRESULT WINAPI IDirectPlay8ServerImpl_ReturnBuffer(IDirectPlay8Server *iface, DPNHANDLE hBufferHandle, DWORD dwFlags)
341 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
342 FIXME("(%p)->(%d %d)\n", This, hBufferHandle, dwFlags);
343 return E_NOTIMPL;
346 static HRESULT WINAPI IDirectPlay8ServerImpl_GetPlayerContext(IDirectPlay8Server *iface, DPNID dpnid, PVOID *ppvPlayerContext, DWORD dwFlags)
348 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
349 FIXME("(%p)->(%d %p %d)\n", This, dpnid, ppvPlayerContext, dwFlags);
350 return E_NOTIMPL;
353 static HRESULT WINAPI IDirectPlay8ServerImpl_GetGroupContext(IDirectPlay8Server *iface, DPNID dpnid, PVOID *ppvGroupContext, DWORD dwFlags)
355 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
356 FIXME("(%p)->(%d %p %d)\n", This, dpnid, ppvGroupContext, dwFlags);
357 return E_NOTIMPL;
360 static HRESULT WINAPI IDirectPlay8ServerImpl_GetCaps(IDirectPlay8Server *iface, DPN_CAPS *pdpCaps, DWORD dwFlags)
362 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
363 FIXME("(%p)->(%p %d)\n", This, pdpCaps, dwFlags);
364 return E_NOTIMPL;
367 static HRESULT WINAPI IDirectPlay8ServerImpl_SetCaps(IDirectPlay8Server *iface, const DPN_CAPS *pdpCaps, DWORD dwFlags)
369 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
370 FIXME("(%p)->(%p %d)\n", This, pdpCaps, dwFlags);
371 return E_NOTIMPL;
374 static HRESULT WINAPI IDirectPlay8ServerImpl_SetSPCaps(IDirectPlay8Server *iface, const GUID *pguidSP, const DPN_SP_CAPS *pdpspCaps, DWORD dwFlags )
376 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
377 FIXME("(%p)->(%p %p %d)\n", This, pguidSP, pdpspCaps, dwFlags);
378 return E_NOTIMPL;
381 static HRESULT WINAPI IDirectPlay8ServerImpl_GetSPCaps(IDirectPlay8Server *iface, const GUID *pguidSP, DPN_SP_CAPS *pdpspCaps, DWORD dwFlags)
383 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
384 FIXME("(%p)->(%p %p %d)\n", This, pguidSP, pdpspCaps, dwFlags);
385 return E_NOTIMPL;
388 static HRESULT WINAPI IDirectPlay8ServerImpl_GetConnectionInfo(IDirectPlay8Server *iface, DPNID dpnid,
389 DPN_CONNECTION_INFO *pdpConnectionInfo, DWORD dwFlags)
391 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
392 FIXME("(%p)->(%d %p %d)\n", This, dpnid, pdpConnectionInfo, dwFlags);
393 return E_NOTIMPL;
396 static HRESULT WINAPI IDirectPlay8ServerImpl_RegisterLobby(IDirectPlay8Server *iface, DPNHANDLE dpnHandle,
397 struct IDirectPlay8LobbiedApplication *pIDP8LobbiedApplication, DWORD dwFlags)
399 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
400 FIXME("(%p)->(%d %p %d)\n", This, dpnHandle, pIDP8LobbiedApplication, dwFlags);
401 return E_NOTIMPL;
404 static const IDirectPlay8ServerVtbl DirectPlay8ServerVtbl =
406 IDirectPlay8ServerImpl_QueryInterface,
407 IDirectPlay8ServerImpl_AddRef,
408 IDirectPlay8ServerImpl_Release,
409 IDirectPlay8ServerImpl_Initialize,
410 IDirectPlay8ServerImpl_EnumServiceProviders,
411 IDirectPlay8ServerImpl_CancelAsyncOperation,
412 IDirectPlay8ServerImpl_GetSendQueueInfo,
413 IDirectPlay8ServerImpl_GetApplicationDesc,
414 IDirectPlay8ServerImpl_SetServerInfo,
415 IDirectPlay8ServerImpl_GetClientInfo,
416 IDirectPlay8ServerImpl_GetClientAddress,
417 IDirectPlay8ServerImpl_GetLocalHostAddresses,
418 IDirectPlay8ServerImpl_SetApplicationDesc,
419 IDirectPlay8ServerImpl_Host,
420 IDirectPlay8ServerImpl_SendTo,
421 IDirectPlay8ServerImpl_CreateGroup,
422 IDirectPlay8ServerImpl_DestroyGroup,
423 IDirectPlay8ServerImpl_AddPlayerToGroup,
424 IDirectPlay8ServerImpl_RemovePlayerFromGroup,
425 IDirectPlay8ServerImpl_SetGroupInfo,
426 IDirectPlay8ServerImpl_GetGroupInfo,
427 IDirectPlay8ServerImpl_EnumPlayersAndGroups,
428 IDirectPlay8ServerImpl_EnumGroupMembers,
429 IDirectPlay8ServerImpl_Close,
430 IDirectPlay8ServerImpl_DestroyClient,
431 IDirectPlay8ServerImpl_ReturnBuffer,
432 IDirectPlay8ServerImpl_GetPlayerContext,
433 IDirectPlay8ServerImpl_GetGroupContext,
434 IDirectPlay8ServerImpl_GetCaps,
435 IDirectPlay8ServerImpl_SetCaps,
436 IDirectPlay8ServerImpl_SetSPCaps,
437 IDirectPlay8ServerImpl_GetSPCaps,
438 IDirectPlay8ServerImpl_GetConnectionInfo,
439 IDirectPlay8ServerImpl_RegisterLobby
442 HRESULT DPNET_CreateDirectPlay8Server(IClassFactory *iface, IUnknown *pUnkOuter, REFIID riid, void **ppv)
444 IDirectPlay8ServerImpl *server;
445 HRESULT hr;
447 TRACE("(%p, %s, %p)\n", pUnkOuter, debugstr_guid(riid), ppv);
449 *ppv = NULL;
451 if(pUnkOuter)
452 return CLASS_E_NOAGGREGATION;
454 server = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8ServerImpl));
455 if (!server)
456 return E_OUTOFMEMORY;
458 server->IDirectPlay8Server_iface.lpVtbl = &DirectPlay8ServerVtbl;
459 server->ref = 1;
460 server->usercontext = NULL;
461 server->msghandler = NULL;
462 server->flags = 0;
464 hr = IDirectPlay8Server_QueryInterface(&server->IDirectPlay8Server_iface, riid, ppv);
465 IDirectPlay8Server_Release(&server->IDirectPlay8Server_iface);
467 return hr;