~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/dplayx/lobbysp.c

Version: ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /* This contains the implementation of the Lobby Service
  2  * Providers interface required to communicate with Direct Play
  3  *
  4  * Copyright 2001 Peter Hunnisett
  5  *
  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.
 10  *
 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.
 15  *
 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
 19  */
 20 
 21 #include "winerror.h"
 22 #include "wine/debug.h"
 23 
 24 #include "lobbysp.h"
 25 #include "dplay_global.h"
 26 #include "dpinit.h"
 27 
 28 WINE_DEFAULT_DEBUG_CHANNEL(dplay);
 29 
 30 /* Prototypes */
 31 static BOOL DPLSP_CreateIUnknown( LPVOID lpSP );
 32 static BOOL DPLSP_DestroyIUnknown( LPVOID lpSP );
 33 static BOOL DPLSP_CreateDPLobbySP( LPVOID lpSP, IDirectPlay2Impl* dp );
 34 static BOOL DPLSP_DestroyDPLobbySP( LPVOID lpSP );
 35 
 36 
 37 /* Predefine the interface */
 38 typedef struct IDPLobbySPImpl IDPLobbySPImpl;
 39 
 40 typedef struct tagDPLobbySPIUnknownData
 41 {
 42   LONG              ulObjRef;
 43   CRITICAL_SECTION  DPLSP_lock;
 44 } DPLobbySPIUnknownData;
 45 
 46 typedef struct tagDPLobbySPData
 47 {
 48   IDirectPlay2Impl* dplay;
 49 } DPLobbySPData;
 50 
 51 #define DPLSP_IMPL_FIELDS \
 52    LONG ulInterfaceRef; \
 53    DPLobbySPIUnknownData* unk; \
 54    DPLobbySPData* sp;
 55 
 56 struct IDPLobbySPImpl
 57 {
 58   const IDPLobbySPVtbl *lpVtbl;
 59   DPLSP_IMPL_FIELDS
 60 };
 61 
 62 /* Forward declaration of virtual tables */
 63 static const IDPLobbySPVtbl dpLobbySPVT;
 64 
 65 HRESULT DPLSP_CreateInterface( REFIID riid, LPVOID* ppvObj, IDirectPlay2Impl* dp )
 66 {
 67   TRACE( " for %s\n", debugstr_guid( riid ) );
 68 
 69   *ppvObj = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
 70                        sizeof( IDPLobbySPImpl ) );
 71 
 72   if( *ppvObj == NULL )
 73   {
 74     return DPERR_OUTOFMEMORY;
 75   }
 76 
 77   if( IsEqualGUID( &IID_IDPLobbySP, riid ) )
 78   {
 79     IDPLobbySPImpl *This = (IDPLobbySPImpl *)*ppvObj;
 80     This->lpVtbl = &dpLobbySPVT;
 81   }
 82   else
 83   {
 84     /* Unsupported interface */
 85     HeapFree( GetProcessHeap(), 0, *ppvObj );
 86     *ppvObj = NULL;
 87 
 88     return E_NOINTERFACE;
 89   }
 90 
 91   /* Initialize it */
 92   if( DPLSP_CreateIUnknown( *ppvObj ) &&
 93       DPLSP_CreateDPLobbySP( *ppvObj, dp )
 94     )
 95   {
 96     IDPLobbySP_AddRef( (LPDPLOBBYSP)*ppvObj );
 97     return S_OK;
 98   }
 99 
100   /* Initialize failed, destroy it */
101   DPLSP_DestroyDPLobbySP( *ppvObj );
102   DPLSP_DestroyIUnknown( *ppvObj );
103 
104   HeapFree( GetProcessHeap(), 0, *ppvObj );
105   *ppvObj = NULL;
106 
107   return DPERR_NOMEMORY;
108 }
109 
110 static BOOL DPLSP_CreateIUnknown( LPVOID lpSP )
111 {
112   IDPLobbySPImpl *This = (IDPLobbySPImpl *)lpSP;
113 
114   This->unk = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->unk) ) );
115 
116   if ( This->unk == NULL )
117   {
118     return FALSE;
119   }
120 
121   InitializeCriticalSection( &This->unk->DPLSP_lock );
122   This->unk->DPLSP_lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IDPLobbySPImpl*->DPLobbySPIUnknownData*->DPLSP_lock");
123 
124   return TRUE;
125 }
126 
127 static BOOL DPLSP_DestroyIUnknown( LPVOID lpSP )
128 {
129   IDPLobbySPImpl *This = (IDPLobbySPImpl *)lpSP;
130 
131   This->unk->DPLSP_lock.DebugInfo->Spare[0] = 0;
132   DeleteCriticalSection( &This->unk->DPLSP_lock );
133   HeapFree( GetProcessHeap(), 0, This->unk );
134 
135   return TRUE;
136 }
137 
138 static BOOL DPLSP_CreateDPLobbySP( LPVOID lpSP, IDirectPlay2Impl* dp )
139 {
140   IDPLobbySPImpl *This = (IDPLobbySPImpl *)lpSP;
141 
142   This->sp = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->sp) ) );
143 
144   if ( This->sp == NULL )
145   {
146     return FALSE;
147   }
148 
149   This->sp->dplay = dp;
150 
151   /* Normally we should be keeping a reference, but since only the dplay
152    * interface that created us can destroy us, we do not keep a reference
153    * to it (ie we'd be stuck with always having one reference to the dplay
154    * object, and hence us, around).
155    * NOTE: The dp object does reference count us.
156    *
157    * FIXME: This is a kludge to get around a problem where a queryinterface
158    *        is used to get a new interface and then is closed. We will then
159    *        reference garbage. However, with this we will never deallocate
160    *        the interface we store. The correct fix is to require all
161    *        DP internal interfaces to use the This->dp2 interface which
162    *        should be changed to This->dp
163    */
164   IDirectPlayX_AddRef( (LPDIRECTPLAY2)dp );
165 
166 
167   return TRUE;
168 }
169 
170 static BOOL DPLSP_DestroyDPLobbySP( LPVOID lpSP )
171 {
172   IDPLobbySPImpl *This = (IDPLobbySPImpl *)lpSP;
173 
174   HeapFree( GetProcessHeap(), 0, This->sp );
175 
176   return TRUE;
177 }
178 
179 static
180 HRESULT WINAPI DPLSP_QueryInterface
181 ( LPDPLOBBYSP iface,
182   REFIID riid,
183   LPVOID* ppvObj
184 )
185 {
186   IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface;
187   TRACE("(%p)->(%s,%p)\n", This, debugstr_guid( riid ), ppvObj );
188 
189   *ppvObj = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
190                        sizeof( *This ) );
191 
192   if( *ppvObj == NULL )
193   {
194     return DPERR_OUTOFMEMORY;
195   }
196 
197   CopyMemory( *ppvObj, This, sizeof( *This )  );
198   (*(IDPLobbySPImpl**)ppvObj)->ulInterfaceRef = 0;
199 
200   if( IsEqualGUID( &IID_IDPLobbySP, riid ) )
201   {
202     IDPLobbySPImpl *This = (IDPLobbySPImpl *)*ppvObj;
203     This->lpVtbl = &dpLobbySPVT;
204   }
205   else
206   {
207     /* Unsupported interface */
208     HeapFree( GetProcessHeap(), 0, *ppvObj );
209     *ppvObj = NULL;
210 
211     return E_NOINTERFACE;
212   }
213 
214   IDPLobbySP_AddRef( (LPDPLOBBYSP)*ppvObj );
215 
216   return S_OK;
217 }
218 
219 static
220 ULONG WINAPI DPLSP_AddRef
221 ( LPDPLOBBYSP iface )
222 {
223   ULONG ulInterfaceRefCount, ulObjRefCount;
224   IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface;
225 
226   ulObjRefCount       = InterlockedIncrement( &This->unk->ulObjRef );
227   ulInterfaceRefCount = InterlockedIncrement( &This->ulInterfaceRef );
228 
229   TRACE( "ref count incremented to %u:%u for %p\n",
230          ulInterfaceRefCount, ulObjRefCount, This );
231 
232   return ulObjRefCount;
233 }
234 
235 static
236 ULONG WINAPI DPLSP_Release
237 ( LPDPLOBBYSP iface )
238 {
239   ULONG ulInterfaceRefCount, ulObjRefCount;
240   IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface;
241 
242   ulObjRefCount       = InterlockedDecrement( &This->unk->ulObjRef );
243   ulInterfaceRefCount = InterlockedDecrement( &This->ulInterfaceRef );
244 
245   TRACE( "ref count decremented to %u:%u for %p\n",
246          ulInterfaceRefCount, ulObjRefCount, This );
247 
248   /* Deallocate if this is the last reference to the object */
249   if( ulObjRefCount == 0 )
250   {
251      DPLSP_DestroyDPLobbySP( This );
252      DPLSP_DestroyIUnknown( This );
253   }
254 
255   if( ulInterfaceRefCount == 0 )
256   {
257     HeapFree( GetProcessHeap(), 0, This );
258   }
259 
260   return ulInterfaceRefCount;
261 }
262 
263 static
264 HRESULT WINAPI IDPLobbySPImpl_AddGroupToGroup
265 ( LPDPLOBBYSP iface,
266   LPSPDATA_ADDREMOTEGROUPTOGROUP argtg
267 )
268 {
269   IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface;
270   FIXME( "(%p)->(%p):stub\n", This, argtg );
271   return DP_OK;
272 }
273 
274 static
275 HRESULT WINAPI IDPLobbySPImpl_AddPlayerToGroup
276 ( LPDPLOBBYSP iface,
277   LPSPDATA_ADDREMOTEPLAYERTOGROUP arptg
278 )
279 {
280   IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface;
281   FIXME( "(%p)->(%p):stub\n", This, arptg );
282   return DP_OK;
283 }
284 
285 static
286 HRESULT WINAPI IDPLobbySPImpl_CreateGroup
287 ( LPDPLOBBYSP iface,
288   LPSPDATA_CREATEREMOTEGROUP crg
289 )
290 {
291   IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface;
292   FIXME( "(%p)->(%p):stub\n", This, crg );
293   return DP_OK;
294 }
295 
296 static
297 HRESULT WINAPI IDPLobbySPImpl_CreateGroupInGroup
298 ( LPDPLOBBYSP iface,
299   LPSPDATA_CREATEREMOTEGROUPINGROUP crgig
300 )
301 {
302   IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface;
303   FIXME( "(%p)->(%p):stub\n", This, crgig );
304   return DP_OK;
305 }
306 
307 static
308 HRESULT WINAPI IDPLobbySPImpl_DeleteGroupFromGroup
309 ( LPDPLOBBYSP iface,
310   LPSPDATA_DELETEREMOTEGROUPFROMGROUP drgfg
311 )
312 {
313   IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface;
314   FIXME( "(%p)->(%p):stub\n", This, drgfg );
315   return DP_OK;
316 }
317 
318 static
319 HRESULT WINAPI IDPLobbySPImpl_DeletePlayerFromGroup
320 ( LPDPLOBBYSP iface,
321   LPSPDATA_DELETEREMOTEPLAYERFROMGROUP drpfg
322 )
323 {
324   IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface;
325   FIXME( "(%p)->(%p):stub\n", This, drpfg );
326   return DP_OK;
327 }
328 
329 static
330 HRESULT WINAPI IDPLobbySPImpl_DestroyGroup
331 ( LPDPLOBBYSP iface,
332   LPSPDATA_DESTROYREMOTEGROUP drg
333 )
334 {
335   IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface;
336   FIXME( "(%p)->(%p):stub\n", This, drg );
337   return DP_OK;
338 }
339 
340 static
341 HRESULT WINAPI IDPLobbySPImpl_EnumSessionsResponse
342 ( LPDPLOBBYSP iface,
343   LPSPDATA_ENUMSESSIONSRESPONSE er
344 )
345 {
346   IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface;
347   FIXME( "(%p)->(%p):stub\n", This, er );
348   return DP_OK;
349 }
350 
351 static
352 HRESULT WINAPI IDPLobbySPImpl_GetSPDataPointer
353 ( LPDPLOBBYSP iface,
354   LPVOID* lplpData
355 )
356 {
357   IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface;
358   FIXME( "(%p)->(%p):stub\n", This, lplpData );
359   return DP_OK;
360 }
361 
362 static
363 HRESULT WINAPI IDPLobbySPImpl_HandleMessage
364 ( LPDPLOBBYSP iface,
365   LPSPDATA_HANDLEMESSAGE hm
366 )
367 {
368   IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface;
369   FIXME( "(%p)->(%p):stub\n", This, hm );
370   return DP_OK;
371 }
372 
373 static
374 HRESULT WINAPI IDPLobbySPImpl_SendChatMessage
375 ( LPDPLOBBYSP iface,
376   LPSPDATA_CHATMESSAGE cm
377 )
378 {
379   IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface;
380   FIXME( "(%p)->(%p):stub\n", This, cm );
381   return DP_OK;
382 }
383 
384 static
385 HRESULT WINAPI IDPLobbySPImpl_SetGroupName
386 ( LPDPLOBBYSP iface,
387   LPSPDATA_SETREMOTEGROUPNAME srgn
388 )
389 {
390   IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface;
391   FIXME( "(%p)->(%p):stub\n", This, srgn );
392   return DP_OK;
393 }
394 
395 static
396 HRESULT WINAPI IDPLobbySPImpl_SetPlayerName
397 ( LPDPLOBBYSP iface,
398   LPSPDATA_SETREMOTEPLAYERNAME srpn
399 )
400 {
401   IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface;
402   FIXME( "(%p)->(%p):stub\n", This, srpn );
403   return DP_OK;
404 }
405 
406 static
407 HRESULT WINAPI IDPLobbySPImpl_SetSessionDesc
408 ( LPDPLOBBYSP iface,
409   LPSPDATA_SETSESSIONDESC ssd
410 )
411 {
412   IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface;
413   FIXME( "(%p)->(%p):stub\n", This, ssd );
414   return DP_OK;
415 }
416 
417 static
418 HRESULT WINAPI IDPLobbySPImpl_SetSPDataPointer
419 ( LPDPLOBBYSP iface,
420   LPVOID lpData
421 )
422 {
423   IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface;
424   FIXME( "(%p)->(%p):stub\n", This, lpData );
425   return DP_OK;
426 }
427 
428 static
429 HRESULT WINAPI IDPLobbySPImpl_StartSession
430 ( LPDPLOBBYSP iface,
431   LPSPDATA_STARTSESSIONCOMMAND ssc
432 )
433 {
434   IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface;
435   FIXME( "(%p)->(%p):stub\n", This, ssc );
436   return DP_OK;
437 }
438 
439 
440 static const IDPLobbySPVtbl dpLobbySPVT =
441 {
442 
443   DPLSP_QueryInterface,
444   DPLSP_AddRef,
445   DPLSP_Release,
446 
447   IDPLobbySPImpl_AddGroupToGroup,
448   IDPLobbySPImpl_AddPlayerToGroup,
449   IDPLobbySPImpl_CreateGroup,
450   IDPLobbySPImpl_CreateGroupInGroup,
451   IDPLobbySPImpl_DeleteGroupFromGroup,
452   IDPLobbySPImpl_DeletePlayerFromGroup,
453   IDPLobbySPImpl_DestroyGroup,
454   IDPLobbySPImpl_EnumSessionsResponse,
455   IDPLobbySPImpl_GetSPDataPointer,
456   IDPLobbySPImpl_HandleMessage,
457   IDPLobbySPImpl_SendChatMessage,
458   IDPLobbySPImpl_SetGroupName,
459   IDPLobbySPImpl_SetPlayerName,
460   IDPLobbySPImpl_SetSessionDesc,
461   IDPLobbySPImpl_SetSPDataPointer,
462   IDPLobbySPImpl_StartSession
463 
464 };
465 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.