Commit 19dabc571b0de44f249dbcd1387e203d904c0bcf
1 parent
63483dc7
Exists in
master
and in
3 other branches
Improving keyboard lock status check.
Showing
7 changed files
with
104 additions
and
60 deletions
Show diff stats
lib3270.cbp
| ... | ... | @@ -196,6 +196,7 @@ |
| 196 | 196 | <Unit filename="src/include/lib3270/filetransfer.h" /> |
| 197 | 197 | <Unit filename="src/include/lib3270/html.h" /> |
| 198 | 198 | <Unit filename="src/include/lib3270/internals.h" /> |
| 199 | + <Unit filename="src/include/lib3270/keyboard.h" /> | |
| 199 | 200 | <Unit filename="src/include/lib3270/log.h" /> |
| 200 | 201 | <Unit filename="src/include/lib3270/popup.h" /> |
| 201 | 202 | <Unit filename="src/include/lib3270/properties.h" /> | ... | ... |
src/core/iocalls.c
| ... | ... | @@ -478,33 +478,6 @@ LIB3270_EXPORT int lib3270_wait_for_update(H3270 *hSession, int seconds) |
| 478 | 478 | return errno = ENOTSUP; |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | -LIB3270_EXPORT int lib3270_wait_for_unlock(H3270 *hSession, int seconds) | |
| 482 | -{ | |
| 483 | - time_t end = time(0)+seconds; | |
| 484 | - | |
| 485 | - FAIL_IF_NOT_ONLINE(hSession); | |
| 486 | - | |
| 487 | - event_dispatcher(hSession,0); | |
| 488 | - | |
| 489 | - do | |
| 490 | - { | |
| 491 | - if(!lib3270_connected(hSession)) | |
| 492 | - { | |
| 493 | - errno = ENOTCONN; | |
| 494 | - return -1; | |
| 495 | - } | |
| 496 | - | |
| 497 | - if(KYBDLOCK_IS_OERR(hSession)) | |
| 498 | - break; | |
| 499 | - | |
| 500 | - event_dispatcher(hSession,1); | |
| 501 | - | |
| 502 | - } | |
| 503 | - while(hSession->kybdlock && time(0) < end); | |
| 504 | - | |
| 505 | - return hSession->kybdlock; | |
| 506 | -} | |
| 507 | - | |
| 508 | 481 | LIB3270_EXPORT int lib3270_wait_for_ready(H3270 *hSession, int seconds) |
| 509 | 482 | { |
| 510 | 483 | time_t end = time(0)+seconds; | ... | ... |
src/core/keyboard/kybd.c
| ... | ... | @@ -337,7 +337,7 @@ static void kybdlock_set(H3270 *hSession, unsigned int bits) |
| 337 | 337 | * @brief Clear bits in the keyboard lock. |
| 338 | 338 | * |
| 339 | 339 | */ |
| 340 | -void lib3270_kybdlock_clear(H3270 *hSession, LIB3270_KL_STATE bits) | |
| 340 | +void lib3270_kybdlock_clear(H3270 *hSession, LIB3270_KEYBOARD_LOCK_STATE bits) | |
| 341 | 341 | { |
| 342 | 342 | unsigned int n = hSession->kybdlock & ~( (unsigned int) bits); |
| 343 | 343 | |
| ... | ... | @@ -2227,3 +2227,26 @@ int kybd_prime(H3270 *hSession) |
| 2227 | 2227 | return len; |
| 2228 | 2228 | } |
| 2229 | 2229 | #endif /*]*/ |
| 2230 | + | |
| 2231 | +LIB3270_EXPORT LIB3270_KEYBOARD_LOCK_STATE lib3270_wait_for_unlock(H3270 *hSession, int seconds) | |
| 2232 | +{ | |
| 2233 | + time_t end = time(0)+seconds; | |
| 2234 | + | |
| 2235 | + lib3270_main_iterate(hSession,0); | |
| 2236 | + | |
| 2237 | + do | |
| 2238 | + { | |
| 2239 | + if(!lib3270_connected(hSession)) | |
| 2240 | + return LIB3270_KL_NOT_CONNECTED; | |
| 2241 | + | |
| 2242 | + if(KYBDLOCK_IS_OERR(hSession)) | |
| 2243 | + break; | |
| 2244 | + | |
| 2245 | + lib3270_main_iterate(hSession,1); | |
| 2246 | + | |
| 2247 | + } | |
| 2248 | + while(hSession->kybdlock && time(0) < end); | |
| 2249 | + | |
| 2250 | + return (LIB3270_KEYBOARD_LOCK_STATE) hSession->kybdlock; | |
| 2251 | +} | |
| 2252 | + | ... | ... |
src/core/properties.c
| ... | ... | @@ -56,7 +56,7 @@ |
| 56 | 56 | return hSession->starting != 0; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - unsigned int lib3270_get_kybdlock(H3270 *hSession) | |
| 59 | + unsigned int lib3270_get_kybdlock_as_int(H3270 *hSession) | |
| 60 | 60 | { |
| 61 | 61 | return hSession->kybdlock; |
| 62 | 62 | } |
| ... | ... | @@ -242,7 +242,7 @@ |
| 242 | 242 | { |
| 243 | 243 | "kybdlock", // Property name. |
| 244 | 244 | N_( "Keyboard lock status" ), // Property description. |
| 245 | - lib3270_get_kybdlock, // Get value. | |
| 245 | + lib3270_get_kybdlock_as_int, // Get value. | |
| 246 | 246 | NULL // Set value. |
| 247 | 247 | }, |
| 248 | 248 | ... | ... |
src/include/kybdc.h
| ... | ... | @@ -19,6 +19,7 @@ |
| 19 | 19 | #ifndef KYBDC_H_INCLUDED |
| 20 | 20 | |
| 21 | 21 | #define KYBDC_H_INCLUDED |
| 22 | + #include <lib3270/keyboard.h> | |
| 22 | 23 | |
| 23 | 24 | /// @brief Element in typeahead queue. |
| 24 | 25 | struct ta |
| ... | ... | @@ -56,26 +57,6 @@ |
| 56 | 57 | |
| 57 | 58 | }; |
| 58 | 59 | |
| 59 | - | |
| 60 | - /* keyboard lock states */ | |
| 61 | - typedef enum lib3270_kl_state | |
| 62 | - { | |
| 63 | - LIB3270_KL_OERR_MASK = 0x000f, | |
| 64 | - LIB3270_KL_OERR_PROTECTED = 0x0001, | |
| 65 | - LIB3270_KL_OERR_NUMERIC = 0x0002, | |
| 66 | - LIB3270_KL_OERR_OVERFLOW = 0x0003, | |
| 67 | - LIB3270_KL_OERR_DBCS = 0x0004, | |
| 68 | - LIB3270_KL_NOT_CONNECTED = 0x0010, | |
| 69 | - LIB3270_KL_AWAITING_FIRST = 0x0020, | |
| 70 | - LIB3270_KL_OIA_TWAIT = 0x0040, | |
| 71 | - LIB3270_KL_OIA_LOCKED = 0x0080, | |
| 72 | - LIB3270_KL_DEFERRED_UNLOCK = 0x0100, | |
| 73 | - LIB3270_KL_ENTER_INHIBIT = 0x0200, | |
| 74 | - LIB3270_KL_SCROLLED = 0x0400, | |
| 75 | - LIB3270_KL_OIA_MINUS = 0x0800 | |
| 76 | - | |
| 77 | - } LIB3270_KL_STATE; | |
| 78 | - | |
| 79 | 60 | #define KL_OERR_MASK LIB3270_KL_OERR_MASK |
| 80 | 61 | #define KL_OERR_PROTECTED LIB3270_KL_OERR_PROTECTED |
| 81 | 62 | #define KL_OERR_NUMERIC LIB3270_KL_OERR_NUMERIC |
| ... | ... | @@ -97,8 +78,7 @@ |
| 97 | 78 | LIB3270_INTERNAL void clear_xks(void); |
| 98 | 79 | LIB3270_INTERNAL void do_reset(H3270 *session, Boolean explicit); |
| 99 | 80 | |
| 100 | - LIB3270_INTERNAL void lib3270_kybdlock_clear(H3270 *hSession, LIB3270_KL_STATE bits); | |
| 101 | - | |
| 81 | + LIB3270_INTERNAL void lib3270_kybdlock_clear(H3270 *hSession, LIB3270_KEYBOARD_LOCK_STATE bits); | |
| 102 | 82 | |
| 103 | 83 | LIB3270_INTERNAL void kybd_inhibit(H3270 *session, Boolean inhibit); |
| 104 | 84 | LIB3270_INTERNAL int kybd_prime(H3270 *hSession); | ... | ... |
src/include/lib3270.h
| ... | ... | @@ -1032,14 +1032,6 @@ |
| 1032 | 1032 | LIB3270_EXPORT int lib3270_wait_for_ready(H3270 *hSession, int seconds); |
| 1033 | 1033 | |
| 1034 | 1034 | /** |
| 1035 | - * @brief Wait for keyboard unlock. | |
| 1036 | - * @param seconds Number of seconds to wait. | |
| 1037 | - * | |
| 1038 | - * @return keyboard lock status or -1 on error. | |
| 1039 | - */ | |
| 1040 | - LIB3270_EXPORT int lib3270_wait_for_unlock(H3270 *hSession, int seconds); | |
| 1041 | - | |
| 1042 | - /** | |
| 1043 | 1035 | * "beep" to notify user. |
| 1044 | 1036 | * |
| 1045 | 1037 | * If available play a sound signal do alert user. | ... | ... |
| ... | ... | @@ -0,0 +1,75 @@ |
| 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., 51 Franklin | |
| 19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 20 | + * | |
| 21 | + * Contatos: | |
| 22 | + * | |
| 23 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 24 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
| 25 | + * | |
| 26 | + */ | |
| 27 | + | |
| 28 | +#ifndef LIB3270_KEYBOARD_H_INCLUDED | |
| 29 | + | |
| 30 | + #define LIB3270_KEYBOARD_H_INCLUDED 1 | |
| 31 | + | |
| 32 | +#ifdef __cplusplus | |
| 33 | + extern "C" { | |
| 34 | +#endif | |
| 35 | + | |
| 36 | + /** | |
| 37 | + * @brief keyboard lock states | |
| 38 | + */ | |
| 39 | + typedef enum lib3270_keyboard_lock_state | |
| 40 | + { | |
| 41 | + // Operator errors | |
| 42 | + LIB3270_KL_OERR_MASK = 0x000f, | |
| 43 | + LIB3270_KL_OERR_PROTECTED = 0x0001, | |
| 44 | + LIB3270_KL_OERR_NUMERIC = 0x0002, | |
| 45 | + LIB3270_KL_OERR_OVERFLOW = 0x0003, | |
| 46 | + LIB3270_KL_OERR_DBCS = 0x0004, | |
| 47 | + | |
| 48 | + LIB3270_KL_NOT_CONNECTED = 0x0010, | |
| 49 | + LIB3270_KL_AWAITING_FIRST = 0x0020, | |
| 50 | + LIB3270_KL_OIA_TWAIT = 0x0040, | |
| 51 | + LIB3270_KL_OIA_LOCKED = 0x0080, | |
| 52 | + LIB3270_KL_DEFERRED_UNLOCK = 0x0100, | |
| 53 | + LIB3270_KL_ENTER_INHIBIT = 0x0200, | |
| 54 | + LIB3270_KL_SCROLLED = 0x0400, | |
| 55 | + LIB3270_KL_OIA_MINUS = 0x0800 | |
| 56 | + | |
| 57 | + } LIB3270_KEYBOARD_LOCK_STATE; | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * @brief Wait for keyboard unlock. | |
| 61 | + * | |
| 62 | + * Return status if the keyboard is locked by operator error ou if disconnected from host, waits until keyboard is unlocked if not. | |
| 63 | + * | |
| 64 | + * @param seconds Number of seconds to wait. | |
| 65 | + * | |
| 66 | + * @return keyboard lock status. | |
| 67 | + */ | |
| 68 | + LIB3270_EXPORT LIB3270_KEYBOARD_LOCK_STATE lib3270_wait_for_unlock(H3270 *hSession, int seconds); | |
| 69 | + | |
| 70 | +#ifdef __cplusplus | |
| 71 | + } | |
| 72 | +#endif | |
| 73 | + | |
| 74 | +#endif // LIB3270_KEYBOARD_H_INCLUDED | |
| 75 | + | ... | ... |