Commit 5840d5310476b2d897bfb47c074542dce2c3bb96
1 parent
494577e5
Exists in
master
and in
5 other branches
Trabalhando na versão Android
Showing
14 changed files
with
150 additions
and
68 deletions
Show diff stats
android/Makefile
... | ... | @@ -28,17 +28,20 @@ JAVAC=javac |
28 | 28 | NDKBUILD=/opt/android-ndk-r8/ndk-build |
29 | 29 | CLASSPATH=br/com/bb/pw3270 |
30 | 30 | ANDROIDSDK=/opt/android-sdk |
31 | - | |
32 | -# package android.os does not exist | |
33 | -# javac -d bin/classes | |
34 | - | |
35 | -# /opt/android-sdk/tools/lib/ | |
36 | - | |
37 | 31 | MKDIR=/bin/mkdir -p |
38 | 32 | CONVERT=rsvg-convert |
39 | 33 | |
40 | 34 | RESOLUTION=xhdpi mdpi ldpi hdpi |
41 | 35 | |
36 | +#---[ Rules ]------------------------------------------------------------------ | |
37 | + | |
38 | +bin/classes/$(CLASSPATH)/%.class: src/$(CLASSPATH)/%.java | |
39 | + @$(MKDIR) `dirname $@` | |
40 | + @echo "Compile thumb : `basename $@` <= `basename $<`" | |
41 | + @$(JAVAC) -classpath $(ANDROIDSDK)/platforms/android-15/android.jar -d bin/classes $< | |
42 | + | |
43 | +#---[ Targets ]---------------------------------------------------------------- | |
44 | + | |
42 | 45 | Debug: jni/lib3270jni.h icons |
43 | 46 | @$(NDKBUILD) |
44 | 47 | |
... | ... | @@ -73,10 +76,6 @@ res/drawable-hdpi/ic_launcher.png: ../src/pw3270/pixmaps/pw3270.svg |
73 | 76 | @$(MKDIR) `dirname $@` |
74 | 77 | @$(CONVERT) --format=png --width=72 --height=72 --output=$@ $< |
75 | 78 | |
76 | -bin/classes/$(CLASSPATH)/lib3270.class: src/$(CLASSPATH)/lib3270.java | |
77 | - @$(MKDIR) `dirname $@` | |
78 | - @$(JAVAC) -classpath $(ANDROIDSDK)/platforms/android-15/android.jar -d bin/classes src/$(CLASSPATH)/lib3270.java | |
79 | - | |
80 | 79 | sigs.txt: bin/classes/$(CLASSPATH)/lib3270.class |
81 | 80 | @javap -classpath ./bin/classes -s -p br.com.bb.pw3270.lib3270 > $@ |
82 | 81 | ... | ... |
android/jni/main.cpp
... | ... | @@ -165,7 +165,7 @@ static void remove_timer(void *id) |
165 | 165 | |
166 | 166 | if(timer == NULL) |
167 | 167 | { |
168 | - __android_log_print(ANDROID_LOG_VERBOSE, PACKAGE_NAME, "Invalid timer ID %08lx",(unsigned long) timer); | |
168 | +// __android_log_print(ANDROID_LOG_VERBOSE, PACKAGE_NAME, "Invalid timer ID %08lx",(unsigned long) timer); | |
169 | 169 | return; |
170 | 170 | } |
171 | 171 | |
... | ... | @@ -181,7 +181,7 @@ JNIEXPORT void JNICALL Java_br_com_bb_pw3270_lib3270_timerFinish(JNIEnv *env, jo |
181 | 181 | |
182 | 182 | if(timer == NULL) |
183 | 183 | { |
184 | - __android_log_print(ANDROID_LOG_VERBOSE, PACKAGE_NAME, "Unexpected call to %s: No timer ID",__FUNCTION__); | |
184 | +// __android_log_print(ANDROID_LOG_VERBOSE, PACKAGE_NAME, "Unexpected call to %s: No timer ID",__FUNCTION__); | |
185 | 185 | return; |
186 | 186 | } |
187 | 187 | ... | ... |
android/jni/text.cpp
... | ... | @@ -113,10 +113,9 @@ JNIEXPORT jbyteArray JNICALL Java_br_com_bb_pw3270_lib3270_getText(JNIEnv *env, |
113 | 113 | |
114 | 114 | JNIEXPORT void JNICALL Java_br_com_bb_pw3270_lib3270_setTextAt(JNIEnv *env, jobject obj, jint pos, jbyteArray inText, jint szText) |
115 | 115 | { |
116 | - char str[szText+1]; | |
117 | - int f; | |
118 | - jbyte * bt; | |
119 | - | |
116 | + unsigned char str[szText+1]; | |
117 | + int f; | |
118 | + jbyte * bt; | |
120 | 119 | |
121 | 120 | session_request(env,obj); |
122 | 121 | |
... | ... | @@ -129,7 +128,29 @@ JNIEXPORT void JNICALL Java_br_com_bb_pw3270_lib3270_setTextAt(JNIEnv *env, jobj |
129 | 128 | str[f] = (char) bt[f]; |
130 | 129 | str[szText] = 0; |
131 | 130 | |
132 | - trace("Buffer(%d)=\"%s\"",(int) pos, str); | |
131 | + trace("Buffer(%d/%d)=\"%s\"",(int) pos, lib3270_field_addr(session, (int) pos), str); | |
132 | + | |
133 | + | |
134 | + if( ((int) pos) == lib3270_field_addr(session, (int) pos)) | |
135 | + { | |
136 | + // Begin of field, clear it first | |
137 | + int sz = lib3270_field_length(session,pos); | |
138 | + unsigned char * buffer = (unsigned char *) lib3270_malloc(sz+1); | |
139 | + | |
140 | + memset(buffer,' ',sz); | |
141 | + | |
142 | + lib3270_clear_operator_error(session); | |
143 | + lib3270_set_cursor_address(session,(int) pos); | |
144 | + lib3270_set_string(session,buffer); | |
145 | + | |
146 | + lib3270_free(buffer); | |
147 | + } | |
148 | + | |
149 | + lib3270_clear_operator_error(session); | |
150 | + lib3270_set_cursor_address(session,(int) pos); | |
151 | + lib3270_set_string(session,str); | |
152 | + | |
153 | + lib3270_clear_operator_error(session); | |
133 | 154 | |
134 | 155 | env->ReleaseByteArrayElements(inText,bt,JNI_ABORT); |
135 | 156 | session_release(); | ... | ... |
android/lib3270NDK.cbp
... | ... | @@ -38,6 +38,9 @@ |
38 | 38 | <Unit filename="../src/include/lib3270/internals.h" /> |
39 | 39 | <Unit filename="../src/include/lib3270/log.h" /> |
40 | 40 | <Unit filename="../src/include/lib3270/session.h" /> |
41 | + <Unit filename="../src/lib3270/ctlr.c"> | |
42 | + <Option compilerVar="CC" /> | |
43 | + </Unit> | |
41 | 44 | <Unit filename="../src/lib3270/html.c"> |
42 | 45 | <Option compilerVar="CC" /> |
43 | 46 | </Unit> | ... | ... |
android/res/raw/jsmain.js
... | ... | @@ -24,10 +24,12 @@ function xmit() |
24 | 24 | if(form.elements[i].name.substr(0,1) == "F") |
25 | 25 | { |
26 | 26 | var offset = parseInt(form.elements[i].name.substr(1,4)); |
27 | - alert("offset="+offset+" \""+form.elements[i].value+"\""); | |
28 | 27 | pw3270.setStringAt(offset,form.elements[i].value); |
29 | 28 | } |
30 | 29 | } |
30 | + | |
31 | + pw3270.sendEnter(); | |
32 | + | |
31 | 33 | return false; |
32 | 34 | } |
33 | 35 | ... | ... |
android/res/raw/theme.css
... | ... | @@ -33,22 +33,22 @@ input:focus |
33 | 33 | |
34 | 34 | input[type="text"] |
35 | 35 | { |
36 | - border: 1px solid #004000 | |
36 | + background-color: #101010; | |
37 | 37 | } |
38 | 38 | |
39 | 39 | input[type="text"]:focus |
40 | 40 | { |
41 | - border: 1px solid #008000 | |
41 | + background-color: #101010; | |
42 | 42 | } |
43 | 43 | |
44 | 44 | input[type="password"] |
45 | 45 | { |
46 | - border: 1px solid #400000 | |
46 | + background-color: #101010; | |
47 | 47 | } |
48 | 48 | |
49 | 49 | input[type="password"]:focus |
50 | 50 | { |
51 | - border: 1px solid #800000 | |
51 | + background-color: #101010; | |
52 | 52 | } |
53 | 53 | |
54 | 54 | #terminal |
... | ... | @@ -294,7 +294,7 @@ a |
294 | 294 | |
295 | 295 | .IW042 |
296 | 296 | { |
297 | - width: 22em; | |
297 | + width: 25.5em; | |
298 | 298 | } |
299 | 299 | |
300 | 300 | .IW043 |
... | ... | @@ -484,5 +484,7 @@ a |
484 | 484 | |
485 | 485 | .IW080 |
486 | 486 | { |
487 | - width: 41em; | |
487 | + margin-left: 0px; | |
488 | + margin-right: 0px; | |
489 | + width: 48em; | |
488 | 490 | } | ... | ... |
android/src/br/com/bb/pw3270/lib3270.java
... | ... | @@ -19,6 +19,7 @@ public class lib3270 |
19 | 19 | |
20 | 20 | private boolean changed; |
21 | 21 | private boolean connected = false; |
22 | + private boolean refresh = true; | |
22 | 23 | |
23 | 24 | DataOutputStream outData = null; |
24 | 25 | DataInputStream inData = null; |
... | ... | @@ -289,7 +290,8 @@ public class lib3270 |
289 | 290 | case 2: // Screen changed |
290 | 291 | Log.d(TAG,"Screen changed"); |
291 | 292 | changed = true; |
292 | - redraw(); | |
293 | + if(refresh) | |
294 | + redraw(); | |
293 | 295 | break; |
294 | 296 | |
295 | 297 | case 3: // Popup |
... | ... | @@ -382,10 +384,12 @@ public class lib3270 |
382 | 384 | |
383 | 385 | public void setStringAt(int offset, String str) |
384 | 386 | { |
387 | + refresh = false; | |
385 | 388 | try |
386 | 389 | { |
387 | 390 | setTextAt(offset,str.getBytes(getEncoding()),str.length()); |
388 | 391 | } catch( Exception e ) { } |
392 | + refresh = true; | |
389 | 393 | } |
390 | 394 | |
391 | 395 | ... | ... |
pw3270.cbp
... | ... | @@ -46,6 +46,7 @@ |
46 | 46 | <Unit filename="android/jni/globals.h" /> |
47 | 47 | <Unit filename="android/jni/main.cpp" /> |
48 | 48 | <Unit filename="android/jni/misc.cpp" /> |
49 | + <Unit filename="android/jni/text.cpp" /> | |
49 | 50 | <Unit filename="android/src/br/com/bb/pw3270/PW3270Activity.java" /> |
50 | 51 | <Unit filename="android/src/br/com/bb/pw3270/lib3270.java" /> |
51 | 52 | <Unit filename="autogen.sh" /> | ... | ... |
src/include/lib3270.h
... | ... | @@ -730,7 +730,39 @@ |
730 | 730 | */ |
731 | 731 | LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len); |
732 | 732 | |
733 | - LIB3270_EXPORT char * lib3270_get_field_at(H3270 *session, int baddr); | |
733 | + /** | |
734 | + * Get contents of the field at position. | |
735 | + * | |
736 | + * @param h Session Handle. | |
737 | + * @param baddr Reference position. | |
738 | + * | |
739 | + * @return Contents of the entire field, release it with lib3270_free() | |
740 | + * | |
741 | + */ | |
742 | + LIB3270_EXPORT char * lib3270_get_field_at(H3270 *h, int baddr); | |
743 | + | |
744 | + /** | |
745 | + * Find the buffer address of the field attribute for a given buffer address. | |
746 | + * | |
747 | + * @param h Session handle. | |
748 | + * @param addr Buffer address of the field. | |
749 | + * | |
750 | + * @return field address or -1 if the screen isn't formatted. | |
751 | + * | |
752 | + */ | |
753 | + LIB3270_EXPORT int lib3270_field_addr(H3270 *h, int baddr); | |
754 | + | |
755 | + /** | |
756 | + * Get the length of the field at given buffer address. | |
757 | + * | |
758 | + * @param h Session handle. | |
759 | + * @param addr Buffer address of the field. | |
760 | + * | |
761 | + * @return field length. | |
762 | + * | |
763 | + */ | |
764 | + LIB3270_EXPORT int lib3270_field_length(H3270 *h, int baddr); | |
765 | + | |
734 | 766 | |
735 | 767 | /** |
736 | 768 | * Get a terminal character and attribute. |
... | ... | @@ -818,6 +850,8 @@ |
818 | 850 | |
819 | 851 | LIB3270_EXPORT char * lib3270_vsprintf(const char *fmt, va_list args); |
820 | 852 | |
853 | + LIB3270_EXPORT int lib3270_clear_operator_error(H3270 *hSession); | |
854 | + | |
821 | 855 | LIB3270_EXPORT void lib3270_trace_event(H3270 *session, const char *fmt, ...); |
822 | 856 | LIB3270_EXPORT void lib3270_set_trace_handler( void (*handler)(H3270 *session, const char *fmt, va_list args) ); |
823 | 857 | LIB3270_EXPORT void lib3270_write_dstrace(H3270 *session, const char *fmt, ...); | ... | ... |
src/lib3270/api.h
... | ... | @@ -331,20 +331,6 @@ |
331 | 331 | #define find_field_attribute(s,a) lib3270_field_addr(s,a) |
332 | 332 | #define find_field_length(s,a) find_field_length(s,a) |
333 | 333 | |
334 | - /** | |
335 | - * Find the buffer address of the field attribute for a given buffer address. | |
336 | - * | |
337 | - * @param h Session handle. | |
338 | - * @param addr Buffer address of the field. | |
339 | - * | |
340 | - * @return field address or -1 if the screen isn't formatted. | |
341 | - * | |
342 | - */ | |
343 | - LIB3270_EXPORT int lib3270_field_addr(H3270 *h, int baddr); | |
344 | - | |
345 | - LIB3270_EXPORT int lib3270_field_length(H3270 *session, int baddr); | |
346 | - | |
347 | - | |
348 | 334 | LOCAL_EXTERN unsigned char get_field_attribute(H3270 *session, int baddr); |
349 | 335 | // LOCAL_EXTERN int screen_read(char *dest, int baddr, int count); |
350 | 336 | LOCAL_EXTERN void Input_String(const unsigned char *str); | ... | ... |
src/lib3270/kybd.c
... | ... | @@ -180,7 +180,7 @@ static struct ta |
180 | 180 | |
181 | 181 | static const char dxl[] = "0123456789abcdef"; |
182 | 182 | #define FROM_HEX(c) (strchr(dxl, tolower(c)) - dxl) |
183 | -#define KYBDLOCK_IS_OERR (h3270.kybdlock && !(h3270.kybdlock & ~KL_OERR_MASK)) | |
183 | +#define KYBDLOCK_IS_OERR(hSession) (hSession->kybdlock && !(hSession->kybdlock & ~KL_OERR_MASK)) | |
184 | 184 | |
185 | 185 | |
186 | 186 | /* |
... | ... | @@ -379,26 +379,26 @@ kybdlock_set(unsigned int bits, const char *cause unused) |
379 | 379 | } |
380 | 380 | } |
381 | 381 | |
382 | -/* Clear bits in the keyboard lock. */ | |
383 | -void | |
384 | -kybdlock_clr(H3270 *session, unsigned int bits, const char *cause unused) | |
382 | +/** | |
383 | + * Clear bits in the keyboard lock. | |
384 | + * | |
385 | + */ | |
386 | +void lib3270_kybdlock_clear(H3270 *hSession, LIB3270_KL_STATE bits) | |
385 | 387 | { |
386 | - unsigned int n; | |
387 | - | |
388 | - n = session->kybdlock & ~bits; | |
388 | + unsigned int n = hSession->kybdlock & ~( (unsigned int) bits); | |
389 | 389 | |
390 | - if (n != session->kybdlock) | |
390 | + if (n != hSession->kybdlock) | |
391 | 391 | { |
392 | 392 | #if defined(KYBDLOCK_TRACE) |
393 | - trace_event(" %s: kybdlock &= ~0x%04x, 0x%04x -> 0x%04x\n",cause, bits, kybdlock, n); | |
393 | + trace_event(" %s: kybdlock &= ~0x%04x, 0x%04x -> 0x%04x\n", __FUNCTION__, bits, kybdlock, n); | |
394 | 394 | #endif |
395 | - if ((session->kybdlock ^ n) & KL_DEFERRED_UNLOCK) | |
395 | + if ((hSession->kybdlock ^ n) & KL_DEFERRED_UNLOCK) | |
396 | 396 | { |
397 | 397 | /* Turned off deferred unlock. */ |
398 | - session->unlock_delay_time = 0; | |
398 | + hSession->unlock_delay_time = 0; | |
399 | 399 | } |
400 | - session->kybdlock = n; | |
401 | - status_changed(session,LIB3270_STATUS_KYBDLOCK); | |
400 | + hSession->kybdlock = n; | |
401 | + status_changed(hSession,LIB3270_STATUS_KYBDLOCK); | |
402 | 402 | } |
403 | 403 | } |
404 | 404 | |
... | ... | @@ -1399,11 +1399,14 @@ LIB3270_KEY_ACTION( tab ) |
1399 | 1399 | |
1400 | 1400 | // reset_idle_timer(); |
1401 | 1401 | |
1402 | - if (hSession->kybdlock) { | |
1403 | - if (KYBDLOCK_IS_OERR) { | |
1402 | + if (hSession->kybdlock) | |
1403 | + { | |
1404 | + if(KYBDLOCK_IS_OERR(hSession)) | |
1405 | + { | |
1404 | 1406 | kybdlock_clr(hSession,KL_OERR_MASK, "Tab"); |
1405 | 1407 | status_reset(hSession); |
1406 | - } else { | |
1408 | + } else | |
1409 | + { | |
1407 | 1410 | ENQUEUE_ACTION(lib3270_tab); |
1408 | 1411 | return 0; |
1409 | 1412 | } |
... | ... | @@ -1418,6 +1421,20 @@ LIB3270_KEY_ACTION( tab ) |
1418 | 1421 | return 0; |
1419 | 1422 | } |
1420 | 1423 | |
1424 | +LIB3270_EXPORT int lib3270_clear_operator_error(H3270 *hSession) | |
1425 | +{ | |
1426 | + if(!hSession->kybdlock) | |
1427 | + return ENOENT; | |
1428 | + | |
1429 | + if(KYBDLOCK_IS_OERR(hSession)) | |
1430 | + { | |
1431 | + lib3270_kybdlock_clear(hSession,KL_OERR_MASK); | |
1432 | + status_reset(hSession); | |
1433 | + return 0; | |
1434 | + } | |
1435 | + return EINVAL; | |
1436 | +} | |
1437 | + | |
1421 | 1438 | |
1422 | 1439 | /* |
1423 | 1440 | * Tab backward to previous field. |
... | ... | @@ -1429,11 +1446,15 @@ LIB3270_KEY_ACTION( backtab ) |
1429 | 1446 | |
1430 | 1447 | // reset_idle_timer(); |
1431 | 1448 | |
1432 | - if (hSession->kybdlock) { | |
1433 | - if (KYBDLOCK_IS_OERR) { | |
1449 | + if (hSession->kybdlock) | |
1450 | + { | |
1451 | + if (KYBDLOCK_IS_OERR(hSession)) | |
1452 | + { | |
1434 | 1453 | kybdlock_clr(hSession,KL_OERR_MASK, "BackTab"); |
1435 | 1454 | status_reset(hSession); |
1436 | - } else { | |
1455 | + } | |
1456 | + else | |
1457 | + { | |
1437 | 1458 | ENQUEUE_ACTION(lib3270_backtab); |
1438 | 1459 | return 0; |
1439 | 1460 | } |
... | ... | @@ -1602,7 +1623,7 @@ LIB3270_CURSOR_ACTION( left ) |
1602 | 1623 | { |
1603 | 1624 | if (hSession->kybdlock) |
1604 | 1625 | { |
1605 | - if (KYBDLOCK_IS_OERR) | |
1626 | + if(KYBDLOCK_IS_OERR(hSession)) | |
1606 | 1627 | { |
1607 | 1628 | kybdlock_clr(hSession,KL_OERR_MASK, "Left"); |
1608 | 1629 | status_reset(&h3270); |
... | ... | @@ -1865,7 +1886,7 @@ LIB3270_CURSOR_ACTION( right ) |
1865 | 1886 | |
1866 | 1887 | if (hSession->kybdlock) |
1867 | 1888 | { |
1868 | - if (KYBDLOCK_IS_OERR) | |
1889 | + if (KYBDLOCK_IS_OERR(hSession)) | |
1869 | 1890 | { |
1870 | 1891 | kybdlock_clr(hSession,KL_OERR_MASK, "Right"); |
1871 | 1892 | status_reset(hSession); |
... | ... | @@ -2093,8 +2114,9 @@ LIB3270_CURSOR_ACTION( up ) |
2093 | 2114 | register int baddr; |
2094 | 2115 | |
2095 | 2116 | // reset_idle_timer(); |
2096 | - if (hSession->kybdlock) { | |
2097 | - if (KYBDLOCK_IS_OERR) | |
2117 | + if (hSession->kybdlock) | |
2118 | + { | |
2119 | + if (KYBDLOCK_IS_OERR(hSession)) | |
2098 | 2120 | { |
2099 | 2121 | kybdlock_clr(hSession,KL_OERR_MASK, "Up"); |
2100 | 2122 | status_reset(hSession); |
... | ... | @@ -2132,7 +2154,7 @@ LIB3270_CURSOR_ACTION( down ) |
2132 | 2154 | // reset_idle_timer(); |
2133 | 2155 | if (hSession->kybdlock) |
2134 | 2156 | { |
2135 | - if (KYBDLOCK_IS_OERR) | |
2157 | + if (KYBDLOCK_IS_OERR(hSession)) | |
2136 | 2158 | { |
2137 | 2159 | kybdlock_clr(hSession,KL_OERR_MASK, "Down"); |
2138 | 2160 | status_reset(hSession); | ... | ... |
src/lib3270/kybdc.h
... | ... | @@ -61,7 +61,11 @@ |
61 | 61 | LIB3270_INTERNAL void clear_xks(void); |
62 | 62 | LIB3270_INTERNAL void do_reset(H3270 *session, Boolean explicit); |
63 | 63 | LIB3270_INTERNAL void hex_input(char *s); |
64 | - LIB3270_INTERNAL void kybdlock_clr(H3270 *session, unsigned int bits, const char *cause); | |
64 | + | |
65 | + #define kybdlock_clr(session, bits, cause) lib3270_kybdlock_clear(session, bits) | |
66 | + LIB3270_INTERNAL void lib3270_kybdlock_clear(H3270 *hSession, LIB3270_KL_STATE bits); | |
67 | + | |
68 | + | |
65 | 69 | LIB3270_INTERNAL void kybd_inhibit(H3270 *session, Boolean inhibit); |
66 | 70 | LIB3270_INTERNAL void kybd_init(void); |
67 | 71 | LIB3270_INTERNAL int kybd_prime(void); | ... | ... |
src/lib3270/sources.mak
... | ... | @@ -26,13 +26,14 @@ |
26 | 26 | |
27 | 27 | # Terminal only sources |
28 | 28 | TERMINAL_SOURCES = bounds.c ctlr.c util.c toggles.c screen.c selection.c kybd.c telnet.c \ |
29 | - host.c sf.c ansi.c resolver.c tables.c utf8.c charset.c \ | |
30 | - version.c session.c state.c html.c trace_ds.c see.c | |
29 | + host.c sf.c ansi.c resolver.c tables.c utf8.c charset.c \ | |
30 | + version.c session.c state.c html.c trace_ds.c see.c \ | |
31 | + paste.c | |
31 | 32 | |
32 | 33 | # Network I/O Sources |
33 | 34 | NETWORK_SOURCES = iocalls.c proxy.c |
34 | 35 | |
35 | 36 | # Full library sources |
36 | 37 | SOURCES = $(TERMINAL_SOURCES) $(NETWORK_SOURCES) ft.c ft_cut.c ft_dft.c glue.c resources.c \ |
37 | - rpq.c paste.c macros.c fallbacks.c log.c | |
38 | + rpq.c macros.c fallbacks.c log.c | |
38 | 39 | ... | ... |