widl: Strip last separator in append_namespaces if suffix is NULL.
[wine.git] / dlls / dpnet / server.c
blob977771697ac9f4b9a5ff50a83cca680362d266ac
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
23 #include <stdarg.h>
25 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wingdi.h"
29 #include "winuser.h"
30 #include "objbase.h"
31 #include "ocidl.h"
32 #include "wine/debug.h"
34 #include "dpnet_private.h"
36 typedef struct IDirectPlay8ServerImpl
38 IDirectPlay8Server IDirectPlay8Server_iface;
39 LONG ref;
41 PFNDPNMESSAGEHANDLER msghandler;
42 DWORD flags;
43 void *usercontext;
45 WCHAR *servername;
46 void *data;
47 DWORD datasize;
48 } IDirectPlay8ServerImpl;
50 WINE_DEFAULT_DEBUG_CHANNEL(dpnet);
52 static inline IDirectPlay8ServerImpl *impl_from_IDirectPlay8Server(IDirectPlay8Server *iface)
54 return CONTAINING_RECORD(iface, IDirectPlay8ServerImpl, IDirectPlay8Server_iface);
57 static HRESULT WINAPI IDirectPlay8ServerImpl_QueryInterface(IDirectPlay8Server *iface, REFIID riid, void **ppv)
59 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
61 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppv);
63 if (IsEqualGUID(riid, &IID_IUnknown) ||
64 IsEqualGUID(riid, &IID_IDirectPlay8Server))
66 TRACE("(%p)->(IID_IDirectPlay8Server %p)\n", This, ppv);
67 *ppv = &This->IDirectPlay8Server_iface;
69 else {
70 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
71 *ppv = NULL;
72 return E_NOINTERFACE;
75 IUnknown_AddRef((IUnknown*)*ppv);
76 return S_OK;
79 static ULONG WINAPI IDirectPlay8ServerImpl_AddRef(IDirectPlay8Server *iface)
81 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
82 ULONG ref = InterlockedIncrement(&This->ref);
84 TRACE("(%p) ref=%d\n", This, ref);
86 return ref;
89 static ULONG WINAPI IDirectPlay8ServerImpl_Release(IDirectPlay8Server *iface)
91 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
92 ULONG ref = InterlockedDecrement(&This->ref);
94 TRACE("(%p) ref=%d\n", This, ref);
96 if (!ref)
98 heap_free(This->servername);
99 heap_free(This->data);
100 heap_free(This);
103 return ref;
106 static HRESULT WINAPI IDirectPlay8ServerImpl_Initialize(IDirectPlay8Server *iface, PVOID pvUserContext,
107 PFNDPNMESSAGEHANDLER pfn, DWORD dwFlags)
109 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
110 TRACE("(%p)->(%p %p %d)\n", This, pvUserContext, pfn, dwFlags);
112 if(!pfn)
113 return DPNERR_INVALIDPARAM;
115 This->usercontext = pvUserContext;
116 This->msghandler = pfn;
117 This->flags = dwFlags;
119 init_winsock();
121 return DPN_OK;
124 static HRESULT WINAPI IDirectPlay8ServerImpl_EnumServiceProviders(IDirectPlay8Server *iface, const GUID *pguidServiceProvider,
125 const GUID *pguidApplication, DPN_SERVICE_PROVIDER_INFO *pSPInfoBuffer, PDWORD pcbEnumData,
126 PDWORD pcReturned, DWORD dwFlags)
128 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
129 FIXME("(%p)->(%s %s %p %p %p %d)\n", This, debugstr_guid(pguidServiceProvider), debugstr_guid(pguidApplication),
130 pSPInfoBuffer, pcbEnumData, pcReturned, dwFlags);
131 return E_NOTIMPL;
134 static HRESULT WINAPI IDirectPlay8ServerImpl_CancelAsyncOperation(IDirectPlay8Server *iface, DPNHANDLE hAsyncHandle, DWORD dwFlags)
136 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
137 FIXME("(%p)->(%d %d)\n", This, hAsyncHandle, dwFlags);
138 return E_NOTIMPL;
141 static HRESULT WINAPI IDirectPlay8ServerImpl_GetSendQueueInfo(IDirectPlay8Server *iface, DPNID dpnid, DWORD *pdwNumMsgs,
142 DWORD *pdwNumBytes, DWORD dwFlags)
144 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
145 FIXME("(%p)->(%d %p %p %d)\n", This, dpnid, pdwNumMsgs, pdwNumBytes, dwFlags);
146 return E_NOTIMPL;
149 static HRESULT WINAPI IDirectPlay8ServerImpl_GetApplicationDesc(IDirectPlay8Server *iface, DPN_APPLICATION_DESC *pAppDescBuffer,
150 DWORD *pcbDataSize, DWORD dwFlags)
152 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
153 FIXME("(%p)->(%p %p %d)\n", This, pAppDescBuffer, pcbDataSize, dwFlags);
154 return E_NOTIMPL;
157 static HRESULT WINAPI IDirectPlay8ServerImpl_SetServerInfo(IDirectPlay8Server *iface, const DPN_PLAYER_INFO *pdpnPlayerInfo,
158 PVOID pvAsyncContext, DPNHANDLE *phAsyncHandle, DWORD dwFlags)
160 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
162 FIXME("(%p)->(%p %p %p %x) Semi-stub\n", This, pdpnPlayerInfo, pvAsyncContext, phAsyncHandle, dwFlags);
164 if(!pdpnPlayerInfo)
165 return E_POINTER;
167 if(!This->msghandler)
168 return DPNERR_UNINITIALIZED;
170 if(phAsyncHandle)
171 FIXME("Async handle currently not supported.\n");
173 if (pdpnPlayerInfo->dwInfoFlags & DPNINFO_NAME)
175 heap_free(This->servername);
176 This->servername = NULL;
178 if(pdpnPlayerInfo->pwszName)
180 This->servername = heap_strdupW(pdpnPlayerInfo->pwszName);
181 if (!This->servername)
182 return E_OUTOFMEMORY;
186 if (pdpnPlayerInfo->dwInfoFlags & DPNINFO_DATA)
188 heap_free(This->data);
189 This->data = NULL;
190 This->datasize = 0;
192 if(!pdpnPlayerInfo->pvData && pdpnPlayerInfo->dwDataSize)
193 return E_POINTER;
195 if(pdpnPlayerInfo->dwDataSize && pdpnPlayerInfo->pvData)
197 This->data = heap_alloc(pdpnPlayerInfo->dwDataSize);
198 if (!This->data)
199 return E_OUTOFMEMORY;
201 This->datasize = pdpnPlayerInfo->dwDataSize;
203 memcpy(This->data, pdpnPlayerInfo->pvData, pdpnPlayerInfo->dwDataSize);
207 /* TODO: Send DPN_MSGID_SERVER_INFO message to all players. */
208 return S_OK;
211 static HRESULT WINAPI IDirectPlay8ServerImpl_GetClientInfo(IDirectPlay8Server *iface, DPNID dpnid, DPN_PLAYER_INFO *pdpnPlayerInfo,
212 DWORD *pdwSize, DWORD dwFlags)
214 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
215 FIXME("(%p)->(%d %p %p %d)\n", This, dpnid, pdpnPlayerInfo, pdwSize, dwFlags);
216 return E_NOTIMPL;
219 static HRESULT WINAPI IDirectPlay8ServerImpl_GetClientAddress(IDirectPlay8Server *iface, DPNID dpnid, IDirectPlay8Address **pAddress,
220 DWORD dwFlags)
222 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
223 FIXME("(%p)->(%d %p %d)\n", This, dpnid, pAddress, dwFlags);
224 return E_NOTIMPL;
227 static HRESULT WINAPI IDirectPlay8ServerImpl_GetLocalHostAddresses(IDirectPlay8Server *iface, IDirectPlay8Address **prgpAddress,
228 DWORD *pcAddress, DWORD dwFlags)
230 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
231 FIXME("(%p)->(%p %p %d)\n", This, prgpAddress, pcAddress, dwFlags);
232 return E_NOTIMPL;
235 static HRESULT WINAPI IDirectPlay8ServerImpl_SetApplicationDesc(IDirectPlay8Server *iface, const DPN_APPLICATION_DESC *pad, DWORD dwFlags)
237 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
238 FIXME("(%p)->(%p %d)\n", This, pad, dwFlags);
239 return E_NOTIMPL;
242 static HRESULT WINAPI IDirectPlay8ServerImpl_Host(IDirectPlay8Server *iface, const DPN_APPLICATION_DESC *pdnAppDesc,
243 IDirectPlay8Address **prgpDeviceInfo, DWORD cDeviceInfo, const DPN_SECURITY_DESC *pdnSecurity,
244 const DPN_SECURITY_CREDENTIALS *pdnCredentials, void *pvPlayerContext, DWORD dwFlags)
246 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
247 FIXME("(%p)->(%p %p %d %p %p %p %d)\n", This, pdnAppDesc, prgpDeviceInfo, cDeviceInfo, pdnSecurity, pdnCredentials,
248 pvPlayerContext, dwFlags);
249 return E_NOTIMPL;
252 static HRESULT WINAPI IDirectPlay8ServerImpl_SendTo(IDirectPlay8Server *iface, DPNID dpnid, const DPN_BUFFER_DESC *prgBufferDesc,
253 DWORD cBufferDesc, DWORD dwTimeOut, void *pvAsyncContext, DPNHANDLE *phAsyncHandle, DWORD dwFlags)
255 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
256 FIXME("(%p)->(%d %p %d %d %p %p %d)\n", This, dpnid, prgBufferDesc, cBufferDesc, dwTimeOut, pvAsyncContext, phAsyncHandle,
257 dwFlags);
258 return E_NOTIMPL;
261 static HRESULT WINAPI IDirectPlay8ServerImpl_CreateGroup(IDirectPlay8Server *iface, const DPN_GROUP_INFO *pdpnGroupInfo,
262 void *pvGroupContext, void *pvAsyncContext, DPNHANDLE *phAsyncHandle, DWORD dwFlags)
264 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
265 FIXME("(%p)->(%p %p %p %p %d)\n", This, pdpnGroupInfo, pvGroupContext, pvAsyncContext, phAsyncHandle, dwFlags);
266 return E_NOTIMPL;
269 static HRESULT WINAPI IDirectPlay8ServerImpl_DestroyGroup(IDirectPlay8Server *iface, DPNID idGroup, PVOID pvAsyncContext,
270 DPNHANDLE *phAsyncHandle, DWORD dwFlags)
272 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
273 FIXME("(%p)->(%d %p %p %d)\n", This, idGroup, pvAsyncContext, phAsyncHandle, dwFlags);
274 return E_NOTIMPL;
277 static HRESULT WINAPI IDirectPlay8ServerImpl_AddPlayerToGroup(IDirectPlay8Server *iface, DPNID idGroup, DPNID idClient,
278 PVOID pvAsyncContext, DPNHANDLE *phAsyncHandle, DWORD dwFlags)
280 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
281 FIXME("(%p)->(%d %d %p %p %d)\n", This, idGroup, idClient, pvAsyncContext, phAsyncHandle, dwFlags);
282 return E_NOTIMPL;
285 static HRESULT WINAPI IDirectPlay8ServerImpl_RemovePlayerFromGroup(IDirectPlay8Server *iface, DPNID idGroup, DPNID idClient,
286 PVOID pvAsyncContext, DPNHANDLE *phAsyncHandle, DWORD dwFlags)
288 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
289 FIXME("(%p)->(%d %d %p %p %d)\n", This, idGroup, idClient, pvAsyncContext, phAsyncHandle, dwFlags);
290 return E_NOTIMPL;
293 static HRESULT WINAPI IDirectPlay8ServerImpl_SetGroupInfo(IDirectPlay8Server *iface, DPNID dpnid, DPN_GROUP_INFO *pdpnGroupInfo,
294 PVOID pvAsyncContext, DPNHANDLE *phAsyncHandle, DWORD dwFlags)
296 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
297 FIXME("(%p)->(%d %p %p %p %d)\n", This, dpnid, pdpnGroupInfo, pvAsyncContext, phAsyncHandle, dwFlags);
298 return E_NOTIMPL;
301 static HRESULT WINAPI IDirectPlay8ServerImpl_GetGroupInfo(IDirectPlay8Server *iface, DPNID dpnid, DPN_GROUP_INFO *pdpnGroupInfo,
302 DWORD *pdwSize, DWORD dwFlags)
304 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
305 FIXME("(%p)->(%d %p %p %d)\n", This, dpnid, pdpnGroupInfo, pdwSize, dwFlags);
306 return E_NOTIMPL;
309 static HRESULT WINAPI IDirectPlay8ServerImpl_EnumPlayersAndGroups(IDirectPlay8Server *iface, DPNID *prgdpnid, DWORD *pcdpnid, DWORD dwFlags)
311 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
312 FIXME("(%p)->(%p %p %d)\n", This, prgdpnid, pcdpnid, dwFlags);
313 return E_NOTIMPL;
316 static HRESULT WINAPI IDirectPlay8ServerImpl_EnumGroupMembers(IDirectPlay8Server *iface, DPNID dpnid, DPNID *prgdpnid, DWORD *pcdpnid, DWORD dwFlags)
318 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
319 FIXME("(%p)->(%d %p %p %d)\n", This, dpnid, prgdpnid, pcdpnid, dwFlags);
320 return E_NOTIMPL;
323 static HRESULT WINAPI IDirectPlay8ServerImpl_Close(IDirectPlay8Server *iface, DWORD dwFlags)
325 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
326 FIXME("(%p)->(%d)\n", This, dwFlags);
327 return E_NOTIMPL;
330 static HRESULT WINAPI IDirectPlay8ServerImpl_DestroyClient(IDirectPlay8Server *iface, DPNID dpnidClient, const void *pvDestroyData,
331 DWORD dwDestroyDataSize, DWORD dwFlags)
333 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
334 FIXME("(%p)->(%d %p %d %d)\n", This, dpnidClient, pvDestroyData, dwDestroyDataSize, dwFlags);
335 return E_NOTIMPL;
338 static HRESULT WINAPI IDirectPlay8ServerImpl_ReturnBuffer(IDirectPlay8Server *iface, DPNHANDLE hBufferHandle, DWORD dwFlags)
340 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
341 FIXME("(%p)->(%d %d)\n", This, hBufferHandle, dwFlags);
342 return E_NOTIMPL;
345 static HRESULT WINAPI IDirectPlay8ServerImpl_GetPlayerContext(IDirectPlay8Server *iface, DPNID dpnid, PVOID *ppvPlayerContext, DWORD dwFlags)
347 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
348 FIXME("(%p)->(%d %p %d)\n", This, dpnid, ppvPlayerContext, dwFlags);
349 return E_NOTIMPL;
352 static HRESULT WINAPI IDirectPlay8ServerImpl_GetGroupContext(IDirectPlay8Server *iface, DPNID dpnid, PVOID *ppvGroupContext, DWORD dwFlags)
354 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
355 FIXME("(%p)->(%d %p %d)\n", This, dpnid, ppvGroupContext, dwFlags);
356 return E_NOTIMPL;
359 static HRESULT WINAPI IDirectPlay8ServerImpl_GetCaps(IDirectPlay8Server *iface, DPN_CAPS *pdpCaps, DWORD dwFlags)
361 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
362 FIXME("(%p)->(%p %d)\n", This, pdpCaps, dwFlags);
363 return E_NOTIMPL;
366 static HRESULT WINAPI IDirectPlay8ServerImpl_SetCaps(IDirectPlay8Server *iface, const DPN_CAPS *pdpCaps, DWORD dwFlags)
368 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
369 FIXME("(%p)->(%p %d)\n", This, pdpCaps, dwFlags);
370 return E_NOTIMPL;
373 static HRESULT WINAPI IDirectPlay8ServerImpl_SetSPCaps(IDirectPlay8Server *iface, const GUID *pguidSP, const DPN_SP_CAPS *pdpspCaps, DWORD dwFlags )
375 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
376 FIXME("(%p)->(%p %p %d)\n", This, pguidSP, pdpspCaps, dwFlags);
377 return E_NOTIMPL;
380 static HRESULT WINAPI IDirectPlay8ServerImpl_GetSPCaps(IDirectPlay8Server *iface, const GUID *pguidSP, DPN_SP_CAPS *pdpspCaps, DWORD dwFlags)
382 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
383 FIXME("(%p)->(%p %p %d)\n", This, pguidSP, pdpspCaps, dwFlags);
384 return E_NOTIMPL;
387 static HRESULT WINAPI IDirectPlay8ServerImpl_GetConnectionInfo(IDirectPlay8Server *iface, DPNID dpnid,
388 DPN_CONNECTION_INFO *pdpConnectionInfo, DWORD dwFlags)
390 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
391 FIXME("(%p)->(%d %p %d)\n", This, dpnid, pdpConnectionInfo, dwFlags);
392 return E_NOTIMPL;
395 static HRESULT WINAPI IDirectPlay8ServerImpl_RegisterLobby(IDirectPlay8Server *iface, DPNHANDLE dpnHandle,
396 struct IDirectPlay8LobbiedApplication *pIDP8LobbiedApplication, DWORD dwFlags)
398 IDirectPlay8ServerImpl *This = impl_from_IDirectPlay8Server(iface);
399 FIXME("(%p)->(%d %p %d)\n", This, dpnHandle, pIDP8LobbiedApplication, dwFlags);
400 return E_NOTIMPL;
403 static const IDirectPlay8ServerVtbl DirectPlay8ServerVtbl =
405 IDirectPlay8ServerImpl_QueryInterface,
406 IDirectPlay8ServerImpl_AddRef,
407 IDirectPlay8ServerImpl_Release,
408 IDirectPlay8ServerImpl_Initialize,
409 IDirectPlay8ServerImpl_EnumServiceProviders,
410 IDirectPlay8ServerImpl_CancelAsyncOperation,
411 IDirectPlay8ServerImpl_GetSendQueueInfo,
412 IDirectPlay8ServerImpl_GetApplicationDesc,
413 IDirectPlay8ServerImpl_SetServerInfo,
414 IDirectPlay8ServerImpl_GetClientInfo,
415 IDirectPlay8ServerImpl_GetClientAddress,
416 IDirectPlay8ServerImpl_GetLocalHostAddresses,
417 IDirectPlay8ServerImpl_SetApplicationDesc,
418 IDirectPlay8ServerImpl_Host,
419 IDirectPlay8ServerImpl_SendTo,
420 IDirectPlay8ServerImpl_CreateGroup,
421 IDirectPlay8ServerImpl_DestroyGroup,
422 IDirectPlay8ServerImpl_AddPlayerToGroup,
423 IDirectPlay8ServerImpl_RemovePlayerFromGroup,
424 IDirectPlay8ServerImpl_SetGroupInfo,
425 IDirectPlay8ServerImpl_GetGroupInfo,
426 IDirectPlay8ServerImpl_EnumPlayersAndGroups,
427 IDirectPlay8ServerImpl_EnumGroupMembers,
428 IDirectPlay8ServerImpl_Close,
429 IDirectPlay8ServerImpl_DestroyClient,
430 IDirectPlay8ServerImpl_ReturnBuffer,
431 IDirectPlay8ServerImpl_GetPlayerContext,
432 IDirectPlay8ServerImpl_GetGroupContext,
433 IDirectPlay8ServerImpl_GetCaps,
434 IDirectPlay8ServerImpl_SetCaps,
435 IDirectPlay8ServerImpl_SetSPCaps,
436 IDirectPlay8ServerImpl_GetSPCaps,
437 IDirectPlay8ServerImpl_GetConnectionInfo,
438 IDirectPlay8ServerImpl_RegisterLobby
441 HRESULT DPNET_CreateDirectPlay8Server(IClassFactory *iface, IUnknown *pUnkOuter, REFIID riid, void **ppv)
443 IDirectPlay8ServerImpl *server;
444 HRESULT hr;
446 TRACE("(%p, %s, %p)\n", pUnkOuter, debugstr_guid(riid), ppv);
448 *ppv = NULL;
450 if(pUnkOuter)
451 return CLASS_E_NOAGGREGATION;
453 server = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8ServerImpl));
454 if (!server)
455 return E_OUTOFMEMORY;
457 server->IDirectPlay8Server_iface.lpVtbl = &DirectPlay8ServerVtbl;
458 server->ref = 1;
459 server->usercontext = NULL;
460 server->msghandler = NULL;
461 server->flags = 0;
463 hr = IDirectPlay8Server_QueryInterface(&server->IDirectPlay8Server_iface, riid, ppv);
464 IDirectPlay8Server_Release(&server->IDirectPlay8Server_iface);
466 return hr;