Commit 9d5150d1c409cdd859ac18ce4a3ddf69ecadbc10
1 parent
d1d71e35
Exists in
master
and in
3 other branches
Android - Iniciando implementação de suporte para script de autostart
Showing
8 changed files
with
98 additions
and
51 deletions
Show diff stats
ctlr.c
| ... | ... | @@ -67,7 +67,8 @@ |
| 67 | 67 | // Boolean dbcs = False; |
| 68 | 68 | |
| 69 | 69 | /* Statics */ |
| 70 | -static void set_formatted(H3270 *session); | |
| 70 | +static void update_formatted(H3270 *session); | |
| 71 | +static void set_formatted(H3270 *hSession, int state); | |
| 71 | 72 | static void ctlr_blanks(H3270 *session); |
| 72 | 73 | static void ctlr_half_connect(H3270 *session, int ignored, void *dunno); |
| 73 | 74 | static void ctlr_connect(H3270 *session, int ignored, void *dunno); |
| ... | ... | @@ -224,37 +225,50 @@ void ctlr_set_rows_cols(H3270 *session, int mn, int ovc, int ovr) |
| 224 | 225 | |
| 225 | 226 | set_viewsize(session,sz[idx].rows,sz[idx].cols); |
| 226 | 227 | |
| 227 | - /* | |
| 228 | - // Make sure that the current rows/cols are still 24x80. | |
| 229 | - session->cols = 80; | |
| 230 | - session->rows = 24; | |
| 231 | - session->screen_alt = 0; | |
| 232 | - */ | |
| 233 | - | |
| 234 | 228 | } |
| 235 | 229 | |
| 236 | - | |
| 230 | +static void set_formatted(H3270 *hSession, int state) | |
| 231 | +{ | |
| 232 | + hSession->formatted = state; | |
| 237 | 233 | /* |
| 238 | - * Set the formatted screen flag. A formatted screen is a screen that | |
| 239 | - * has at least one field somewhere on it. | |
| 234 | + int last = (int) hSession->formatted; | |
| 235 | + hSession->formatted = state; | |
| 236 | + | |
| 237 | + if( ((int) hSession->formatted) != last) | |
| 238 | + { | |
| 239 | + trace("Screen is now %s",hSession->formatted ? "formatted" : "unformatted"); | |
| 240 | + hSession->update_formatted(hSession,hSession->formatted); | |
| 241 | + } | |
| 242 | +*/ | |
| 243 | + trace("Screen is now %s",hSession->formatted ? "formatted" : "unformatted"); | |
| 244 | +} | |
| 245 | + | |
| 246 | +/** | |
| 247 | + * Update the formatted screen flag. | |
| 248 | + * | |
| 249 | + * A formatted screen is a screen that has at least one field somewhere on it. | |
| 250 | + * | |
| 251 | + * @param hSession Session Handle | |
| 240 | 252 | */ |
| 241 | -static void set_formatted(H3270 *hSession) | |
| 253 | +static void update_formatted(H3270 *hSession) | |
| 242 | 254 | { |
| 243 | 255 | register int baddr; |
| 244 | 256 | |
| 245 | 257 | CHECK_SESSION_HANDLE(hSession); |
| 246 | 258 | |
| 247 | - hSession->formatted = False; | |
| 248 | 259 | baddr = 0; |
| 249 | 260 | do |
| 250 | 261 | { |
| 251 | 262 | if(hSession->ea_buf[baddr].fa) |
| 252 | 263 | { |
| 253 | - hSession->formatted = True; | |
| 254 | - break; | |
| 264 | + set_formatted(hSession,1); | |
| 265 | + return; | |
| 255 | 266 | } |
| 256 | 267 | INC_BA(baddr); |
| 257 | 268 | } while (baddr != 0); |
| 269 | + | |
| 270 | + set_formatted(hSession,0); | |
| 271 | + | |
| 258 | 272 | } |
| 259 | 273 | |
| 260 | 274 | /* |
| ... | ... | @@ -277,6 +291,7 @@ static void ctlr_connect(H3270 *hSession, int ignored unused, void *dunno) |
| 277 | 291 | hSession->ea_buf[-1].fa = FA_PRINTABLE | FA_MODIFY; |
| 278 | 292 | else |
| 279 | 293 | hSession->ea_buf[-1].fa = FA_PRINTABLE | FA_PROTECT; |
| 294 | + | |
| 280 | 295 | if (!IN_3270 || (IN_SSCP && (hSession->kybdlock & KL_OIA_TWAIT))) |
| 281 | 296 | { |
| 282 | 297 | lib3270_kybdlock_clear(hSession,KL_OIA_TWAIT); |
| ... | ... | @@ -292,8 +307,6 @@ static void ctlr_connect(H3270 *hSession, int ignored unused, void *dunno) |
| 292 | 307 | hSession->crm_nattr = 0; |
| 293 | 308 | } |
| 294 | 309 | |
| 295 | - | |
| 296 | - | |
| 297 | 310 | LIB3270_EXPORT int lib3270_field_addr(H3270 *hSession, int baddr) |
| 298 | 311 | { |
| 299 | 312 | int sbaddr; |
| ... | ... | @@ -886,7 +899,8 @@ void ctlr_erase_all_unprotected(H3270 *hSession) |
| 886 | 899 | |
| 887 | 900 | kybd_inhibit(hSession,False); |
| 888 | 901 | |
| 889 | - if (hSession->formatted) { | |
| 902 | + if (hSession->formatted) | |
| 903 | + { | |
| 890 | 904 | /* find first field attribute */ |
| 891 | 905 | baddr = 0; |
| 892 | 906 | do { |
| ... | ... | @@ -975,7 +989,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er |
| 975 | 989 | ctlr_add_gr(hSession,hSession->buffer_addr, 0); \ |
| 976 | 990 | ctlr_add_ic(hSession,hSession->buffer_addr, 0); \ |
| 977 | 991 | trace_ds(hSession,"%s",see_attr(fa)); \ |
| 978 | - hSession->formatted = True; \ | |
| 992 | + set_formatted(hSession,1); \ | |
| 979 | 993 | } |
| 980 | 994 | |
| 981 | 995 | kybd_inhibit(hSession,False); |
| ... | ... | @@ -1721,7 +1735,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er |
| 1721 | 1735 | break; |
| 1722 | 1736 | } |
| 1723 | 1737 | } |
| 1724 | - set_formatted(hSession); | |
| 1738 | + update_formatted(hSession); | |
| 1725 | 1739 | END_TEXT0; |
| 1726 | 1740 | trace_ds(hSession,"\n"); |
| 1727 | 1741 | if (wcc_keyboard_restore) { |
| ... | ... | @@ -2196,7 +2210,7 @@ ctlr_clear(H3270 *session, Boolean can_snap) |
| 2196 | 2210 | cursor_move(session,0); |
| 2197 | 2211 | session->buffer_addr = 0; |
| 2198 | 2212 | lib3270_unselect(session); |
| 2199 | - session->formatted = False; | |
| 2213 | + set_formatted(session,0); | |
| 2200 | 2214 | session->default_fg = 0; |
| 2201 | 2215 | session->default_bg = 0; |
| 2202 | 2216 | session->default_gr = 0; |
| ... | ... | @@ -2225,7 +2239,7 @@ static void ctlr_blanks(H3270 *session) |
| 2225 | 2239 | cursor_move(session,0); |
| 2226 | 2240 | session->buffer_addr = 0; |
| 2227 | 2241 | lib3270_unselect(session); |
| 2228 | - session->formatted = False; | |
| 2242 | + set_formatted(session,0); | |
| 2229 | 2243 | ALL_CHANGED(session); |
| 2230 | 2244 | } |
| 2231 | 2245 | ... | ... |
host.c
| ... | ... | @@ -706,7 +706,9 @@ void host_in3270(H3270 *hSession, LIB3270_CSTATE new_cstate) |
| 706 | 706 | |
| 707 | 707 | void lib3270_set_connected(H3270 *hSession) |
| 708 | 708 | { |
| 709 | - hSession->cstate = CONNECTED_INITIAL; | |
| 709 | + hSession->cstate = CONNECTED_INITIAL; | |
| 710 | + hSession->starting = 1; // Enable autostart | |
| 711 | + | |
| 710 | 712 | lib3270_st_changed(hSession, LIB3270_STATE_CONNECT, True); |
| 711 | 713 | if(hSession->update_connect) |
| 712 | 714 | hSession->update_connect(hSession,1); |
| ... | ... | @@ -716,7 +718,9 @@ void lib3270_set_disconnected(H3270 *hSession) |
| 716 | 718 | { |
| 717 | 719 | CHECK_SESSION_HANDLE(hSession); |
| 718 | 720 | |
| 719 | - hSession->cstate = NOT_CONNECTED; | |
| 721 | + hSession->cstate = NOT_CONNECTED; | |
| 722 | + hSession->starting = 0; | |
| 723 | + | |
| 720 | 724 | set_status(hSession,OIA_FLAG_UNDERA,False); |
| 721 | 725 | lib3270_st_changed(hSession,LIB3270_STATE_CONNECT, False); |
| 722 | 726 | status_changed(hSession,LIB3270_MESSAGE_DISCONNECTED); | ... | ... |
kybd.c
| ... | ... | @@ -1209,7 +1209,8 @@ LIB3270_ACTION( firstfield ) |
| 1209 | 1209 | return 0; |
| 1210 | 1210 | } |
| 1211 | 1211 | #endif /*]*/ |
| 1212 | - if (!hSession->formatted) { | |
| 1212 | + if (!hSession->formatted) | |
| 1213 | + { | |
| 1213 | 1214 | cursor_move(hSession,0); |
| 1214 | 1215 | return 0; |
| 1215 | 1216 | } |
| ... | ... | @@ -2066,8 +2067,10 @@ LIB3270_ACTION( eraseeof ) |
| 2066 | 2067 | operator_error(hSession,KL_OERR_PROTECTED); |
| 2067 | 2068 | return -1; |
| 2068 | 2069 | } |
| 2069 | - if (hSession->formatted) { /* erase to next field attribute */ | |
| 2070 | - do { | |
| 2070 | + if (hSession->formatted) | |
| 2071 | + { /* erase to next field attribute */ | |
| 2072 | + do | |
| 2073 | + { | |
| 2071 | 2074 | ctlr_add(hSession,baddr, EBC_null, 0); |
| 2072 | 2075 | INC_BA(baddr); |
| 2073 | 2076 | } while (!hSession->ea_buf[baddr].fa); |
| ... | ... | @@ -2109,7 +2112,8 @@ LIB3270_ACTION( eraseinput ) |
| 2109 | 2112 | if (IN_ANSI) |
| 2110 | 2113 | return 0; |
| 2111 | 2114 | #endif /*]*/ |
| 2112 | - if (hSession->formatted) { | |
| 2115 | + if (hSession->formatted) | |
| 2116 | + { | |
| 2113 | 2117 | /* find first field attribute */ |
| 2114 | 2118 | baddr = 0; |
| 2115 | 2119 | do { |
| ... | ... | @@ -2170,7 +2174,8 @@ LIB3270_ACTION( deleteword ) |
| 2170 | 2174 | return 0; |
| 2171 | 2175 | } |
| 2172 | 2176 | #if defined(X3270_ANSI) /*[*/ |
| 2173 | - if (IN_ANSI) { | |
| 2177 | + if (IN_ANSI) | |
| 2178 | + { | |
| 2174 | 2179 | net_send_werase(hSession); |
| 2175 | 2180 | return 0; |
| 2176 | 2181 | } |
| ... | ... | @@ -2455,7 +2460,7 @@ static Boolean remargin(H3270 *hSession, int lmargin) |
| 2455 | 2460 | return True; |
| 2456 | 2461 | } |
| 2457 | 2462 | |
| 2458 | -LIB3270_EXPORT int lib3270_emulate_input(H3270 *hSession, char *s, int len, int pasting) | |
| 2463 | +LIB3270_EXPORT int lib3270_emulate_input(H3270 *hSession, const char *s, int len, int pasting) | |
| 2459 | 2464 | { |
| 2460 | 2465 | enum { BASE, BACKSLASH, BACKX, BACKP, BACKPA, BACKPF, OCTAL, HEX, XGE } state = BASE; |
| 2461 | 2466 | int literal = 0; |
| ... | ... | @@ -2474,7 +2479,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *hSession, char *s, int len, int |
| 2474 | 2479 | UChar *ws; |
| 2475 | 2480 | #else /*][*/ |
| 2476 | 2481 | char c; |
| 2477 | - char *ws; | |
| 2482 | + const char *ws; | |
| 2478 | 2483 | #endif /*]*/ |
| 2479 | 2484 | |
| 2480 | 2485 | CHECK_SESSION_HANDLE(hSession); | ... | ... |
resolver.c
| ... | ... | @@ -183,10 +183,10 @@ static int cresolve_host_and_port(H3270 *h, struct parms *p) |
| 183 | 183 | int resolve_host_and_port(H3270 *hSession, const char *host, char *portname, unsigned short *pport,struct sockaddr *sa, socklen_t *sa_len, char *errmsg, int em_len) |
| 184 | 184 | { |
| 185 | 185 | int rc; |
| 186 | - LIB3270_STATUS saved_status = hSession->oia_status; | |
| 186 | + LIB3270_MESSAGE saved_status = hSession->oia_status; | |
| 187 | 187 | struct parms p = { sizeof(struct parms), host, portname, pport, sa, sa_len, errmsg, em_len }; |
| 188 | 188 | |
| 189 | - trace("Calling resolver for %s", p.host); | |
| 189 | + trace("Calling resolver for %s status=%d", p.host, (int) saved_status); | |
| 190 | 190 | |
| 191 | 191 | status_changed(hSession,LIB3270_STATUS_RESOLVING); |
| 192 | 192 | hSession->cursor(hSession,CURSOR_MODE_LOCKED); |
| ... | ... | @@ -194,7 +194,9 @@ int resolve_host_and_port(H3270 *hSession, const char *host, char *portname, uns |
| 194 | 194 | rc = lib3270_call_thread((int (*)(H3270 *, void *)) cresolve_host_and_port,hSession,&p); |
| 195 | 195 | |
| 196 | 196 | hSession->cursor(hSession,CURSOR_MODE_NORMAL); |
| 197 | - status_changed(hSession,saved_status); | |
| 197 | + | |
| 198 | + if(saved_status != -1) | |
| 199 | + status_changed(hSession,saved_status); | |
| 198 | 200 | |
| 199 | 201 | trace("Calling resolver for %s exits with %d", p.host, rc); |
| 200 | 202 | ... | ... |
screen.c
| ... | ... | @@ -372,7 +372,21 @@ void screen_update(H3270 *session, int bstart, int bend) |
| 372 | 372 | session->changed(session,first,len); |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | - trace("%s ends",__FUNCTION__); | |
| 375 | + if(session->starting && session->formatted && lib3270_in_3270(session)) | |
| 376 | + { | |
| 377 | + session->starting = 0; | |
| 378 | + session->autostart(session); | |
| 379 | +#ifdef DEBUG | |
| 380 | + { | |
| 381 | + char *text = lib3270_get_text(session,0,-1); | |
| 382 | + trace("First screen:\n%s\n",text); | |
| 383 | + lib3270_free(text); | |
| 384 | + } | |
| 385 | +#endif | |
| 386 | + } | |
| 387 | + | |
| 388 | +// trace("%s ends",__FUNCTION__); | |
| 389 | + | |
| 376 | 390 | } |
| 377 | 391 | |
| 378 | 392 | LIB3270_EXPORT int lib3270_get_cursor_address(H3270 *h) |
| ... | ... | @@ -426,20 +440,20 @@ void status_ctlr_done(H3270 *session) |
| 426 | 440 | |
| 427 | 441 | void status_oerr(H3270 *session, int error_type) |
| 428 | 442 | { |
| 429 | - LIB3270_STATUS sts = LIB3270_STATUS_USER; | |
| 443 | + LIB3270_STATUS sts = LIB3270_MESSAGE_USER; | |
| 430 | 444 | |
| 431 | 445 | CHECK_SESSION_HANDLE(session); |
| 432 | 446 | |
| 433 | 447 | switch (error_type) |
| 434 | 448 | { |
| 435 | 449 | case KL_OERR_PROTECTED: |
| 436 | - sts = LIB3270_STATUS_PROTECTED; | |
| 450 | + sts = LIB3270_MESSAGE_PROTECTED; | |
| 437 | 451 | break; |
| 438 | 452 | case KL_OERR_NUMERIC: |
| 439 | - sts = LIB3270_STATUS_NUMERIC; | |
| 453 | + sts = LIB3270_MESSAGE_NUMERIC; | |
| 440 | 454 | break; |
| 441 | 455 | case KL_OERR_OVERFLOW: |
| 442 | - sts = LIB3270_STATUS_OVERFLOW; | |
| 456 | + sts = LIB3270_MESSAGE_OVERFLOW; | |
| 443 | 457 | break; |
| 444 | 458 | |
| 445 | 459 | default: |
| ... | ... | @@ -453,9 +467,9 @@ void status_oerr(H3270 *session, int error_type) |
| 453 | 467 | void status_connecting(H3270 *session, Boolean on) |
| 454 | 468 | { |
| 455 | 469 | if(session->cursor) |
| 456 | - session->cursor(session,on ? CURSOR_MODE_LOCKED : CURSOR_MODE_NORMAL); | |
| 470 | + session->cursor(session,on ? CURSOR_MODE_LOCKED : CURSOR_MODE_NORMAL); | |
| 457 | 471 | |
| 458 | - status_changed(session, on ? LIB3270_STATUS_CONNECTING : LIB3270_STATUS_BLANK); | |
| 472 | + status_changed(session, on ? LIB3270_MESSAGE_CONNECTING : LIB3270_MESSAGE_NONE); | |
| 459 | 473 | } |
| 460 | 474 | |
| 461 | 475 | void status_reset(H3270 *session) |
| ... | ... | @@ -464,17 +478,17 @@ void status_reset(H3270 *session) |
| 464 | 478 | |
| 465 | 479 | if (session->kybdlock & KL_ENTER_INHIBIT) |
| 466 | 480 | { |
| 467 | - status_changed(session,LIB3270_STATUS_INHIBIT); | |
| 481 | + status_changed(session,LIB3270_MESSAGE_INHIBIT); | |
| 468 | 482 | } |
| 469 | 483 | else if (session->kybdlock & KL_DEFERRED_UNLOCK) |
| 470 | 484 | { |
| 471 | - status_changed(session,LIB3270_STATUS_X); | |
| 485 | + status_changed(session,LIB3270_MESSAGE_X); | |
| 472 | 486 | } |
| 473 | 487 | else |
| 474 | 488 | { |
| 475 | 489 | if(session->cursor) |
| 476 | 490 | session->cursor(session,CURSOR_MODE_NORMAL); |
| 477 | - status_changed(session,LIB3270_STATUS_BLANK); | |
| 491 | + status_changed(session,LIB3270_MESSAGE_NONE); | |
| 478 | 492 | } |
| 479 | 493 | |
| 480 | 494 | session->display(session); |
| ... | ... | @@ -503,8 +517,7 @@ void status_changed(H3270 *session, LIB3270_STATUS id) |
| 503 | 517 | |
| 504 | 518 | session->oia_status = id; |
| 505 | 519 | |
| 506 | - if(session->update_status) | |
| 507 | - session->update_status(session,id); | |
| 520 | + session->update_status(session,id); | |
| 508 | 521 | } |
| 509 | 522 | |
| 510 | 523 | void status_twait(H3270 *session) | ... | ... |
selection.c
| ... | ... | @@ -378,7 +378,7 @@ static char * get_text(H3270 *hSession,unsigned char all) |
| 378 | 378 | size_t buflen = (hSession->rows * (hSession->cols+1))+1; |
| 379 | 379 | size_t sz = 0; |
| 380 | 380 | |
| 381 | - if(!lib3270_connected(hSession)) | |
| 381 | + if(!(lib3270_connected(hSession) && hSession->text)) | |
| 382 | 382 | return NULL; |
| 383 | 383 | |
| 384 | 384 | ret = lib3270_malloc(buflen); | ... | ... |
session.c
| ... | ... | @@ -160,7 +160,7 @@ static void screen_disp(H3270 *session) |
| 160 | 160 | screen_update(session,0,session->rows*session->cols); |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | -static void set_width(H3270 *session, int width) | |
| 163 | +static void nop_int(H3270 *session, int width) | |
| 164 | 164 | { |
| 165 | 165 | return; |
| 166 | 166 | } |
| ... | ... | @@ -194,7 +194,9 @@ static void lib3270_session_init(H3270 *hSession, const char *model) |
| 194 | 194 | hSession->message = message; |
| 195 | 195 | hSession->update_ssl = update_ssl; |
| 196 | 196 | hSession->display = screen_disp; |
| 197 | - hSession->set_width = set_width; | |
| 197 | + hSession->set_width = nop_int; | |
| 198 | + hSession->update_status = (void (*)(H3270 *, LIB3270_STATUS)) nop_int; | |
| 199 | + hSession->autostart = nop; | |
| 198 | 200 | |
| 199 | 201 | // Set the defaults. |
| 200 | 202 | hSession->extended = 1; |
| ... | ... | @@ -425,7 +427,11 @@ void check_session_handle(H3270 **hSession) |
| 425 | 427 | |
| 426 | 428 | *hSession = lib3270_get_default_session_handle(); |
| 427 | 429 | |
| 430 | +#ifdef ANDROID | |
| 431 | + __android_log_print(ANDROID_LOG_VERBOSE, PACKAGE_NAME, "%s called with empty session\n", __FUNCTION__); | |
| 432 | +#else | |
| 428 | 433 | lib3270_write_log(*hSession,"%s called with empty session",__FUNCTION__); |
| 434 | +#endif // ANDROID | |
| 429 | 435 | } |
| 430 | 436 | |
| 431 | 437 | LIB3270_EXPORT H3270 * lib3270_get_default_session_handle(void) | ... | ... |
telnet.c
| ... | ... | @@ -1300,9 +1300,11 @@ static int telnet_fsm(H3270 *hSession, unsigned char c) |
| 1300 | 1300 | hSession->ns_rrcvd++; |
| 1301 | 1301 | if (process_eor(hSession)) |
| 1302 | 1302 | return -1; |
| 1303 | - } else | |
| 1303 | + } | |
| 1304 | + else | |
| 1305 | + { | |
| 1304 | 1306 | Warning(hSession, _( "EOR received when not in 3270 mode, ignored." )); |
| 1305 | - | |
| 1307 | + } | |
| 1306 | 1308 | trace_dsn(hSession,"RCVD EOR\n"); |
| 1307 | 1309 | hSession->ibptr = hSession->ibuf; |
| 1308 | 1310 | hSession->telnet_state = TNS_DATA; |
| ... | ... | @@ -1900,6 +1902,7 @@ static void process_bind(H3270 *hSession, unsigned char *buf, int buflen) |
| 1900 | 1902 | static int |
| 1901 | 1903 | process_eor(H3270 *hSession) |
| 1902 | 1904 | { |
| 1905 | + trace("%s: syncing=%s",__FUNCTION__,hSession->syncing ? "Yes" : "No"); | |
| 1903 | 1906 | if (hSession->syncing || !(hSession->ibptr - hSession->ibuf)) |
| 1904 | 1907 | return(0); |
| 1905 | 1908 | ... | ... |