mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-27 09:58:45 +01:00
add summary DB column and jni code to fetch it to store and display number of unacked messages a game has. And add debug-only option to display it in the main list. In the future I want to be able to iterate over all these games and resend their packets (without opening them visually) when an internet connection comes back up.
This commit is contained in:
parent
242f722f2e
commit
c1e22dd3cf
10 changed files with 60 additions and 5 deletions
|
@ -1279,6 +1279,8 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1summarize
|
|||
setInt( env, jsummary, "seed", comms_getChannelSeed( comms ) );
|
||||
setInt( env, jsummary, "missingPlayers",
|
||||
server_getMissingPlayers( state->game.server ) );
|
||||
setInt( env, jsummary, "nPacketsPending",
|
||||
comms_countPendingPackets( state->game.comms ) );
|
||||
if ( COMMS_CONN_RELAY == addr.conType ) {
|
||||
XP_UCHAR buf[128];
|
||||
XP_U16 len = VSIZE(buf);
|
||||
|
|
|
@ -123,6 +123,7 @@
|
|||
<string name="invite_mime">application/x-xwordsinvite</string>
|
||||
<string name="game_summary_field_rowid">rowid</string>
|
||||
<string name="game_summary_field_gameid">gameid</string>
|
||||
<string name="game_summary_field_npackets">packets</string>
|
||||
<!--string name="invite_mime">text/plain</string-->
|
||||
|
||||
<string name="dict_url">http://eehouse.org/and_wordlists</string>
|
||||
|
|
|
@ -38,7 +38,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||
public static final String TABLE_NAME_GROUPS = "groups";
|
||||
public static final String TABLE_NAME_STUDYLIST = "study";
|
||||
private static final String DB_NAME = "xwdb";
|
||||
private static final int DB_VERSION = 19;
|
||||
private static final int DB_VERSION = 20;
|
||||
|
||||
public static final String GAME_NAME = "GAME_NAME";
|
||||
public static final String VISID = "VISID";
|
||||
|
@ -70,6 +70,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||
public static final String SMSPHONE = "SMSPHONE"; // unused -- so far
|
||||
public static final String LASTMOVE = "LASTMOVE";
|
||||
public static final String GROUPID = "GROUPID";
|
||||
public static final String NPACKETSPENDING = "NPACKETSPENDING";
|
||||
|
||||
public static final String DICTNAME = "DICTNAME";
|
||||
public static final String MD5SUM = "MD5SUM";
|
||||
|
@ -124,6 +125,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||
,{ CONTRACTED, "INTEGER DEFAULT 0" }
|
||||
,{ CREATE_TIME, "INTEGER" }
|
||||
,{ LASTPLAY_TIME,"INTEGER" }
|
||||
,{ NPACKETSPENDING,"INTEGER" }
|
||||
,{ SNAPSHOT, "BLOB" }
|
||||
,{ THUMBNAIL, "BLOB" }
|
||||
};
|
||||
|
@ -192,6 +194,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||
{
|
||||
DbgUtils.logf( "onUpgrade: old: %d; new: %d", oldVersion, newVersion );
|
||||
|
||||
boolean madeSumTable = false;
|
||||
switch( oldVersion ) {
|
||||
case 5:
|
||||
createTable( db, TABLE_NAME_OBITS, s_obitsColsAndTypes );
|
||||
|
@ -224,13 +227,19 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||
addSumColumn( db, VISID );
|
||||
setColumnsEqual( db, TABLE_NAME_SUM, VISID, "rowid" );
|
||||
makeAutoincrement( db, TABLE_NAME_SUM, s_summaryColsAndTypes );
|
||||
madeSumTable = true;
|
||||
case 17:
|
||||
if ( 17 == oldVersion ) {
|
||||
if ( !madeSumTable ) {
|
||||
// THUMBNAIL also added by makeAutoincrement above
|
||||
addSumColumn( db, THUMBNAIL );
|
||||
}
|
||||
case 18:
|
||||
createStudyTable( db );
|
||||
case 19:
|
||||
if ( !madeSumTable ) {
|
||||
// NPACKETSPENDING also added by makeAutoincrement above
|
||||
addSumColumn( db, NPACKETSPENDING );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
db.execSQL( "DROP TABLE " + TABLE_NAME_SUM + ";" );
|
||||
|
|
|
@ -135,7 +135,7 @@ public class DBUtils {
|
|||
DBHelper.DICTLANG, DBHelper.GAMEID,
|
||||
DBHelper.SCORES, DBHelper.HASMSGS,
|
||||
DBHelper.LASTPLAY_TIME, DBHelper.REMOTEDEVS,
|
||||
DBHelper.LASTMOVE
|
||||
DBHelper.LASTMOVE, DBHelper.NPACKETSPENDING
|
||||
};
|
||||
String selection = String.format( ROW_ID_FMT, lock.getRowid() );
|
||||
|
||||
|
@ -202,13 +202,18 @@ public class DBUtils {
|
|||
summary.scores = scores;
|
||||
|
||||
int col = cursor.getColumnIndex( DBHelper.CONTYPE );
|
||||
if ( col >= 0 ) {
|
||||
if ( 0 <= col ) {
|
||||
tmp = cursor.getInt( col );
|
||||
summary.conType = CommsAddrRec.CommsConnType.values()[tmp];
|
||||
col = cursor.getColumnIndex( DBHelper.SEED );
|
||||
if ( col >= 0 ) {
|
||||
if ( 0 < col ) {
|
||||
summary.seed = cursor.getInt( col );
|
||||
}
|
||||
col = cursor.getColumnIndex( DBHelper.NPACKETSPENDING );
|
||||
if ( 0 <= col ) {
|
||||
summary.nPacketsPending = cursor.getInt( col );
|
||||
}
|
||||
|
||||
switch ( summary.conType ) {
|
||||
case COMMS_CONN_RELAY:
|
||||
col = cursor.getColumnIndex( DBHelper.ROOMNAME );
|
||||
|
@ -295,6 +300,7 @@ public class DBUtils {
|
|||
if ( null != summary.conType ) {
|
||||
values.put( DBHelper.CONTYPE, summary.conType.ordinal() );
|
||||
values.put( DBHelper.SEED, summary.seed );
|
||||
values.put( DBHelper.NPACKETSPENDING, summary.nPacketsPending );
|
||||
switch( summary.conType ) {
|
||||
case COMMS_CONN_RELAY:
|
||||
values.put( DBHelper.ROOMNAME, summary.roomName );
|
||||
|
@ -493,6 +499,28 @@ public class DBUtils {
|
|||
return result;
|
||||
}
|
||||
|
||||
// Not read to use this yet
|
||||
// public static long[] getGamesWithSendsPending( Context context )
|
||||
// {
|
||||
// long[] result = null;
|
||||
// String[] columns = { ROW_ID };
|
||||
// String selection = String.format( "%s > 0", DBHelper.NPACKETSPENDING );
|
||||
// initDB( context );
|
||||
// synchronized( s_dbHelper ) {
|
||||
// SQLiteDatabase db = s_dbHelper.getReadableDatabase();
|
||||
// Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
|
||||
// selection, null, null, null, null );
|
||||
// result = new long[cursor.getCount()];
|
||||
// int indx = cursor.getColumnIndex( ROW_ID );
|
||||
// for ( int ii = 0; cursor.moveToNext(); ++ii ) {
|
||||
// result[ii] = cursor.getLong( indx );
|
||||
// }
|
||||
// cursor.close();
|
||||
// db.close();
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
|
||||
public static long[] getRowIDsFor( Context context, String relayID )
|
||||
{
|
||||
long[] result = null;
|
||||
|
|
|
@ -457,6 +457,7 @@ public class GameListAdapter implements ExpandableListAdapter {
|
|||
R.string.game_summary_field_state,
|
||||
R.string.game_summary_field_rowid,
|
||||
R.string.game_summary_field_gameid,
|
||||
R.string.game_summary_field_npackets,
|
||||
};
|
||||
int result = -1;
|
||||
for ( int id : ids ) {
|
||||
|
|
|
@ -221,6 +221,9 @@ public class GameListItem extends LinearLayout
|
|||
case R.string.game_summary_field_rowid:
|
||||
value = String.format( "%d", m_rowid );
|
||||
break;
|
||||
case R.string.game_summary_field_npackets:
|
||||
value = String.format( "%d", m_summary.nPacketsPending );
|
||||
break;
|
||||
case R.string.game_summary_field_language:
|
||||
value =
|
||||
DictLangCache.getLangName( m_context,
|
||||
|
|
|
@ -26,6 +26,7 @@ import android.util.AttributeSet;
|
|||
public class XWSumListPreference extends XWListPreference {
|
||||
|
||||
private static final int[] s_ADDROWS = {
|
||||
R.string.game_summary_field_npackets,
|
||||
R.string.game_summary_field_rowid,
|
||||
R.string.game_summary_field_gameid,
|
||||
};
|
||||
|
|
|
@ -62,6 +62,7 @@ public class GameSummary {
|
|||
|
||||
public int dictLang;
|
||||
public DeviceRole serverRole;
|
||||
public int nPacketsPending;
|
||||
|
||||
private int m_giFlags;
|
||||
private String m_playersSummary;
|
||||
|
|
|
@ -867,6 +867,13 @@ comms_getAddrs( const CommsCtxt* comms, CommsAddrRec addr[], XP_U16* nRecs )
|
|||
*nRecs = count;
|
||||
}
|
||||
|
||||
XP_U16
|
||||
comms_countPendingPackets( const CommsCtxt* comms )
|
||||
{
|
||||
// LOG_RETURNF( "%d", comms->queueLen );
|
||||
return comms->queueLen;
|
||||
}
|
||||
|
||||
#ifdef XWFEATURE_RELAY
|
||||
static XP_Bool
|
||||
haveRelayID( const CommsCtxt* comms )
|
||||
|
|
|
@ -186,6 +186,8 @@ void comms_getAddr( const CommsCtxt* comms, CommsAddrRec* addr );
|
|||
void comms_setAddr( CommsCtxt* comms, const CommsAddrRec* addr );
|
||||
void comms_getAddrs( const CommsCtxt* comms, CommsAddrRec addr[],
|
||||
XP_U16* nRecs );
|
||||
XP_U16 comms_countPendingPackets( const CommsCtxt* comms );
|
||||
|
||||
|
||||
#ifdef XWFEATURE_RELAY
|
||||
XP_Bool comms_getRelayID( const CommsCtxt* comms, XP_UCHAR* buf, XP_U16* len );
|
||||
|
|
Loading…
Reference in a new issue