mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
cleanup
This commit is contained in:
parent
bae7f8a641
commit
377bb36c73
5 changed files with 29 additions and 23 deletions
|
@ -1407,7 +1407,7 @@ handle_invite_button( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
|||
XP_U32 relayDevID = 0;
|
||||
XP_Bool confirmed = gtkInviteDlg( globals, &inviteAddr, &nPlayers,
|
||||
&relayDevID );
|
||||
XP_LOGF( "%s: inviteDlg => %s", __func__, boolToStr(confirmed) );
|
||||
XP_LOGFF( "gtkInviteDlg() => %s", boolToStr(confirmed) );
|
||||
|
||||
if ( confirmed ) {
|
||||
send_invites( cGlobals, nPlayers, relayDevID, NULL, &inviteAddr );
|
||||
|
@ -1417,25 +1417,25 @@ handle_invite_button( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
|||
static void
|
||||
send_invites( CommonGlobals* cGlobals, XP_U16 nPlayers,
|
||||
XP_U32 relayDevID, const XP_UCHAR* relayID,
|
||||
const CommsAddrRec* addrs )
|
||||
const CommsAddrRec* destAddr )
|
||||
{
|
||||
CommsAddrRec addr = {0};
|
||||
CommsAddrRec myAddr = {0};
|
||||
CommsCtxt* comms = cGlobals->game.comms;
|
||||
XP_ASSERT( comms );
|
||||
comms_getAddr( comms, &addr );
|
||||
comms_getAddr( comms, &myAddr );
|
||||
|
||||
gint forceChannel = 1; /* 1 is what Android does. Limits to two-device games */
|
||||
|
||||
NetLaunchInfo nli = {0};
|
||||
nli_init( &nli, cGlobals->gi, &addr, nPlayers, forceChannel );
|
||||
if ( addr_hasType( &addr, COMMS_CONN_RELAY ) ) {
|
||||
NetLaunchInfo nli = {0}; /* include everything!!! */
|
||||
nli_init( &nli, cGlobals->gi, &myAddr, nPlayers, forceChannel );
|
||||
if ( addr_hasType( &myAddr, COMMS_CONN_RELAY ) ) {
|
||||
XP_UCHAR buf[32];
|
||||
snprintf( buf, sizeof(buf), "%X", makeRandomInt() );
|
||||
nli_setInviteID( &nli, buf ); /* should not be relay only!!! */
|
||||
nli_setInviteID( &nli, buf ); /* PENDING: should not be relay only!!! */
|
||||
}
|
||||
// nli_setDevID( &nli, linux_getDevIDRelay( cGlobals->params ) );
|
||||
|
||||
if ( addr_hasType( &addr, COMMS_CONN_MQTT ) ) {
|
||||
if ( addr_hasType( &myAddr, COMMS_CONN_MQTT ) ) {
|
||||
const MQTTDevID* devid = mqttc_getDevID( cGlobals->params );
|
||||
nli_setMQTTDevID( &nli, devid );
|
||||
}
|
||||
|
@ -1452,12 +1452,12 @@ send_invites( CommonGlobals* cGlobals, XP_U16 nPlayers,
|
|||
}
|
||||
#endif
|
||||
|
||||
if ( !!addrs && '\0' != addrs->u.sms.phone[0] && 0 < addrs->u.sms.port ) {
|
||||
if ( !!destAddr && '\0' != destAddr->u.sms.phone[0] && 0 < destAddr->u.sms.port ) {
|
||||
gchar gameName[64];
|
||||
snprintf( gameName, VSIZE(gameName), "Game %d", cGlobals->gi->gameID );
|
||||
|
||||
linux_sms_invite( cGlobals->params, &nli,
|
||||
addrs->u.sms.phone, addrs->u.sms.port );
|
||||
destAddr->u.sms.phone, destAddr->u.sms.port );
|
||||
}
|
||||
|
||||
if ( 0 != relayDevID || !!relayID ) {
|
||||
|
@ -1465,8 +1465,8 @@ send_invites( CommonGlobals* cGlobals, XP_U16 nPlayers,
|
|||
relaycon_invite( cGlobals->params, relayDevID, relayID, &nli );
|
||||
}
|
||||
|
||||
if ( addr_hasType( addrs, COMMS_CONN_MQTT ) ) {
|
||||
mqttc_invite( cGlobals->params, &nli, &addrs->u.mqtt.devID );
|
||||
if ( addr_hasType( destAddr, COMMS_CONN_MQTT ) ) {
|
||||
mqttc_invite( cGlobals->params, &nli, &destAddr->u.mqtt.devID );
|
||||
}
|
||||
|
||||
/* while ( gtkaskm( "Invite how many and how?", infos, VSIZE(infos) ) ) { */
|
||||
|
|
|
@ -749,7 +749,7 @@ gameFromInvite( GtkAppGlobals* apg, const NetLaunchInfo* invite,
|
|||
}
|
||||
|
||||
void
|
||||
relayInviteReceivedGTK( void* closure, const NetLaunchInfo* invite )
|
||||
inviteReceivedGTK( void* closure, const NetLaunchInfo* invite )
|
||||
{
|
||||
GtkAppGlobals* apg = (GtkAppGlobals*)closure;
|
||||
|
||||
|
@ -951,7 +951,7 @@ gtkmain( LaunchParams* params )
|
|||
.msgNoticeReceived = gtkNoticeRcvd,
|
||||
.devIDReceived = gtkDevIDReceived,
|
||||
.msgErrorMsg = gtkErrorMsgRcvd,
|
||||
.inviteReceived = relayInviteReceivedGTK,
|
||||
.inviteReceived = inviteReceivedGTK,
|
||||
};
|
||||
|
||||
relaycon_init( params, &procs, &apg,
|
||||
|
|
|
@ -27,7 +27,7 @@ int gtkmain( LaunchParams* params );
|
|||
void windowDestroyed( GtkGameGlobals* globals );
|
||||
void gtkOnGameSaved( void* closure, sqlite3_int64 rowid, XP_Bool firstTime );
|
||||
void make_rematch( GtkAppGlobals* apg, const CommonGlobals* cGlobals );
|
||||
void relayInviteReceivedGTK( void* closure, const NetLaunchInfo* invite );
|
||||
void inviteReceivedGTK( void* closure, const NetLaunchInfo* invite );
|
||||
void msgReceivedGTK( void* closure, const CommsAddrRec* from, XP_U32 gameID,
|
||||
const XP_U8* buf, XP_U16 len );
|
||||
void gameGoneGTK( void* closure, const CommsAddrRec* from, XP_U32 gameID );
|
||||
|
|
|
@ -94,7 +94,7 @@ linux_dutil_onInviteReceived( XW_DUtilCtxt* duc, XWEnv XP_UNUSED(xwe),
|
|||
nli_makeAddrRec( nli, &addr );
|
||||
inviteReceivedCurses( params->appGlobals, nli, &addr );
|
||||
} else {
|
||||
relayInviteReceivedGTK( params->appGlobals, nli );
|
||||
inviteReceivedGTK( params->appGlobals, nli );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -331,13 +331,19 @@ linux_sms_send( LaunchParams* params, const XP_U8* buf,
|
|||
XP_U16 buflen, const XP_UCHAR* msgNo, const XP_UCHAR* phone,
|
||||
XP_U16 port, XP_U32 gameID )
|
||||
{
|
||||
XP_S16 nSent = -1;
|
||||
LinSMSData* storage = getStorage( params );
|
||||
XP_U16 waitSecs;
|
||||
SMSMsgArray* arr = smsproto_prepOutbound( storage->protoState, NULL_XWE, DATA, gameID,
|
||||
buf, buflen, phone, port,
|
||||
XP_TRUE, &waitSecs );
|
||||
sendOrRetry( params, arr, DATA, waitSecs, phone, port, gameID, msgNo );
|
||||
return buflen;
|
||||
if ( !!storage->protoState ) {
|
||||
XP_U16 waitSecs;
|
||||
SMSMsgArray* arr = smsproto_prepOutbound( storage->protoState, NULL_XWE, DATA, gameID,
|
||||
buf, buflen, phone, port,
|
||||
XP_TRUE, &waitSecs );
|
||||
sendOrRetry( params, arr, DATA, waitSecs, phone, port, gameID, msgNo );
|
||||
nSent = buflen;
|
||||
} else {
|
||||
XP_LOGFF( "dropping: sms not configured" );
|
||||
}
|
||||
return nSent;
|
||||
}
|
||||
|
||||
typedef struct _RetryClosure {
|
||||
|
|
Loading…
Reference in a new issue