mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-30 10:26:58 +01:00
cleanup
This commit is contained in:
parent
f1ab7be1a3
commit
4caf660c1c
13 changed files with 31 additions and 184 deletions
|
@ -710,7 +710,6 @@ public class BoardDelegate extends DelegateBase
|
|||
// straight to asking for the permission.
|
||||
private void callInviteChoices()
|
||||
{
|
||||
Log.d( TAG, "callInviteChoices()" );
|
||||
if ( !Perms23.NBSPermsInManifest( m_activity ) ) {
|
||||
showInviteChoicesThen();
|
||||
} else {
|
||||
|
|
|
@ -881,8 +881,8 @@ public class DBUtils {
|
|||
}
|
||||
cursor.close();
|
||||
}
|
||||
if ( 1 < result.length ) {
|
||||
Log.i( TAG, "getRowIDsFor(%x)=>length %d array", gameID,
|
||||
if ( 1 != result.length ) {
|
||||
Log.d( TAG, "getRowIDsFor(gameID=%X)=>length %d array", gameID,
|
||||
result.length );
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -437,7 +437,8 @@ public class GameUtils {
|
|||
CommsAddrRec selfAddr = CommsAddrRec.getSelfAddr( context, gi );
|
||||
gamePtr = XwJNI.initNew( gi, selfAddr, (CommsAddrRec)null,
|
||||
(UtilCtxt)null, (DrawCtx)null,
|
||||
CommonPrefs.get(context), null );
|
||||
CommonPrefs.get(context),
|
||||
(TransportProcs)null );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,8 @@ class InvitesNeededAlert {
|
|||
Wrapper( Callbacks callbacks, GamePtr gamePtr )
|
||||
{
|
||||
mCallbacks = callbacks;
|
||||
// PENGING should be calling gamePtr.retain()? Would need to
|
||||
// release then somewhere
|
||||
mGamePtr = gamePtr;
|
||||
}
|
||||
|
||||
|
|
|
@ -749,17 +749,17 @@ public class MQTTUtils extends Thread
|
|||
public static void handleCtrlReceived( Context context, byte[] buf )
|
||||
{
|
||||
try {
|
||||
JSONObject obj = new JSONObject( new String(buf) );
|
||||
String msg = obj.optString( "msg", null );
|
||||
if ( null != msg ) {
|
||||
String title = obj.optString( "title", null );
|
||||
if ( null == title ) {
|
||||
title = LocUtils.getString( context, R.string.remote_msg_title );
|
||||
JSONObject obj = new JSONObject( new String(buf) );
|
||||
String msg = obj.optString( "msg", null );
|
||||
if ( null != msg ) {
|
||||
String title = obj.optString( "title", null );
|
||||
if ( null == 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 ) {
|
||||
Log.e( TAG, "handleCtrlReceived() ex: %s", je );
|
||||
}
|
||||
|
|
|
@ -143,50 +143,6 @@ abstract class XWServiceHelper {
|
|||
nli.gameID() );
|
||||
}
|
||||
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;
|
||||
|
|
|
@ -249,8 +249,6 @@ public class DUtilCtxt {
|
|||
String result = isRobot
|
||||
? CommonPrefs.getDefaultRobotName( m_context )
|
||||
: CommonPrefs.getDefaultPlayerName( m_context, posn );
|
||||
Log.d( TAG, "getUsername(posn=%d; isLocal=%b, isRobot=%b) => %s",
|
||||
posn, isLocal, isRobot, result );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -291,7 +289,6 @@ public class DUtilCtxt {
|
|||
public boolean haveGame( int gameID, int channel )
|
||||
{
|
||||
boolean result = GameUtils.haveGame( m_context, gameID, channel );
|
||||
Log.d( TAG, "haveGame(%d, %d) => %b", gameID, channel, result );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.Arrays;
|
|||
|
||||
import org.eehouse.android.xw4.Assert;
|
||||
import org.eehouse.android.xw4.BuildConfig;
|
||||
import org.eehouse.android.xw4.DbgUtils;
|
||||
import org.eehouse.android.xw4.Log;
|
||||
import org.eehouse.android.xw4.NetLaunchInfo;
|
||||
import org.eehouse.android.xw4.Quarantine;
|
||||
|
@ -170,6 +171,8 @@ public class XwJNI {
|
|||
public static void dvc_makeMQTTNoSuchGames( String addressee, int gameID,
|
||||
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,
|
||||
topics, packets );
|
||||
}
|
||||
|
@ -323,7 +326,6 @@ public class XwJNI {
|
|||
initNew( CurGameInfo gi, CommsAddrRec selfAddr, CommsAddrRec hostAddr,
|
||||
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
|
||||
Assert.assertTrueNR( null != selfAddr || gi.serverRole == DeviceRole.SERVER_STANDALONE );
|
||||
// Only client should be providing host addr
|
||||
|
|
|
@ -211,9 +211,8 @@ makeXportProcs( MPFORMAL JNIEnv* env,
|
|||
#endif
|
||||
jobject jxport )
|
||||
{
|
||||
AndTransportProcs* aprocs = NULL;
|
||||
|
||||
aprocs = (AndTransportProcs*)XP_CALLOC( mpool, sizeof(*aprocs) );
|
||||
AndTransportProcs* aprocs = (AndTransportProcs*)
|
||||
XP_CALLOC( mpool, sizeof(*aprocs) );
|
||||
#ifdef MAP_THREAD_TO_ENV
|
||||
aprocs->ti = ti;
|
||||
#endif
|
||||
|
|
|
@ -667,7 +667,6 @@ JNIEXPORT jobjectArray JNICALL
|
|||
Java_org_eehouse_android_xw4_jni_XwJNI_dvc_1getMQTTSubTopics
|
||||
( JNIEnv* env, jclass C, jlong jniGlobalPtr )
|
||||
{
|
||||
LOG_FUNC();
|
||||
jobjectArray result = NULL;
|
||||
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 );
|
||||
|
||||
DVC_HEADER_END();
|
||||
LOG_RETURNF( "%p", result );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
typedef struct _MTPData {
|
||||
JNIEnv* env;
|
||||
int count;
|
||||
|
@ -1461,7 +1457,6 @@ initGameGlobals( JNIEnv* env, JNIState* state, jobject jutil, jobject jprocs )
|
|||
{
|
||||
AndGameGlobals* globals = &state->globals;
|
||||
globals->gi = (CurGameInfo*)XP_CALLOC( state->mpool, sizeof(*globals->gi) );
|
||||
// gi_copy( MPPARM(state->mpool) globals->gi, globals.util->gameInfo );
|
||||
if ( !!jutil ) {
|
||||
XP_ASSERT( !globals->util );
|
||||
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,
|
||||
jobject jutil, jobject jcp, jstring jGameName )
|
||||
{
|
||||
LOG_FUNC();
|
||||
XWJNI_START_GLOBALS(gamePtr);
|
||||
|
||||
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 );
|
||||
(*env)->ReleaseStringUTFChars( env, jGameName, gameName );
|
||||
|
||||
XWJNI_END(); /* matches second XWJNI_START_GLOBALS! */
|
||||
XWJNI_END();
|
||||
XWJNI_END();
|
||||
LOG_RETURN_VOID();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
|
@ -2298,7 +2291,6 @@ JNIEXPORT jobject JNICALL
|
|||
Java_org_eehouse_android_xw4_jni_XwJNI_comms_1getHostAddr
|
||||
(JNIEnv* env, jclass C, GamePtrType gamePtr )
|
||||
{
|
||||
LOG_FUNC();
|
||||
jobject jaddr = NULL;
|
||||
XWJNI_START(gamePtr);
|
||||
XP_ASSERT( state->game.comms );
|
||||
|
@ -2698,26 +2690,6 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1invite
|
|||
}
|
||||
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
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include "knownplyr.h"
|
||||
#include "device.h"
|
||||
#include "nli.h"
|
||||
#include "device.h"
|
||||
|
||||
#define HEARTBEAT_NONE 0
|
||||
|
||||
|
@ -271,14 +270,10 @@ static const char* relayCmdToStr( XWRELAY_Cmd cmd );
|
|||
static void printQueue( const CommsCtxt* comms );
|
||||
static void logAddr( const CommsCtxt* comms, XWEnv xwe,
|
||||
const CommsAddrRec* addr, const char* caller );
|
||||
/* static void logAddrs( const CommsCtxt* comms, XWEnv xwe, */
|
||||
/* const char* caller ); */
|
||||
|
||||
#else
|
||||
# define ASSERT_ADDR_OK(addr)
|
||||
# define printQueue( comms )
|
||||
# define logAddr( comms, xwe, addr, caller)
|
||||
# define logAddrs( comms, caller )
|
||||
# define listRecs( comms, caller )
|
||||
#endif /* def DEBUG */
|
||||
|
||||
|
@ -446,7 +441,6 @@ comms_make( MPFORMAL XWEnv xwe, XW_UtilCtxt* util, XP_Bool isServer,
|
|||
#endif
|
||||
|
||||
if ( !!selfAddr ) {
|
||||
logAddr( comms, xwe, selfAddr, __func__ );
|
||||
augmentSelfAddr( comms, xwe, selfAddr );
|
||||
}
|
||||
if ( !!hostAddr ) {
|
||||
|
@ -491,30 +485,6 @@ cleanupAddrRecs( CommsCtxt* comms )
|
|||
comms->recs = (AddressRecord*)NULL;
|
||||
} /* 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
|
||||
comms_resetSame( CommsCtxt* comms, XWEnv xwe )
|
||||
{
|
||||
|
@ -829,7 +799,6 @@ comms_makeFromStream( MPFORMAL XWEnv xwe, XWStreamCtxt* stream,
|
|||
comms->channelSeed = 0;
|
||||
} else {
|
||||
comms->channelSeed = stream_getU16( stream );
|
||||
// CNO_FMT( cbuf, comms->channelSeed );
|
||||
}
|
||||
if ( STREAM_VERS_COMMSBACKOFF <= version ) {
|
||||
comms->resendBackoff = stream_getU16( stream );
|
||||
|
@ -999,10 +968,8 @@ sendConnect( CommsCtxt* comms, XWEnv xwe
|
|||
#endif
|
||||
)
|
||||
{
|
||||
// CommsAddrRec addr = comms->selfAddr;
|
||||
CommsConnType typ;
|
||||
for ( XP_U32 st = 0; addr_iter( &comms->selfAddr, &typ, &st ); ) {
|
||||
// addr._conTypes = typ;
|
||||
switch( typ ) {
|
||||
#ifdef XWFEATURE_RELAY
|
||||
case COMMS_CONN_RELAY:
|
||||
|
@ -1087,7 +1054,7 @@ addrToStreamOne( XWStreamCtxt* stream, CommsConnType typ,
|
|||
break;
|
||||
default:
|
||||
XP_LOGFF( "unexpected typ: %s", ConnType2Str(typ) );
|
||||
XP_ASSERT(0); /* firing */
|
||||
XP_ASSERT(0);
|
||||
break;
|
||||
}
|
||||
} /* addrToStreamOne */
|
||||
|
@ -1252,8 +1219,10 @@ augmentSelfAddr( CommsCtxt* comms, XWEnv xwe, const CommsAddrRec* addr )
|
|||
logAddr( comms, xwe, addr, __func__ );
|
||||
XP_ASSERT( comms != NULL );
|
||||
|
||||
#ifdef XWFEATURE_RELAY
|
||||
XP_Bool addingRelay = addr_hasType( addr, COMMS_CONN_RELAY )
|
||||
&& ! addr_hasType( &comms->selfAddr, COMMS_CONN_RELAY );
|
||||
#endif
|
||||
|
||||
CommsAddrRec tmp = comms->selfAddr;
|
||||
augmentAddrIntrnl( comms, &tmp, addr, XP_TRUE );
|
||||
|
@ -1265,14 +1234,13 @@ augmentSelfAddr( CommsCtxt* comms, XWEnv xwe, const CommsAddrRec* addr )
|
|||
#ifdef COMMS_HEARTBEAT
|
||||
setDoHeartbeat( comms );
|
||||
#endif
|
||||
#ifdef XWFEATURE_RELAY
|
||||
if ( addingRelay ) {
|
||||
XP_ASSERT(0);
|
||||
sendConnect( comms, xwe
|
||||
#ifdef XWFEATURE_RELAY
|
||||
, XP_TRUE
|
||||
#endif
|
||||
sendConnect( comms, xwe , XP_TRUE
|
||||
);
|
||||
}
|
||||
#endif
|
||||
} /* comms_setHostAddr */
|
||||
|
||||
void
|
||||
|
@ -3485,18 +3453,6 @@ logAddr( const CommsCtxt* comms, XWEnv 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
|
||||
|
||||
static void
|
||||
|
|
|
@ -4231,10 +4231,9 @@ server_receiveMessage( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* incoming )
|
|||
}
|
||||
break;
|
||||
case XWPROTO_CLIENT_SETUP:
|
||||
accepted = XWSTATE_NONE == server->nv.gameState && !isServer;
|
||||
if ( accepted ) {
|
||||
accepted = client_readInitialMessage( server, xwe, incoming );
|
||||
}
|
||||
accepted = !isServer
|
||||
&& XWSTATE_NONE == server->nv.gameState
|
||||
&& client_readInitialMessage( server, xwe, incoming );
|
||||
break;
|
||||
#ifdef XWFEATURE_CHAT
|
||||
case XWPROTO_CHAT:
|
||||
|
|
|
@ -164,42 +164,6 @@ handle_gotmsg( GIOChannel* source, GIOCondition XP_UNUSED(condition), gpointer d
|
|||
return TRUE;
|
||||
} /* 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
|
||||
postOne( MQTTConStorage* storage, const XP_UCHAR* topic, const XP_U8* buf, XP_U16 len )
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue