From cdcf63a0bff7468db73e4db1be717d0034926e48 Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 31 Jan 2020 17:34:41 -0800 Subject: [PATCH] enable invite by relayID (and rematch from gtk side) --- xwords4/linux/cursesboard.c | 21 ++++++++++++--------- xwords4/linux/gtkboard.c | 3 ++- xwords4/linux/linuxmain.c | 6 ++++++ xwords4/linux/main.h | 1 + 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/xwords4/linux/cursesboard.c b/xwords4/linux/cursesboard.c index ad68254d6..a1f40afaa 100644 --- a/xwords4/linux/cursesboard.c +++ b/xwords4/linux/cursesboard.c @@ -1,4 +1,4 @@ -/* -*- compile-command: "make MEMDEBUG=TRUE -j3"; -*- */ +/* -*- compile-command: "make MEMDEBUG=TRUE -j5"; -*- */ /* * Copyright 2000 - 2020 by Eric House (xwords@eehouse.org). All rights * reserved. @@ -1235,19 +1235,22 @@ handleInvite( void* closure, int XP_UNUSED(key) ) CommsCtxt* comms = cGlobals->game.comms; XP_ASSERT( comms ); comms_getAddr( comms, &addr ); + + XP_U16 nPlayers = 1; + gint forceChannel = 1; + NetLaunchInfo nli = {0}; + nli_init( &nli, cGlobals->gi, &addr, nPlayers, forceChannel ); + if ( SERVER_ISSERVER != cGlobals->gi->serverRole ) { ca_inform( bGlobals->boardWin, "Only hosts can invite" ); - } else if ( !params->connInfo.sms.inviteePhone ) { - ca_inform( bGlobals->boardWin, "No way to invite; use --invitee-sms-number" ); - } else { + } else if ( 0 != params->connInfo.relay.inviteeRelayID ) { + relaycon_invite( params, params->connInfo.relay.inviteeRelayID, NULL, &nli ); + } else if ( !!params->connInfo.sms.inviteePhone ) { /* These should both be settable/derivable */ - XP_U16 nPlayers = 1; - gint forceChannel = 1; - NetLaunchInfo nli = {0}; - nli_init( &nli, cGlobals->gi, &addr, nPlayers, forceChannel ); - linux_sms_invite( params, &nli, params->connInfo.sms.inviteePhone, params->connInfo.sms.port ); + } else { + ca_inform( bGlobals->boardWin, "No way to invite; use --invitee-sms-number or --invitee-relayid" ); } return XP_TRUE; } diff --git a/xwords4/linux/gtkboard.c b/xwords4/linux/gtkboard.c index 44e2210d3..35f2bf8f4 100644 --- a/xwords4/linux/gtkboard.c +++ b/xwords4/linux/gtkboard.c @@ -1448,13 +1448,14 @@ send_invites( CommonGlobals* cGlobals, XP_U16 nPlayers, } #endif - if ( '\0' != addrs->u.sms.phone[0] && 0 < addrs->u.sms.port ) { + if ( !!addrs && '\0' != addrs->u.sms.phone[0] && 0 < addrs->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 ); } + if ( 0 != relayDevID || !!relayID ) { XP_ASSERT( 0 != relayDevID || (!!relayID && !!relayID[0]) ); relaycon_invite( cGlobals->params, relayDevID, relayID, &nli ); diff --git a/xwords4/linux/linuxmain.c b/xwords4/linux/linuxmain.c index 07c5eec1e..82aa99ba7 100644 --- a/xwords4/linux/linuxmain.c +++ b/xwords4/linux/linuxmain.c @@ -860,6 +860,7 @@ typedef enum { ,CMD_JOINADVERTISED ,CMD_PHONIES ,CMD_BONUSFILE + ,CMD_INVITEE_RELAYID #endif #ifdef XWFEATURE_BLUETOOTH ,CMD_BTADDR @@ -991,6 +992,7 @@ static CmdInfoRec CmdInfoRecs[] = { "ignore (0, default), warn (1) or lose turn (2)" } ,{ CMD_BONUSFILE, true, "bonus-file", "provides bonus info: . + * ^ and ! are legal" } + ,{ CMD_INVITEE_RELAYID, true, "invitee-relayid", "relayID to send any invitation to" } #endif #ifdef XWFEATURE_BLUETOOTH ,{ CMD_BTADDR, true, "btaddr", "bluetooth address of host" } @@ -2624,6 +2626,10 @@ main( int argc, char** argv ) case CMD_BONUSFILE: mainParams.bonusFile = optarg; break; + case CMD_INVITEE_RELAYID: + mainParams.connInfo.relay.inviteeRelayID = atoi(optarg); + addr_addType( &mainParams.addr, COMMS_CONN_RELAY ); + break; #endif case CMD_CLOSESTDIN: mainParams.closeStdin = XP_TRUE; diff --git a/xwords4/linux/main.h b/xwords4/linux/main.h index cd5be1b0b..6eb61c675 100644 --- a/xwords4/linux/main.h +++ b/xwords4/linux/main.h @@ -139,6 +139,7 @@ typedef struct LaunchParams { short defaultSendPort; XP_Bool seeksPublicRoom; XP_Bool advertiseRoom; + XP_U32 inviteeRelayID; } relay; #endif #ifdef XWFEATURE_BLUETOOTH