Commit 1d213a96f7e2e314660233beefe7abeab34f6d83

Authored by perry.werneck@gmail.com
1 parent 138676dc
Exists in master

Movendo indicador do estado da conexao para a estrutura de sessao

latest/src/gtk2/actions1.c
... ... @@ -756,7 +756,7 @@
756 756 gtk_action_group_set_sensitive(action_group[id],status);
757 757 }
758 758  
759   - static void set_ft_action_state(H3270 *session,int state)
  759 + static void set_ft_action_state(H3270 *session,int state,void *dunno)
760 760 {
761 761 gtk_action_group_set_sensitive(action_group[ACTION_GROUP_FT],state);
762 762 }
... ... @@ -790,7 +790,7 @@
790 790 action_by_id[f] = dunno;
791 791  
792 792 #ifdef X3270_FT
793   - set_ft_action_state(hSession,0);
  793 + set_ft_action_state(hSession,0,NULL);
794 794 register_schange(ST_3270_MODE, set_ft_action_state);
795 795 #else
796 796 gtk_action_group_set_sensitive(ft_actions,FALSE);
... ...
latest/src/include/lib3270.h
... ... @@ -95,5 +95,16 @@
95 95 */
96 96 LIB3270_EXPORT int lib3270_reconnect(H3270 *h,int wait);
97 97  
  98 + /**
  99 + * Get connection state.
  100 + *
  101 + * @param h Session handle.
  102 + *
  103 + * @return Connection state.
  104 + *
  105 + */
  106 + LIB3270_EXPORT enum cstate lib3270_get_connection_state(H3270 *h);
  107 +
  108 +
98 109  
99 110 #endif // LIB3270_H_INCLUDED
... ...
latest/src/include/lib3270/api.h
... ... @@ -145,6 +145,21 @@
145 145 #define ST_CHARSET LIB3270_STATE_CHARSET
146 146 #define LIB3270_STATE_CHANGE LIB3270_STATE
147 147  
  148 + /** connection state */
  149 + enum cstate
  150 + {
  151 + NOT_CONNECTED, /**< no socket, unknown mode */
  152 + RESOLVING, /**< resolving hostname */
  153 + PENDING, /**< connection pending */
  154 + CONNECTED_INITIAL, /**< connected, no mode yet */
  155 + CONNECTED_ANSI, /**< connected in NVT ANSI mode */
  156 + CONNECTED_3270, /**< connected in old-style 3270 mode */
  157 + CONNECTED_INITIAL_E, /**< connected in TN3270E mode, unnegotiated */
  158 + CONNECTED_NVT, /**< connected in TN3270E mode, NVT mode */
  159 + CONNECTED_SSCP, /**< connected in TN3270E mode, SSCP-LU mode */
  160 + CONNECTED_TN3270E /**< connected in TN3270E mode, 3270 mode */
  161 + };
  162 +
148 163 struct lib3270_state_callback;
149 164  
150 165 typedef struct _h3270
... ... @@ -154,6 +169,7 @@
154 169 // Connection info
155 170 int secure_connection;
156 171 int sock; /**< Network socket */
  172 + enum cstate cstate;
157 173  
158 174 #if defined(_WIN32) /*[*/
159 175 HANDLE sock_handle;
... ... @@ -216,22 +232,6 @@
216 232 KT_GE
217 233 };
218 234  
219   - /** connection state */
220   - enum cstate
221   - {
222   - NOT_CONNECTED, /**< no socket, unknown mode */
223   - RESOLVING, /**< resolving hostname */
224   - PENDING, /**< connection pending */
225   - CONNECTED_INITIAL, /**< connected, no mode yet */
226   - CONNECTED_ANSI, /**< connected in NVT ANSI mode */
227   - CONNECTED_3270, /**< connected in old-style 3270 mode */
228   - CONNECTED_INITIAL_E, /**< connected in TN3270E mode, unnegotiated */
229   - CONNECTED_NVT, /**< connected in TN3270E mode, NVT mode */
230   - CONNECTED_SSCP, /**< connected in TN3270E mode, SSCP-LU mode */
231   - CONNECTED_TN3270E /**< connected in TN3270E mode, 3270 mode */
232   - };
233   -
234   -
235 235 /** extended attributes */
236 236 struct ea
237 237 {
... ... @@ -312,9 +312,11 @@
312 312  
313 313 LIB3270_EXPORT int RegisterFTCallbacks(const struct filetransfer_callbacks *cbk);
314 314  
  315 + #define QueryCstate() lib3270_get_connection_state(NULL)
  316 +
315 317 #ifndef LIB3270
316 318  
317   - LIB3270_EXPORT enum cstate QueryCstate(void);
  319 +
318 320 LIB3270_EXPORT enum ft_state QueryFTstate(void);
319 321  
320 322 #define PCONNECTED ((int) QueryCstate() >= (int)RESOLVING)
... ...
latest/src/lib/XtGlue.c
... ... @@ -893,9 +893,12 @@ int Register3270IOCallbacks(const struct lib3270_io_callbacks *cbk)
893 893  
894 894 }
895 895  
896   -LIB3270_EXPORT enum cstate QueryCstate(void)
  896 +LIB3270_EXPORT enum cstate lib3270_get_connection_state(H3270 *h)
897 897 {
898   - return cstate;
  898 + if(!h)
  899 + h = &h3270;
  900 +
  901 + return h->cstate;
899 902 }
900 903  
901 904 int CallAndWait(int(*callback)(void *),void *parm)
... ...
latest/src/lib/globals.h
... ... @@ -245,15 +245,15 @@ LIB3270_INTERNAL int *xtra_width;
245 245 LIB3270_INTERNAL enum ft_state ft_state;
246 246 LIB3270_INTERNAL enum cstate cstate;
247 247  
248   -#define PCONNECTED ((int)cstate >= (int)RESOLVING)
249   -#define HALF_CONNECTED (cstate == RESOLVING || cstate == PENDING)
250   -#define CONNECTED ((int)cstate >= (int)CONNECTED_INITIAL)
251   -#define IN_NEITHER (cstate == CONNECTED_INITIAL)
252   -#define IN_ANSI (cstate == CONNECTED_ANSI || cstate == CONNECTED_NVT)
253   -#define IN_3270 (cstate == CONNECTED_3270 || cstate == CONNECTED_TN3270E || cstate == CONNECTED_SSCP)
254   -#define IN_SSCP (cstate == CONNECTED_SSCP)
255   -#define IN_TN3270E (cstate == CONNECTED_TN3270E)
256   -#define IN_E (cstate >= CONNECTED_INITIAL_E)
  248 +#define PCONNECTED ((int)h3270.cstate >= (int)RESOLVING)
  249 +#define HALF_CONNECTED (h3270.cstate == RESOLVING || h3270.cstate == PENDING)
  250 +#define CONNECTED ((int)h3270.cstate >= (int)CONNECTED_INITIAL)
  251 +#define IN_NEITHER (h3270.cstate == CONNECTED_INITIAL)
  252 +#define IN_ANSI (h3270.cstate == CONNECTED_ANSI || h3270.cstate == CONNECTED_NVT)
  253 +#define IN_3270 (h3270.cstate == CONNECTED_3270 || h3270.cstate == CONNECTED_TN3270E || h3270.cstate == CONNECTED_SSCP)
  254 +#define IN_SSCP (h3270.cstate == CONNECTED_SSCP)
  255 +#define IN_TN3270E (h3270.cstate == CONNECTED_TN3270E)
  256 +#define IN_E (h3270.cstate >= CONNECTED_INITIAL_E)
257 257  
258 258 /* keyboard modifer bitmap */
259 259 #define ShiftKeyDown 0x01
... ...
latest/src/lib/glue.c
... ... @@ -169,6 +169,7 @@ H3270 * lib3270_session_new(const char *model)
169 169 hSession->model_num = -1;
170 170 hSession->first_changed = -1;
171 171 hSession->last_changed = -1;
  172 + hSession->cstate = NOT_CONNECTED;
172 173  
173 174 strncpy(hSession->full_model_name,"IBM-",FULL_MODEL_NAME_SIZE);
174 175 hSession->model_name = &hSession->full_model_name[4];
... ...
latest/src/lib/host.c
... ... @@ -59,7 +59,7 @@
59 59  
60 60 #define MAX_RECENT 5
61 61  
62   -enum cstate cstate = NOT_CONNECTED;
  62 +// enum cstate cstate = NOT_CONNECTED;
63 63 Boolean std_ds_host = False;
64 64 Boolean no_login_host = False;
65 65 Boolean non_tn3270e_host = False;
... ... @@ -620,7 +620,7 @@ static int do_connect(H3270 *hSession, const char *n)
620 620  
621 621 /* Still thinking about it? */
622 622 if (resolving) {
623   - cstate = RESOLVING;
  623 + h3270.cstate = RESOLVING;
624 624 st_changed(ST_RESOLVING, True);
625 625 return 0;
626 626 }
... ... @@ -639,10 +639,10 @@ static int do_connect(H3270 *hSession, const char *n)
639 639  
640 640 /* Set state and tell the world. */
641 641 if (pending) {
642   - cstate = PENDING;
  642 + h3270.cstate = PENDING;
643 643 st_changed(ST_HALF_CONNECT, True);
644 644 } else {
645   - cstate = CONNECTED_INITIAL;
  645 + h3270.cstate = CONNECTED_INITIAL;
646 646 st_changed(ST_CONNECT, True);
647 647 #if defined(X3270_DISPLAY) /*[*/
648 648 if (toggled(RECONNECT) && error_popup_visible())
... ... @@ -737,7 +737,7 @@ void host_disconnect(H3270 *h, int failed)
737 737 trace_ansi_disc();
738 738 #endif /*]*/
739 739  
740   - cstate = NOT_CONNECTED;
  740 + h3270.cstate = NOT_CONNECTED;
741 741  
742 742 /* Propagate the news to everyone else. */
743 743 st_changed(ST_CONNECT, False);
... ... @@ -752,7 +752,7 @@ host_in3270(enum cstate new_cstate)
752 752 new_cstate == CONNECTED_SSCP ||
753 753 new_cstate == CONNECTED_TN3270E);
754 754  
755   - cstate = new_cstate;
  755 + h3270.cstate = new_cstate;
756 756 ever_3270 = now3270;
757 757 st_changed(ST_3270_MODE, now3270);
758 758 }
... ... @@ -760,7 +760,7 @@ host_in3270(enum cstate new_cstate)
760 760 void
761 761 host_connected(void)
762 762 {
763   - cstate = CONNECTED_INITIAL;
  763 + h3270.cstate = CONNECTED_INITIAL;
764 764 st_changed(ST_CONNECT, True);
765 765  
766 766 #if defined(X3270_DISPLAY) /*[*/
... ... @@ -1058,14 +1058,6 @@ LIB3270_EXPORT int lib3270_reconnect(H3270 *h,int wait)
1058 1058 return rc;
1059 1059 }
1060 1060  
1061   - /*
1062   - * If called from a script and the connection was successful (or
1063   - * half-successful), pause the script until we are connected and
1064   - * we have identified the host type.
1065   - if (!w && (CONNECTED || HALF_CONNECTED))
1066   - sms_connect_wait();
1067   - */
1068   -
1069 1061 return 0;
1070 1062 }
1071 1063  
... ...
latest/src/lib/telnet.c
... ... @@ -2418,14 +2418,14 @@ check_in3270(void)
2418 2418 hisopts[TELOPT_BINARY] &&
2419 2419 hisopts[TELOPT_EOR]) {
2420 2420 new_cstate = CONNECTED_3270;
2421   - } else if (cstate == CONNECTED_INITIAL) {
  2421 + } else if (h3270.cstate == CONNECTED_INITIAL) {
2422 2422 /* Nothing has happened, yet. */
2423 2423 return;
2424 2424 } else {
2425 2425 new_cstate = CONNECTED_ANSI;
2426 2426 }
2427 2427  
2428   - if (new_cstate != cstate) {
  2428 + if (new_cstate != h3270.cstate) {
2429 2429 #if defined(X3270_TN3270E) /*[*/
2430 2430 int was_in_e = IN_E;
2431 2431 #endif /*]*/
... ...