Commit 3d7cd876 authored by Peter Hunnisett's avatar Peter Hunnisett Committed by Alexandre Julliard

- Provide lobby provider COM object header file and stub implementation

- Break out dpl and dp service provider intialization - Add missing definition of E_PENDING - Resolve a few fixmes - Fix includes for dplay.h
parent 3f03975f
......@@ -16,6 +16,7 @@ C_SRCS = \
dplayx_main.c \
dplayx_messages.c \
dplobby.c \
lobbysp.c \
name_server.c
@MAKE_DLL_RULES@
......
......@@ -9,5 +9,8 @@ extern HRESULT DP_CreateInterface( REFIID riid, LPVOID* ppvObj );
extern HRESULT DPL_CreateInterface( REFIID riid, LPVOID* ppvObj );
extern HRESULT DPSP_CreateInterface( REFIID riid, LPVOID* ppvObj,
IDirectPlay2Impl* dp );
extern HRESULT DPLSP_CreateInterface( REFIID riid, LPVOID* ppvObj,
IDirectPlay2Impl* dp );
#endif
......@@ -2,6 +2,7 @@
#define __WINE_DPLAY_GLOBAL_INCLUDED
#include "dplaysp.h"
#include "lobbysp.h"
#include "dplayx_queue.h"
extern HRESULT DPL_EnumAddress( LPDPENUMADDRESSCALLBACK lpEnumAddressCallback,
......@@ -126,7 +127,14 @@ struct DPMSG
};
typedef struct DPMSG* LPDPMSG;
/* Contains all dp1 and dp2 data members */
enum SPSTATE
{
NO_PROVIDER = 0,
DP_SERVICE_PROVIDER = 1,
DP_LOBBY_PROVIDER = 2
};
/* Contains all data members. FIXME: Rename me */
typedef struct tagDirectPlay2Data
{
BOOL bConnectionOpen;
......@@ -149,11 +157,19 @@ typedef struct tagDirectPlay2Data
/* Information about the service provider active on this connection */
SPINITDATA spData;
BOOL bSPInitialized;
/* Information about the lobby server that's attached to this DP object */
SPDATA_INIT dplspData;
BOOL bDPLSPInitialized;
/* Our service provider */
HMODULE hServiceProvider;
BOOL bConnectionInitialized;
/* Our DP lobby provider */
HMODULE hDPLobbyProvider;
enum SPSTATE connectionInitialized;
/* Expected messages queue */
DPQ_HEAD( tagDP_MSG_REPLY_STRUCT_LIST ) replysExpected;
......
......@@ -168,10 +168,8 @@ static BOOL DPSP_CreateDirectPlaySP( LPVOID lpSP, IDirectPlay2Impl* dp )
* to it (ie we'd be stuck with always having one reference to the dplay
* object, and hence us, around).
* NOTE: The dp object does reference count us.
*/
/* IDirectPlayX_AddRef( (LPDIRECTPLAY2)dp ); */
/* FIXME: This is a kludge to get around a problem where a queryinterface
*
* FIXME: This is a kludge to get around a problem where a queryinterface
* is used to get a new interface and then is closed. We will then
* reference garbage. However, with this we will never deallocate
* the interface we store. The correct fix is to require all
......@@ -297,6 +295,8 @@ static HRESULT WINAPI IDirectPlaySPImpl_AddMRUEntry
{
ICOM_THIS(IDirectPlaySPImpl,iface);
/* Should be able to call the comctl32 undocumented MRU routines.
I suspect that the interface works appropriately */
FIXME( "(%p)->(%p,%p%p,0x%08lx,0x%08lx): stub\n",
This, lpSection, lpKey, lpData, dwDataSize, dwMaxEntries );
......@@ -350,6 +350,8 @@ static HRESULT WINAPI IDirectPlaySPImpl_EnumMRUEntries
{
ICOM_THIS(IDirectPlaySPImpl,iface);
/* Should be able to call the comctl32 undocumented MRU routines.
I suspect that the interface works appropriately */
FIXME( "(%p)->(%p,%p,%p,%p,): stub\n",
This, lpSection, lpKey, lpEnumMRUCallback, lpContext );
......@@ -382,7 +384,6 @@ static HRESULT WINAPI IDirectPlaySPImpl_GetSPPlayerData
LPDP_SPPLAYERDATA lpPlayerData;
ICOM_THIS(IDirectPlaySPImpl,iface);
/* TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); */
TRACE( "(%p)->(0x%08lx,%p,%p,0x%08lx)\n",
This, idPlayer, lplpData, lpdwDataSize, dwFlags );
......@@ -435,10 +436,10 @@ static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage
HRESULT hr = DPERR_GENERIC;
WORD wCommandId;
WORD wVersion;
DPSP_REPLYDATA data;
ICOM_THIS(IDirectPlaySPImpl,iface);
/* TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); */
FIXME( "(%p)->(%p,0x%08lx,%p): mostly stub\n",
This, lpMessageBody, dwMessageBodySize, lpMessageHeader );
......@@ -451,52 +452,19 @@ static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage
if( lpMsg->dwMagic != DPMSGMAGIC_DPLAYMSG )
{
ERR( "Unknown magic 0x%08lx!\n", lpMsg->dwMagic );
return DPERR_GENERIC;
}
switch( lpMsg->wCommandId )
{
/* Name server needs to handle this request */
/* FIXME: This should be done in direct play handler */
case DPMSGCMD_ENUMSESSIONSREQUEST:
{
DPSP_REPLYDATA data;
data.lpSPMessageHeader = lpMessageHeader;
data.idNameServer = 0;
data.lpISP = iface;
NS_ReplyToEnumSessionsRequest( lpMessageBody, &data, This->sp->dplay );
hr = (This->sp->dplay->dp2->spData.lpCB->Reply)( &data );
if( FAILED(hr) )
{
ERR( "Reply failed 0x%08lx\n", hr );
}
break;
}
/* Name server needs to handle this request */
/* FIXME: This should be done in direct play handler */
case DPMSGCMD_ENUMSESSIONSREPLY:
#if 0
{
NS_SetRemoteComputerAsNameServer( lpMessageHeader,
This->sp->dplay->dp2->spData.dwSPHeaderSize,
(LPDPMSG_ENUMSESSIONSREPLY)lpMessageBody,
This->sp->dplay->dp2->lpNameServerData );
const LPDWORD lpcHeader = (LPDWORD)lpMessageHeader;
/* No reply expected */
hr = DP_OK;
break;
TRACE( "lpMessageHeader = [0x%08lx] [0x%08lx] [0x%08lx] [0x%08lx] [0x%08lx]\n",
lpcHeader[0], lpcHeader[1], lpcHeader[2], lpcHeader[3], lpcHeader[4] );
}
#endif
/* Pass everything else to Direct Play */
default:
{
DPSP_REPLYDATA data;
data.lpMessage = NULL;
data.dwMessageSize = 0;
......@@ -505,11 +473,14 @@ static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage
lpMessageHeader, wCommandId, wVersion,
&data.lpMessage, &data.dwMessageSize );
if( FAILED(hr) )
{
ERR( "Command processing failed %s\n", DPLAYX_HresultToString(hr) );
}
/* Do we want a reply? */
if( data.lpMessage != NULL )
{
HRESULT hr;
data.lpSPMessageHeader = lpMessageHeader;
data.idNameServer = 0;
data.lpISP = iface;
......@@ -522,9 +493,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage
}
}
break;
}
}
return hr;
#if 0
HRESULT hr = DP_OK;
......@@ -768,8 +737,6 @@ static HRESULT WINAPI IDirectPlaySPImpl_HandleMessage
SetEvent( hReceiveEvent );
}
#endif
return hr;
}
static HRESULT WINAPI IDirectPlaySPImpl_SetSPPlayerData
......@@ -859,7 +826,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_GetSPData
*/
if( dwFlags != DPSET_REMOTE )
{
FIXME( "Undocumented dwFlags 0x%08lx used\n", dwFlags );
TRACE( "Undocumented dwFlags 0x%08lx used\n", dwFlags );
}
#endif
......@@ -918,7 +885,7 @@ static HRESULT WINAPI IDirectPlaySPImpl_SetSPData
*/
if( dwFlags != DPSET_REMOTE )
{
FIXME( "Undocumented dwFlags 0x%08lx used\n", dwFlags );
TRACE( "Undocumented dwFlags 0x%08lx used\n", dwFlags );
}
#endif
......
......@@ -1240,10 +1240,8 @@ LPCSTR DPLAYX_HresultToString(HRESULT hr)
return "DPERR_NOPLAYERS";
case DPERR_NOSESSIONS:
return "DPERR_NOSESSIONS";
/* This one isn't defined yet in WINE sources. I don't know the value
case DPERR_PENDING:
return "DPERR_PENDING";
*/
case DPERR_SENDTOOBIG:
return "DPERR_SENDTOOBIG";
case DPERR_TIMEOUT:
......
/* DirectPlay & DirectPlayLobby messaging implementation
*
* Copyright 2000 - Peter Hunnisett
* Copyright 2000,2001 - Peter Hunnisett
*
* <presently under construction - contact hunnise@nortelnetworks.com>
*
......@@ -17,6 +17,7 @@
#include "dplayx_messages.h"
#include "dplay_global.h"
#include "dplayx_global.h"
#include "name_server.h"
DEFAULT_DEBUG_CHANNEL(dplay);
......@@ -212,7 +213,6 @@ HRESULT DP_MSG_SendRequestPlayerId( IDirectPlay2AImpl* This, DWORD dwFlags,
TRACE( "Asking for player id w/ dwFlags 0x%08lx\n",
lpMsgBody->dwFlags );
DP_MSG_ExpectReply( This, &data, DPMSG_DEFAULT_WAIT_TIME, DPMSGCMD_NEWPLAYERIDREPLY,
&lpMsg, &dwMsgSize );
}
......@@ -267,7 +267,7 @@ HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlay2AImpl* This, DPID dpidServer )
DWORD dwDataSize;
/* SP Player remote data needs to be propagated at some point - is this the point? */
IDirectPlaySP_GetSPPlayerData( This->dp2->spData.lpISP, dpidServer, (LPVOID*)&lpPData, &dwDataSize, DPSET_REMOTE );
IDirectPlaySP_GetSPPlayerData( This->dp2->spData.lpISP, 0, (LPVOID*)&lpPData, &dwDataSize, DPSET_REMOTE );
ERR( "Player Data size is 0x%08lx\n"
"[%02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x %02x%02x]\n"
......@@ -305,11 +305,22 @@ HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlay2AImpl* This, DPID dpidServer )
lpMsgBody->unknown4[0] = 0x30;
lpMsgBody->unknown4[1] = 0xb;
lpMsgBody->unknown4[2] = 0x0;
lpMsgBody->unknown4[3] = 0x1e090002;
lpMsgBody->unknown4[3] = NS_GetNsMagic( This->dp2->lpNameServerData ) -
0x02000000;
TRACE( "Setting first magic to 0x%08lx\n", lpMsgBody->unknown4[3] );
lpMsgBody->unknown4[4] = 0x0;
lpMsgBody->unknown4[5] = 0x0;
lpMsgBody->unknown4[6] = 0x0;
lpMsgBody->unknown4[7] = 0x32090002;
#if 0
lpMsgBody->unknown4[7] = NS_GetOtherMagic( This->dp2->lpNameServerData )
#else
lpMsgBody->unknown4[7] = NS_GetNsMagic( This->dp2->lpNameServerData );
#endif
TRACE( "Setting second magic to 0x%08lx\n", lpMsgBody->unknown4[7] );
lpMsgBody->unknown4[8] = 0x0;
lpMsgBody->unknown4[9] = 0x0;
lpMsgBody->unknown4[10] = 0x0;
......@@ -331,6 +342,8 @@ HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlay2AImpl* This, DPID dpidServer )
data.bSystemMessage = TRUE; /* Allow reply to be sent */
data.lpISP = This->dp2->spData.lpISP;
TRACE( "Sending forward player request with 0x%08lx\n", dpidServer );
lpMsg = DP_MSG_ExpectReply( This, &data,
DPMSG_WAIT_60_SECS,
DPMSGCMD_GETNAMETABLEREPLY,
......@@ -372,11 +385,13 @@ LPVOID DP_MSG_ExpectReply( IDirectPlay2AImpl* This, LPDPSP_SENDDATA lpData,
if( FAILED(hr) )
{
ERR( "Request for new playerID send failed: %s\n",
DPLAYX_HresultToString( hr ) );
ERR( "Send failed: %s\n", DPLAYX_HresultToString( hr ) );
return NULL;
}
/* The reply message will trigger the hMsgReceipt event effectively switching
* control back to this thread. See DP_MSG_ReplyReceived.
*/
dwWaitReturn = WaitForSingleObject( hMsgReceipt, dwWaitTime );
if( dwWaitReturn != WAIT_OBJECT_0 )
{
......@@ -429,7 +444,43 @@ void DP_MSG_ReplyReceived( IDirectPlay2AImpl* This, WORD wCommandId,
ERR( "No receipt event set - only expecting in reply mode\n" );
DebugBreak();
}
}
void DP_MSG_ToSelf( IDirectPlay2AImpl* This, DPID dpidSelf )
{
LPVOID lpMsg;
LPDPMSG_SENDENVELOPE lpMsgBody;
DWORD dwMsgSize;
dwMsgSize = This->dp2->spData.dwSPHeaderSize + sizeof( *lpMsgBody );
lpMsg = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwMsgSize );
lpMsgBody = (LPDPMSG_SENDENVELOPE)( (BYTE*)lpMsg +
This->dp2->spData.dwSPHeaderSize );
/* Compose dplay message envelope */
lpMsgBody->dwMagic = DPMSGMAGIC_DPLAYMSG;
lpMsgBody->wCommandId = DPMSGCMD_JUSTENVELOPE;
lpMsgBody->wVersion = DPMSGVER_DP6;
/* Send the message to ourselves */
{
DPSP_SENDDATA data;
data.dwFlags = 0;
data.idPlayerTo = dpidSelf; /* Sending to session server */
data.idPlayerFrom = 0; /* Sending from session server */
data.lpMessage = lpMsg;
data.dwMessageSize = dwMsgSize;
data.bSystemMessage = TRUE; /* Allow reply to be sent */
data.lpISP = This->dp2->spData.lpISP;
lpMsg = DP_MSG_ExpectReply( This, &data,
DPMSG_WAIT_5_SECS,
DPMSGCMD_JUSTENVELOPE,
&lpMsg, &dwMsgSize );
}
}
void DP_MSG_ErrorReceived( IDirectPlay2AImpl* This, WORD wCommandId,
......
......@@ -19,6 +19,7 @@ void DP_MSG_ReplyReceived( IDirectPlay2AImpl* This, WORD wCommandId,
LPCVOID lpMsgBody, DWORD dwMsgBodySize );
void DP_MSG_ErrorReceived( IDirectPlay2AImpl* This, WORD wCommandId,
LPCVOID lpMsgBody, DWORD dwMsgBodySize );
void DP_MSG_ToSelf( IDirectPlay2AImpl* This, DPID dpidSelf );
/* Timings -> 1000 ticks/sec */
#define DPMSG_WAIT_5_SECS 5000
......@@ -47,8 +48,13 @@ void DP_MSG_ErrorReceived( IDirectPlay2AImpl* This, WORD wCommandId,
#define DPMSGCMD_FORWARDADDPLAYER 19
#define DPMSGCMD_PLAYERCHAT 22
#define DPMSGCMD_FORWARDADDPLAYERNACK 36
#define DPMSGCMD_JUSTENVELOPE 1000
#define DPMSGCMD_JUSTENVELOPEREPLY 1001
/* This is what DP 6 defines it as. Don't know what it means. All messages
* defined below are DPMSGVER_DP6.
*/
......@@ -163,21 +169,21 @@ typedef struct tagDPMSG_FORWARDADDPLAYER
DWORD unknown; /* 0 */
DPID dpidAppServer; /* Remote application server id */
DWORD unknown2[5]; /* ??? */
#define FORWARDADDPLAYER_UNKNOWN2_INIT { 0x0, 0x1c, 0x6c, 0x50, 0x9 }
DWORD unknown2[5]; /* 0x0, 0x1c, 0x6c, 0x50, 0x9 */
DPID dpidAppServer2; /* Remote application server id again !? */
DWORD unknown3[5]; /* ??? */
#define FORWARDADDPLAYER_UNKNOWN3_INIT { 0x0, 0x0, 0x20, 0x0, 0x0 }
DWORD unknown3[5]; /* 0x0, 0x0, 0x20, 0x0, 0x0 */
DPID dpidAppServer3; /* Remote application server id again !? */
DWORD unknown4[12]; /* ??? - Is this a clump of 5 and then 8? */
/* NOTE: 1 byte infront of the two 0x??090002 entries changes! */
/* NOTE: 1 byte infront of the two 0x??090002 entries changes!
* Is it a timestamp of some sort? 1st always smaller than
* other...
*/
#define FORWARDADDPLAYER_UNKNOWN4_INIT { 0x30, 0xb, 0x0, 0x1e090002, 0x0, 0x0, 0x0, 0x32090002, 0x0, 0x0, 0x0, 0x0 }
BYTE unknown5[2]; /* 2 bytes at the end. This may be a part of something! */
#define FORWARDADDPLAYER_UNKNOWN5_INIT { 0x0 }
BYTE unknown5[2]; /* 2 bytes at the end. This may be a part of something! ( 0x0, 0x0) */
} DPMSG_FORWARDADDPLAYER, *LPDPMSG_FORWARDADDPLAYER;
typedef const DPMSG_FORWARDADDPLAYER* LPCDPMSG_FORWARDADDPLAYER;
......
/* DPLAYX.DLL name server implementation
*
* Copyright 2000 - Peter Hunnisett
* Copyright 2000-2001 - Peter Hunnisett
*
* <presently under construction - contact hunnise@nortelnetworks.com>
*
......@@ -43,6 +43,10 @@ struct NSCache
lpNSCacheData present; /* keep track of what is to be looked at when walking */
DPQ_HEAD(NSCacheData) first;
BOOL bNsIsLocal;
LPVOID lpLocalAddrHdr; /* FIXME: Not yet used */
LPVOID lpRemoteAddrHdr; /* FIXME: Not yet used */
};
typedef struct NSCache NSCache, *lpNSCache;
......@@ -52,12 +56,22 @@ DPQ_DECL_DELETECB( cbDeleteNSNodeFromHeap, lpNSCacheData );
/* Name Server functions
* ---------------------
*/
void NS_SetLocalComputerAsNameServer( LPCDPSESSIONDESC2 lpsd )
void NS_SetLocalComputerAsNameServer( LPCDPSESSIONDESC2 lpsd, LPVOID lpNSInfo )
{
#if 0
/* FIXME: Remove this method? */
DPLAYX_SetLocalSession( lpsd );
#endif
lpNSCache lpCache = (lpNSCache)lpNSInfo;
lpCache->bNsIsLocal = TRUE;
}
void NS_SetRemoteComputerAsNameServer( LPCDPSESSIONDESC2 lpsd, LPVOID lpNSInfo )
{
lpNSCache lpCache = (lpNSCache)lpNSInfo;
lpCache->bNsIsLocal = FALSE;
}
DPQ_DECL_COMPARECB( cbUglyPig, GUID )
......@@ -66,7 +80,8 @@ DPQ_DECL_COMPARECB( cbUglyPig, GUID )
}
/* Store the given NS remote address for future reference */
void NS_SetRemoteComputerAsNameServer( LPVOID lpNSAddrHdr,
/* FIXME: LPDPMSG_ENUMSESSIONSREPLY should be const */
void NS_AddRemoteComputerAsNameServer( LPCVOID lpcNSAddrHdr,
DWORD dwHdrSize,
LPDPMSG_ENUMSESSIONSREPLY lpMsg,
LPVOID lpNSInfo )
......@@ -75,11 +90,7 @@ void NS_SetRemoteComputerAsNameServer( LPVOID lpNSAddrHdr,
lpNSCache lpCache = (lpNSCache)lpNSInfo;
lpNSCacheData lpCacheNode;
TRACE( "%p, %p, %p\n", lpNSAddrHdr, lpMsg, lpNSInfo );
/* FIXME: Should check to see if the reply is for an existing session. If
* so we remove the old and add the new so oldest is at front.
*/
TRACE( "%p, %p, %p\n", lpcNSAddrHdr, lpMsg, lpNSInfo );
/* See if we can find this session. If we can, remove it as it's a dup */
DPQ_REMOVE_ENTRY_CB( lpCache->first, next, data->guidInstance, cbUglyPig,
......@@ -104,12 +115,12 @@ void NS_SetRemoteComputerAsNameServer( LPVOID lpNSAddrHdr,
lpCacheNode->lpNSAddrHdr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
dwHdrSize );
CopyMemory( lpCacheNode->lpNSAddrHdr, lpNSAddrHdr, dwHdrSize );
CopyMemory( lpCacheNode->lpNSAddrHdr, lpcNSAddrHdr, dwHdrSize );
lpCacheNode->data = (LPDPSESSIONDESC2)HeapAlloc( GetProcessHeap(),
HEAP_ZERO_MEMORY,
sizeof( *lpCacheNode->data ) );
sizeof( *(lpCacheNode->data) ) );
if( lpCacheNode->data == NULL )
{
......@@ -120,8 +131,10 @@ void NS_SetRemoteComputerAsNameServer( LPVOID lpNSAddrHdr,
CopyMemory( lpCacheNode->data, &lpMsg->sd, sizeof( *lpCacheNode->data ) );
len = WideCharToMultiByte( CP_ACP, 0, (LPWSTR)(lpMsg+1), -1, NULL, 0, NULL, NULL );
if ((lpCacheNode->data->u1.lpszSessionNameA = HeapAlloc( GetProcessHeap(), 0, len )))
{
WideCharToMultiByte( CP_ACP, 0, (LPWSTR)(lpMsg+1), -1,
lpCacheNode->data->u1.lpszSessionNameA, len, NULL, NULL );
}
lpCacheNode->dwTime = timeGetTime();
......@@ -148,8 +161,38 @@ LPVOID NS_GetNSAddr( LPVOID lpNSInfo )
* must be it. That would make this method obsolete once that's
* in place.
*/
#if 1
return lpCache->first.lpQHFirst->lpNSAddrHdr;
#else
/* FIXME: Should convert over to this */
return lpCache->bNsIsLocal ? lpCache->lpLocalAddrHdr
: lpCache->lpRemoteAddrHdr;
#endif
}
/* Get the magic number associated with the Name Server */
DWORD NS_GetNsMagic( LPVOID lpNSInfo )
{
LPDWORD lpHdrInfo = (LPDWORD)NS_GetNSAddr( lpNSInfo );
return lpHdrInfo[1];
}
/* Get the magic number associated with the non NS end */
DWORD NS_GetOtherMagic( LPVOID lpNSInfo )
{
lpNSCache lpCache = (lpNSCache)lpNSInfo;
return ((LPDWORD)lpCache->lpLocalAddrHdr)[1];
}
void NS_SetLocalAddr( LPVOID lpNSInfo, LPCVOID lpHdr, DWORD dwHdrSize )
{
lpNSCache lpCache = (lpNSCache)lpNSInfo;
lpCache->lpLocalAddrHdr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwHdrSize );
CopyMemory( lpCache->lpLocalAddrHdr, lpHdr, dwHdrSize );
}
/* This function is responsible for sending a request for all other known
......@@ -216,6 +259,9 @@ void NS_InvalidateSessionCache( LPVOID lpNSInfo )
/* NULL out the walking pointer */
lpCache->present = NULL;
lpCache->bNsIsLocal = FALSE;
}
/* Create and initialize a session cache */
......@@ -235,6 +281,8 @@ BOOL NS_InitializeSessionCache( LPVOID* lplpNSInfo )
DPQ_INIT(lpCache->first);
lpCache->present = NULL;
lpCache->bNsIsLocal = FALSE;
return TRUE;
}
......@@ -280,8 +328,7 @@ void NS_PruneSessionCache( LPVOID lpNSInfo )
lpNSCache lpCache = lpNSInfo;
const DWORD dwPresentTime = timeGetTime();
const DWORD dwPrunePeriod = 60000; /* is 60 secs enough? */
const DWORD dwPruneTime = dwPresentTime - dwPrunePeriod;
const DWORD dwPrunePeriod = DPMSG_WAIT_60_SECS; /* is 60 secs enough? */
/* This silly little algorithm is based on the fact we keep entries in
* the queue in a time based order. It also assumes that it is not possible
......@@ -299,26 +346,13 @@ void NS_PruneSessionCache( LPVOID lpNSInfo )
break;
}
if( dwPruneTime > dwPresentTime ) /* 0 <= dwPresentTime <= dwPrunePeriod */
{
if( ( DPQ_FIRST(lpCache->first)->dwTime <= dwPresentTime ) ||
( DPQ_FIRST(lpCache->first)->dwTime > dwPruneTime )
)
/* Deal with time in a wrap around safe manner - unsigned arithmatic.
* Check the difference in time */
if( (dwPresentTime - (DPQ_FIRST(lpCache->first)->dwTime)) < dwPrunePeriod )
{
/* Less than dwPrunePeriod old - keep */
/* First entry has not expired yet; don't prune */
break;
}
}
else /* dwPrunePeriod <= dwPresentTime <= max dword */
{
if( ( DPQ_FIRST(lpCache->first)->dwTime <= dwPresentTime ) &&
( DPQ_FIRST(lpCache->first)->dwTime > dwPruneTime )
)
{
/* Less than dwPrunePeriod old - keep */
break;
}
}
lpFirstData = DPQ_FIRST(lpCache->first);
DPQ_REMOVE( lpCache->first, DPQ_FIRST(lpCache->first), next );
......@@ -328,33 +362,38 @@ void NS_PruneSessionCache( LPVOID lpNSInfo )
}
/* NAME SERVER Message stuff */
void NS_ReplyToEnumSessionsRequest( LPVOID lpMsg,
LPDPSP_REPLYDATA lpReplyData,
void NS_ReplyToEnumSessionsRequest( LPCVOID lpcMsg,
LPVOID* lplpReplyData,
LPDWORD lpdwReplySize,
IDirectPlay2Impl* lpDP )
{
LPDPMSG_ENUMSESSIONSREPLY rmsg;
DWORD dwVariableSize;
DWORD dwVariableLen;
/* LPDPMSG_ENUMSESSIONSREQUEST msg = (LPDPMSG_ENUMSESSIONSREQUEST)lpMsg; */
/* LPCDPMSG_ENUMSESSIONSREQUEST msg = (LPDPMSG_ENUMSESSIONSREQUEST)lpcMsg; */
BOOL bAnsi = TRUE; /* FIXME: This needs to be in the DPLAY interface */
FIXME( ": few fixed + need to check request for response\n" );
if (bAnsi)
{
dwVariableLen = MultiByteToWideChar( CP_ACP, 0,
lpDP->dp2->lpSessionDesc->u1.lpszSessionNameA,
-1, NULL, 0 );
}
else
{
dwVariableLen = strlenW( lpDP->dp2->lpSessionDesc->u1.lpszSessionName ) + 1;
}
dwVariableSize = dwVariableLen * sizeof( WCHAR );
lpReplyData->dwMessageSize = lpDP->dp2->spData.dwSPHeaderSize +
*lpdwReplySize = lpDP->dp2->spData.dwSPHeaderSize +
sizeof( *rmsg ) + dwVariableSize;
lpReplyData->lpMessage = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
lpReplyData->dwMessageSize );
*lplpReplyData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
*lpdwReplySize );
rmsg = (LPDPMSG_ENUMSESSIONSREPLY)( (BYTE*)lpReplyData->lpMessage +
rmsg = (LPDPMSG_ENUMSESSIONSREPLY)( (BYTE*)*lplpReplyData +
lpDP->dp2->spData.dwSPHeaderSize);
rmsg->envelope.dwMagic = DPMSGMAGIC_DPLAYMSG;
......@@ -365,8 +404,12 @@ void NS_ReplyToEnumSessionsRequest( LPVOID lpMsg,
sizeof( lpDP->dp2->lpSessionDesc->dwSize ) );
rmsg->dwUnknown = 0x0000005c;
if( bAnsi )
{
MultiByteToWideChar( CP_ACP, 0, lpDP->dp2->lpSessionDesc->u1.lpszSessionNameA, -1,
(LPWSTR)(rmsg+1), dwVariableLen );
}
else
{
strcpyW( (LPWSTR)(rmsg+1), lpDP->dp2->lpSessionDesc->u1.lpszSessionName );
}
}
......@@ -7,15 +7,20 @@
#include "dplayx_messages.h"
#include "dplay_global.h"
void NS_SetLocalComputerAsNameServer( LPCDPSESSIONDESC2 lpsd );
void NS_SetRemoteComputerAsNameServer( LPVOID lpNSAddrHdr,
void NS_SetLocalComputerAsNameServer( LPCDPSESSIONDESC2 lpsd, LPVOID lpNSInfo );
void NS_SetRemoteComputerAsNameServer( LPCDPSESSIONDESC2 lpsd, LPVOID lpNSInfo );
void NS_AddRemoteComputerAsNameServer( LPCVOID lpNSAddrHdr,
DWORD dwHdrSize,
LPDPMSG_ENUMSESSIONSREPLY lpMsg,
LPVOID lpNSInfo );
LPVOID NS_GetNSAddr( LPVOID lpNSInfo );
DWORD NS_GetNsMagic( LPVOID lpNSInfo );
DWORD NS_GetOtherMagic( LPVOID lpNSInfo );
void NS_SetLocalAddr( LPVOID lpNSInfo, LPCVOID lpHdr, DWORD dwHdrSize );
void NS_ReplyToEnumSessionsRequest( LPVOID lpMsg,
LPDPSP_REPLYDATA lpReplyData,
void NS_ReplyToEnumSessionsRequest( LPCVOID lpcMsg,
LPVOID* lplpReplyData,
LPDWORD lpdwReplySize,
IDirectPlay2Impl* lpDP );
HRESULT NS_SendSessionRequestBroadcast( LPCGUID lpcGuid,
......
#ifndef __WINE_DPLAY_H
#define __WINE_DPLAY_H
#include "ole2.h"
#include "wine/obj_base.h"
#ifdef __cplusplus
......
......@@ -26,7 +26,9 @@
#include <stdlib.h>
#endif
#ifndef INITGUID
#include "cguid.h"
#endif
#ifdef __cplusplus
extern "C" {
......
......@@ -1464,6 +1464,8 @@ extern int WIN32_LastError;
#define S_OK ((HRESULT)0L)
#define S_FALSE ((HRESULT)1L)
#define E_PENDING 0x8000000AL
#define E_NOTIMPL 0x80004001L
#define E_NOINTERFACE 0x80004002L
......
......@@ -49,3 +49,4 @@ DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
/* GUIDs not declared in an exported header file */
DEFINE_GUID(IID_IDirectPlaySP,0xc9f6360,0xcc61,0x11cf,0xac,0xec,0x00,0xaa,0x00,0x68,0x86,0xe3);
DEFINE_GUID(IID_ISFHelper,0x1fe68efb,0x1874,0x9812,0x56,0xdc,0x00,0x00,0x00,0x00,0x00,0x00);
DEFINE_GUID(IID_IDPLobbySP,0x5a4e5a20,0x2ced,0x11d0,0xa8,0x89,0x00,0xa0,0xc9,0x05,0x43,0x3c);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment