mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-31 19:57:06 +01:00
list known player in invite info where known
(for mqtt only)
This commit is contained in:
parent
2bfeedceb3
commit
dbde9c87ae
5 changed files with 55 additions and 0 deletions
|
@ -603,6 +603,15 @@ public class DBUtils {
|
||||||
msg = LocUtils.getString( context, R.string.invit_expl_relay_fmt,
|
msg = LocUtils.getString( context, R.string.invit_expl_relay_fmt,
|
||||||
timestamp );
|
timestamp );
|
||||||
break;
|
break;
|
||||||
|
case MQTT:
|
||||||
|
String player = XwJNI.kplr_nameForMqttDev( target );
|
||||||
|
if ( null != player ) {
|
||||||
|
msg = LocUtils.getString( context,
|
||||||
|
R.string.invit_expl_player_fmt,
|
||||||
|
player, timestamp );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// else FALLTHRU
|
||||||
default:
|
default:
|
||||||
msg = LocUtils.getString( context, R.string.invit_expl_notarget_fmt,
|
msg = LocUtils.getString( context, R.string.invit_expl_notarget_fmt,
|
||||||
means.toString(), timestamp );
|
means.toString(), timestamp );
|
||||||
|
|
|
@ -204,6 +204,13 @@ public class XwJNI {
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String kplr_nameForMqttDev( String mqttID )
|
||||||
|
{
|
||||||
|
return BuildConfig.HAVE_KNOWN_PLAYERS
|
||||||
|
? kplr_nameForMqttDev( getJNI().m_ptrGlobals, mqttID )
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
private static void cleanGlobals()
|
private static void cleanGlobals()
|
||||||
{
|
{
|
||||||
synchronized( XwJNI.class ) { // let's be safe here
|
synchronized( XwJNI.class ) { // let's be safe here
|
||||||
|
@ -724,6 +731,7 @@ public class XwJNI {
|
||||||
String newName );
|
String newName );
|
||||||
private static native void kplr_deletePlayer( long jniState, String player );
|
private static native void kplr_deletePlayer( long jniState, String player );
|
||||||
private static native CommsAddrRec kplr_getAddr( long jniState, String name );
|
private static native CommsAddrRec kplr_getAddr( long jniState, String name );
|
||||||
|
public static native String kplr_nameForMqttDev( long jniState, String mqttID );
|
||||||
|
|
||||||
private static native void cleanGlobals( long jniState );
|
private static native void cleanGlobals( long jniState );
|
||||||
private static native byte[] gi_to_stream( long jniState, CurGameInfo gi );
|
private static native byte[] gi_to_stream( long jniState, CurGameInfo gi );
|
||||||
|
|
|
@ -833,6 +833,20 @@ Java_org_eehouse_android_xw4_jni_XwJNI_kplr_1getAddr
|
||||||
DVC_HEADER_END();
|
DVC_HEADER_END();
|
||||||
return jaddr;
|
return jaddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jstring JNICALL
|
||||||
|
Java_org_eehouse_android_xw4_jni_XwJNI_kplr_1nameForMqttDev
|
||||||
|
( JNIEnv* env, jclass C, jlong jniGlobalPtr, jstring jDevID )
|
||||||
|
{
|
||||||
|
jstring result = NULL;
|
||||||
|
DVC_HEADER(jniGlobalPtr);
|
||||||
|
const char* devid = (*env)->GetStringUTFChars( env, jDevID, NULL );
|
||||||
|
const XP_UCHAR* name = kplr_nameForMqttDev( globalState->dutil, env, devid );
|
||||||
|
result = (*env)->NewStringUTF( env, name );
|
||||||
|
(*env)->ReleaseStringUTFChars( env, jDevID, devid );
|
||||||
|
DVC_HEADER_END();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
JNIEXPORT jbyteArray JNICALL
|
JNIEXPORT jbyteArray JNICALL
|
||||||
|
|
|
@ -292,6 +292,27 @@ kplr_getAddr( XW_DUtilCtxt* dutil, XWEnv xwe, const XP_UCHAR* name,
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const XP_UCHAR*
|
||||||
|
kplr_nameForMqttDev( XW_DUtilCtxt* dutil, XWEnv xwe, const XP_UCHAR* mqttDevID )
|
||||||
|
{
|
||||||
|
const XP_UCHAR* name = NULL;
|
||||||
|
MQTTDevID devID;
|
||||||
|
if ( strToMQTTCDevID( mqttDevID, &devID ) ) {
|
||||||
|
KPState* state = loadState( dutil, xwe );
|
||||||
|
for ( KnownPlayer* kp = state->players; !!kp && !name; kp = kp->next ) {
|
||||||
|
const CommsAddrRec* addr = &kp->addr;
|
||||||
|
if ( addr_hasType( addr, COMMS_CONN_MQTT ) ) {
|
||||||
|
if ( 0 == XP_MEMCMP( &addr->u.mqtt.devID, &devID, sizeof(devID) ) ) {
|
||||||
|
name = kp->name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
releaseState( dutil, xwe, state );
|
||||||
|
}
|
||||||
|
LOG_RETURNF( "%s", name );
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
freeKP( XW_DUtilCtxt* dutil, KnownPlayer* kp )
|
freeKP( XW_DUtilCtxt* dutil, KnownPlayer* kp )
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,6 +43,9 @@ void kplr_getNames( XW_DUtilCtxt* dutil, XWEnv xwe, const XP_UCHAR** players,
|
||||||
XP_U16* nFound );
|
XP_U16* nFound );
|
||||||
XP_Bool kplr_getAddr( XW_DUtilCtxt* dutil, XWEnv xwe, const XP_UCHAR* name,
|
XP_Bool kplr_getAddr( XW_DUtilCtxt* dutil, XWEnv xwe, const XP_UCHAR* name,
|
||||||
CommsAddrRec* addr );
|
CommsAddrRec* addr );
|
||||||
|
const XP_UCHAR* kplr_nameForMqttDev( XW_DUtilCtxt* dutil, XWEnv xwe,
|
||||||
|
const XP_UCHAR* mqttDevID );
|
||||||
|
|
||||||
KP_Rslt kplr_renamePlayer( XW_DUtilCtxt* dutil, XWEnv xwe, const XP_UCHAR* oldName,
|
KP_Rslt kplr_renamePlayer( XW_DUtilCtxt* dutil, XWEnv xwe, const XP_UCHAR* oldName,
|
||||||
const XP_UCHAR* newName );
|
const XP_UCHAR* newName );
|
||||||
KP_Rslt kplr_deletePlayer( XW_DUtilCtxt* dutil, XWEnv xwe, const XP_UCHAR* name );
|
KP_Rslt kplr_deletePlayer( XW_DUtilCtxt* dutil, XWEnv xwe, const XP_UCHAR* name );
|
||||||
|
|
Loading…
Add table
Reference in a new issue