Commit a37acd6982131b159e4aedff4035502494ad703d
1 parent
96dfceca
Exists in
master
Melhorando a sinalização de connect/disconnect
Showing
4 changed files
with
19 additions
and
43 deletions
Show diff stats
src/include/lib3270/api.h
... | ... | @@ -273,6 +273,7 @@ |
273 | 273 | void (*update_toggle)(H3270 *session, LIB3270_TOGGLE ix, unsigned char value, LIB3270_TOGGLE_TYPE reason, const char *name); |
274 | 274 | void (*update_luname)(H3270 *session, const char *name); |
275 | 275 | void (*update_status)(H3270 *session, LIB3270_STATUS id); |
276 | + void (*update_connect)(H3270 *session, unsigned char connected); | |
276 | 277 | |
277 | 278 | void (*set_timer)(H3270 *session, unsigned char on); |
278 | 279 | void (*erase)(H3270 *session); | ... | ... |
src/lib/globals.h
src/lib/host.c
... | ... | @@ -57,30 +57,6 @@ |
57 | 57 | #define RECONNECT_MS 2000 /* 2 sec before reconnecting to host */ |
58 | 58 | #define RECONNECT_ERR_MS 5000 /* 5 sec before reconnecting to host */ |
59 | 59 | |
60 | -// #define MAX_RECENT 5 | |
61 | - | |
62 | -// enum cstate cstate = NOT_CONNECTED; | |
63 | -// Boolean std_ds_host = False; | |
64 | -// Boolean no_login_host = False; | |
65 | -// Boolean non_tn3270e_host = False; | |
66 | -// Boolean passthru_host = False; | |
67 | -// Boolean ssl_host = False; | |
68 | -// Boolean ever_3270 = False; | |
69 | - | |
70 | -// char *full_current_host = CN; | |
71 | -//unsigned short current_port; | |
72 | -//char *reconnect_host = CN; | |
73 | -//char *qualified_host = CN; | |
74 | - | |
75 | -// struct host *hosts = (struct host *)NULL; | |
76 | -// static struct host *last_host = (struct host *)NULL; | |
77 | -// static Boolean auto_reconnect_inprogress = False; | |
78 | -// static int net_sock = -1; | |
79 | - | |
80 | -// #if defined(X3270_DISPLAY) | |
81 | -// static void save_recent(const char *); | |
82 | -// #endif | |
83 | - | |
84 | 60 | static void try_reconnect(H3270 *session); |
85 | 61 | |
86 | 62 | /* |
... | ... | @@ -605,7 +581,7 @@ static int do_connect(H3270 *hSession, const char *n) |
605 | 581 | if (hSession->net_sock < 0 && !resolving) |
606 | 582 | { |
607 | 583 | /* Redundantly signal a disconnect. */ |
608 | - lib3270_st_changed(hSession, ST_CONNECT, False); | |
584 | + host_disconnected(hSession); | |
609 | 585 | return -1; |
610 | 586 | } |
611 | 587 | |
... | ... | @@ -637,12 +613,7 @@ static int do_connect(H3270 *hSession, const char *n) |
637 | 613 | } |
638 | 614 | else |
639 | 615 | { |
640 | - hSession->cstate = CONNECTED_INITIAL; | |
641 | - lib3270_st_changed(hSession, ST_CONNECT, True); | |
642 | -#if defined(X3270_DISPLAY) /*[*/ | |
643 | - if (toggled(RECONNECT) && error_popup_visible()) | |
644 | - popdown_an_error(); | |
645 | -#endif /*]*/ | |
616 | + host_connected(hSession); | |
646 | 617 | } |
647 | 618 | |
648 | 619 | return 0; |
... | ... | @@ -722,10 +693,7 @@ void host_disconnect(H3270 *h, int failed) |
722 | 693 | trace_ansi_disc(); |
723 | 694 | #endif /*]*/ |
724 | 695 | |
725 | - h->cstate = NOT_CONNECTED; | |
726 | - | |
727 | - /* Propagate the news to everyone else. */ | |
728 | - lib3270_st_changed(h,ST_CONNECT, False); | |
696 | + host_disconnected(h); | |
729 | 697 | } |
730 | 698 | } |
731 | 699 | |
... | ... | @@ -745,13 +713,18 @@ void host_connected(H3270 *session) |
745 | 713 | { |
746 | 714 | session->cstate = CONNECTED_INITIAL; |
747 | 715 | lib3270_st_changed(session, ST_CONNECT, True); |
716 | + if(session->update_connect) | |
717 | + session->update_connect(session,1); | |
718 | +} | |
748 | 719 | |
749 | -/* | |
750 | -#if defined(X3270_DISPLAY) | |
751 | - if (toggled(RECONNECT) && error_popup_visible()) | |
752 | - popdown_an_error(); | |
753 | -#endif | |
754 | -*/ | |
720 | +void host_disconnected(H3270 *session) | |
721 | +{ | |
722 | + session->cstate = NOT_CONNECTED; | |
723 | + set_status(session,OIA_FLAG_UNDERA,False); | |
724 | + lib3270_st_changed(session,ST_CONNECT, False); | |
725 | + status_changed(session,LIB3270_MESSAGE_DISCONNECTED); | |
726 | + if(session->update_connect) | |
727 | + session->update_connect(session,0); | |
755 | 728 | } |
756 | 729 | |
757 | 730 | /* Register a function interested in a state change. */ | ... | ... |
src/lib/hostc.h
... | ... | @@ -19,6 +19,7 @@ |
19 | 19 | |
20 | 20 | #include <lib3270/api.h> |
21 | 21 | |
22 | +/* | |
22 | 23 | struct host { |
23 | 24 | char *name; |
24 | 25 | char **parents; |
... | ... | @@ -29,12 +30,14 @@ |
29 | 30 | struct host *prev, *next; |
30 | 31 | }; |
31 | 32 | extern struct host *hosts; |
33 | +*/ | |
32 | 34 | |
33 | 35 | #define st_changed(tx,mode) lib3270_st_changed(NULL,tx,mode) |
34 | 36 | |
35 | 37 | LIB3270_INTERNAL void lib3270_st_changed(H3270 *h, int tx, int mode); |
36 | - LIB3270_INTERNAL void hostfile_init(void); | |
38 | +// LIB3270_INTERNAL void hostfile_init(void); | |
37 | 39 | LIB3270_INTERNAL void host_connected(H3270 *session); |
40 | + LIB3270_INTERNAL void host_disconnected(H3270 *session); | |
38 | 41 | LIB3270_INTERNAL void host_in3270(H3270 *session, LIB3270_CSTATE); |
39 | 42 | LIB3270_INTERNAL void host_disconnect(H3270 *h, int disable); |
40 | 43 | ... | ... |