Commit 615e14f3488b8c9021bfbf08d6ef3c0c4df63058

Authored by perry.werneck@gmail.com
1 parent 0a721dd2

Melhorando teste de "TerminalReady"

src/include/lib3270.h
@@ -189,7 +189,7 @@ @@ -189,7 +189,7 @@
189 LIB3270_MESSAGE_NUMERIC, /**< 8 - */ 189 LIB3270_MESSAGE_NUMERIC, /**< 8 - */
190 LIB3270_MESSAGE_OVERFLOW, /**< 9 - */ 190 LIB3270_MESSAGE_OVERFLOW, /**< 9 - */
191 LIB3270_MESSAGE_INHIBIT, /**< 10 - */ 191 LIB3270_MESSAGE_INHIBIT, /**< 10 - */
192 - LIB3270_MESSAGE_KYBDLOCK, /**< 11 - */ 192 + LIB3270_MESSAGE_KYBDLOCK, /**< 11 - Keyboard is locked */
193 193
194 LIB3270_MESSAGE_X, /**< 12 - */ 194 LIB3270_MESSAGE_X, /**< 12 - */
195 LIB3270_MESSAGE_RESOLVING, /**< 13 - Resolving hostname (running DNS query) */ 195 LIB3270_MESSAGE_RESOLVING, /**< 13 - Resolving hostname (running DNS query) */
@@ -707,9 +707,10 @@ @@ -707,9 +707,10 @@
707 LIB3270_EXPORT int lib3270_in_sscp(H3270 *h); 707 LIB3270_EXPORT int lib3270_in_sscp(H3270 *h);
708 LIB3270_EXPORT int lib3270_in_tn3270e(H3270 *h); 708 LIB3270_EXPORT int lib3270_in_tn3270e(H3270 *h);
709 LIB3270_EXPORT int lib3270_in_e(H3270 *h); 709 LIB3270_EXPORT int lib3270_in_e(H3270 *h);
  710 + LIB3270_EXPORT int lib3270_lock_status(H3270 *h);
  711 + LIB3270_EXPORT int lib3270_is_ready(H3270 *h);
710 712
711 #define lib3270_is_connected(h) lib3270_in_tn3270e(h) 713 #define lib3270_is_connected(h) lib3270_in_tn3270e(h)
712 - #define lib3270_is_ready(h) lib3270_get_program_message(h) == LIB3270_MESSAGE_NONE  
713 714
714 LIB3270_EXPORT LIB3270_SSL_STATE lib3270_get_secure(H3270 *session); 715 LIB3270_EXPORT LIB3270_SSL_STATE lib3270_get_secure(H3270 *session);
715 LIB3270_EXPORT long lib3270_get_SSL_verify_result(H3270 *session); 716 LIB3270_EXPORT long lib3270_get_SSL_verify_result(H3270 *session);
src/lib3270/ctlr.c
@@ -2205,21 +2205,20 @@ int ctlr_any_data(H3270 *session) @@ -2205,21 +2205,20 @@ int ctlr_any_data(H3270 *session)
2205 * Clear the text (non-status) portion of the display. Also resets the cursor 2205 * Clear the text (non-status) portion of the display. Also resets the cursor
2206 * and buffer addresses and extended attributes. 2206 * and buffer addresses and extended attributes.
2207 */ 2207 */
2208 -void  
2209 -ctlr_clear(H3270 *session, Boolean can_snap) 2208 +void ctlr_clear(H3270 *session, Boolean can_snap)
2210 { 2209 {
2211 /* Snap any data that is about to be lost into the trace file. */ 2210 /* Snap any data that is about to be lost into the trace file. */
  2211 +#if defined(X3270_TRACE)
  2212 +
2212 if (ctlr_any_data(session)) 2213 if (ctlr_any_data(session))
2213 { 2214 {
2214 -#if defined(X3270_TRACE) /*[*/  
2215 if (can_snap && !session->trace_skipping && lib3270_get_toggle(session,LIB3270_TOGGLE_SCREEN_TRACE)) 2215 if (can_snap && !session->trace_skipping && lib3270_get_toggle(session,LIB3270_TOGGLE_SCREEN_TRACE))
2216 trace_screen(session); 2216 trace_screen(session);
2217 -#endif /*]*/  
2218 -// scroll_save(session->maxROWS, ever_3270 ? False : True);  
2219 } 2217 }
2220 -#if defined(X3270_TRACE) /*[*/ 2218 +
2221 session->trace_skipping = 0; 2219 session->trace_skipping = 0;
2222 -#endif /*]*/ 2220 +
  2221 +#endif
2223 2222
2224 /* Clear the screen. */ 2223 /* Clear the screen. */
2225 (void) memset((char *)session->ea_buf, 0, session->rows*session->cols*sizeof(struct lib3270_ea)); 2224 (void) memset((char *)session->ea_buf, 0, session->rows*session->cols*sizeof(struct lib3270_ea));
src/lib3270/iocalls.c
@@ -726,14 +726,14 @@ LIB3270_EXPORT int lib3270_wait_for_ready(H3270 *hSession, int seconds) @@ -726,14 +726,14 @@ LIB3270_EXPORT int lib3270_wait_for_ready(H3270 *hSession, int seconds)
726 { 726 {
727 time_t end = time(0)+seconds; 727 time_t end = time(0)+seconds;
728 728
729 - if(hSession->oia_status == LIB3270_STATUS_BLANK) 729 + if(!lib3270_lock_status(hSession))
730 return 0; 730 return 0;
731 731
732 while(time(0) < end) 732 while(time(0) < end)
733 { 733 {
734 event_dispatcher(hSession,1); 734 event_dispatcher(hSession,1);
735 735
736 - if(hSession->oia_status == LIB3270_STATUS_BLANK) 736 + if(!lib3270_lock_status(hSession))
737 return 0; 737 return 0;
738 738
739 if(!lib3270_connected(hSession)) 739 if(!lib3270_connected(hSession))
src/lib3270/kybd.c
@@ -384,7 +384,7 @@ static void kybdlock_set(H3270 *hSession, unsigned int bits) @@ -384,7 +384,7 @@ static void kybdlock_set(H3270 *hSession, unsigned int bits)
384 hSession->unlock_delay_time = time(NULL); 384 hSession->unlock_delay_time = time(NULL);
385 } 385 }
386 hSession->kybdlock = n; 386 hSession->kybdlock = n;
387 - status_changed(hSession,LIB3270_STATUS_KYBDLOCK); 387 + status_changed(hSession,LIB3270_MESSAGE_KYBDLOCK);
388 } 388 }
389 } 389 }
390 390
@@ -409,7 +409,7 @@ void lib3270_kybdlock_clear(H3270 *hSession, LIB3270_KL_STATE bits) @@ -409,7 +409,7 @@ void lib3270_kybdlock_clear(H3270 *hSession, LIB3270_KL_STATE bits)
409 hSession->unlock_delay_time = 0; 409 hSession->unlock_delay_time = 0;
410 } 410 }
411 hSession->kybdlock = n; 411 hSession->kybdlock = n;
412 - status_changed(hSession,LIB3270_STATUS_KYBDLOCK); 412 + status_changed(hSession,LIB3270_MESSAGE_KYBDLOCK);
413 } 413 }
414 } 414 }
415 415
src/lib3270/screen.c
@@ -528,6 +528,42 @@ LIB3270_EXPORT LIB3270_STATUS lib3270_get_program_message(H3270 *session) @@ -528,6 +528,42 @@ LIB3270_EXPORT LIB3270_STATUS lib3270_get_program_message(H3270 *session)
528 return session->oia_status; 528 return session->oia_status;
529 } 529 }
530 530
  531 +/**
  532 + * Check if the terminal is ready for commands.
  533 + *
  534 + * @param h Session handle.
  535 + *
  536 + * @return 0 if the terminal is ready (no message, keyboard unlocked), LIB3270_MESSAGE if not
  537 + *
  538 + */
  539 +LIB3270_EXPORT int lib3270_lock_status(H3270 *hSession)
  540 +{
  541 + CHECK_SESSION_HANDLE(hSession);
  542 +
  543 + if(hSession->oia_status)
  544 + return hSession->oia_status;
  545 +
  546 + if(hSession->kybdlock)
  547 + return LIB3270_MESSAGE_KYBDLOCK;
  548 +
  549 + return LIB3270_MESSAGE_NONE;
  550 +
  551 +}
  552 +
  553 +/**
  554 + * Check if terminal is ready for actions.
  555 + *
  556 + * @param h Session handle.
  557 + *
  558 + * @return Non zero if terminal is ready for commands.
  559 + *
  560 + */
  561 +LIB3270_EXPORT int lib3270_is_ready(H3270 *hSession)
  562 +{
  563 + return lib3270_lock_status(hSession) == LIB3270_MESSAGE_NONE;
  564 +}
  565 +
  566 +
531 void status_changed(H3270 *session, LIB3270_STATUS id) 567 void status_changed(H3270 *session, LIB3270_STATUS id)
532 { 568 {
533 CHECK_SESSION_HANDLE(session); 569 CHECK_SESSION_HANDLE(session);
src/lib3270/statusc.h
@@ -35,7 +35,4 @@ LIB3270_INTERNAL void set_status(H3270 *session, OIA_FLAG id, Boolean on); @@ -35,7 +35,4 @@ LIB3270_INTERNAL void set_status(H3270 *session, OIA_FLAG id, Boolean on);
35 35
36 36
37 #define status_typeahead(h,on) set_status(h,OIA_FLAG_TYPEAHEAD,on) 37 #define status_typeahead(h,on) set_status(h,OIA_FLAG_TYPEAHEAD,on)
38 -// #define status_kybdlock(h) status_changed(h,LIB3270_STATUS_KYBDLOCK)  
39 -// #define status_syswait(h) status_changed(h,LIB3270_STATUS_SYSWAIT)  
40 -// #define status_minus() status_changed(NULL,LIB3270_STATUS_MINUS)  
41 38