Commit e5fc82f478434fcada6a2f9c0774f826fb4f9788
1 parent
a4aa3906
Exists in
master
and in
5 other branches
Melhorando tratamento do indicador de SSL
Showing
9 changed files
with
163 additions
and
51 deletions
Show diff stats
src/include/lib3270.h
| @@ -138,7 +138,7 @@ | @@ -138,7 +138,7 @@ | ||
| 138 | { | 138 | { |
| 139 | LIB3270_FLAG_BOXSOLID, /**< System available */ | 139 | LIB3270_FLAG_BOXSOLID, /**< System available */ |
| 140 | LIB3270_FLAG_UNDERA, /**< Control Unit STATUS */ | 140 | LIB3270_FLAG_UNDERA, /**< Control Unit STATUS */ |
| 141 | - LIB3270_FLAG_SECURE, /**< Security status */ | 141 | +// LIB3270_FLAG_SECURE, /**< Security status */ |
| 142 | LIB3270_FLAG_TYPEAHEAD, | 142 | LIB3270_FLAG_TYPEAHEAD, |
| 143 | LIB3270_FLAG_PRINTER, | 143 | LIB3270_FLAG_PRINTER, |
| 144 | LIB3270_FLAG_REVERSE, | 144 | LIB3270_FLAG_REVERSE, |
| @@ -213,6 +213,20 @@ | @@ -213,6 +213,20 @@ | ||
| 213 | 213 | ||
| 214 | 214 | ||
| 215 | /** | 215 | /** |
| 216 | + * SSL state | ||
| 217 | + * | ||
| 218 | + */ | ||
| 219 | + typedef enum lib3270_ssl_state | ||
| 220 | + { | ||
| 221 | + LIB3270_SSL_UNSECURE, /**< No secure connection */ | ||
| 222 | + LIB3270_SSL_SECURE, /**< Connection secure */ | ||
| 223 | + LIB3270_SSL_NEGOTIATING, /**< Negotiating SSL */ | ||
| 224 | + LIB3270_SSL_UNDEFINED /**< Undefined */ | ||
| 225 | + } LIB3270_SSL_STATE; | ||
| 226 | + | ||
| 227 | + #define LIB3270_SSL_FAILED LIB3270_SSL_UNSECURE | ||
| 228 | + | ||
| 229 | + /** | ||
| 216 | * Notification message types. | 230 | * Notification message types. |
| 217 | * | 231 | * |
| 218 | */ | 232 | */ |
| @@ -611,6 +625,9 @@ | @@ -611,6 +625,9 @@ | ||
| 611 | LIB3270_EXPORT int lib3270_in_tn3270e(H3270 *h); | 625 | LIB3270_EXPORT int lib3270_in_tn3270e(H3270 *h); |
| 612 | LIB3270_EXPORT int lib3270_in_e(H3270 *h); | 626 | LIB3270_EXPORT int lib3270_in_e(H3270 *h); |
| 613 | 627 | ||
| 628 | + LIB3270_EXPORT LIB3270_SSL_STATE lib3270_get_secure(H3270 *session); | ||
| 629 | + | ||
| 630 | + | ||
| 614 | /** | 631 | /** |
| 615 | * Call non gui function. | 632 | * Call non gui function. |
| 616 | * | 633 | * |
src/include/lib3270/session.h
| @@ -71,7 +71,7 @@ | @@ -71,7 +71,7 @@ | ||
| 71 | unsigned short sz; /**< Struct size */ | 71 | unsigned short sz; /**< Struct size */ |
| 72 | 72 | ||
| 73 | // Connection info | 73 | // Connection info |
| 74 | - int secure_connection; | 74 | +// int secure_connection; |
| 75 | int sock; /**< Network socket */ | 75 | int sock; /**< Network socket */ |
| 76 | int net_sock; | 76 | int net_sock; |
| 77 | LIB3270_CSTATE cstate; /**< Connection state */ | 77 | LIB3270_CSTATE cstate; /**< Connection state */ |
| @@ -81,6 +81,8 @@ | @@ -81,6 +81,8 @@ | ||
| 81 | int selected : 1; /**< Has selected region? */ | 81 | int selected : 1; /**< Has selected region? */ |
| 82 | int rectsel : 1; /**< Selected region is a rectangle ? */ | 82 | int rectsel : 1; /**< Selected region is a rectangle ? */ |
| 83 | 83 | ||
| 84 | + LIB3270_SSL_STATE secure; | ||
| 85 | + | ||
| 84 | struct lib3270_toggle toggle[LIB3270_TOGGLE_COUNT]; | 86 | struct lib3270_toggle toggle[LIB3270_TOGGLE_COUNT]; |
| 85 | 87 | ||
| 86 | // Network & Termtype | 88 | // Network & Termtype |
| @@ -177,6 +179,7 @@ | @@ -177,6 +179,7 @@ | ||
| 177 | void (*update_connect)(H3270 *session, unsigned char connected); | 179 | void (*update_connect)(H3270 *session, unsigned char connected); |
| 178 | void (*update_model)(H3270 *session, const char *name, int model, int rows, int cols); | 180 | void (*update_model)(H3270 *session, const char *name, int model, int rows, int cols); |
| 179 | void (*update_selection)(H3270 *session, int start, int end); | 181 | void (*update_selection)(H3270 *session, int start, int end); |
| 182 | + void (*update_ssl)(H3270 *session, LIB3270_SSL_STATE state); | ||
| 180 | 183 | ||
| 181 | void (*set_timer)(H3270 *session, unsigned char on); | 184 | void (*set_timer)(H3270 *session, unsigned char on); |
| 182 | void (*erase)(H3270 *session); | 185 | void (*erase)(H3270 *session); |
src/lib3270/api.h
| @@ -157,7 +157,7 @@ | @@ -157,7 +157,7 @@ | ||
| 157 | 157 | ||
| 158 | #define OIA_FLAG_BOXSOLID LIB3270_FLAG_BOXSOLID | 158 | #define OIA_FLAG_BOXSOLID LIB3270_FLAG_BOXSOLID |
| 159 | #define OIA_FLAG_UNDERA LIB3270_FLAG_UNDERA | 159 | #define OIA_FLAG_UNDERA LIB3270_FLAG_UNDERA |
| 160 | - #define OIA_FLAG_SECURE LIB3270_FLAG_SECURE | 160 | +// #define OIA_FLAG_SECURE LIB3270_FLAG_SECURE |
| 161 | #define OIA_FLAG_TYPEAHEAD LIB3270_FLAG_TYPEAHEAD | 161 | #define OIA_FLAG_TYPEAHEAD LIB3270_FLAG_TYPEAHEAD |
| 162 | #define OIA_FLAG_PRINTER LIB3270_FLAG_PRINTER | 162 | #define OIA_FLAG_PRINTER LIB3270_FLAG_PRINTER |
| 163 | #define OIA_FLAG_REVERSE LIB3270_FLAG_REVERSE | 163 | #define OIA_FLAG_REVERSE LIB3270_FLAG_REVERSE |
| @@ -356,7 +356,7 @@ | @@ -356,7 +356,7 @@ | ||
| 356 | LOCAL_EXTERN void Input_String(const unsigned char *str); | 356 | LOCAL_EXTERN void Input_String(const unsigned char *str); |
| 357 | LOCAL_EXTERN void screen_size(int *rows, int *cols); | 357 | LOCAL_EXTERN void screen_size(int *rows, int *cols); |
| 358 | 358 | ||
| 359 | - #define query_secure_connection(h) lib3270_get_ssl_state(h) | 359 | +// #define query_secure_connection(h) lib3270_get_ssl_state(h) |
| 360 | #define lib3270_paste_string(str) lib3270_set_string(NULL,str) | 360 | #define lib3270_paste_string(str) lib3270_set_string(NULL,str) |
| 361 | #define get_3270_terminal_size(h,r,c) lib3270_get_screen_size(h,r,c) | 361 | #define get_3270_terminal_size(h,r,c) lib3270_get_screen_size(h,r,c) |
| 362 | 362 |
src/lib3270/init.c
| @@ -118,6 +118,10 @@ static void message(H3270 *session, LIB3270_NOTIFY id , const char *title, const | @@ -118,6 +118,10 @@ static void message(H3270 *session, LIB3270_NOTIFY id , const char *title, const | ||
| 118 | lib3270_write_log(session,"%s",text); | 118 | lib3270_write_log(session,"%s",text); |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | +static void update_ssl(H3270 *session, LIB3270_SSL_STATE state) | ||
| 122 | +{ | ||
| 123 | +} | ||
| 124 | + | ||
| 121 | static void lib3270_session_init(H3270 *hSession, const char *model) | 125 | static void lib3270_session_init(H3270 *hSession, const char *model) |
| 122 | { | 126 | { |
| 123 | int ovc, ovr; | 127 | int ovc, ovr; |
| @@ -144,6 +148,7 @@ static void lib3270_session_init(H3270 *hSession, const char *model) | @@ -144,6 +148,7 @@ static void lib3270_session_init(H3270 *hSession, const char *model) | ||
| 144 | hSession->update_selection = update_selection; | 148 | hSession->update_selection = update_selection; |
| 145 | hSession->cursor = set_cursor; | 149 | hSession->cursor = set_cursor; |
| 146 | hSession->message = message; | 150 | hSession->message = message; |
| 151 | + hSession->update_ssl = update_ssl; | ||
| 147 | 152 | ||
| 148 | hSession->sock = -1; | 153 | hSession->sock = -1; |
| 149 | hSession->model_num = -1; | 154 | hSession->model_num = -1; |
src/lib3270/screen.c
| @@ -546,15 +546,19 @@ static void status_connect(H3270 *session, int connected, void *dunno) | @@ -546,15 +546,19 @@ static void status_connect(H3270 *session, int connected, void *dunno) | ||
| 546 | else | 546 | else |
| 547 | id = LIB3270_STATUS_CONNECTED; | 547 | id = LIB3270_STATUS_CONNECTED; |
| 548 | 548 | ||
| 549 | -#if defined(HAVE_LIBSSL) /*[*/ | 549 | +/* |
| 550 | +#if defined(HAVE_LIBSSL) | ||
| 550 | set_status(session,OIA_FLAG_SECURE,session->secure_connection); | 551 | set_status(session,OIA_FLAG_SECURE,session->secure_connection); |
| 551 | -#endif /*]*/ | 552 | +#endif |
| 553 | +*/ | ||
| 552 | 554 | ||
| 553 | } | 555 | } |
| 554 | else | 556 | else |
| 555 | { | 557 | { |
| 556 | set_status(session,OIA_FLAG_BOXSOLID,False); | 558 | set_status(session,OIA_FLAG_BOXSOLID,False); |
| 559 | +/* | ||
| 557 | set_status(session,OIA_FLAG_SECURE,False); | 560 | set_status(session,OIA_FLAG_SECURE,False); |
| 561 | +*/ | ||
| 558 | 562 | ||
| 559 | id = LIB3270_STATUS_DISCONNECTED; | 563 | id = LIB3270_STATUS_DISCONNECTED; |
| 560 | } | 564 | } |
src/lib3270/telnet.c
| @@ -351,8 +351,19 @@ static void output_possible(H3270 *session); | @@ -351,8 +351,19 @@ static void output_possible(H3270 *session); | ||
| 351 | #endif /*]*/ | 351 | #endif /*]*/ |
| 352 | 352 | ||
| 353 | 353 | ||
| 354 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | ||
| 355 | + | ||
| 356 | +void set_ssl_state(H3270 *session, LIB3270_SSL_STATE state) | ||
| 357 | +{ | ||
| 358 | + if(state == session->secure) | ||
| 359 | + return; | ||
| 360 | + | ||
| 361 | + trace_dsn("SSL state changes to %d",(int) state); | ||
| 362 | + trace("SSL state changes to %d",(int) state); | ||
| 363 | + | ||
| 364 | + session->update_ssl(session,session->secure = state); | ||
| 365 | +} | ||
| 354 | 366 | ||
| 355 | - | ||
| 356 | #if defined(_WIN32) /*[*/ | 367 | #if defined(_WIN32) /*[*/ |
| 357 | void sockstart(H3270 *session) | 368 | void sockstart(H3270 *session) |
| 358 | { | 369 | { |
| @@ -477,6 +488,8 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo | @@ -477,6 +488,8 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo | ||
| 477 | 488 | ||
| 478 | #define close_fail { (void) SOCK_CLOSE(session->sock); session->sock = -1; return -1; } | 489 | #define close_fail { (void) SOCK_CLOSE(session->sock); session->sock = -1; return -1; } |
| 479 | 490 | ||
| 491 | + set_ssl_state(session,LIB3270_SSL_UNSECURE); | ||
| 492 | + | ||
| 480 | #if defined(_WIN32) | 493 | #if defined(_WIN32) |
| 481 | sockstart(session); | 494 | sockstart(session); |
| 482 | #endif | 495 | #endif |
| @@ -763,44 +776,49 @@ static void net_connected(H3270 *session) | @@ -763,44 +776,49 @@ static void net_connected(H3270 *session) | ||
| 763 | 776 | ||
| 764 | #if defined(HAVE_LIBSSL) /*[*/ | 777 | #if defined(HAVE_LIBSSL) /*[*/ |
| 765 | /* Set up SSL. */ | 778 | /* Set up SSL. */ |
| 766 | - if(session->ssl_host && !session->secure_connection) | 779 | + if(session->ssl_con && session->secure == LIB3270_SSL_UNDEFINED) |
| 767 | { | 780 | { |
| 768 | int rc; | 781 | int rc; |
| 769 | 782 | ||
| 783 | + set_ssl_state(session,LIB3270_SSL_NEGOTIATING); | ||
| 784 | + | ||
| 770 | if (SSL_set_fd(session->ssl_con, session->sock) != 1) | 785 | if (SSL_set_fd(session->ssl_con, session->sock) != 1) |
| 771 | { | 786 | { |
| 772 | trace_dsn("Can't set fd!\n"); | 787 | trace_dsn("Can't set fd!\n"); |
| 773 | popup_system_error(&h3270,_( "Connection failed" ), _( "Can't set SSL socket file descriptor" ), "%s", SSL_state_string_long(session->ssl_con)); | 788 | popup_system_error(&h3270,_( "Connection failed" ), _( "Can't set SSL socket file descriptor" ), "%s", SSL_state_string_long(session->ssl_con)); |
| 789 | + set_ssl_state(session,LIB3270_SSL_UNSECURE); | ||
| 774 | } | 790 | } |
| 791 | + else | ||
| 792 | + { | ||
| 793 | + non_blocking(False); | ||
| 794 | + rc = SSL_connect(session->ssl_con); | ||
| 775 | 795 | ||
| 776 | - non_blocking(False); | ||
| 777 | - rc = SSL_connect(session->ssl_con); | 796 | + if(rc != 1) |
| 797 | + { | ||
| 798 | + unsigned long e = ERR_get_error(); | ||
| 799 | + const char * state = SSL_state_string_long(session->ssl_con); | ||
| 778 | 800 | ||
| 779 | - if(rc != 1) | ||
| 780 | - { | ||
| 781 | - unsigned long e = ERR_get_error(); | ||
| 782 | - const char * state = SSL_state_string_long(session->ssl_con); | 801 | + trace_dsn("TLS/SSL tunneled connection failed with error %ld, rc=%d and state=%s",e,rc,state); |
| 783 | 802 | ||
| 784 | - trace_dsn("TLS/SSL tunneled connection failed with error %ld, rc=%d and state=%s",e,rc,state); | 803 | + host_disconnect(session,True); |
| 785 | 804 | ||
| 786 | - host_disconnect(session,True); | 805 | + if(e != session->last_ssl_error) |
| 806 | + { | ||
| 807 | + session->message( &h3270, | ||
| 808 | + LIB3270_NOTIFY_ERROR, | ||
| 809 | + _( "Connection failed" ), | ||
| 810 | + _( "SSL negotiation failed" ), | ||
| 811 | + state); | ||
| 812 | + session->last_ssl_error = e; | ||
| 813 | + } | ||
| 814 | + return; | ||
| 787 | 815 | ||
| 788 | - if(e != session->last_ssl_error) | ||
| 789 | - { | ||
| 790 | - session->message( &h3270, | ||
| 791 | - LIB3270_NOTIFY_ERROR, | ||
| 792 | - _( "Connection failed" ), | ||
| 793 | - _( "SSL negotiation failed" ), | ||
| 794 | - state); | ||
| 795 | - session->last_ssl_error = e; | ||
| 796 | } | 816 | } |
| 797 | - return; | ||
| 798 | - | 817 | + non_blocking(True); |
| 799 | } | 818 | } |
| 800 | - non_blocking(True); | ||
| 801 | 819 | ||
| 802 | - session->secure_connection = True; | ||
| 803 | - trace_dsn("TLS/SSL tunneled connection complete. Connection is now secure.\n"); | 820 | +// session->secure_connection = True; |
| 821 | +// trace_dsn("TLS/SSL tunneled connection complete. Connection is now secure.\n"); | ||
| 804 | 822 | ||
| 805 | /* Tell everyone else again. */ | 823 | /* Tell everyone else again. */ |
| 806 | host_connected(session); | 824 | host_connected(session); |
| @@ -897,18 +915,22 @@ static void output_possible(H3270 *session) | @@ -897,18 +915,22 @@ static void output_possible(H3270 *session) | ||
| 897 | */ | 915 | */ |
| 898 | void net_disconnect(void) | 916 | void net_disconnect(void) |
| 899 | { | 917 | { |
| 900 | -#if defined(HAVE_LIBSSL) /*[*/ | 918 | +#if defined(HAVE_LIBSSL) |
| 901 | if (h3270.ssl_con != NULL) | 919 | if (h3270.ssl_con != NULL) |
| 902 | { | 920 | { |
| 903 | SSL_shutdown(h3270.ssl_con); | 921 | SSL_shutdown(h3270.ssl_con); |
| 904 | SSL_free(h3270.ssl_con); | 922 | SSL_free(h3270.ssl_con); |
| 905 | h3270.ssl_con = NULL; | 923 | h3270.ssl_con = NULL; |
| 906 | } | 924 | } |
| 907 | - h3270.secure_connection = False; | ||
| 908 | -#endif /*]*/ | 925 | +#endif |
| 926 | + | ||
| 927 | + set_ssl_state(&h3270,LIB3270_SSL_UNSECURE); | ||
| 928 | + | ||
| 909 | if (CONNECTED) | 929 | if (CONNECTED) |
| 910 | (void) shutdown(h3270.sock, 2); | 930 | (void) shutdown(h3270.sock, 2); |
| 931 | + | ||
| 911 | (void) SOCK_CLOSE(h3270.sock); | 932 | (void) SOCK_CLOSE(h3270.sock); |
| 933 | + | ||
| 912 | h3270.sock = -1; | 934 | h3270.sock = -1; |
| 913 | trace_dsn("SENT disconnect\n"); | 935 | trace_dsn("SENT disconnect\n"); |
| 914 | 936 | ||
| @@ -3233,6 +3255,8 @@ static void ssl_init(H3270 *session) | @@ -3233,6 +3255,8 @@ static void ssl_init(H3270 *session) | ||
| 3233 | { | 3255 | { |
| 3234 | static SSL_CTX *ssl_ctx = NULL; | 3256 | static SSL_CTX *ssl_ctx = NULL; |
| 3235 | 3257 | ||
| 3258 | + set_ssl_state(session,LIB3270_SSL_UNDEFINED); | ||
| 3259 | + | ||
| 3236 | if(ssl_ctx == NULL) | 3260 | if(ssl_ctx == NULL) |
| 3237 | { | 3261 | { |
| 3238 | lib3270_write_log(session,"%s","Initializing SSL context"); | 3262 | lib3270_write_log(session,"%s","Initializing SSL context"); |
| @@ -3293,6 +3317,9 @@ static void client_info_callback(INFO_CONST SSL *s, int where, int ret) | @@ -3293,6 +3317,9 @@ static void client_info_callback(INFO_CONST SSL *s, int where, int ret) | ||
| 3293 | break; | 3317 | break; |
| 3294 | 3318 | ||
| 3295 | case SSL_CB_CONNECT_EXIT: | 3319 | case SSL_CB_CONNECT_EXIT: |
| 3320 | + | ||
| 3321 | + trace("%s: SSL_CB_CONNECT_EXIT",__FUNCTION__); | ||
| 3322 | + | ||
| 3296 | if (ret == 0) | 3323 | if (ret == 0) |
| 3297 | { | 3324 | { |
| 3298 | trace_dsn("SSL_connect: failed in %s\n",SSL_state_string_long(s)); | 3325 | trace_dsn("SSL_connect: failed in %s\n",SSL_state_string_long(s)); |
| @@ -3349,6 +3376,15 @@ static void client_info_callback(INFO_CONST SSL *s, int where, int ret) | @@ -3349,6 +3376,15 @@ static void client_info_callback(INFO_CONST SSL *s, int where, int ret) | ||
| 3349 | 3376 | ||
| 3350 | if(where & SSL_CB_ALERT) | 3377 | if(where & SSL_CB_ALERT) |
| 3351 | lib3270_write_log(NULL,"SSL","ALERT: %s",SSL_alert_type_string_long(ret)); | 3378 | lib3270_write_log(NULL,"SSL","ALERT: %s",SSL_alert_type_string_long(ret)); |
| 3379 | + | ||
| 3380 | + if(where & SSL_CB_HANDSHAKE_DONE) | ||
| 3381 | + { | ||
| 3382 | + trace("%s: SSL_CB_HANDSHAKE_DONE state=%04x",__FUNCTION__,SSL_state(s)); | ||
| 3383 | + if(SSL_state(s) == 0x03) | ||
| 3384 | + set_ssl_state(&h3270,LIB3270_SSL_SECURE); | ||
| 3385 | + else | ||
| 3386 | + set_ssl_state(&h3270,LIB3270_SSL_UNSECURE); | ||
| 3387 | + } | ||
| 3352 | } | 3388 | } |
| 3353 | 3389 | ||
| 3354 | /* Process a STARTTLS subnegotiation. */ | 3390 | /* Process a STARTTLS subnegotiation. */ |
| @@ -3406,10 +3442,10 @@ static void continue_tls(unsigned char *sbbuf, int len) | @@ -3406,10 +3442,10 @@ static void continue_tls(unsigned char *sbbuf, int len) | ||
| 3406 | return; | 3442 | return; |
| 3407 | } | 3443 | } |
| 3408 | 3444 | ||
| 3409 | - h3270.secure_connection = True; | 3445 | +// h3270.secure_connection = True; |
| 3410 | 3446 | ||
| 3411 | /* Success. */ | 3447 | /* Success. */ |
| 3412 | - trace_dsn("TLS/SSL negotiated connection complete. Connection is now secure.\n"); | 3448 | +// trace_dsn("TLS/SSL negotiated connection complete. Connection is now secure.\n"); |
| 3413 | 3449 | ||
| 3414 | /* Tell the world that we are (still) connected, now in secure mode. */ | 3450 | /* Tell the world that we are (still) connected, now in secure mode. */ |
| 3415 | host_connected(&h3270); | 3451 | host_connected(&h3270); |
| @@ -3455,6 +3491,13 @@ net_proxy_port(void) | @@ -3455,6 +3491,13 @@ net_proxy_port(void) | ||
| 3455 | return NULL; | 3491 | return NULL; |
| 3456 | } | 3492 | } |
| 3457 | 3493 | ||
| 3494 | +LIB3270_EXPORT LIB3270_SSL_STATE lib3270_get_secure(H3270 *session) | ||
| 3495 | +{ | ||
| 3496 | + CHECK_SESSION_HANDLE(session); | ||
| 3497 | + return session->secure; | ||
| 3498 | +} | ||
| 3499 | + | ||
| 3500 | +/* | ||
| 3458 | LIB3270_EXPORT int lib3270_get_ssl_state(H3270 *h) | 3501 | LIB3270_EXPORT int lib3270_get_ssl_state(H3270 *h) |
| 3459 | { | 3502 | { |
| 3460 | CHECK_SESSION_HANDLE(h); | 3503 | CHECK_SESSION_HANDLE(h); |
| @@ -3465,6 +3508,7 @@ LIB3270_EXPORT int lib3270_get_ssl_state(H3270 *h) | @@ -3465,6 +3508,7 @@ LIB3270_EXPORT int lib3270_get_ssl_state(H3270 *h) | ||
| 3465 | return 0; | 3508 | return 0; |
| 3466 | #endif | 3509 | #endif |
| 3467 | } | 3510 | } |
| 3511 | +*/ | ||
| 3468 | 3512 | ||
| 3469 | /* | 3513 | /* |
| 3470 | int Get3270Socket(void) | 3514 | int Get3270Socket(void) |
src/pw3270/v3270/oia.c
| @@ -306,18 +306,10 @@ void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metri | @@ -306,18 +306,10 @@ void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metri | ||
| 306 | { | 306 | { |
| 307 | cairo_surface_t * icon; | 307 | cairo_surface_t * icon; |
| 308 | double sz = rect->width < rect->height ? rect->width : rect->height; | 308 | double sz = rect->width < rect->height ? rect->width : rect->height; |
| 309 | - int idx = lib3270_get_ssl_state(host) ? 1 : 0; | ||
| 310 | - | ||
| 311 | - static const struct | ||
| 312 | - { | ||
| 313 | - unsigned short width; | ||
| 314 | - unsigned short height; | ||
| 315 | - unsigned char * bits; | ||
| 316 | - } bitmap[] = | ||
| 317 | - { | ||
| 318 | - { unlocked_width, unlocked_height, unlocked_bits }, | ||
| 319 | - { locked_width, locked_height, locked_bits }, | ||
| 320 | - }; | 309 | + int idx = 0; // lib3270_get_ssl_state(host) ? 1 : 0; |
| 310 | + unsigned short width; | ||
| 311 | + unsigned short height; | ||
| 312 | + unsigned char * bits; | ||
| 321 | 313 | ||
| 322 | #ifdef DEBUG | 314 | #ifdef DEBUG |
| 323 | cairo_set_source_rgb(cr,0.1,0.1,0.1); | 315 | cairo_set_source_rgb(cr,0.1,0.1,0.1); |
| @@ -330,15 +322,42 @@ void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metri | @@ -330,15 +322,42 @@ void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metri | ||
| 330 | cairo_rectangle(cr, 0, 0, rect->width, rect->height); | 322 | cairo_rectangle(cr, 0, 0, rect->width, rect->height); |
| 331 | cairo_fill(cr); | 323 | cairo_fill(cr); |
| 332 | 324 | ||
| 333 | - gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_FOREGROUND); | 325 | + switch(lib3270_get_secure(host)) |
| 326 | + { | ||
| 327 | + case LIB3270_SSL_UNSECURE: /**< No secure connection */ | ||
| 328 | + gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_FOREGROUND); | ||
| 329 | + width = unlocked_width; | ||
| 330 | + height = unlocked_height; | ||
| 331 | + bits = (unsigned char *) unlocked_bits; | ||
| 332 | + break; | ||
| 333 | + | ||
| 334 | + case LIB3270_SSL_SECURE: /**< Connection secure */ | ||
| 335 | + gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_FOREGROUND); | ||
| 336 | + width = locked_width; | ||
| 337 | + height = locked_height; | ||
| 338 | + bits = (unsigned char *) locked_bits; | ||
| 339 | + break; | ||
| 340 | + | ||
| 341 | + case LIB3270_SSL_NEGOTIATING: /**< Negotiating SSL */ | ||
| 342 | + gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_STATUS_WARNING); | ||
| 343 | + width = locked_width; | ||
| 344 | + height = locked_height; | ||
| 345 | + bits = (unsigned char *) locked_bits; | ||
| 346 | + break; | ||
| 347 | + | ||
| 348 | + default: | ||
| 349 | + return; | ||
| 350 | + | ||
| 351 | + } | ||
| 352 | + | ||
| 334 | 353 | ||
| 335 | - icon = cairo_image_surface_create_for_data( (unsigned char *) bitmap[idx].bits, | 354 | + icon = cairo_image_surface_create_for_data( bits, |
| 336 | CAIRO_FORMAT_A1, | 355 | CAIRO_FORMAT_A1, |
| 337 | - bitmap[idx].width,bitmap[idx].height, | 356 | + width,height, |
| 338 | cairo_format_stride_for_width(CAIRO_FORMAT_A1,locked_width)); | 357 | cairo_format_stride_for_width(CAIRO_FORMAT_A1,locked_width)); |
| 339 | 358 | ||
| 340 | - cairo_scale(cr, sz / ((double) bitmap[idx].width), | ||
| 341 | - sz / ((double) bitmap[idx].height)); | 359 | + cairo_scale(cr, sz / ((double) width), |
| 360 | + sz / ((double) height)); | ||
| 342 | 361 | ||
| 343 | cairo_mask_surface(cr,icon,(rect->width-sz)/2,(rect->height-sz)/2); | 362 | cairo_mask_surface(cr,icon,(rect->width-sz)/2,(rect->height-sz)/2); |
| 344 | 363 | ||
| @@ -985,6 +1004,22 @@ void v3270_stop_timer(GtkWidget *widget) | @@ -985,6 +1004,22 @@ void v3270_stop_timer(GtkWidget *widget) | ||
| 985 | 1004 | ||
| 986 | } | 1005 | } |
| 987 | 1006 | ||
| 1007 | +void v3270_update_ssl(H3270 *session, LIB3270_SSL_STATE state) | ||
| 1008 | +{ | ||
| 1009 | + v3270 * terminal = GTK_V3270(session->widget); | ||
| 1010 | + cairo_t * cr; | ||
| 1011 | + GdkRectangle * r; | ||
| 1012 | + | ||
| 1013 | + if(!terminal->surface) | ||
| 1014 | + return; | ||
| 1015 | + | ||
| 1016 | + cr = set_update_region(terminal,&r,V3270_OIA_SSL); | ||
| 1017 | + v3270_draw_ssl_status(cr,terminal->host,&terminal->metrics,terminal->color,r); | ||
| 1018 | + gtk_widget_queue_draw_area(GTK_WIDGET(terminal),r->x,r->y,r->width,r->height); | ||
| 1019 | + cairo_destroy(cr); | ||
| 1020 | + | ||
| 1021 | +} | ||
| 1022 | + | ||
| 988 | void v3270_update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on) | 1023 | void v3270_update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on) |
| 989 | { | 1024 | { |
| 990 | cairo_t *cr; | 1025 | cairo_t *cr; |
| @@ -1011,12 +1046,14 @@ void v3270_update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on) | @@ -1011,12 +1046,14 @@ void v3270_update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on) | ||
| 1011 | cairo_destroy(cr); | 1046 | cairo_destroy(cr); |
| 1012 | break; | 1047 | break; |
| 1013 | 1048 | ||
| 1049 | +/* | ||
| 1014 | case LIB3270_FLAG_SECURE: | 1050 | case LIB3270_FLAG_SECURE: |
| 1015 | cr = set_update_region(terminal,&r,V3270_OIA_SSL); | 1051 | cr = set_update_region(terminal,&r,V3270_OIA_SSL); |
| 1016 | v3270_draw_ssl_status(cr,terminal->host,&terminal->metrics,terminal->color,r); | 1052 | v3270_draw_ssl_status(cr,terminal->host,&terminal->metrics,terminal->color,r); |
| 1017 | gtk_widget_queue_draw_area(GTK_WIDGET(terminal),r->x,r->y,r->width,r->height); | 1053 | gtk_widget_queue_draw_area(GTK_WIDGET(terminal),r->x,r->y,r->width,r->height); |
| 1018 | cairo_destroy(cr); | 1054 | cairo_destroy(cr); |
| 1019 | break; | 1055 | break; |
| 1056 | +*/ | ||
| 1020 | 1057 | ||
| 1021 | case LIB3270_FLAG_TYPEAHEAD: | 1058 | case LIB3270_FLAG_TYPEAHEAD: |
| 1022 | update_text_field(terminal,on,V3270_OIA_TYPEAHEAD,"T"); | 1059 | update_text_field(terminal,on,V3270_OIA_TYPEAHEAD,"T"); |
src/pw3270/v3270/private.h
| @@ -224,6 +224,7 @@ void v3270_update_luname(GtkWidget *widget,const gchar *name); | @@ -224,6 +224,7 @@ void v3270_update_luname(GtkWidget *widget,const gchar *name); | ||
| 224 | void v3270_update_message(v3270 *widget, LIB3270_MESSAGE id); | 224 | void v3270_update_message(v3270 *widget, LIB3270_MESSAGE id); |
| 225 | void v3270_update_cursor(H3270 *session, unsigned short row, unsigned short col, unsigned char c, unsigned short attr); | 225 | void v3270_update_cursor(H3270 *session, unsigned short row, unsigned short col, unsigned char c, unsigned short attr); |
| 226 | void v3270_update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on); | 226 | void v3270_update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on); |
| 227 | +void v3270_update_ssl(H3270 *session, LIB3270_SSL_STATE state); | ||
| 227 | 228 | ||
| 228 | // Keyboard & Mouse | 229 | // Keyboard & Mouse |
| 229 | gboolean v3270_key_press_event(GtkWidget *widget, GdkEventKey *event); | 230 | gboolean v3270_key_press_event(GtkWidget *widget, GdkEventKey *event); |
src/pw3270/v3270/widget.c
| @@ -769,6 +769,7 @@ static void v3270_init(v3270 *widget) | @@ -769,6 +769,7 @@ static void v3270_init(v3270 *widget) | ||
| 769 | widget->host->changed = changed; | 769 | widget->host->changed = changed; |
| 770 | widget->host->ctlr_done = ctlr_done; | 770 | widget->host->ctlr_done = ctlr_done; |
| 771 | widget->host->message = message; | 771 | widget->host->message = message; |
| 772 | + widget->host->update_ssl = v3270_update_ssl; | ||
| 772 | 773 | ||
| 773 | // Setup input method | 774 | // Setup input method |
| 774 | widget->input_method = gtk_im_multicontext_new(); | 775 | widget->input_method = gtk_im_multicontext_new(); |