Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenlobbysp.c
Go to the documentation of this file.
00001 /* This contains the implementation of the Lobby Service 00002 * Providers interface required to communicate with Direct Play 00003 * 00004 * Copyright 2001 Peter Hunnisett 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 */ 00020 00021 #include "winerror.h" 00022 #include "wine/debug.h" 00023 00024 #include "lobbysp.h" 00025 #include "dplay_global.h" 00026 #include "dpinit.h" 00027 00028 WINE_DEFAULT_DEBUG_CHANNEL(dplay); 00029 00030 /* Prototypes */ 00031 static BOOL DPLSP_CreateIUnknown( LPVOID lpSP ); 00032 static BOOL DPLSP_DestroyIUnknown( LPVOID lpSP ); 00033 static BOOL DPLSP_CreateDPLobbySP( LPVOID lpSP, IDirectPlay2Impl* dp ); 00034 static BOOL DPLSP_DestroyDPLobbySP( LPVOID lpSP ); 00035 00036 00037 /* Predefine the interface */ 00038 typedef struct IDPLobbySPImpl IDPLobbySPImpl; 00039 00040 typedef struct tagDPLobbySPIUnknownData 00041 { 00042 LONG ulObjRef; 00043 CRITICAL_SECTION DPLSP_lock; 00044 } DPLobbySPIUnknownData; 00045 00046 typedef struct tagDPLobbySPData 00047 { 00048 IDirectPlay2Impl* dplay; 00049 } DPLobbySPData; 00050 00051 #define DPLSP_IMPL_FIELDS \ 00052 LONG ulInterfaceRef; \ 00053 DPLobbySPIUnknownData* unk; \ 00054 DPLobbySPData* sp; 00055 00056 struct IDPLobbySPImpl 00057 { 00058 const IDPLobbySPVtbl *lpVtbl; 00059 DPLSP_IMPL_FIELDS 00060 }; 00061 00062 /* Forward declaration of virtual tables */ 00063 static const IDPLobbySPVtbl dpLobbySPVT; 00064 00065 HRESULT DPLSP_CreateInterface( REFIID riid, LPVOID* ppvObj, IDirectPlay2Impl* dp ) 00066 { 00067 TRACE( " for %s\n", debugstr_guid( riid ) ); 00068 00069 *ppvObj = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, 00070 sizeof( IDPLobbySPImpl ) ); 00071 00072 if( *ppvObj == NULL ) 00073 { 00074 return DPERR_OUTOFMEMORY; 00075 } 00076 00077 if( IsEqualGUID( &IID_IDPLobbySP, riid ) ) 00078 { 00079 IDPLobbySPImpl *This = (IDPLobbySPImpl *)*ppvObj; 00080 This->lpVtbl = &dpLobbySPVT; 00081 } 00082 else 00083 { 00084 /* Unsupported interface */ 00085 HeapFree( GetProcessHeap(), 0, *ppvObj ); 00086 *ppvObj = NULL; 00087 00088 return E_NOINTERFACE; 00089 } 00090 00091 /* Initialize it */ 00092 if( DPLSP_CreateIUnknown( *ppvObj ) && 00093 DPLSP_CreateDPLobbySP( *ppvObj, dp ) 00094 ) 00095 { 00096 IDPLobbySP_AddRef( (LPDPLOBBYSP)*ppvObj ); 00097 return S_OK; 00098 } 00099 00100 /* Initialize failed, destroy it */ 00101 DPLSP_DestroyDPLobbySP( *ppvObj ); 00102 DPLSP_DestroyIUnknown( *ppvObj ); 00103 00104 HeapFree( GetProcessHeap(), 0, *ppvObj ); 00105 *ppvObj = NULL; 00106 00107 return DPERR_NOMEMORY; 00108 } 00109 00110 static BOOL DPLSP_CreateIUnknown( LPVOID lpSP ) 00111 { 00112 IDPLobbySPImpl *This = (IDPLobbySPImpl *)lpSP; 00113 00114 This->unk = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->unk) ) ); 00115 00116 if ( This->unk == NULL ) 00117 { 00118 return FALSE; 00119 } 00120 00121 InitializeCriticalSection( &This->unk->DPLSP_lock ); 00122 00123 return TRUE; 00124 } 00125 00126 static BOOL DPLSP_DestroyIUnknown( LPVOID lpSP ) 00127 { 00128 IDPLobbySPImpl *This = (IDPLobbySPImpl *)lpSP; 00129 00130 DeleteCriticalSection( &This->unk->DPLSP_lock ); 00131 HeapFree( GetProcessHeap(), 0, This->unk ); 00132 00133 return TRUE; 00134 } 00135 00136 static BOOL DPLSP_CreateDPLobbySP( LPVOID lpSP, IDirectPlay2Impl* dp ) 00137 { 00138 IDPLobbySPImpl *This = (IDPLobbySPImpl *)lpSP; 00139 00140 This->sp = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->sp) ) ); 00141 00142 if ( This->sp == NULL ) 00143 { 00144 return FALSE; 00145 } 00146 00147 This->sp->dplay = dp; 00148 00149 /* Normally we should be keeping a reference, but since only the dplay 00150 * interface that created us can destroy us, we do not keep a reference 00151 * to it (ie we'd be stuck with always having one reference to the dplay 00152 * object, and hence us, around). 00153 * NOTE: The dp object does reference count us. 00154 * 00155 * FIXME: This is a kludge to get around a problem where a queryinterface 00156 * is used to get a new interface and then is closed. We will then 00157 * reference garbage. However, with this we will never deallocate 00158 * the interface we store. The correct fix is to require all 00159 * DP internal interfaces to use the This->dp2 interface which 00160 * should be changed to This->dp 00161 */ 00162 IDirectPlayX_AddRef( (LPDIRECTPLAY2)dp ); 00163 00164 00165 return TRUE; 00166 } 00167 00168 static BOOL DPLSP_DestroyDPLobbySP( LPVOID lpSP ) 00169 { 00170 IDPLobbySPImpl *This = (IDPLobbySPImpl *)lpSP; 00171 00172 HeapFree( GetProcessHeap(), 0, This->sp ); 00173 00174 return TRUE; 00175 } 00176 00177 static 00178 HRESULT WINAPI DPLSP_QueryInterface 00179 ( LPDPLOBBYSP iface, 00180 REFIID riid, 00181 LPVOID* ppvObj 00182 ) 00183 { 00184 IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface; 00185 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid( riid ), ppvObj ); 00186 00187 *ppvObj = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, 00188 sizeof( *This ) ); 00189 00190 if( *ppvObj == NULL ) 00191 { 00192 return DPERR_OUTOFMEMORY; 00193 } 00194 00195 CopyMemory( *ppvObj, This, sizeof( *This ) ); 00196 (*(IDPLobbySPImpl**)ppvObj)->ulInterfaceRef = 0; 00197 00198 if( IsEqualGUID( &IID_IDPLobbySP, riid ) ) 00199 { 00200 IDPLobbySPImpl *This = (IDPLobbySPImpl *)*ppvObj; 00201 This->lpVtbl = &dpLobbySPVT; 00202 } 00203 else 00204 { 00205 /* Unsupported interface */ 00206 HeapFree( GetProcessHeap(), 0, *ppvObj ); 00207 *ppvObj = NULL; 00208 00209 return E_NOINTERFACE; 00210 } 00211 00212 IDPLobbySP_AddRef( (LPDPLOBBYSP)*ppvObj ); 00213 00214 return S_OK; 00215 } 00216 00217 static 00218 ULONG WINAPI DPLSP_AddRef 00219 ( LPDPLOBBYSP iface ) 00220 { 00221 ULONG ulInterfaceRefCount, ulObjRefCount; 00222 IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface; 00223 00224 ulObjRefCount = InterlockedIncrement( &This->unk->ulObjRef ); 00225 ulInterfaceRefCount = InterlockedIncrement( &This->ulInterfaceRef ); 00226 00227 TRACE( "ref count incremented to %lu:%lu for %p\n", 00228 ulInterfaceRefCount, ulObjRefCount, This ); 00229 00230 return ulObjRefCount; 00231 } 00232 00233 static 00234 ULONG WINAPI DPLSP_Release 00235 ( LPDPLOBBYSP iface ) 00236 { 00237 ULONG ulInterfaceRefCount, ulObjRefCount; 00238 IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface; 00239 00240 ulObjRefCount = InterlockedDecrement( &This->unk->ulObjRef ); 00241 ulInterfaceRefCount = InterlockedDecrement( &This->ulInterfaceRef ); 00242 00243 TRACE( "ref count decremented to %lu:%lu for %p\n", 00244 ulInterfaceRefCount, ulObjRefCount, This ); 00245 00246 /* Deallocate if this is the last reference to the object */ 00247 if( ulObjRefCount == 0 ) 00248 { 00249 DPLSP_DestroyDPLobbySP( This ); 00250 DPLSP_DestroyIUnknown( This ); 00251 } 00252 00253 if( ulInterfaceRefCount == 0 ) 00254 { 00255 HeapFree( GetProcessHeap(), 0, This ); 00256 } 00257 00258 return ulInterfaceRefCount; 00259 } 00260 00261 static 00262 HRESULT WINAPI IDPLobbySPImpl_AddGroupToGroup 00263 ( LPDPLOBBYSP iface, 00264 LPSPDATA_ADDREMOTEGROUPTOGROUP argtg 00265 ) 00266 { 00267 IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface; 00268 FIXME( "(%p)->(%p):stub\n", This, argtg ); 00269 return DP_OK; 00270 } 00271 00272 static 00273 HRESULT WINAPI IDPLobbySPImpl_AddPlayerToGroup 00274 ( LPDPLOBBYSP iface, 00275 LPSPDATA_ADDREMOTEPLAYERTOGROUP arptg 00276 ) 00277 { 00278 IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface; 00279 FIXME( "(%p)->(%p):stub\n", This, arptg ); 00280 return DP_OK; 00281 } 00282 00283 static 00284 HRESULT WINAPI IDPLobbySPImpl_CreateGroup 00285 ( LPDPLOBBYSP iface, 00286 LPSPDATA_CREATEREMOTEGROUP crg 00287 ) 00288 { 00289 IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface; 00290 FIXME( "(%p)->(%p):stub\n", This, crg ); 00291 return DP_OK; 00292 } 00293 00294 static 00295 HRESULT WINAPI IDPLobbySPImpl_CreateGroupInGroup 00296 ( LPDPLOBBYSP iface, 00297 LPSPDATA_CREATEREMOTEGROUPINGROUP crgig 00298 ) 00299 { 00300 IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface; 00301 FIXME( "(%p)->(%p):stub\n", This, crgig ); 00302 return DP_OK; 00303 } 00304 00305 static 00306 HRESULT WINAPI IDPLobbySPImpl_DeleteGroupFromGroup 00307 ( LPDPLOBBYSP iface, 00308 LPSPDATA_DELETEREMOTEGROUPFROMGROUP drgfg 00309 ) 00310 { 00311 IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface; 00312 FIXME( "(%p)->(%p):stub\n", This, drgfg ); 00313 return DP_OK; 00314 } 00315 00316 static 00317 HRESULT WINAPI IDPLobbySPImpl_DeletePlayerFromGroup 00318 ( LPDPLOBBYSP iface, 00319 LPSPDATA_DELETEREMOTEPLAYERFROMGROUP drpfg 00320 ) 00321 { 00322 IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface; 00323 FIXME( "(%p)->(%p):stub\n", This, drpfg ); 00324 return DP_OK; 00325 } 00326 00327 static 00328 HRESULT WINAPI IDPLobbySPImpl_DestroyGroup 00329 ( LPDPLOBBYSP iface, 00330 LPSPDATA_DESTROYREMOTEGROUP drg 00331 ) 00332 { 00333 IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface; 00334 FIXME( "(%p)->(%p):stub\n", This, drg ); 00335 return DP_OK; 00336 } 00337 00338 static 00339 HRESULT WINAPI IDPLobbySPImpl_EnumSessionsResponse 00340 ( LPDPLOBBYSP iface, 00341 LPSPDATA_ENUMSESSIONSRESPONSE er 00342 ) 00343 { 00344 IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface; 00345 FIXME( "(%p)->(%p):stub\n", This, er ); 00346 return DP_OK; 00347 } 00348 00349 static 00350 HRESULT WINAPI IDPLobbySPImpl_GetSPDataPointer 00351 ( LPDPLOBBYSP iface, 00352 LPVOID* lplpData 00353 ) 00354 { 00355 IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface; 00356 FIXME( "(%p)->(%p):stub\n", This, lplpData ); 00357 return DP_OK; 00358 } 00359 00360 static 00361 HRESULT WINAPI IDPLobbySPImpl_HandleMessage 00362 ( LPDPLOBBYSP iface, 00363 LPSPDATA_HANDLEMESSAGE hm 00364 ) 00365 { 00366 IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface; 00367 FIXME( "(%p)->(%p):stub\n", This, hm ); 00368 return DP_OK; 00369 } 00370 00371 static 00372 HRESULT WINAPI IDPLobbySPImpl_SendChatMessage 00373 ( LPDPLOBBYSP iface, 00374 LPSPDATA_CHATMESSAGE cm 00375 ) 00376 { 00377 IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface; 00378 FIXME( "(%p)->(%p):stub\n", This, cm ); 00379 return DP_OK; 00380 } 00381 00382 static 00383 HRESULT WINAPI IDPLobbySPImpl_SetGroupName 00384 ( LPDPLOBBYSP iface, 00385 LPSPDATA_SETREMOTEGROUPNAME srgn 00386 ) 00387 { 00388 IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface; 00389 FIXME( "(%p)->(%p):stub\n", This, srgn ); 00390 return DP_OK; 00391 } 00392 00393 static 00394 HRESULT WINAPI IDPLobbySPImpl_SetPlayerName 00395 ( LPDPLOBBYSP iface, 00396 LPSPDATA_SETREMOTEPLAYERNAME srpn 00397 ) 00398 { 00399 IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface; 00400 FIXME( "(%p)->(%p):stub\n", This, srpn ); 00401 return DP_OK; 00402 } 00403 00404 static 00405 HRESULT WINAPI IDPLobbySPImpl_SetSessionDesc 00406 ( LPDPLOBBYSP iface, 00407 LPSPDATA_SETSESSIONDESC ssd 00408 ) 00409 { 00410 IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface; 00411 FIXME( "(%p)->(%p):stub\n", This, ssd ); 00412 return DP_OK; 00413 } 00414 00415 static 00416 HRESULT WINAPI IDPLobbySPImpl_SetSPDataPointer 00417 ( LPDPLOBBYSP iface, 00418 LPVOID lpData 00419 ) 00420 { 00421 IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface; 00422 FIXME( "(%p)->(%p):stub\n", This, lpData ); 00423 return DP_OK; 00424 } 00425 00426 static 00427 HRESULT WINAPI IDPLobbySPImpl_StartSession 00428 ( LPDPLOBBYSP iface, 00429 LPSPDATA_STARTSESSIONCOMMAND ssc 00430 ) 00431 { 00432 IDPLobbySPImpl *This = (IDPLobbySPImpl *)iface; 00433 FIXME( "(%p)->(%p):stub\n", This, ssc ); 00434 return DP_OK; 00435 } 00436 00437 00438 static const IDPLobbySPVtbl dpLobbySPVT = 00439 { 00440 00441 DPLSP_QueryInterface, 00442 DPLSP_AddRef, 00443 DPLSP_Release, 00444 00445 IDPLobbySPImpl_AddGroupToGroup, 00446 IDPLobbySPImpl_AddPlayerToGroup, 00447 IDPLobbySPImpl_CreateGroup, 00448 IDPLobbySPImpl_CreateGroupInGroup, 00449 IDPLobbySPImpl_DeleteGroupFromGroup, 00450 IDPLobbySPImpl_DeletePlayerFromGroup, 00451 IDPLobbySPImpl_DestroyGroup, 00452 IDPLobbySPImpl_EnumSessionsResponse, 00453 IDPLobbySPImpl_GetSPDataPointer, 00454 IDPLobbySPImpl_HandleMessage, 00455 IDPLobbySPImpl_SendChatMessage, 00456 IDPLobbySPImpl_SetGroupName, 00457 IDPLobbySPImpl_SetPlayerName, 00458 IDPLobbySPImpl_SetSessionDesc, 00459 IDPLobbySPImpl_SetSPDataPointer, 00460 IDPLobbySPImpl_StartSession 00461 00462 }; Generated on Sat May 26 2012 04:20:10 for ReactOS by
1.7.6.1
|