mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-07 05:24:46 +01:00
add new jni methods (untested)
This commit is contained in:
parent
11266ece5b
commit
b8c588e02c
3 changed files with 52 additions and 0 deletions
|
@ -165,6 +165,16 @@ public class XwJNI {
|
||||||
dvc_parseMQTTPacket( getJNI().m_ptrGlobals, buf );
|
dvc_parseMQTTPacket( getJNI().m_ptrGlobals, buf );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String[] kplr_getPlayers()
|
||||||
|
{
|
||||||
|
return kplr_getPlayers( getJNI().m_ptrGlobals );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CommsAddrRec kplr_getAddr( String name )
|
||||||
|
{
|
||||||
|
return kplr_getAddr( getJNI().m_ptrGlobals, name );
|
||||||
|
}
|
||||||
|
|
||||||
private static void cleanGlobals()
|
private static void cleanGlobals()
|
||||||
{
|
{
|
||||||
synchronized( XwJNI.class ) { // let's be safe here
|
synchronized( XwJNI.class ) { // let's be safe here
|
||||||
|
@ -679,6 +689,10 @@ public class XwJNI {
|
||||||
String[] addrToTopic );
|
String[] addrToTopic );
|
||||||
|
|
||||||
private static native void dvc_parseMQTTPacket( long jniState, byte[] buf );
|
private static native void dvc_parseMQTTPacket( long jniState, byte[] buf );
|
||||||
|
|
||||||
|
private static native String[] kplr_getPlayers( long jniState );
|
||||||
|
private static native CommsAddrRec kplr_getAddr( long jniState, String name );
|
||||||
|
|
||||||
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 );
|
||||||
private static native void gi_from_stream( long jniState, CurGameInfo gi,
|
private static native void gi_from_stream( long jniState, CurGameInfo gi,
|
||||||
|
|
|
@ -87,6 +87,7 @@ COMMON_SRC_FILES += \
|
||||||
$(COMMON_PATH)/nli.c \
|
$(COMMON_PATH)/nli.c \
|
||||||
$(COMMON_PATH)/smsproto.c \
|
$(COMMON_PATH)/smsproto.c \
|
||||||
$(COMMON_PATH)/device.c \
|
$(COMMON_PATH)/device.c \
|
||||||
|
$(COMMON_PATH)/knownplyr.c \
|
||||||
|
|
||||||
LOCAL_CFLAGS+=$(LOCAL_C_INCLUDES) $(LOCAL_DEFINES) -Wall -std=c99
|
LOCAL_CFLAGS+=$(LOCAL_C_INCLUDES) $(LOCAL_DEFINES) -Wall -std=c99
|
||||||
LOCAL_SRC_FILES := $(linux_SRC_FILES) $(LOCAL_SRC_FILES) $(COMMON_SRC_FILES)
|
LOCAL_SRC_FILES := $(linux_SRC_FILES) $(LOCAL_SRC_FILES) $(COMMON_SRC_FILES)
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "nli.h"
|
#include "nli.h"
|
||||||
#include "smsproto.h"
|
#include "smsproto.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
|
#include "knownplyr.h"
|
||||||
|
|
||||||
#include "utilwrapper.h"
|
#include "utilwrapper.h"
|
||||||
#include "drawwrapper.h"
|
#include "drawwrapper.h"
|
||||||
|
@ -770,6 +771,42 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dvc_1parseMQTTPacket
|
||||||
DVC_HEADER_END();
|
DVC_HEADER_END();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jobjectArray JNICALL
|
||||||
|
Java_org_eehouse_android_xw4_jni_XwJNI_kplr_1getPlayers
|
||||||
|
( JNIEnv* env, jclass C, jlong jniGlobalPtr )
|
||||||
|
{
|
||||||
|
jobjectArray jnames = NULL;
|
||||||
|
DVC_HEADER(jniGlobalPtr);
|
||||||
|
|
||||||
|
XP_U16 nFound = 0;
|
||||||
|
kplr_getPlayers( globalState->dutil, env, NULL, &nFound );
|
||||||
|
if ( 0 < nFound ) {
|
||||||
|
const XP_UCHAR* names[nFound];
|
||||||
|
kplr_getPlayers( globalState->dutil, env, names, &nFound );
|
||||||
|
jnames = makeStringArray( env, nFound, names );
|
||||||
|
}
|
||||||
|
DVC_HEADER_END();
|
||||||
|
return jnames;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jobject JNICALL
|
||||||
|
Java_org_eehouse_android_xw4_jni_XwJNI_kplr_1getAddr
|
||||||
|
( JNIEnv* env, jclass C, jlong jniGlobalPtr, jstring jName )
|
||||||
|
{
|
||||||
|
jobject jaddr = NULL;
|
||||||
|
DVC_HEADER(jniGlobalPtr);
|
||||||
|
|
||||||
|
CommsAddrRec addr;
|
||||||
|
const char* name = (*env)->GetStringUTFChars( env, jName, NULL );
|
||||||
|
kplr_getAddr( globalState->dutil, env, name, &addr );
|
||||||
|
(*env)->ReleaseStringUTFChars( env, jName, name );
|
||||||
|
jaddr = makeObjectEmptyConst( env, PKG_PATH("jni/CommsAddrRec") );
|
||||||
|
setJAddrRec( env, jaddr, &addr );
|
||||||
|
|
||||||
|
DVC_HEADER_END();
|
||||||
|
return jaddr;
|
||||||
|
}
|
||||||
|
|
||||||
JNIEXPORT jbyteArray JNICALL
|
JNIEXPORT jbyteArray JNICALL
|
||||||
Java_org_eehouse_android_xw4_jni_XwJNI_gi_1to_1stream
|
Java_org_eehouse_android_xw4_jni_XwJNI_gi_1to_1stream
|
||||||
( JNIEnv* env, jclass C, jlong jniGlobalPtr, jobject jgi )
|
( JNIEnv* env, jclass C, jlong jniGlobalPtr, jobject jgi )
|
||||||
|
|
Loading…
Reference in a new issue