From 47954f82d038eff50cbb3a5de409352f09267159 Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 12 Aug 2015 07:43:20 -0700 Subject: [PATCH] add index of sending player to chat transmission, and on receiving side translate that into showing the sender's name in notification. Not yet done: replacing silly "not me" in chat listing with same, but now it should be easy. Conflicts: xwords4/android/XWords4/archive/R.java --- xwords4/android/XWords4/jni/utilwrapper.c | 15 ++++++++++---- xwords4/android/XWords4/jni/xwjni.c | 4 ++-- .../android/XWords4/res/values/strings.xml | 2 +- .../XWords4/res_src/values-ba_CK/strings.xml | 1 + .../XWords4/res_src/values-ca_PS/strings.xml | 1 + .../eehouse/android/xw4/BoardDelegate.java | 2 +- .../org/eehouse/android/xw4/GameUtils.java | 15 ++++++++++++-- .../eehouse/android/xw4/jni/JNIThread.java | 2 +- .../org/eehouse/android/xw4/jni/UtilCtxt.java | 2 +- .../eehouse/android/xw4/jni/UtilCtxtImpl.java | 2 +- .../org/eehouse/android/xw4/jni/XwJNI.java | 2 +- xwords4/common/board.c | 6 ++++++ xwords4/common/board.h | 1 + xwords4/common/server.c | 20 +++++++++++-------- xwords4/common/server.h | 3 ++- xwords4/common/util.h | 5 +++-- xwords4/linux/cursesmain.c | 15 ++++++++++---- xwords4/linux/gtkboard.c | 12 ++++++++--- 18 files changed, 78 insertions(+), 32 deletions(-) diff --git a/xwords4/android/XWords4/jni/utilwrapper.c b/xwords4/android/XWords4/jni/utilwrapper.c index d9f6cd1c3..be8a093cb 100644 --- a/xwords4/android/XWords4/jni/utilwrapper.c +++ b/xwords4/android/XWords4/jni/utilwrapper.c @@ -501,12 +501,19 @@ and_util_warnIllegalWord( XW_UtilCtxt* uc, BadWordInfo* bwi, #ifdef XWFEATURE_CHAT static void -and_util_showChat( XW_UtilCtxt* uc, const XP_UCHAR const* msg ) +and_util_showChat( XW_UtilCtxt* uc, const XP_UCHAR const* msg, XP_S16 from ) { - UTIL_CBK_HEADER("showChat", "(Ljava/lang/String;)V" ); + UTIL_CBK_HEADER( "showChat", "(Ljava/lang/String;Ljava/lang/String;)V" ); + jstring jname = NULL; + if ( 0 <= from ) { + LocalPlayer* lp = &uc->gameInfo->players[from]; + XP_ASSERT( !lp->isLocal ); + jname = (*env)->NewStringUTF( env, lp->name ); + } + jstring jmsg = (*env)->NewStringUTF( env, msg ); - (*env)->CallVoidMethod( env, util->jutil, mid, jmsg ); - deleteLocalRef( env, jmsg ); + (*env)->CallVoidMethod( env, util->jutil, mid, jmsg, jname ); + deleteLocalRefs( env, jmsg, jname, DELETE_NO_REF ); UTIL_CBK_TAIL(); } #endif diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c index 86ed0ee6f..a5e40d8c0 100644 --- a/xwords4/android/XWords4/jni/xwjni.c +++ b/xwords4/android/XWords4/jni/xwjni.c @@ -1872,13 +1872,13 @@ Java_org_eehouse_android_xw4_jni_XwJNI_server_1endGame #ifdef XWFEATURE_CHAT JNIEXPORT void JNICALL -Java_org_eehouse_android_xw4_jni_XwJNI_server_1sendChat +Java_org_eehouse_android_xw4_jni_XwJNI_board_1sendChat ( JNIEnv* env, jclass C, jint gamePtr, jstring jmsg ) { XWJNI_START(); XP_ASSERT( !!state->game.server ); const char* msg = (*env)->GetStringUTFChars( env, jmsg, NULL ); - server_sendChat( state->game.server, msg ); + board_sendChat( state->game.board, msg ); (*env)->ReleaseStringUTFChars( env, jmsg, msg ); XWJNI_END(); } diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml index 1d2b77e27..ada5c43f7 100644 --- a/xwords4/android/XWords4/res/values/strings.xml +++ b/xwords4/android/XWords4/res/values/strings.xml @@ -1464,7 +1464,7 @@ down. --> Move in game %1$s Chat message in game %1$s - + %1$s: %2$s Evom ni emag %1$s Tahc egassem ni emag %1$s + %1$s: %2$s MOVE IN GAME %1$s CHAT MESSAGE IN GAME %1$s + %1$s: %2$s