mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-15 15:41:24 +01:00
linux: add option to delete orphaned game
This commit is contained in:
parent
3dcac063b5
commit
e44584e652
1 changed files with 37 additions and 27 deletions
|
@ -394,37 +394,42 @@ handle_rematch_button( GtkWidget* XP_UNUSED(widget), void* closure )
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
delete_game( GtkAppGlobals* apg, sqlite3_int64 rowid )
|
||||
{
|
||||
LaunchParams* params = apg->cag.params;
|
||||
GameInfo gib;
|
||||
#ifdef DEBUG
|
||||
XP_Bool success =
|
||||
#endif
|
||||
gdb_getGameInfo( params->pDb, rowid, &gib );
|
||||
XP_ASSERT( success );
|
||||
#ifdef XWFEATURE_RELAY
|
||||
XP_U32 clientToken = makeClientToken( rowid, gib.seed );
|
||||
#endif
|
||||
removeRow( apg, rowid );
|
||||
gdb_deleteGame( params->pDb, rowid );
|
||||
|
||||
#ifdef XWFEATURE_RELAY
|
||||
XP_UCHAR devIDBuf[64] = {0};
|
||||
gdb_fetch_safe( params->pDb, KEY_RDEVID, NULL, devIDBuf, sizeof(devIDBuf) );
|
||||
if ( '\0' != devIDBuf[0] ) {
|
||||
relaycon_deleted( params, devIDBuf, clientToken );
|
||||
} else {
|
||||
XP_LOGF( "%s: not calling relaycon_deleted: no relayID", __func__ );
|
||||
}
|
||||
#endif
|
||||
g_object_unref( gib.snap );
|
||||
}
|
||||
|
||||
static void
|
||||
handle_delete_button( GtkWidget* XP_UNUSED(widget), void* closure )
|
||||
{
|
||||
GtkAppGlobals* apg = (GtkAppGlobals*)closure;
|
||||
LaunchParams* params = apg->cag.params;
|
||||
guint len = apg->selRows->len;
|
||||
for ( guint ii = 0; ii < len; ++ii ) {
|
||||
sqlite3_int64 rowid = g_array_index( apg->selRows, sqlite3_int64, ii );
|
||||
|
||||
GameInfo gib;
|
||||
#ifdef DEBUG
|
||||
XP_Bool success =
|
||||
#endif
|
||||
gdb_getGameInfo( params->pDb, rowid, &gib );
|
||||
XP_ASSERT( success );
|
||||
#ifdef XWFEATURE_RELAY
|
||||
XP_U32 clientToken = makeClientToken( rowid, gib.seed );
|
||||
#endif
|
||||
removeRow( apg, rowid );
|
||||
gdb_deleteGame( params->pDb, rowid );
|
||||
|
||||
#ifdef XWFEATURE_RELAY
|
||||
XP_UCHAR devIDBuf[64] = {0};
|
||||
gdb_fetch_safe( params->pDb, KEY_RDEVID, NULL, devIDBuf, sizeof(devIDBuf) );
|
||||
if ( '\0' != devIDBuf[0] ) {
|
||||
relaycon_deleted( params, devIDBuf, clientToken );
|
||||
} else {
|
||||
XP_LOGF( "%s: not calling relaycon_deleted: no relayID", __func__ );
|
||||
}
|
||||
#endif
|
||||
g_object_unref( gib.snap );
|
||||
delete_game( apg, rowid );
|
||||
}
|
||||
apg->selRows = g_array_set_size( apg->selRows, 0 );
|
||||
updateButtons( apg );
|
||||
|
@ -863,9 +868,14 @@ gameGoneGTK( void* closure, const CommsAddrRec* XP_UNUSED(from), XP_U32 gameID )
|
|||
XP_LOGFF( "Old msg? Game %X no longer here", gameID );
|
||||
} else {
|
||||
gchar buf[128];
|
||||
snprintf( buf, VSIZE(buf), "game %X has been deleted on a remote device",
|
||||
gameID );
|
||||
gtktell( apg->window, buf );
|
||||
snprintf( buf, VSIZE(buf), "Game %X has been deleted on a remote device. "
|
||||
"Do you want to delete it?", gameID );
|
||||
if ( GTK_RESPONSE_YES == gtkask( apg->window, buf, GTK_BUTTONS_YES_NO, NULL ) ) {
|
||||
XP_ASSERT( 1 == nRowIDs );
|
||||
delete_game( apg, rowids[0] );
|
||||
} else {
|
||||
XP_LOGFF( "we need to call comms_setQuashed() here but don't have comms" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue