# HG changeset patch # User Carl Byington # Date 1556487956 25200 # Node ID 0bc0b4798d9e276a12945eb48b77a05016d23b53 # Parent 89b6389aa5b23e3ee8e5cfb6261d489c53eecf41 fix saystring(12) command for proper unicode and document it diff -r 89b6389aa5b2 -r 0bc0b4798d9e Makefile --- a/Makefile Thu Nov 08 11:59:30 2018 -0800 +++ b/Makefile Sun Apr 28 14:45:56 2019 -0700 @@ -1,12 +1,13 @@ #mc40 is "On Device Storage" #tc55 is "Internal Storage" +na=$(shell find . -iname '*.c' -o -iname '*.h' -o -iname '*.cpp') style:=release dest:=/run/user/1000/gvfs/mtp*/*torage/Download ver:=$(shell grep versionName app/src/main/AndroidManifest.xml | cut -d'"' -f2) -apk:='app/build/outputs/apk/510ConnectbotMonitor-$(ver).apk' +apk:='app/build/outputs/apk/510ConnectbotMonitor-$(ver).$(style).apk' id:=$(shell hg id --id || echo 1) -da:=$(shell date +%Y-%m-%d) +da:=$(shell date '+%Y-%m-%dT%H:%M:%S') version:=\ \n\ \n\ @@ -15,8 +16,10 @@ ifeq ($(style),release) task:=assembleArmRelease + debug:=0 else task:=assembleArmDebug + debug:=1 endif all: @@ -54,6 +57,8 @@ convert res/drawable-ldpi/icon.png -resize 50% -colorspace Gray res/drawable-ldpi/notification_icon.png indentc: + dos2unix $(na) + for i in $(na); do sed -i -e 's/\r//g' $$i; done indent --line-length100 \ --brace-indent4 \ --braces-on-if-line \ @@ -62,15 +67,17 @@ --case-indentation4 \ --comment-indentation60 \ --cuddle-else \ + --cuddle-do-while \ --declaration-comment-column60 \ --no-tabs \ -nbbo \ -npcs \ -nprs \ -npsl \ + -bad -bap -bbb -sob \ -saf -sai -saw \ -i4 \ - $(shell find . -iname *.c -o -iname *.h -o -iname *.cpp) + $(na) indentjava: astyle --style=java \ @@ -93,5 +100,4 @@ --convert-tabs \ --break-after-logical \ --mode=java \ - $(shell find . -iname *.java | grep -v /gen/) - + $(shell find . -iname '*.java' | grep -v /gen/) diff -r 89b6389aa5b2 -r 0bc0b4798d9e app/build.gradle --- a/app/build.gradle Thu Nov 08 11:59:30 2018 -0800 +++ b/app/build.gradle Sun Apr 28 14:45:56 2019 -0700 @@ -1,23 +1,3 @@ -task copyDebugLibTask(type: Copy) { - from 'build/intermediates/binaries/debug/arm/lib/armeabi' - into 'src/main/jniLibs/armeabi' -} -task copyReleaseLibTask(type: Copy) { - from 'build/intermediates/binaries/release/arm/lib/armeabi' - into 'src/main/jniLibs/armeabi' -} - -tasks.whenTaskAdded { task -> - if (task.name.contains("merge") && task.name.contains("JniLibFolders")) { - if (task.name.contains("ArmDebug")) { - task.dependsOn copyDebugLibTask - } - if (task.name.contains("ArmRelease")) { - task.dependsOn copyReleaseLibTask - } - } -} - apply plugin: 'com.android.application' @@ -36,14 +16,29 @@ keyAlias = "510Connectbot" } } - compileSdkVersion = 16 + compileSdkVersion = 28 buildTypes { release { minifyEnabled = false - signingConfig = signingConfigs.release + signingConfig = android.signingConfigs.release + ndk { + debuggable = false + abiFilters 'armeabi-v7a', 'arm64-v8a' + } } debug { debuggable = true + initWith debug + jniDebuggable true + externalNativeBuild { + ndkBuild { + cFlags "-DDEBUG=1" + } + } + ndk { + debuggable = true + abiFilters 'armeabi-v7a', 'arm64-v8a' + } } } flavorDimensions "arch" @@ -57,9 +52,13 @@ } defaultConfig { - applicationId = "com.five_ten_sg.connectbot" - minSdkVersion = 8 - targetSdkVersion = 15 + applicationId = "com.five_ten_sg.connectbot.monitor" + minSdkVersion 21 + targetSdkVersion 28 + ndk { + moduleName = "monitor" + abiFilters 'armeabi-v7a', 'arm64-v8a' + } } } diff -r 89b6389aa5b2 -r 0bc0b4798d9e app/src/main/AndroidManifest.xml --- a/app/src/main/AndroidManifest.xml Thu Nov 08 11:59:30 2018 -0800 +++ b/app/src/main/AndroidManifest.xml Sun Apr 28 14:45:56 2019 -0700 @@ -1,12 +1,8 @@ - - + android:versionName="1.0.5-0" + android:versionCode="100500" > diff -r 89b6389aa5b2 -r 0bc0b4798d9e app/src/main/java/com/five_ten_sg/connectbot/monitor/MonitorActivity.java --- a/app/src/main/java/com/five_ten_sg/connectbot/monitor/MonitorActivity.java Thu Nov 08 11:59:30 2018 -0800 +++ b/app/src/main/java/com/five_ten_sg/connectbot/monitor/MonitorActivity.java Sun Apr 28 14:45:56 2019 -0700 @@ -24,8 +24,7 @@ import android.widget.TextView; public class MonitorActivity extends Activity { - public final static String TAG = "ConnectBot.MonitorActivity"; - + public static final String TAG = "ConnectBot.MonitorAct."; public static final int MESSAGE_CODE_PRINT = 6000; private final int LINES = 20; private String[] texts = new String[LINES]; @@ -67,6 +66,7 @@ printer(""); Log.i(TAG, "binding to monitor service"); Intent intent = new Intent ("com.five_ten_sg.connectbot.monitor.MonitorService"); + intent.setPackage("com.five_ten_sg.connectbot.monitor"); bindService(intent, connection, Context.BIND_AUTO_CREATE); } diff -r 89b6389aa5b2 -r 0bc0b4798d9e app/src/main/java/com/five_ten_sg/connectbot/monitor/MonitorService.java --- a/app/src/main/java/com/five_ten_sg/connectbot/monitor/MonitorService.java Thu Nov 08 11:59:30 2018 -0800 +++ b/app/src/main/java/com/five_ten_sg/connectbot/monitor/MonitorService.java Sun Apr 28 14:45:56 2019 -0700 @@ -45,6 +45,7 @@ public static final char MONITOR_CMD_SHOWURL = 9; public static final char MONITOR_CMD_SWITCHSESSION = 10; public static final char MONITOR_CMD_CURSORREQUEST = 11; + public static final char MONITOR_CMD_SAYSTRING = 12; public static final char CURSOR_REQUESTED = 0; public static final char CURSOR_SCREEN_CHANGE = 1; @@ -199,12 +200,19 @@ } public void speak(byte [] msg, boolean flush, boolean synchronous) { + speak(utf8BytesToString(msg), flush, synchronous); + } + + public void speak(char [] msg, boolean flush, boolean synchronous) { + speak(new String(msg), flush, synchronous); + } + + public void speak(String msg, boolean flush, boolean synchronous) { if (speech) { - String smsg = bytesToString(msg); if (synchronous) { HashMap myHashParms = new HashMap(); myHashParms.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, String.format("connection %d", connection)); - talker.speak(smsg, (flush) ? TextToSpeech.QUEUE_FLUSH : TextToSpeech.QUEUE_ADD, myHashParms); + talker.speak(msg, (flush) ? TextToSpeech.QUEUE_FLUSH : TextToSpeech.QUEUE_ADD, myHashParms); try { String x = talkerQueue.take(); // wait for completion } catch (InterruptedException e) { @@ -212,20 +220,18 @@ } } else { - talker.speak(smsg, (flush) ? TextToSpeech.QUEUE_FLUSH : TextToSpeech.QUEUE_ADD, null); + talker.speak(msg, (flush) ? TextToSpeech.QUEUE_FLUSH : TextToSpeech.QUEUE_ADD, null); } } } - public String bytesToString(byte[] b) { - char[] c = new char[b.length]; - int bp = 0; - for(int i = 0; i < c.length; i++) { - byte b1 = 0; - byte b2 = b[bp++]; - c[i] = (char) (((b1 & 0x00FF) << 8) + (b2 & 0x00FF)); + public String utf8BytesToString(byte[] b) { + try { + return new String(b, "UTF-8"); } - return new String(c); + catch (Exception e) { + return "invalid utf-8"; + } } public char[] bytesToChars(byte[] b, int len) { @@ -287,7 +293,7 @@ } client_out = null; } - }; + } private char[] forceRead(int len) throws IOException { int len2 = len*2; @@ -398,6 +404,11 @@ value_queue.clear(); value_queue.put(reformatValue(packet)); break; + case MONITOR_CMD_SAYSTRING: + buf = new char[plen-3]; + System.arraycopy(packet, 3, buf, 0, plen-3); + cleanup(buf); + speak(buf, (packet[1] != 0), (packet[2] != 0)); default: break; } @@ -411,6 +422,7 @@ } Log.i(TAG, String.format("shutting down connection %d", connection)); try { + teClose(connection); if (client_in != null) client_in.close(); if (client_out != null) client_out.close(); if (client_socket != null) client_socket.close(); @@ -457,7 +469,7 @@ boolean sameinit = false; CommunicationThread cm = clients.get(currentConnection); if (cm != null) { - sameinit = (cm.initString == fn); + sameinit = (cm.initString.equals(fn)); } setCurrentConnection(connection); } @@ -535,7 +547,7 @@ arg[2] = (char) (l & 0x0000ffff); arg[3] = (char) (c & 0x0000ffff); arg[4] = (char) (len & 0x0000ffff); - cm.clientWrite(MONITOR_CMD_GETFIELD, arg); + cm.clientWrite(MONITOR_CMD_SCREENWATCH, arg); } } diff -r 89b6389aa5b2 -r 0bc0b4798d9e build.gradle --- a/build.gradle Thu Nov 08 11:59:30 2018 -0800 +++ b/build.gradle Sun Apr 28 14:45:56 2019 -0700 @@ -6,7 +6,7 @@ google() } dependencies { - classpath 'com.android.tools.build:gradle:3.2.1' + classpath 'com.android.tools.build:gradle:3.4.0' } } diff -r 89b6389aa5b2 -r 0bc0b4798d9e gradle/wrapper/gradle-wrapper.properties --- a/gradle/wrapper/gradle-wrapper.properties Thu Nov 08 11:59:30 2018 -0800 +++ b/gradle/wrapper/gradle-wrapper.properties Sun Apr 28 14:45:56 2019 -0700 @@ -1,8 +1,6 @@ -#Wed Oct 21 11:34:03 PDT 2015 +#Wed Apr 17 12:40:18 PDT 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -#distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip - +distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip diff -r 89b6389aa5b2 -r 0bc0b4798d9e xml/510connectbotmonitor.in --- a/xml/510connectbotmonitor.in Thu Nov 08 11:59:30 2018 -0800 +++ b/xml/510connectbotmonitor.in Sun Apr 28 14:45:56 2019 -0700 @@ -19,7 +19,7 @@ - 2015-05-01 + 2019-04-28 Carl Byington @@ -42,8 +42,7 @@ Build method This is an android project with no native code, so - "android update project -p . -t android-16; ant debug" - should build cleanly. + "make docs; make builder style=release" should build cleanly. @@ -77,9 +76,9 @@ The messages exchanged between the terminal emulator and the terminal monitor are arrays of uint16 values in network byte - order. Each message starts with a uint16 message byte length, - followed by that many bytes of data. Note that the message length - will always be even. The next uint16 contains the message + order. Each message starts with a uint16 message length, + followed by that many uint16 values. + The next uint16 contains the message command value, and the remaining uint16 values are the arguments if any for that command. @@ -139,7 +138,7 @@ and the second argument is the column number (0..79). That is followed by the field value, a sequence of uint16 character codes from the screen buffer. The field - covers N columns, where N = (message length - 4) / 2. + covers N columns, where N = (message length - 4). When sent from the monitor to the emulator, this causes the emulator to send the field codes to the host (for async modes) or to set the specified field contents (for block modes). @@ -192,6 +191,13 @@ in block mode (tn5250) sessions. Those commands do trigger CURSORMOVE updates in async mode (telnet, ssh) sessions. + + + SAYSTRING = 12 (TE -> Monitor). The first argument is nonzero if + any current speech should be flushed. The second argument is nonzero + if this speech should be synchronous. That is followed by uint16 + character codes to be spoken. + diff -r 89b6389aa5b2 -r 0bc0b4798d9e xml/Makefile --- a/xml/Makefile Thu Nov 08 11:59:30 2018 -0800 +++ b/xml/Makefile Sun Apr 28 14:45:56 2019 -0700 @@ -4,9 +4,8 @@ all: sed -e 's/@PACKAGE@/$(pkg)/g' -e 's/@VERSION@/$(ver)/g' <510connectbotmonitor.in >510connectbotmonitor cat header.xml 510connectbotmonitor >510connectbotmonitor.xml - cat header.sgml 510connectbotmonitor >510connectbotmonitor.sgml rm -f ../html/*html rm -f ../html/*pdf xmlto -o ../html xhtml 510connectbotmonitor.xml xmlto -o ../html pdf 510connectbotmonitor.xml - rm -f 510connectbotmonitor.xml 510connectbotmonitor.sgml + rm -f 510connectbotmonitor.xml