Commit b00a36907c88022a670aba509b1da52372ad441f
1 parent
2a4054a8
Exists in
master
and in
5 other branches
Melhorando sistema de callbacks.
Showing
5 changed files
with
55 additions
and
53 deletions
Show diff stats
src/include/lib3270/session.h
| ... | ... | @@ -83,8 +83,6 @@ |
| 83 | 83 | |
| 84 | 84 | struct lib3270_session_callbacks |
| 85 | 85 | { |
| 86 | - unsigned short sz; | |
| 87 | - | |
| 88 | 86 | int (*write)(H3270 *hSession, unsigned const char *buf, int len); |
| 89 | 87 | void (*disconnect)(H3270 *hSession); |
| 90 | 88 | |
| ... | ... | @@ -119,6 +117,8 @@ |
| 119 | 117 | }; |
| 120 | 118 | |
| 121 | 119 | |
| 120 | + LIB3270_EXPORT struct lib3270_session_callbacks * lib3270_get_session_callbacks(H3270 *session, unsigned short sz); | |
| 121 | + | |
| 122 | 122 | struct _h3270 |
| 123 | 123 | { |
| 124 | 124 | unsigned short sz; /**< Struct size */ |
| ... | ... | @@ -182,10 +182,10 @@ |
| 182 | 182 | |
| 183 | 183 | struct |
| 184 | 184 | { |
| 185 | - char * current; /**< The hostname part, stripped of qualifiers, luname and port number */ | |
| 186 | - char * full; /**< The entire string, for use in reconnecting */ | |
| 187 | - char * srvc; /**< The service name */ | |
| 188 | - char * qualified; | |
| 185 | + char * current; /**< The hostname part, stripped of qualifiers, luname and port number */ | |
| 186 | + char * full; /**< The entire string, for use in reconnecting */ | |
| 187 | + char * srvc; /**< The service name */ | |
| 188 | + char * qualified; | |
| 189 | 189 | } host; |
| 190 | 190 | |
| 191 | 191 | char * proxy; /**< Proxy server (type:host[:port]) */ | ... | ... |
src/lib3270/ctlr.c
| ... | ... | @@ -2696,27 +2696,6 @@ void ctlr_scroll(H3270 *hSession) |
| 2696 | 2696 | #endif /*]*/ |
| 2697 | 2697 | |
| 2698 | 2698 | /* |
| 2699 | - * Note that a particular region of the screen has changed. | |
| 2700 | - */ | |
| 2701 | - | |
| 2702 | -// void changed(H3270 *session, int bstart, int bend) | |
| 2703 | -// { | |
| 2704 | - /* | |
| 2705 | - if(session->first_changed < 0) | |
| 2706 | - { | |
| 2707 | - session->first_changed = bstart; | |
| 2708 | - session->last_changed = bend; | |
| 2709 | - return; | |
| 2710 | - } | |
| 2711 | - if(bstart < session->first_changed) | |
| 2712 | - session->first_changed = bstart; | |
| 2713 | - | |
| 2714 | - if(bend > session->last_changed) | |
| 2715 | - session->last_changed = bend; | |
| 2716 | - */ | |
| 2717 | -// } | |
| 2718 | - | |
| 2719 | -/* | |
| 2720 | 2699 | * Swap the regular and alternate screen buffers |
| 2721 | 2700 | */ |
| 2722 | 2701 | void ctlr_altbuffer(H3270 *session, int alt) | ... | ... |
src/lib3270/session.c
| ... | ... | @@ -331,3 +331,15 @@ LIB3270_EXPORT void * lib3270_get_user_data(H3270 *h) |
| 331 | 331 | CHECK_SESSION_HANDLE(h); |
| 332 | 332 | return h->user_data; |
| 333 | 333 | } |
| 334 | + | |
| 335 | +struct lib3270_session_callbacks * lib3270_get_session_callbacks(H3270 *session, unsigned short sz) | |
| 336 | +{ | |
| 337 | + CHECK_SESSION_HANDLE(session); | |
| 338 | + | |
| 339 | + if(sz != sizeof(struct lib3270_session_callbacks)) | |
| 340 | + return NULL; | |
| 341 | + | |
| 342 | + return &session->cbk; | |
| 343 | +} | |
| 344 | + | |
| 345 | + | ... | ... |
src/lib3270/telnet.c
| ... | ... | @@ -1866,10 +1866,11 @@ static void process_bind(H3270 *hSession, unsigned char *buf, int buflen) |
| 1866 | 1866 | } |
| 1867 | 1867 | #endif /*]*/ |
| 1868 | 1868 | |
| 1869 | -static int | |
| 1870 | -process_eor(H3270 *hSession) | |
| 1869 | +static int process_eor(H3270 *hSession) | |
| 1871 | 1870 | { |
| 1871 | + | |
| 1872 | 1872 | trace("%s: syncing=%s",__FUNCTION__,hSession->syncing ? "Yes" : "No"); |
| 1873 | + | |
| 1873 | 1874 | if (hSession->syncing || !(hSession->ibptr - hSession->ibuf)) |
| 1874 | 1875 | return(0); |
| 1875 | 1876 | ... | ... |
src/pw3270/v3270/widget.c
| ... | ... | @@ -918,7 +918,11 @@ static void release_activity_timer(v3270 *widget) |
| 918 | 918 | |
| 919 | 919 | static void v3270_init(v3270 *widget) |
| 920 | 920 | { |
| 921 | - widget->host = lib3270_session_new(""); | |
| 921 | + struct lib3270_session_callbacks *cbk; | |
| 922 | + | |
| 923 | + widget->host = lib3270_session_new(""); | |
| 924 | + widget->host->user_data = widget; | |
| 925 | + | |
| 922 | 926 | |
| 923 | 927 | trace("%s host->sz=%d expected=%d revision=%s expected=%s",__FUNCTION__,widget->host->sz,(int) sizeof(H3270),lib3270_get_revision(),PACKAGE_REVISION); |
| 924 | 928 | |
| ... | ... | @@ -928,29 +932,35 @@ static void v3270_init(v3270 *widget) |
| 928 | 932 | return; |
| 929 | 933 | } |
| 930 | 934 | |
| 931 | - widget->host->user_data = widget; | |
| 932 | - | |
| 933 | - widget->host->cbk.update = v3270_update_char; | |
| 934 | - widget->host->cbk.changed = changed; | |
| 935 | - widget->host->cbk.set_timer = set_timer; | |
| 936 | - | |
| 937 | - widget->host->cbk.set_selection = set_selection; | |
| 938 | - widget->host->cbk.update_selection = update_selection; | |
| 939 | - | |
| 940 | - widget->host->cbk.update_luname = update_luname; | |
| 941 | - widget->host->cbk.configure = update_screen_size; | |
| 942 | - widget->host->cbk.update_status = update_message; | |
| 943 | - widget->host->cbk.update_cursor = v3270_update_cursor; | |
| 944 | - widget->host->cbk.update_toggle = update_toggle; | |
| 945 | - widget->host->cbk.update_oia = v3270_update_oia; | |
| 946 | - widget->host->cbk.cursor = select_cursor; | |
| 947 | - widget->host->cbk.update_connect = update_connect; | |
| 948 | - widget->host->cbk.update_model = update_model; | |
| 949 | - widget->host->cbk.changed = changed; | |
| 950 | - widget->host->cbk.ctlr_done = ctlr_done; | |
| 951 | - widget->host->cbk.message = message; | |
| 952 | - widget->host->cbk.update_ssl = v3270_update_ssl; | |
| 953 | - widget->host->cbk.print = emit_print_signal; | |
| 935 | + cbk = lib3270_get_session_callbacks(widget->host,sizeof(struct lib3270_session_callbacks)); | |
| 936 | + if(!cbk) | |
| 937 | + { | |
| 938 | + g_error( _( "Invalid callback table, possible version mismatch in lib3270") ); | |
| 939 | + return; | |
| 940 | + } | |
| 941 | + | |
| 942 | + | |
| 943 | + cbk->update = v3270_update_char; | |
| 944 | + cbk->changed = changed; | |
| 945 | + cbk->set_timer = set_timer; | |
| 946 | + | |
| 947 | + cbk->set_selection = set_selection; | |
| 948 | + cbk->update_selection = update_selection; | |
| 949 | + | |
| 950 | + cbk->update_luname = update_luname; | |
| 951 | + cbk->configure = update_screen_size; | |
| 952 | + cbk->update_status = update_message; | |
| 953 | + cbk->update_cursor = v3270_update_cursor; | |
| 954 | + cbk->update_toggle = update_toggle; | |
| 955 | + cbk->update_oia = v3270_update_oia; | |
| 956 | + cbk->cursor = select_cursor; | |
| 957 | + cbk->update_connect = update_connect; | |
| 958 | + cbk->update_model = update_model; | |
| 959 | + cbk->changed = changed; | |
| 960 | + cbk->ctlr_done = ctlr_done; | |
| 961 | + cbk->message = message; | |
| 962 | + cbk->update_ssl = v3270_update_ssl; | |
| 963 | + cbk->print = emit_print_signal; | |
| 954 | 964 | |
| 955 | 965 | |
| 956 | 966 | // Reset timer | ... | ... |