mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-13 20:48:02 +01:00
fix so invite via SMS works too (discon_ok2 test passes)
This commit is contained in:
parent
61faf1a730
commit
5bc2a38439
2 changed files with 21 additions and 11 deletions
|
@ -1188,21 +1188,23 @@ handleReplace( void* closure, int XP_UNUSED(key) )
|
||||||
return XP_TRUE;
|
return XP_TRUE;
|
||||||
} /* handleReplace */
|
} /* handleReplace */
|
||||||
|
|
||||||
#ifndef XWFEATURE_COMMS_INVITE
|
|
||||||
static bool
|
static bool
|
||||||
inviteList( CommonGlobals* cGlobals, CommsAddrRec* addr, GSList* invitees,
|
inviteList( CommonGlobals* cGlobals, CommsAddrRec* myAddr, GSList* invitees,
|
||||||
CommsConnType typ )
|
CommsConnType typ )
|
||||||
{
|
{
|
||||||
bool haveAddressees = !!invitees;
|
bool haveAddressees = !!invitees;
|
||||||
if ( haveAddressees ) {
|
if ( haveAddressees ) {
|
||||||
LaunchParams* params = cGlobals->params;
|
LaunchParams* params = cGlobals->params;
|
||||||
|
#ifdef XWFEATURE_COMMS_INVITE
|
||||||
|
CommsAddrRec destAddr = {0};
|
||||||
|
#endif
|
||||||
for ( int ii = 0; ii < g_slist_length(invitees); ++ii ) {
|
for ( int ii = 0; ii < g_slist_length(invitees); ++ii ) {
|
||||||
const XP_U16 nPlayersH = params->connInfo.inviteeCounts[ii];
|
const XP_U16 nPlayersH = params->connInfo.inviteeCounts[ii];
|
||||||
const gint forceChannel = ii + 1;
|
const gint forceChannel = ii + 1;
|
||||||
XP_LOGFF( "using nPlayersH of %d, forceChannel of %d for guest device %d",
|
XP_LOGFF( "using nPlayersH of %d, forceChannel of %d for guest device %d",
|
||||||
nPlayersH, forceChannel, ii );
|
nPlayersH, forceChannel, ii );
|
||||||
NetLaunchInfo nli = {0};
|
NetLaunchInfo nli = {0};
|
||||||
nli_init( &nli, cGlobals->gi, addr, nPlayersH, forceChannel );
|
nli_init( &nli, cGlobals->gi, myAddr, nPlayersH, forceChannel );
|
||||||
switch ( typ ) {
|
switch ( typ ) {
|
||||||
case COMMS_CONN_RELAY: {
|
case COMMS_CONN_RELAY: {
|
||||||
uint64_t inviteeRelayID = *(uint64_t*)g_slist_nth_data( invitees, ii );
|
uint64_t inviteeRelayID = *(uint64_t*)g_slist_nth_data( invitees, ii );
|
||||||
|
@ -1211,15 +1213,27 @@ inviteList( CommonGlobals* cGlobals, CommsAddrRec* addr, GSList* invitees,
|
||||||
break;
|
break;
|
||||||
case COMMS_CONN_SMS: {
|
case COMMS_CONN_SMS: {
|
||||||
const gchar* inviteePhone = (const gchar*)g_slist_nth_data( invitees, ii );
|
const gchar* inviteePhone = (const gchar*)g_slist_nth_data( invitees, ii );
|
||||||
|
#ifdef XWFEATURE_COMMS_INVITE
|
||||||
|
addr_addType( &destAddr, COMMS_CONN_SMS );
|
||||||
|
destAddr.u.sms.port = params->connInfo.sms.port;
|
||||||
|
XP_STRNCPY( destAddr.u.sms.phone, inviteePhone,
|
||||||
|
sizeof(destAddr.u.sms.phone) );
|
||||||
|
#else
|
||||||
linux_sms_invite( params, &nli, inviteePhone,
|
linux_sms_invite( params, &nli, inviteePhone,
|
||||||
params->connInfo.sms.port );
|
params->connInfo.sms.port );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COMMS_CONN_MQTT: {
|
case COMMS_CONN_MQTT: {
|
||||||
MQTTDevID devID;
|
MQTTDevID devID;
|
||||||
const gchar* str = g_slist_nth_data( invitees, ii );
|
const gchar* str = g_slist_nth_data( invitees, ii );
|
||||||
if ( strToMQTTCDevID( str, &devID ) ) {
|
if ( strToMQTTCDevID( str, &devID ) ) {
|
||||||
|
#ifdef XWFEATURE_COMMS_INVITE
|
||||||
|
addr_addType( &destAddr, COMMS_CONN_MQTT );
|
||||||
|
destAddr.u.mqtt.devID = devID;
|
||||||
|
#else
|
||||||
mqttc_invite( params, 0, &nli, &devID );
|
mqttc_invite( params, 0, &nli, &devID );
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
XP_LOGFF( "unable to convert devid %s", str );
|
XP_LOGFF( "unable to convert devid %s", str );
|
||||||
}
|
}
|
||||||
|
@ -1228,11 +1242,13 @@ inviteList( CommonGlobals* cGlobals, CommsAddrRec* addr, GSList* invitees,
|
||||||
default:
|
default:
|
||||||
XP_ASSERT(0);
|
XP_ASSERT(0);
|
||||||
}
|
}
|
||||||
|
#ifdef XWFEATURE_COMMS_INVITE
|
||||||
|
comms_invite( cGlobals->game.comms, NULL_XWE, &nli, &destAddr );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return haveAddressees;
|
return haveAddressees;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
handleInvite( void* closure, int XP_UNUSED(key) )
|
handleInvite( void* closure, int XP_UNUSED(key) )
|
||||||
|
@ -1253,11 +1269,6 @@ handleInvite( void* closure, int XP_UNUSED(key) )
|
||||||
if ( SERVER_ISSERVER != cGlobals->gi->serverRole ) {
|
if ( SERVER_ISSERVER != cGlobals->gi->serverRole ) {
|
||||||
ca_inform( bGlobals->boardWin, "Only hosts can invite" );
|
ca_inform( bGlobals->boardWin, "Only hosts can invite" );
|
||||||
|
|
||||||
|
|
||||||
#ifdef XWFEATURE_COMMS_INVITE
|
|
||||||
} else if ( XP_TRUE ) {
|
|
||||||
comms_invite( cGlobals->game.comms, NULL_XWE, &nli, &addr );
|
|
||||||
#else
|
|
||||||
/* Invite first based on an invitee provided. Otherwise, fall back to
|
/* Invite first based on an invitee provided. Otherwise, fall back to
|
||||||
doing a send-to-self. Let the recipient code reject a duplicate if
|
doing a send-to-self. Let the recipient code reject a duplicate if
|
||||||
the user so desires. */
|
the user so desires. */
|
||||||
|
@ -1288,7 +1299,6 @@ handleInvite( void* closure, int XP_UNUSED(key) )
|
||||||
if ( 0 != relayID ) {
|
if ( 0 != relayID ) {
|
||||||
relaycon_invite( params, relayID, NULL, &nli );
|
relaycon_invite( params, relayID, NULL, &nli );
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
ca_inform( bGlobals->boardWin, "Cannot invite via relayID, MQTT or by \"sms phone\"." );
|
ca_inform( bGlobals->boardWin, "Cannot invite via relayID, MQTT or by \"sms phone\"." );
|
||||||
}
|
}
|
||||||
|
|
|
@ -306,7 +306,7 @@ void
|
||||||
linux_sms_invite( LaunchParams* params, const NetLaunchInfo* nli,
|
linux_sms_invite( LaunchParams* params, const NetLaunchInfo* nli,
|
||||||
const gchar* toPhone, int toPort )
|
const gchar* toPhone, int toPort )
|
||||||
{
|
{
|
||||||
LOG_FUNC();
|
XP_LOGFF( "(toPhone: %s, toPort: %d)", toPhone, toPort );
|
||||||
LinSMSData* storage = getStorage( params );
|
LinSMSData* storage = getStorage( params );
|
||||||
|
|
||||||
XWStreamCtxt* stream = mem_stream_make_raw( MPPARM(params->mpool)
|
XWStreamCtxt* stream = mem_stream_make_raw( MPPARM(params->mpool)
|
||||||
|
|
Loading…
Add table
Reference in a new issue