Commit dcb8845e0e9e6a3eb87eef090863e9ce5e8ae6d3
1 parent
31eff1cb
Exists in
master
and in
1 other branch
Melhorando tratamento do indicador de SSL
Showing
3 changed files
with
56 additions
and
17 deletions
Show diff stats
@@ -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"); |
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); |
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(); |