add params to set public-room-related booleans; add timeout option on

modal dialogs so gtk version can run unattended.
This commit is contained in:
Eric House 2010-09-14 21:13:45 -07:00
parent 3b5b5f0241
commit 9fc39a55ed
6 changed files with 45 additions and 3 deletions

View file

@ -1539,7 +1539,7 @@ cursesmain( XP_Bool isServer, LaunchParams* params )
#ifndef XWFEATURE_STANDALONE_ONLY
if ( g_globals.cGlobals.game.comms ) {
CommsAddrRec addr;
CommsAddrRec addr = {0};
if ( 0 ) {
# ifdef XWFEATURE_RELAY
@ -1547,6 +1547,8 @@ cursesmain( XP_Bool isServer, LaunchParams* params )
addr.conType = COMMS_CONN_RELAY;
addr.u.ip_relay.ipAddr = 0; /* ??? */
addr.u.ip_relay.port = params->connInfo.relay.defaultSendPort;
addr.u.ip_relay.seeksPublicRoom = params->connInfo.relay.seeksPublicRoom;
addr.u.ip_relay.advertiseRoom = params->connInfo.relay.advertiseRoom;
XP_STRNCPY( addr.u.ip_relay.hostName, params->connInfo.relay.relayName,
sizeof(addr.u.ip_relay.hostName) - 1 );
XP_STRNCPY( addr.u.ip_relay.invite, params->connInfo.relay.invite,

View file

@ -23,15 +23,40 @@
#include "gtkask.h"
static gint
timer_func( gpointer data )
{
GtkWidget* dlg = (GtkWidget*)data;
gtk_widget_destroy( dlg );
return 0;
}
XP_Bool
gtkask( const gchar *message, GtkButtonsType buttons )
{
return gtkask_timeout( message, buttons, 0 );
}
XP_Bool
gtkask_timeout( const gchar *message, GtkButtonsType buttons, XP_U16 timeout )
{
guint src = 0;
GtkWidget* dlg = gtk_message_dialog_new( NULL, /* parent */
GTK_MESSAGE_QUESTION,
GTK_DIALOG_MODAL,
buttons, "%s", message );
if ( timeout > 0 ) {
src = g_timeout_add( 1000 * timeout, timer_func, dlg );
}
gint response = gtk_dialog_run( GTK_DIALOG(dlg) );
gtk_widget_destroy( dlg );
if ( 0 != src ) {
g_source_remove( src );
}
return response == GTK_RESPONSE_OK || response == GTK_RESPONSE_YES;
} /* gtkask */

View file

@ -28,6 +28,7 @@
/* Returns true for "yes" or "ok" answer, false otherwise.
*/
XP_Bool gtkask( const gchar *message, GtkButtonsType buttons );
XP_Bool gtkask_timeout( const gchar *message, GtkButtonsType buttons, XP_U16 timeout );
#endif
#endif /* PLATFORM_GTK */

View file

@ -330,7 +330,7 @@ relay_connd_gtk( void* XP_UNUSED(closure), XP_Bool allHere, XP_U16 nMissing )
}
if ( !skip ) {
(void)gtkask( buf, GTK_BUTTONS_OK );
(void)gtkask_timeout( buf, GTK_BUTTONS_OK, 3 );
}
}
@ -439,6 +439,8 @@ createOrLoadObjects( GtkAppGlobals* globals )
} else if ( addr.conType == COMMS_CONN_RELAY ) {
addr.u.ip_relay.ipAddr = 0;
addr.u.ip_relay.port = params->connInfo.relay.defaultSendPort;
addr.u.ip_relay.seeksPublicRoom = params->connInfo.relay.seeksPublicRoom;
addr.u.ip_relay.advertiseRoom = params->connInfo.relay.advertiseRoom;
XP_STRNCPY( addr.u.ip_relay.hostName, params->connInfo.relay.relayName,
sizeof(addr.u.ip_relay.hostName) - 1 );
XP_STRNCPY( addr.u.ip_relay.invite, params->connInfo.relay.invite,

View file

@ -212,6 +212,8 @@ usage( char* appName, char* msg )
"\t [-O] # sort the tray each time tiles are added\n"
#ifdef XWFEATURE_RELAY
"\t [-H] # Don't send heartbeats to relay\n"
"\t [-A] # advertise room as public\n"
"\t [-R] # connect to a public room\n"
#endif
#ifdef XWFEATURE_SMS
"\t [-M phone] # Server phone number for SMS\n"
@ -830,7 +832,7 @@ main( int argc, char** argv )
"M:"
#endif
#ifdef XWFEATURE_RELAY
"a:p:C:H"
"a:p:C:HAR"
#endif
#if defined XWFEATURE_RELAY || defined XWFEATURE_IP_DIRECT
"p:"
@ -963,6 +965,14 @@ main( int argc, char** argv )
conType = COMMS_CONN_RELAY;
hostName = optarg;
break;
#ifdef XWFEATURE_RELAY
case 'A':
mainParams.connInfo.relay.advertiseRoom = true;
break;
case 'R':
mainParams.connInfo.relay.seeksPublicRoom = true;
break;
#endif
case '0':
closeStdin = XP_TRUE;
break;

View file

@ -86,6 +86,8 @@ typedef struct LaunchParams {
char* relayName;
char* invite;
short defaultSendPort;
XP_Bool seeksPublicRoom;
XP_Bool advertiseRoom;
} relay;
#endif
#ifdef XWFEATURE_BLUETOOTH