mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-15 15:41:24 +01:00
Fix dialog title; send heartbeat based on when connected even if no
messages yet received; reset bt connection on palm in two stages; remove unused param. Change version number for beta.
This commit is contained in:
parent
9ec0177592
commit
e4c2143aed
4 changed files with 40 additions and 31 deletions
|
@ -43,7 +43,7 @@ compilation_error_here( "Choose one or the other or none." );
|
|||
/* It might make sense for this to be a parameter or somehow tied to the
|
||||
platform and transport. But in that case it'd have to be passed across
|
||||
since all devices must agree. */
|
||||
# define HB_INTERVAL 5
|
||||
# define HB_INTERVAL 3
|
||||
#endif
|
||||
|
||||
EXTERN_C_START
|
||||
|
@ -94,6 +94,7 @@ struct CommsCtxt {
|
|||
TransportSend sendproc;
|
||||
#ifdef COMMS_HEARTBEAT
|
||||
TransportReset resetproc;
|
||||
XP_U32 hbStartTime;
|
||||
#endif
|
||||
void* sendClosure;
|
||||
|
||||
|
@ -428,6 +429,7 @@ comms_start( CommsCtxt* comms )
|
|||
{
|
||||
#ifdef COMMS_HEARTBEAT
|
||||
comms->doHeartbeat = comms->addr.conType != COMMS_CONN_IR;
|
||||
comms->hbStartTime = util_getCurSeconds( comms->util );
|
||||
#endif
|
||||
|
||||
sendConnect( comms );
|
||||
|
@ -575,12 +577,10 @@ comms_setAddr( CommsCtxt* comms, const CommsAddrRec* addr )
|
|||
|
||||
#ifdef COMMS_HEARTBEAT
|
||||
comms->doHeartbeat = comms->addr.conType != COMMS_CONN_IR;
|
||||
comms->hbStartTime = util_getCurSeconds( comms->util );
|
||||
#endif
|
||||
sendConnect( comms );
|
||||
|
||||
#ifdef COMMS_HEARTBEAT
|
||||
comms->doHeartbeat = comms->addr.conType != COMMS_CONN_IR;
|
||||
#endif
|
||||
} /* comms_setAddr */
|
||||
|
||||
void
|
||||
|
@ -957,7 +957,7 @@ btIpPreProcess( CommsCtxt* comms, XWStreamCtxt* stream )
|
|||
|
||||
static XP_Bool
|
||||
preProcess( CommsCtxt* comms, XWStreamCtxt* stream,
|
||||
XP_Bool* usingRelay, XWHostID* senderID )
|
||||
XP_Bool* usingRelay, XWHostID* XP_UNUSED_RELAY(senderID) )
|
||||
{
|
||||
XP_Bool consumed = XP_FALSE;
|
||||
switch ( comms->addr.conType ) {
|
||||
|
@ -1211,8 +1211,10 @@ heartbeat_checks( CommsCtxt* comms )
|
|||
XP_U32 lastMsgRcvdTime = rec->lastMsgRcvdTime;
|
||||
if ( lastMsgRcvdTime == 0 ) { /* nothing received yet */
|
||||
XP_LOGF( "no last message" );
|
||||
/* do nothing; or should we send? */
|
||||
} else if ( (lastMsgRcvdTime > 0) && (lastMsgRcvdTime < tooLongAgo) ) {
|
||||
lastMsgRcvdTime = comms->hbStartTime;
|
||||
}
|
||||
XP_ASSERT( lastMsgRcvdTime > 0 );
|
||||
if ( lastMsgRcvdTime < tooLongAgo ) {
|
||||
XP_LOGF( "calling reset proc; last was %ld secs too long ago",
|
||||
tooLongAgo-lastMsgRcvdTime );
|
||||
(*comms->resetproc)(comms->sendClosure);
|
||||
|
|
|
@ -99,7 +99,7 @@
|
|||
{ "STR_ROBOT_MOVED", "The robot made this move:\n" },
|
||||
{ "STR_REMOTE_MOVED", "Remote player made this move:\n" },
|
||||
{ "STRD_ROBOT_TRADED", "%d tiles traded this turn." },
|
||||
{ "STR_ROBOT_TITLE", "Robot score" },
|
||||
{ "STR_ROBOT_TITLE", "Remote/robot score" },
|
||||
|
||||
/* The end of 4.0.5's strings */
|
||||
|
||||
|
@ -141,7 +141,7 @@
|
|||
|
||||
{ "STR_ABOUT_CONTENT",
|
||||
#ifdef XWFEATURE_BLUETOOTH
|
||||
"THANKS FOR LOOKING at this alpha version of "
|
||||
"THANKS FOR DOWNLOADING this beta version of "
|
||||
"Crosswords. Please see the notes and caveats at "
|
||||
"xwords.sf.net/bt_palm.php. Please report bugs to "
|
||||
"ehouse@users.sf.net. Enjoy!\n\n"
|
||||
|
|
|
@ -46,6 +46,8 @@ typedef enum { PBT_UNINIT = 0, PBT_MASTER, PBT_SLAVE } PBT_PicoRole;
|
|||
|
||||
typedef enum {
|
||||
PBT_ACT_NONE
|
||||
, PBT_ACT_MASTER_RESET
|
||||
, PBT_ACT_SLAVE_RESET
|
||||
, PBT_ACT_SETUP_LISTEN
|
||||
, PBT_ACT_CONNECT_ACL
|
||||
, PBT_ACT_GETSDP /* slave only */
|
||||
|
@ -159,7 +161,7 @@ static void pbt_handoffIncoming( PalmBTStuff* btStuff, BtCbEvtProc proc );
|
|||
|
||||
static void waitACL( PalmBTStuff* btStuff );
|
||||
static void pbt_reset_buffers( PalmBTStuff* btStuff );
|
||||
static void pbt_killLinks( PalmBTStuff* btStuff, BtLibSocketRef sock );
|
||||
static void pbt_killLinks( PalmBTStuff* btStuff );
|
||||
static XP_Bool pbt_checkAddress( PalmBTStuff* btStuff, const CommsAddrRec* addr );
|
||||
static void pbt_setstate( PalmBTStuff* btStuff, PBT_STATE newState,
|
||||
const char* whence );
|
||||
|
@ -226,20 +228,14 @@ void
|
|||
palm_bt_reset( PalmAppGlobals* globals )
|
||||
{
|
||||
PalmBTStuff* btStuff = globals->btStuff;
|
||||
if ( !!btStuff ) {
|
||||
if ( btStuff->dataSocket != SOCK_INVAL ) {
|
||||
pbt_killLinks( btStuff, btStuff->dataSocket );
|
||||
}
|
||||
/* nuke all pending messages */
|
||||
pbt_reset_buffers( btStuff );
|
||||
btStuff->queueLen = 0;
|
||||
|
||||
if ( !!btStuff ) {
|
||||
if ( btStuff->picoRole == PBT_MASTER ) {
|
||||
pbt_setup_master( btStuff );
|
||||
pbt_takedown_master( btStuff );
|
||||
pbt_postpone( btStuff, PBT_ACT_MASTER_RESET );
|
||||
} else if ( btStuff->picoRole == PBT_SLAVE ) {
|
||||
CommsAddrRec remoteAddr;
|
||||
comms_getAddr( globals->game.comms, &remoteAddr );
|
||||
pbt_setup_slave( btStuff, &remoteAddr );
|
||||
pbt_takedown_slave( btStuff );
|
||||
pbt_postpone( btStuff, PBT_ACT_SLAVE_RESET );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -292,7 +288,7 @@ palm_bt_doWork( PalmAppGlobals* globals, BtCbEvtProc proc, BtUIState* btUIStateP
|
|||
if ( haveWork ) {
|
||||
pbt_do_work( btStuff, proc );
|
||||
}
|
||||
if ( !!btStuff && !!btUIStateP ) {
|
||||
if ( haveWork && !!btStuff && !!btUIStateP ) {
|
||||
BtUIState btUIState = BTUI_NONE; /* default */
|
||||
switch( GET_STATE(btStuff) ) {
|
||||
case PBTST_NONE:
|
||||
|
@ -311,6 +307,9 @@ palm_bt_doWork( PalmAppGlobals* globals, BtCbEvtProc proc, BtUIState* btUIStateP
|
|||
btUIState = btStuff->picoRole == PBT_MASTER?
|
||||
BTUI_SERVING : BTUI_CONNECTED;
|
||||
break;
|
||||
default:
|
||||
XP_ASSERT(0); /* Don't add new stated without handling here */
|
||||
break;
|
||||
}
|
||||
*btUIStateP = btUIState;
|
||||
}
|
||||
|
@ -682,8 +681,13 @@ pbt_do_work( PalmBTStuff* btStuff, BtCbEvtProc proc )
|
|||
stateToStr(GET_STATE(btStuff)) );
|
||||
|
||||
switch( act ) {
|
||||
case PBT_ACT_MASTER_RESET:
|
||||
pbt_setup_master( btStuff );
|
||||
break;
|
||||
case PBT_ACT_SLAVE_RESET:
|
||||
pbt_setup_slave( btStuff, NULL );
|
||||
break;
|
||||
case PBT_ACT_SETUP_LISTEN:
|
||||
XP_ASSERT( btStuff->picoRole == PBT_MASTER );
|
||||
pbt_setup_master( btStuff );
|
||||
break;
|
||||
|
||||
|
@ -735,6 +739,7 @@ pbt_do_work( PalmBTStuff* btStuff, BtCbEvtProc proc )
|
|||
}
|
||||
/* Presumably state's been reset since PBT_ACT_GETSDP issued */
|
||||
XP_LOGF( "aborting b/c state wrong" );
|
||||
XP_ASSERT( PBT_SLAVE == btStuff->picoRole );
|
||||
pbt_close_sdpsocket( btStuff );
|
||||
SET_STATE( btStuff, PBTST_NONE );
|
||||
waitACL( btStuff );
|
||||
|
@ -1004,7 +1009,7 @@ pbt_setup_slave( PalmBTStuff* btStuff, const CommsAddrRec* addr )
|
|||
static void
|
||||
pbt_takedown_slave( PalmBTStuff* btStuff )
|
||||
{
|
||||
pbt_killLinks( btStuff, btStuff->dataSocket );
|
||||
pbt_killLinks( btStuff );
|
||||
btStuff->picoRole = PBT_UNINIT;
|
||||
}
|
||||
|
||||
|
@ -1051,11 +1056,10 @@ pbt_checkInit( PalmAppGlobals* globals, XP_Bool* userCancelledP )
|
|||
} /* pbt_checkInit */
|
||||
|
||||
static void
|
||||
pbt_killLinks( PalmBTStuff* btStuff, BtLibSocketRef sock )
|
||||
pbt_killLinks( PalmBTStuff* btStuff )
|
||||
{
|
||||
Err err;
|
||||
|
||||
XP_ASSERT( sock == btStuff->dataSocket );
|
||||
pbt_close_datasocket( btStuff );
|
||||
|
||||
if ( PBT_SLAVE == btStuff->picoRole ) {
|
||||
|
@ -1086,7 +1090,7 @@ pbt_checkAddress( PalmBTStuff* btStuff, const CommsAddrRec* addr )
|
|||
LOG_HEX( &addr->u.bt.btAddr.bits, sizeof(addr->u.bt.btAddr.bits),
|
||||
"new" );
|
||||
|
||||
pbt_killLinks( btStuff, btStuff->dataSocket );
|
||||
pbt_killLinks( btStuff );
|
||||
|
||||
XP_MEMCPY( &btStuff->otherAddr, &addr->u.bt.btAddr,
|
||||
sizeof(btStuff->otherAddr) );
|
||||
|
@ -1249,7 +1253,7 @@ socketCallback( BtLibSocketEventType* sEvent, UInt32 refCon )
|
|||
}
|
||||
|
||||
if ( PBT_SLAVE == btStuff->picoRole ) {
|
||||
pbt_killLinks( btStuff, sEvent->socket );
|
||||
pbt_killLinks( btStuff );
|
||||
waitACL( btStuff );
|
||||
} else if ( PBT_MASTER == btStuff->picoRole ) {
|
||||
pbt_close_datasocket( btStuff );
|
||||
|
@ -1274,8 +1278,9 @@ socketCallback( BtLibSocketEventType* sEvent, UInt32 refCon )
|
|||
pbt_postpone( btStuff, PBT_ACT_CONNECT_DATA );
|
||||
} else if ( sEvent->status == btLibErrSdpQueryDisconnect ) {
|
||||
/* Maybe we can just ignore this... */
|
||||
XP_ASSERT( GET_STATE(btStuff) == PBTST_NONE );
|
||||
/* waitACL( btStuff ); */
|
||||
XP_ASSERT( GET_STATE(btStuff) == PBTST_NONE ); /* still still firing!!! */
|
||||
pbt_killLinks( btStuff );
|
||||
waitACL( btStuff );
|
||||
} else {
|
||||
if ( sEvent->status == btLibErrSdpAttributeNotSet ) {
|
||||
pbt_postpone( btStuff, PBT_ACT_TELLNOHOST );
|
||||
|
@ -1396,6 +1401,8 @@ actToStr(PBT_ACTION act)
|
|||
{
|
||||
switch( act ) {
|
||||
CASESTR(PBT_ACT_NONE);
|
||||
CASESTR(PBT_ACT_MASTER_RESET);
|
||||
CASESTR(PBT_ACT_SLAVE_RESET);
|
||||
CASESTR(PBT_ACT_SETUP_LISTEN);
|
||||
CASESTR(PBT_ACT_CONNECT_ACL);
|
||||
CASESTR(PBT_ACT_GETSDP);
|
||||
|
|
|
@ -434,7 +434,7 @@
|
|||
|
||||
/* versioning stuff */
|
||||
#ifdef XWFEATURE_BLUETOOTH
|
||||
# define XW_PALM_VERSION_STRING "4.3a11"
|
||||
# define XW_PALM_VERSION_STRING "4.3b1"
|
||||
#else
|
||||
# define XW_PALM_VERSION_STRING "4.2.1"
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue