Commit 844f2ac240556597dfb14ec803ef409c659248a6
1 parent
14e89689
Exists in
master
and in
5 other branches
Iniciando implementação da passagem de valores da interface jni para o buffer de terminal
Showing
9 changed files
with
172 additions
and
120 deletions
Show diff stats
android/jni/Android.mk
| @@ -34,7 +34,7 @@ LOCAL_DEFAULT_CPP_EXTENSION := cpp | @@ -34,7 +34,7 @@ LOCAL_DEFAULT_CPP_EXTENSION := cpp | ||
| 34 | LOCAL_MODULE := lib3270 | 34 | LOCAL_MODULE := lib3270 |
| 35 | LOCAL_LDLIBS := -llog | 35 | LOCAL_LDLIBS := -llog |
| 36 | LOCAL_SRC_FILES := $(foreach SRC, $(TERMINAL_SOURCES) $(NETWORK_SOURCES), ../../src/lib3270/$(SRC)) \ | 36 | LOCAL_SRC_FILES := $(foreach SRC, $(TERMINAL_SOURCES) $(NETWORK_SOURCES), ../../src/lib3270/$(SRC)) \ |
| 37 | - main.cpp misc.cpp html.cpp actions.cpp | 37 | + main.cpp misc.cpp text.cpp actions.cpp |
| 38 | 38 | ||
| 39 | include $(BUILD_SHARED_LIBRARY) | 39 | include $(BUILD_SHARED_LIBRARY) |
| 40 | 40 |
android/jni/html.cpp
| @@ -1,112 +0,0 @@ | @@ -1,112 +0,0 @@ | ||
| 1 | -/* | ||
| 2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
| 3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
| 4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270. | ||
| 5 | - * | ||
| 6 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
| 7 | - * | ||
| 8 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
| 9 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
| 10 | - * Free Software Foundation. | ||
| 11 | - * | ||
| 12 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
| 13 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
| 14 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
| 15 | - * obter mais detalhes. | ||
| 16 | - * | ||
| 17 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
| 18 | - * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple | ||
| 19 | - * Place, Suite 330, Boston, MA, 02111-1307, USA | ||
| 20 | - * | ||
| 21 | - * Este programa está nomeado como main.cpp e possui - linhas de código. | ||
| 22 | - * | ||
| 23 | - * Contatos: | ||
| 24 | - * | ||
| 25 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
| 26 | - * | ||
| 27 | - */ | ||
| 28 | - | ||
| 29 | - #include "globals.h" | ||
| 30 | - #include <lib3270/html.h> | ||
| 31 | - #include <string.h> | ||
| 32 | - | ||
| 33 | -/*--[ Implement ]------------------------------------------------------------------------------------*/ | ||
| 34 | - | ||
| 35 | -static jbyteArray retString(JNIEnv *env, const char *txt) | ||
| 36 | -{ | ||
| 37 | - size_t len = strlen(txt); | ||
| 38 | - jbyteArray ret = env->NewByteArray(len); | ||
| 39 | - env->SetByteArrayRegion(ret, 0, len, (jbyte*) txt); | ||
| 40 | - return ret; | ||
| 41 | -} | ||
| 42 | - | ||
| 43 | -JNIEXPORT jbyteArray JNICALL Java_br_com_bb_pw3270_lib3270_getHTML(JNIEnv *env, jobject obj) | ||
| 44 | -{ | ||
| 45 | - jbyteArray ret; | ||
| 46 | - | ||
| 47 | - session_request(env,obj); | ||
| 48 | - | ||
| 49 | - trace("%s starts, session=%p",__FUNCTION__,session); | ||
| 50 | - | ||
| 51 | - if(session) | ||
| 52 | - { | ||
| 53 | - char *text = lib3270_get_as_html(session,(LIB3270_HTML_OPTION) (LIB3270_HTML_OPTION_ALL|LIB3270_HTML_OPTION_FORM)); | ||
| 54 | - | ||
| 55 | - if(text) | ||
| 56 | - { | ||
| 57 | - ret = retString(env,text); | ||
| 58 | - lib3270_free(text); | ||
| 59 | - } | ||
| 60 | - else | ||
| 61 | - { | ||
| 62 | - ret = retString(env, "<b>Empty session</b>"); | ||
| 63 | - } | ||
| 64 | - } | ||
| 65 | - else | ||
| 66 | - { | ||
| 67 | - ret = retString(env, "<b>Invalid Session ID</b>"); | ||
| 68 | - } | ||
| 69 | - | ||
| 70 | - trace("%s ends",__FUNCTION__); | ||
| 71 | - | ||
| 72 | - session_release(); | ||
| 73 | - | ||
| 74 | - return ret; | ||
| 75 | -} | ||
| 76 | - | ||
| 77 | - | ||
| 78 | -JNIEXPORT jbyteArray JNICALL Java_br_com_bb_pw3270_lib3270_getText(JNIEnv *env, jobject obj) | ||
| 79 | -{ | ||
| 80 | - jbyteArray ret; | ||
| 81 | - | ||
| 82 | - session_request(env,obj); | ||
| 83 | - | ||
| 84 | - trace("%s starts, session=%p",__FUNCTION__,session); | ||
| 85 | - | ||
| 86 | - if(session) | ||
| 87 | - { | ||
| 88 | - char *text = lib3270_get_text(session,0,-1); | ||
| 89 | - | ||
| 90 | - trace("%s will return \"%s\"",__FUNCTION__,text ? text : ""); | ||
| 91 | - | ||
| 92 | - if(text) | ||
| 93 | - { | ||
| 94 | - ret = retString(env,text); | ||
| 95 | - lib3270_free(text); | ||
| 96 | - } | ||
| 97 | - else | ||
| 98 | - { | ||
| 99 | - ret = retString(env, ""); | ||
| 100 | - } | ||
| 101 | - } | ||
| 102 | - else | ||
| 103 | - { | ||
| 104 | - ret = retString(env, "<b>Invalid Session ID</b>"); | ||
| 105 | - } | ||
| 106 | - | ||
| 107 | - trace("%s ends",__FUNCTION__); | ||
| 108 | - | ||
| 109 | - session_release(); | ||
| 110 | - | ||
| 111 | - return ret; | ||
| 112 | -} |
| @@ -0,0 +1,136 @@ | @@ -0,0 +1,136 @@ | ||
| 1 | +/* | ||
| 2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
| 3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
| 4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270. | ||
| 5 | + * | ||
| 6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
| 7 | + * | ||
| 8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
| 9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
| 10 | + * Free Software Foundation. | ||
| 11 | + * | ||
| 12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
| 13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
| 14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
| 15 | + * obter mais detalhes. | ||
| 16 | + * | ||
| 17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
| 18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple | ||
| 19 | + * Place, Suite 330, Boston, MA, 02111-1307, USA | ||
| 20 | + * | ||
| 21 | + * Este programa está nomeado como text.cpp e possui - linhas de código. | ||
| 22 | + * | ||
| 23 | + * Contatos: | ||
| 24 | + * | ||
| 25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
| 26 | + * | ||
| 27 | + */ | ||
| 28 | + | ||
| 29 | + #include "globals.h" | ||
| 30 | + #include <lib3270/html.h> | ||
| 31 | + #include <string.h> | ||
| 32 | + | ||
| 33 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | ||
| 34 | + | ||
| 35 | +static jbyteArray retString(JNIEnv *env, const char *txt) | ||
| 36 | +{ | ||
| 37 | + size_t len = strlen(txt); | ||
| 38 | + jbyteArray ret = env->NewByteArray(len); | ||
| 39 | + env->SetByteArrayRegion(ret, 0, len, (jbyte*) txt); | ||
| 40 | + return ret; | ||
| 41 | +} | ||
| 42 | + | ||
| 43 | +JNIEXPORT jbyteArray JNICALL Java_br_com_bb_pw3270_lib3270_getHTML(JNIEnv *env, jobject obj) | ||
| 44 | +{ | ||
| 45 | + jbyteArray ret; | ||
| 46 | + | ||
| 47 | + session_request(env,obj); | ||
| 48 | + | ||
| 49 | + trace("%s starts, session=%p",__FUNCTION__,session); | ||
| 50 | + | ||
| 51 | + if(session) | ||
| 52 | + { | ||
| 53 | + char *text = lib3270_get_as_html(session,(LIB3270_HTML_OPTION) (LIB3270_HTML_OPTION_ALL|LIB3270_HTML_OPTION_FORM)); | ||
| 54 | + | ||
| 55 | + if(text) | ||
| 56 | + { | ||
| 57 | + ret = retString(env,text); | ||
| 58 | + lib3270_free(text); | ||
| 59 | + } | ||
| 60 | + else | ||
| 61 | + { | ||
| 62 | + ret = retString(env, "<b>Empty session</b>"); | ||
| 63 | + } | ||
| 64 | + } | ||
| 65 | + else | ||
| 66 | + { | ||
| 67 | + ret = retString(env, "<b>Invalid Session ID</b>"); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + trace("%s ends",__FUNCTION__); | ||
| 71 | + | ||
| 72 | + session_release(); | ||
| 73 | + | ||
| 74 | + return ret; | ||
| 75 | +} | ||
| 76 | + | ||
| 77 | + | ||
| 78 | +JNIEXPORT jbyteArray JNICALL Java_br_com_bb_pw3270_lib3270_getText(JNIEnv *env, jobject obj) | ||
| 79 | +{ | ||
| 80 | + jbyteArray ret; | ||
| 81 | + | ||
| 82 | + session_request(env,obj); | ||
| 83 | + | ||
| 84 | + trace("%s starts, session=%p",__FUNCTION__,session); | ||
| 85 | + | ||
| 86 | + if(session) | ||
| 87 | + { | ||
| 88 | + char *text = lib3270_get_text(session,0,-1); | ||
| 89 | + | ||
| 90 | + trace("%s will return \"%s\"",__FUNCTION__,text ? text : ""); | ||
| 91 | + | ||
| 92 | + if(text) | ||
| 93 | + { | ||
| 94 | + ret = retString(env,text); | ||
| 95 | + lib3270_free(text); | ||
| 96 | + } | ||
| 97 | + else | ||
| 98 | + { | ||
| 99 | + ret = retString(env, ""); | ||
| 100 | + } | ||
| 101 | + } | ||
| 102 | + else | ||
| 103 | + { | ||
| 104 | + ret = retString(env, "<b>Invalid Session ID</b>"); | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + trace("%s ends",__FUNCTION__); | ||
| 108 | + | ||
| 109 | + session_release(); | ||
| 110 | + | ||
| 111 | + return ret; | ||
| 112 | +} | ||
| 113 | + | ||
| 114 | +JNIEXPORT void JNICALL Java_br_com_bb_pw3270_lib3270_setTextAt(JNIEnv *env, jobject obj, jint pos, jbyteArray inText, jint szText) | ||
| 115 | +{ | ||
| 116 | + char str[szText+1]; | ||
| 117 | + int f; | ||
| 118 | + jbyte * bt; | ||
| 119 | + | ||
| 120 | + | ||
| 121 | + session_request(env,obj); | ||
| 122 | + | ||
| 123 | + if(!session) | ||
| 124 | + return; | ||
| 125 | + | ||
| 126 | + bt = env->GetByteArrayElements(inText,0); | ||
| 127 | + | ||
| 128 | + for(int f=0;f<szText;f++) | ||
| 129 | + str[f] = (char) bt[f]; | ||
| 130 | + str[szText] = 0; | ||
| 131 | + | ||
| 132 | + trace("Buffer(%d)=\"%s\"",(int) pos, str); | ||
| 133 | + | ||
| 134 | + env->ReleaseByteArrayElements(inText,bt,JNI_ABORT); | ||
| 135 | + session_release(); | ||
| 136 | +} |
android/lib3270NDK.cbp
| @@ -58,10 +58,10 @@ | @@ -58,10 +58,10 @@ | ||
| 58 | <Unit filename="jni/Android.mk" /> | 58 | <Unit filename="jni/Android.mk" /> |
| 59 | <Unit filename="jni/actions.cpp" /> | 59 | <Unit filename="jni/actions.cpp" /> |
| 60 | <Unit filename="jni/globals.h" /> | 60 | <Unit filename="jni/globals.h" /> |
| 61 | - <Unit filename="jni/html.cpp" /> | ||
| 62 | <Unit filename="jni/lib3270jni.h" /> | 61 | <Unit filename="jni/lib3270jni.h" /> |
| 63 | <Unit filename="jni/main.cpp" /> | 62 | <Unit filename="jni/main.cpp" /> |
| 64 | <Unit filename="jni/misc.cpp" /> | 63 | <Unit filename="jni/misc.cpp" /> |
| 64 | + <Unit filename="jni/text.cpp" /> | ||
| 65 | <Unit filename="src/br/com/bb/pw3270/PW3270Activity.java" /> | 65 | <Unit filename="src/br/com/bb/pw3270/PW3270Activity.java" /> |
| 66 | <Unit filename="src/br/com/bb/pw3270/lib3270.java" /> | 66 | <Unit filename="src/br/com/bb/pw3270/lib3270.java" /> |
| 67 | <Extensions> | 67 | <Extensions> |
android/res/raw/jsmain.js
| @@ -17,7 +17,17 @@ function pfkey(id) | @@ -17,7 +17,17 @@ function pfkey(id) | ||
| 17 | 17 | ||
| 18 | function xmit() | 18 | function xmit() |
| 19 | { | 19 | { |
| 20 | - pw3270.xmit(); | 20 | + var form = document.getElementById("form3270"); |
| 21 | + | ||
| 22 | + for(var i=0;i < form.elements.length;i++) | ||
| 23 | + { | ||
| 24 | + if(form.elements[i].name.substr(0,1) == "F") | ||
| 25 | + { | ||
| 26 | + var offset = parseInt(form.elements[i].name.substr(1,4)); | ||
| 27 | + alert("offset="+offset+" \""+form.elements[i].value+"\""); | ||
| 28 | + pw3270.setStringAt(offset,form.elements[i].value); | ||
| 29 | + } | ||
| 30 | + } | ||
| 21 | return false; | 31 | return false; |
| 22 | } | 32 | } |
| 23 | 33 | ||
| @@ -25,4 +35,3 @@ function eraseinput() | @@ -25,4 +35,3 @@ function eraseinput() | ||
| 25 | { | 35 | { |
| 26 | return false; | 36 | return false; |
| 27 | } | 37 | } |
| 28 | - |
android/res/raw/theme.css
| @@ -60,8 +60,6 @@ input[type="password"]:focus | @@ -60,8 +60,6 @@ input[type="password"]:focus | ||
| 60 | #pfbar | 60 | #pfbar |
| 61 | { | 61 | { |
| 62 | z-index: -1; | 62 | z-index: -1; |
| 63 | - position: fixed; | ||
| 64 | - bottom: 1px; | ||
| 65 | width: 49em; | 63 | width: 49em; |
| 66 | background: black; | 64 | background: black; |
| 67 | color: white; | 65 | color: white; |
android/src/br/com/bb/pw3270/lib3270.java
| @@ -55,7 +55,7 @@ public class lib3270 | @@ -55,7 +55,7 @@ public class lib3270 | ||
| 55 | id = timer_id; | 55 | id = timer_id; |
| 56 | 56 | ||
| 57 | Log.d(TAG,"Timer " + id + " set to " + msec + " ms"); | 57 | Log.d(TAG,"Timer " + id + " set to " + msec + " ms"); |
| 58 | - | 58 | + |
| 59 | this.start(); | 59 | this.start(); |
| 60 | } | 60 | } |
| 61 | 61 | ||
| @@ -380,6 +380,15 @@ public class lib3270 | @@ -380,6 +380,15 @@ public class lib3270 | ||
| 380 | return 0; | 380 | return 0; |
| 381 | } | 381 | } |
| 382 | 382 | ||
| 383 | + public void setStringAt(int offset, String str) | ||
| 384 | + { | ||
| 385 | + try | ||
| 386 | + { | ||
| 387 | + setTextAt(offset,str.getBytes(getEncoding()),str.length()); | ||
| 388 | + } catch( Exception e ) { } | ||
| 389 | + } | ||
| 390 | + | ||
| 391 | + | ||
| 383 | /*---[ Native calls ]----------------------------------------------------*/ | 392 | /*---[ Native calls ]----------------------------------------------------*/ |
| 384 | static private native int init(); | 393 | static private native int init(); |
| 385 | 394 | ||
| @@ -417,6 +426,7 @@ public class lib3270 | @@ -417,6 +426,7 @@ public class lib3270 | ||
| 417 | // Get/Set screen contents | 426 | // Get/Set screen contents |
| 418 | public native byte[] getHTML(); | 427 | public native byte[] getHTML(); |
| 419 | public native byte[] getText(); | 428 | public native byte[] getText(); |
| 429 | + public native void setTextAt(int offset, byte[] str, int len); | ||
| 420 | 430 | ||
| 421 | 431 | ||
| 422 | } | 432 | } |
pw3270.cbp
| @@ -53,6 +53,7 @@ | @@ -53,6 +53,7 @@ | ||
| 53 | <Unit filename="configure.ac" /> | 53 | <Unit filename="configure.ac" /> |
| 54 | <Unit filename="pw3270.spec.in" /> | 54 | <Unit filename="pw3270.spec.in" /> |
| 55 | <Unit filename="src/include/lib3270.h" /> | 55 | <Unit filename="src/include/lib3270.h" /> |
| 56 | + <Unit filename="src/include/lib3270/3270ds.h" /> | ||
| 56 | <Unit filename="src/include/lib3270/action_table.h" /> | 57 | <Unit filename="src/include/lib3270/action_table.h" /> |
| 57 | <Unit filename="src/include/lib3270/actions.h" /> | 58 | <Unit filename="src/include/lib3270/actions.h" /> |
| 58 | <Unit filename="src/include/lib3270/config.h.in" /> | 59 | <Unit filename="src/include/lib3270/config.h.in" /> |
src/lib3270/html.c
| @@ -274,6 +274,16 @@ | @@ -274,6 +274,16 @@ | ||
| 274 | 274 | ||
| 275 | if(*ptr) | 275 | if(*ptr) |
| 276 | { | 276 | { |
| 277 | + int f; | ||
| 278 | + char * last = ptr; | ||
| 279 | + | ||
| 280 | + for(f=0;ptr[f];f++) | ||
| 281 | + { | ||
| 282 | + if(ptr[f] > ' ') | ||
| 283 | + last = ptr+f+1; | ||
| 284 | + } | ||
| 285 | + *last = 0; | ||
| 286 | + | ||
| 277 | append_string(&info," value=\""); | 287 | append_string(&info," value=\""); |
| 278 | append_string(&info,ptr); | 288 | append_string(&info,ptr); |
| 279 | append_string(&info,"\""); | 289 | append_string(&info,"\""); |
| @@ -397,7 +407,7 @@ | @@ -397,7 +407,7 @@ | ||
| 397 | 407 | ||
| 398 | if(info.form) | 408 | if(info.form) |
| 399 | { | 409 | { |
| 400 | - static const char * prefix = "<form name=\"" PACKAGE_NAME "\">"; | 410 | + static const char * prefix = "<form name=\"" PACKAGE_NAME "\" id=\"form3270\" >"; |
| 401 | static const char * suffix = "</form>"; | 411 | static const char * suffix = "</form>"; |
| 402 | char *text = info.text; | 412 | char *text = info.text; |
| 403 | 413 |