This commit is contained in:
Eric House 2023-01-04 14:13:18 -08:00
parent f1ab7be1a3
commit 4caf660c1c
13 changed files with 31 additions and 184 deletions

View file

@ -710,7 +710,6 @@ public class BoardDelegate extends DelegateBase
// straight to asking for the permission. // straight to asking for the permission.
private void callInviteChoices() private void callInviteChoices()
{ {
Log.d( TAG, "callInviteChoices()" );
if ( !Perms23.NBSPermsInManifest( m_activity ) ) { if ( !Perms23.NBSPermsInManifest( m_activity ) ) {
showInviteChoicesThen(); showInviteChoicesThen();
} else { } else {

View file

@ -881,8 +881,8 @@ public class DBUtils {
} }
cursor.close(); cursor.close();
} }
if ( 1 < result.length ) { if ( 1 != result.length ) {
Log.i( TAG, "getRowIDsFor(%x)=>length %d array", gameID, Log.d( TAG, "getRowIDsFor(gameID=%X)=>length %d array", gameID,
result.length ); result.length );
} }
return result; return result;

View file

@ -437,7 +437,8 @@ public class GameUtils {
CommsAddrRec selfAddr = CommsAddrRec.getSelfAddr( context, gi ); CommsAddrRec selfAddr = CommsAddrRec.getSelfAddr( context, gi );
gamePtr = XwJNI.initNew( gi, selfAddr, (CommsAddrRec)null, gamePtr = XwJNI.initNew( gi, selfAddr, (CommsAddrRec)null,
(UtilCtxt)null, (DrawCtx)null, (UtilCtxt)null, (DrawCtx)null,
CommonPrefs.get(context), null ); CommonPrefs.get(context),
(TransportProcs)null );
} }
} }
} }

View file

@ -51,6 +51,8 @@ class InvitesNeededAlert {
Wrapper( Callbacks callbacks, GamePtr gamePtr ) Wrapper( Callbacks callbacks, GamePtr gamePtr )
{ {
mCallbacks = callbacks; mCallbacks = callbacks;
// PENGING should be calling gamePtr.retain()? Would need to
// release then somewhere
mGamePtr = gamePtr; mGamePtr = gamePtr;
} }

View file

@ -749,17 +749,17 @@ public class MQTTUtils extends Thread
public static void handleCtrlReceived( Context context, byte[] buf ) public static void handleCtrlReceived( Context context, byte[] buf )
{ {
try { try {
JSONObject obj = new JSONObject( new String(buf) ); JSONObject obj = new JSONObject( new String(buf) );
String msg = obj.optString( "msg", null ); String msg = obj.optString( "msg", null );
if ( null != msg ) { if ( null != msg ) {
String title = obj.optString( "title", null ); String title = obj.optString( "title", null );
if ( null == title ) { if ( null == title ) {
title = LocUtils.getString( context, R.string.remote_msg_title ); title = LocUtils.getString( context, R.string.remote_msg_title );
}
Intent alertIntent = GamesListDelegate.makeAlertIntent( context, msg );
int code = msg.hashCode() ^ title.hashCode();
Utils.postNotification( context, alertIntent, title, msg, code );
} }
Intent alertIntent = GamesListDelegate.makeAlertIntent( context, msg );
int code = msg.hashCode() ^ title.hashCode();
Utils.postNotification( context, alertIntent, title, msg, code );
}
} catch ( JSONException je ) { } catch ( JSONException je ) {
Log.e( TAG, "handleCtrlReceived() ex: %s", je ); Log.e( TAG, "handleCtrlReceived() ex: %s", je );
} }

View file

@ -143,50 +143,6 @@ abstract class XWServiceHelper {
nli.gameID() ); nli.gameID() );
} }
return true; return true;
// boolean success = false;
// if ( !nli.isValid() ) {
// Log.d( TAG, "invalid nli" );
// } else if ( ! checkNotInFlight( nli ) ) {
// Log.e( TAG, "checkNotInFlight() => false" );
// } else {
// success = true;
// }
// if ( success ) {
// Map<Long, Integer> rowids = DBUtils.getRowIDsAndChannels( mContext, nli.gameID() );
// // Accept only if there isn't already a game with the channel
// for ( long rowid : rowids.keySet() ) {
// if ( rowids.get( rowid ) == nli.forceChannel ) {
// if ( BuildConfig.DEBUG ) {
// DbgUtils.showf( mContext, "Dropping duplicate invite" );
// }
// success = false;
// break;
// }
// }
// if ( success ) {
// if ( DictLangCache.haveDict( mContext, nli.isoCode(), nli.dict ) ) {
// long rowid = GameUtils.makeNewMultiGame2( mContext, nli,
// getSink( 0 ),
// getUtilCtxt() );
// if ( null != nli.gameName && 0 < nli.gameName.length() ) {
// DBUtils.setName( mContext, rowid, nli.gameName );
// }
// postNotification( device, nli.gameID(), rowid );
// } else {
// Intent intent = MultiService
// .makeMissingDictIntent( mContext, nli, dfo );
// MultiService.postMissingDictNotification( mContext, intent,
// nli.gameID() );
// }
// }
// }
// Log.d( TAG, "handleInvitation() => %b", success );
// return success;
} }
private UtilCtxt m_utilCtxt; private UtilCtxt m_utilCtxt;

View file

@ -249,8 +249,6 @@ public class DUtilCtxt {
String result = isRobot String result = isRobot
? CommonPrefs.getDefaultRobotName( m_context ) ? CommonPrefs.getDefaultRobotName( m_context )
: CommonPrefs.getDefaultPlayerName( m_context, posn ); : CommonPrefs.getDefaultPlayerName( m_context, posn );
Log.d( TAG, "getUsername(posn=%d; isLocal=%b, isRobot=%b) => %s",
posn, isLocal, isRobot, result );
return result; return result;
} }
@ -291,7 +289,6 @@ public class DUtilCtxt {
public boolean haveGame( int gameID, int channel ) public boolean haveGame( int gameID, int channel )
{ {
boolean result = GameUtils.haveGame( m_context, gameID, channel ); boolean result = GameUtils.haveGame( m_context, gameID, channel );
Log.d( TAG, "haveGame(%d, %d) => %b", gameID, channel, result );
return result; return result;
} }

View file

@ -27,6 +27,7 @@ import java.util.Arrays;
import org.eehouse.android.xw4.Assert; import org.eehouse.android.xw4.Assert;
import org.eehouse.android.xw4.BuildConfig; import org.eehouse.android.xw4.BuildConfig;
import org.eehouse.android.xw4.DbgUtils;
import org.eehouse.android.xw4.Log; import org.eehouse.android.xw4.Log;
import org.eehouse.android.xw4.NetLaunchInfo; import org.eehouse.android.xw4.NetLaunchInfo;
import org.eehouse.android.xw4.Quarantine; import org.eehouse.android.xw4.Quarantine;
@ -170,6 +171,8 @@ public class XwJNI {
public static void dvc_makeMQTTNoSuchGames( String addressee, int gameID, public static void dvc_makeMQTTNoSuchGames( String addressee, int gameID,
String[][] topics, byte[][][] packets ) String[][] topics, byte[][][] packets )
{ {
Log.d( TAG, "dvc_makeMQTTNoSuchGames(to: %s, gameID: %X)", addressee, gameID );
DbgUtils.printStack( TAG );
dvc_makeMQTTNoSuchGames( getJNI().m_ptrGlobals, addressee, gameID, dvc_makeMQTTNoSuchGames( getJNI().m_ptrGlobals, addressee, gameID,
topics, packets ); topics, packets );
} }
@ -323,7 +326,6 @@ public class XwJNI {
initNew( CurGameInfo gi, CommsAddrRec selfAddr, CommsAddrRec hostAddr, initNew( CurGameInfo gi, CommsAddrRec selfAddr, CommsAddrRec hostAddr,
UtilCtxt util, DrawCtx draw, CommonPrefs cp, TransportProcs procs ) UtilCtxt util, DrawCtx draw, CommonPrefs cp, TransportProcs procs )
{ {
Log.d( TAG, "initNew(self: %s; host: %s)", selfAddr, hostAddr );
// Only standalone doesn't provide self address // Only standalone doesn't provide self address
Assert.assertTrueNR( null != selfAddr || gi.serverRole == DeviceRole.SERVER_STANDALONE ); Assert.assertTrueNR( null != selfAddr || gi.serverRole == DeviceRole.SERVER_STANDALONE );
// Only client should be providing host addr // Only client should be providing host addr

View file

@ -211,9 +211,8 @@ makeXportProcs( MPFORMAL JNIEnv* env,
#endif #endif
jobject jxport ) jobject jxport )
{ {
AndTransportProcs* aprocs = NULL; AndTransportProcs* aprocs = (AndTransportProcs*)
XP_CALLOC( mpool, sizeof(*aprocs) );
aprocs = (AndTransportProcs*)XP_CALLOC( mpool, sizeof(*aprocs) );
#ifdef MAP_THREAD_TO_ENV #ifdef MAP_THREAD_TO_ENV
aprocs->ti = ti; aprocs->ti = ti;
#endif #endif

View file

@ -667,7 +667,6 @@ JNIEXPORT jobjectArray JNICALL
Java_org_eehouse_android_xw4_jni_XwJNI_dvc_1getMQTTSubTopics Java_org_eehouse_android_xw4_jni_XwJNI_dvc_1getMQTTSubTopics
( JNIEnv* env, jclass C, jlong jniGlobalPtr ) ( JNIEnv* env, jclass C, jlong jniGlobalPtr )
{ {
LOG_FUNC();
jobjectArray result = NULL; jobjectArray result = NULL;
DVC_HEADER(jniGlobalPtr); DVC_HEADER(jniGlobalPtr);
@ -682,12 +681,9 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dvc_1getMQTTSubTopics
result = makeStringArray( env, nTopics, (const XP_UCHAR* const*)topics ); result = makeStringArray( env, nTopics, (const XP_UCHAR* const*)topics );
DVC_HEADER_END(); DVC_HEADER_END();
LOG_RETURNF( "%p", result );
return result; return result;
} }
typedef struct _MTPData { typedef struct _MTPData {
JNIEnv* env; JNIEnv* env;
int count; int count;
@ -1461,7 +1457,6 @@ initGameGlobals( JNIEnv* env, JNIState* state, jobject jutil, jobject jprocs )
{ {
AndGameGlobals* globals = &state->globals; AndGameGlobals* globals = &state->globals;
globals->gi = (CurGameInfo*)XP_CALLOC( state->mpool, sizeof(*globals->gi) ); globals->gi = (CurGameInfo*)XP_CALLOC( state->mpool, sizeof(*globals->gi) );
// gi_copy( MPPARM(state->mpool) globals->gi, globals.util->gameInfo );
if ( !!jutil ) { if ( !!jutil ) {
XP_ASSERT( !globals->util ); XP_ASSERT( !globals->util );
globals->util = makeUtil( MPPARM(state->mpool) env, globals->util = makeUtil( MPPARM(state->mpool) env,
@ -1481,7 +1476,6 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1makeRematch
( JNIEnv* env, jclass C, GamePtrType gamePtr, GamePtrType gamePtrNew, ( JNIEnv* env, jclass C, GamePtrType gamePtr, GamePtrType gamePtrNew,
jobject jutil, jobject jcp, jstring jGameName ) jobject jutil, jobject jcp, jstring jGameName )
{ {
LOG_FUNC();
XWJNI_START_GLOBALS(gamePtr); XWJNI_START_GLOBALS(gamePtr);
JNIState* oldState = state; /* state about to go out-of-scope */ JNIState* oldState = state; /* state about to go out-of-scope */
@ -1497,9 +1491,8 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1makeRematch
&state->game, gameName ); &state->game, gameName );
(*env)->ReleaseStringUTFChars( env, jGameName, gameName ); (*env)->ReleaseStringUTFChars( env, jGameName, gameName );
XWJNI_END(); /* matches second XWJNI_START_GLOBALS! */
XWJNI_END(); XWJNI_END();
XWJNI_END();
LOG_RETURN_VOID();
} }
JNIEXPORT jboolean JNICALL JNIEXPORT jboolean JNICALL
@ -2298,7 +2291,6 @@ JNIEXPORT jobject JNICALL
Java_org_eehouse_android_xw4_jni_XwJNI_comms_1getHostAddr Java_org_eehouse_android_xw4_jni_XwJNI_comms_1getHostAddr
(JNIEnv* env, jclass C, GamePtrType gamePtr ) (JNIEnv* env, jclass C, GamePtrType gamePtr )
{ {
LOG_FUNC();
jobject jaddr = NULL; jobject jaddr = NULL;
XWJNI_START(gamePtr); XWJNI_START(gamePtr);
XP_ASSERT( state->game.comms ); XP_ASSERT( state->game.comms );
@ -2698,26 +2690,6 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1invite
} }
XWJNI_END(); XWJNI_END();
} }
# if 0
JNIEXPORT jobjectArray JNICALL
Java_org_eehouse_android_xw4_jni_XwJNI_comms_1getInvites
( JNIEnv* env, jclass C, GamePtrType gamePtr )
{
jobjectArray result = NULL;
XWJNI_START_GLOBALS(gamePtr);
CommsCtxt* comms = state->game.comms;
XP_ASSERT( NULL != comms );
if ( NULL != comms ) {
CommsAddrRec inviteRecs[4];
XP_U16 nInvites = VSIZE(inviteRecs);
comms_getInvited( comms, env, &nInvites, inviteRecs );
result = makeAddrArray( env, nInvites, inviteRecs );
}
XWJNI_END();
return result;
}
# endif
#endif #endif
JNIEXPORT void JNICALL JNIEXPORT void JNICALL

View file

@ -35,7 +35,6 @@
#include "knownplyr.h" #include "knownplyr.h"
#include "device.h" #include "device.h"
#include "nli.h" #include "nli.h"
#include "device.h"
#define HEARTBEAT_NONE 0 #define HEARTBEAT_NONE 0
@ -271,14 +270,10 @@ static const char* relayCmdToStr( XWRELAY_Cmd cmd );
static void printQueue( const CommsCtxt* comms ); static void printQueue( const CommsCtxt* comms );
static void logAddr( const CommsCtxt* comms, XWEnv xwe, static void logAddr( const CommsCtxt* comms, XWEnv xwe,
const CommsAddrRec* addr, const char* caller ); const CommsAddrRec* addr, const char* caller );
/* static void logAddrs( const CommsCtxt* comms, XWEnv xwe, */
/* const char* caller ); */
#else #else
# define ASSERT_ADDR_OK(addr) # define ASSERT_ADDR_OK(addr)
# define printQueue( comms ) # define printQueue( comms )
# define logAddr( comms, xwe, addr, caller) # define logAddr( comms, xwe, addr, caller)
# define logAddrs( comms, caller )
# define listRecs( comms, caller ) # define listRecs( comms, caller )
#endif /* def DEBUG */ #endif /* def DEBUG */
@ -446,7 +441,6 @@ comms_make( MPFORMAL XWEnv xwe, XW_UtilCtxt* util, XP_Bool isServer,
#endif #endif
if ( !!selfAddr ) { if ( !!selfAddr ) {
logAddr( comms, xwe, selfAddr, __func__ );
augmentSelfAddr( comms, xwe, selfAddr ); augmentSelfAddr( comms, xwe, selfAddr );
} }
if ( !!hostAddr ) { if ( !!hostAddr ) {
@ -491,30 +485,6 @@ cleanupAddrRecs( CommsCtxt* comms )
comms->recs = (AddressRecord*)NULL; comms->recs = (AddressRecord*)NULL;
} /* cleanupAddrRecs */ } /* cleanupAddrRecs */
/* static void */
/* removeAddrRec( CommsCtxt* comms, XWEnv XP_UNUSED_DBG(xwe), AddressRecord* rec ) */
/* { */
/* XP_LOGFF( TAGFMT(%p), TAGPRMS, rec ); */
/* #ifdef DEBUG */
/* logAddrs( comms, xwe, "BEFORE" ); */
/* XP_U16 nBefore = countAddrRecs( comms ); */
/* #endif */
/* AddressRecord** curp = &comms->recs; */
/* while ( NULL != *curp ) { */
/* if ( rec == *curp ) { */
/* *curp = rec->next; */
/* XP_FREE( comms->mpool, rec ); */
/* break; */
/* } */
/* curp = &(*curp)->next; */
/* } */
/* #ifdef DEBUG */
/* XP_U16 nAfter = countAddrRecs( comms ); */
/* XP_ASSERT( (nAfter + 1) == nBefore ); */
/* logAddrs( comms, xwe, "AFTER" ); */
/* #endif */
/* } */
void void
comms_resetSame( CommsCtxt* comms, XWEnv xwe ) comms_resetSame( CommsCtxt* comms, XWEnv xwe )
{ {
@ -829,7 +799,6 @@ comms_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream,
comms->channelSeed = 0; comms->channelSeed = 0;
} else { } else {
comms->channelSeed = stream_getU16( stream ); comms->channelSeed = stream_getU16( stream );
// CNO_FMT( cbuf, comms->channelSeed );
} }
if ( STREAM_VERS_COMMSBACKOFF <= version ) { if ( STREAM_VERS_COMMSBACKOFF <= version ) {
comms->resendBackoff = stream_getU16( stream ); comms->resendBackoff = stream_getU16( stream );
@ -999,10 +968,8 @@ sendConnect( CommsCtxt* comms, XWEnv xwe
#endif #endif
) )
{ {
// CommsAddrRec addr = comms->selfAddr;
CommsConnType typ; CommsConnType typ;
for ( XP_U32 st = 0; addr_iter( &comms->selfAddr, &typ, &st ); ) { for ( XP_U32 st = 0; addr_iter( &comms->selfAddr, &typ, &st ); ) {
// addr._conTypes = typ;
switch( typ ) { switch( typ ) {
#ifdef XWFEATURE_RELAY #ifdef XWFEATURE_RELAY
case COMMS_CONN_RELAY: case COMMS_CONN_RELAY:
@ -1087,7 +1054,7 @@ addrToStreamOne( XWStreamCtxt* stream, CommsConnType typ,
break; break;
default: default:
XP_LOGFF( "unexpected typ: %s", ConnType2Str(typ) ); XP_LOGFF( "unexpected typ: %s", ConnType2Str(typ) );
XP_ASSERT(0); /* firing */ XP_ASSERT(0);
break; break;
} }
} /* addrToStreamOne */ } /* addrToStreamOne */
@ -1252,8 +1219,10 @@ augmentSelfAddr( CommsCtxt* comms, XWEnv xwe, const CommsAddrRec* addr )
logAddr( comms, xwe, addr, __func__ ); logAddr( comms, xwe, addr, __func__ );
XP_ASSERT( comms != NULL ); XP_ASSERT( comms != NULL );
#ifdef XWFEATURE_RELAY
XP_Bool addingRelay = addr_hasType( addr, COMMS_CONN_RELAY ) XP_Bool addingRelay = addr_hasType( addr, COMMS_CONN_RELAY )
&& ! addr_hasType( &comms->selfAddr, COMMS_CONN_RELAY ); && ! addr_hasType( &comms->selfAddr, COMMS_CONN_RELAY );
#endif
CommsAddrRec tmp = comms->selfAddr; CommsAddrRec tmp = comms->selfAddr;
augmentAddrIntrnl( comms, &tmp, addr, XP_TRUE ); augmentAddrIntrnl( comms, &tmp, addr, XP_TRUE );
@ -1265,14 +1234,13 @@ augmentSelfAddr( CommsCtxt* comms, XWEnv xwe, const CommsAddrRec* addr )
#ifdef COMMS_HEARTBEAT #ifdef COMMS_HEARTBEAT
setDoHeartbeat( comms ); setDoHeartbeat( comms );
#endif #endif
#ifdef XWFEATURE_RELAY
if ( addingRelay ) { if ( addingRelay ) {
XP_ASSERT(0); XP_ASSERT(0);
sendConnect( comms, xwe sendConnect( comms, xwe , XP_TRUE
#ifdef XWFEATURE_RELAY
, XP_TRUE
#endif
); );
} }
#endif
} /* comms_setHostAddr */ } /* comms_setHostAddr */
void void
@ -3485,18 +3453,6 @@ logAddr( const CommsCtxt* comms, XWEnv xwe,
stream_destroy( stream, xwe ); stream_destroy( stream, xwe );
} }
} }
/* static void */
/* logAddrs( const CommsCtxt* comms, XWEnv xwe, const char* caller ) */
/* { */
/* const AddressRecord* rec = comms->recs; */
/* while ( !!rec ) { */
/* CNO_FMT( cbuf, rec->channelNo ); */
/* XP_LOGFF( TAGFMT() "%s", TAGPRMS, cbuf ); */
/* logAddr( comms, xwe, &rec->addr, caller ); */
/* rec = rec->next; */
/* } */
/* } */
#endif #endif
static void static void

View file

@ -4231,10 +4231,9 @@ server_receiveMessage( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* incoming )
} }
break; break;
case XWPROTO_CLIENT_SETUP: case XWPROTO_CLIENT_SETUP:
accepted = XWSTATE_NONE == server->nv.gameState && !isServer; accepted = !isServer
if ( accepted ) { && XWSTATE_NONE == server->nv.gameState
accepted = client_readInitialMessage( server, xwe, incoming ); && client_readInitialMessage( server, xwe, incoming );
}
break; break;
#ifdef XWFEATURE_CHAT #ifdef XWFEATURE_CHAT
case XWPROTO_CHAT: case XWPROTO_CHAT:

View file

@ -164,42 +164,6 @@ handle_gotmsg( GIOChannel* source, GIOCondition XP_UNUSED(condition), gpointer d
return TRUE; return TRUE;
} /* handle_gotmsg */ } /* handle_gotmsg */
/* static bool */
/* postMsg( MQTTConStorage* storage, XWStreamCtxt* stream, XP_U32 gameID, */
/* const MQTTDevID* invitee ) */
/* { */
/* XP_ASSERT(0); /\* I need to go away! *\/ */
/* const XP_U8* bytes = stream_getPtr( stream ); */
/* XP_U16 len = stream_getSize( stream ); */
/* int mid; */
/* #ifdef DEBUG */
/* XP_UCHAR* sum = dutil_md5sum( storage->params->dutil, NULL_XWE, bytes, len ); */
/* XP_LOGFF( "sending %d bytes with sum %s", len, sum ); */
/* XP_FREEP( storage->params->mpool, &sum ); */
/* #endif */
/* XP_UCHAR topicStorage[128]; */
/* XP_UCHAR* topics[4]; */
/* XP_U16 nTopics = VSIZE(topics); */
/* dvc_getMQTTPubTopics( storage->params->dutil, NULL_XWE, */
/* invitee, gameID, topicStorage, VSIZE(topicStorage), */
/* &nTopics, topics ); */
/* bool success = XP_TRUE; */
/* for ( int ii = 0; success && ii < nTopics; ++ii ) { */
/* int err = mosquitto_publish( storage->mosq, &mid, topics[ii], */
/* len, bytes, DEFAULT_QOS, true ); */
/* XP_LOGFF( "mosquitto_publish(topic=%s) => %s; mid=%d", topics[ii], */
/* mosquitto_strerror(err), mid ); */
/* success = 0 == err; */
/* } */
/* stream_destroy( stream, NULL_XWE ); */
/* return success; */
/* } */
static bool static bool
postOne( MQTTConStorage* storage, const XP_UCHAR* topic, const XP_U8* buf, XP_U16 len ) postOne( MQTTConStorage* storage, const XP_UCHAR* topic, const XP_U8* buf, XP_U16 len )
{ {