From 3414cdc23c5d734690abb864232860cf6c05dc53 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Fri, 4 Jan 2013 16:32:59 +0000 Subject: [PATCH] Incluindo ícone extra no indicador de SSL quando a conexão não está assinada --- src/pw3270/v3270/oia.c | 59 ++++++++++++++++++++++++++++------------------------------- src/pw3270/v3270/warning.xbm | 14 ++++++++++++++ 2 files changed, 42 insertions(+), 31 deletions(-) create mode 100644 src/pw3270/v3270/warning.xbm diff --git a/src/pw3270/v3270/oia.c b/src/pw3270/v3270/oia.c index 79d6b21..30f76d3 100644 --- a/src/pw3270/v3270/oia.c +++ b/src/pw3270/v3270/oia.c @@ -53,6 +53,7 @@ static void draw_cursor_position(cairo_t *cr, GdkRectangle *rect, struct v3270_m #include "locked.xbm" #include "unlocked.xbm" #include "negotiated.xbm" + #include "warning.xbm" /*--[ Implement ]------------------------------------------------------------------------------------*/ @@ -306,15 +307,29 @@ void v3270_draw_connection(cairo_t *cr, H3270 *host, struct v3270_metrics *metri } -void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, GdkColor *color, GdkRectangle *rect) +static void draw_xbm(cairo_t *cr, GdkRectangle *rect, int width, int height, unsigned char *bits) { - cairo_surface_t * icon; - double sz = rect->width < rect->height ? rect->width : rect->height; -// int idx = 0; // lib3270_get_ssl_state(host) ? 1 : 0; - unsigned short width; - unsigned short height; - unsigned char * bits; + double sz = rect->width < rect->height ? rect->width : rect->height; + cairo_surface_t * icon = cairo_image_surface_create_for_data( + bits, + CAIRO_FORMAT_A1, + width,height, + cairo_format_stride_for_width(CAIRO_FORMAT_A1,width)); + + cairo_save(cr); + + cairo_scale(cr, sz / ((double) width), + sz / ((double) height)); + + cairo_mask_surface(cr,icon,(rect->width-sz)/2,(rect->height-sz)/2); + + cairo_surface_destroy(icon); + + cairo_restore(cr); +} +void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, GdkColor *color, GdkRectangle *rect) +{ #ifdef DEBUG cairo_set_source_rgb(cr,0.1,0.1,0.1); #else @@ -322,7 +337,6 @@ void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metri #endif cairo_translate(cr, rect->x, rect->y); - cairo_rectangle(cr, 0, 0, rect->width, rect->height); cairo_fill(cr); @@ -330,30 +344,24 @@ void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metri { case LIB3270_SSL_UNSECURE: /**< No secure connection */ gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_FOREGROUND); - width = unlocked_width; - height = unlocked_height; - bits = (unsigned char *) unlocked_bits; + draw_xbm(cr,rect,unlocked_width,unlocked_height,unlocked_bits); break; case LIB3270_SSL_NEGOTIATING: /**< Negotiating SSL */ gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_STATUS_WARNING); - width = unlocked_width; - height = unlocked_height; - bits = (unsigned char *) unlocked_bits; + draw_xbm(cr,rect,unlocked_width,unlocked_height,unlocked_bits); break; case LIB3270_SSL_NEGOTIATED: /**< Connection secure, no CA or self-signed */ + gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_STATUS_OK); + draw_xbm(cr,rect,negotiated_width,negotiated_height,negotiated_bits); gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_STATUS_WARNING); - width = negotiated_width; - height = negotiated_height; - bits = (unsigned char *) negotiated_bits; + draw_xbm(cr,rect,warning_width,warning_height,warning_bits); break; case LIB3270_SSL_SECURE: /**< Connection secure with CA check */ gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_STATUS_OK); - width = locked_width; - height = locked_height; - bits = (unsigned char *) locked_bits; + draw_xbm(cr,rect,locked_width,locked_height,locked_bits); break; default: @@ -361,17 +369,6 @@ void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metri } - icon = cairo_image_surface_create_for_data( bits, - CAIRO_FORMAT_A1, - width,height, - cairo_format_stride_for_width(CAIRO_FORMAT_A1,locked_width)); - - cairo_scale(cr, sz / ((double) width), - sz / ((double) height)); - - cairo_mask_surface(cr,icon,(rect->width-sz)/2,(rect->height-sz)/2); - - cairo_surface_destroy(icon); } diff --git a/src/pw3270/v3270/warning.xbm b/src/pw3270/v3270/warning.xbm new file mode 100644 index 0000000..596779e --- /dev/null +++ b/src/pw3270/v3270/warning.xbm @@ -0,0 +1,14 @@ +#define warning_width 32 +#define warning_height 32 +static unsigned char warning_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0xe0, 0x00, + 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0xf0, 0x01, + 0x00, 0x00, 0xf8, 0x03, 0x00, 0x00, 0xf8, 0x03, 0x00, 0x00, 0xfc, 0x07, + 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00, 0xfe, 0x0f, 0x00, 0x00, 0xfe, 0x0f, + 0x00, 0x00, 0xff, 0x1f, 0x00, 0x00, 0xff, 0x1f, 0x00, 0x80, 0xff, 0x3f, + 0x00, 0x80, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -- libgit2 0.21.2