diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c
index f12a6a3db..540f4d174 100644
--- a/xwords4/android/XWords4/jni/xwjni.c
+++ b/xwords4/android/XWords4/jni/xwjni.c
@@ -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);
diff --git a/xwords4/android/XWords4/res/values/common_rsrc.xml b/xwords4/android/XWords4/res/values/common_rsrc.xml
index a0a2076cf..ab0d93a49 100644
--- a/xwords4/android/XWords4/res/values/common_rsrc.xml
+++ b/xwords4/android/XWords4/res/values/common_rsrc.xml
@@ -123,6 +123,7 @@
application/x-xwordsinvite
rowid
gameid
+ packets
http://eehouse.org/and_wordlists
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBHelper.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBHelper.java
index e1bfc8c91..3a6fd4f2f 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBHelper.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBHelper.java
@@ -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 + ";" );
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java
index ee4e61cd6..6f5bfab0d 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java
@@ -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;
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java
index 08129ac7d..d9deeff17 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java
@@ -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 ) {
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
index 7f6346d4d..e27712633 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java
@@ -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,
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWSumListPreference.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWSumListPreference.java
index f1175deee..e2b3c3518 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWSumListPreference.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWSumListPreference.java
@@ -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,
};
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/GameSummary.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/GameSummary.java
index e9ffaabcd..c8174afe1 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/GameSummary.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/GameSummary.java
@@ -62,6 +62,7 @@ public class GameSummary {
public int dictLang;
public DeviceRole serverRole;
+ public int nPacketsPending;
private int m_giFlags;
private String m_playersSummary;
diff --git a/xwords4/common/comms.c b/xwords4/common/comms.c
index c6e6084e0..a882a891d 100644
--- a/xwords4/common/comms.c
+++ b/xwords4/common/comms.c
@@ -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 )
diff --git a/xwords4/common/comms.h b/xwords4/common/comms.h
index b7062e337..d83f7b0b6 100644
--- a/xwords4/common/comms.h
+++ b/xwords4/common/comms.h
@@ -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 );