From ff929058a548fcfe17903e98cd5d0ca88e59c564 Mon Sep 17 00:00:00 2001 From: Bill Wilson Date: Fri, 3 Jun 2016 15:18:07 -0500 Subject: [PATCH] Version 2.3.7 - replace deprecated gdk function / gkrellmd error flush Use gdk_pixbuf_new_from_data() instead of deprecated gdk_pixbuf_new_from_inline(). Inline alert_inline[] needed to be --raw. When gkrellmd refused connections, the socket was not flushed and the error message might not be sent back to the client. Also, add a dialog to display the error message. --- Makefile | 2 +- server/gkrellmd.h | 4 +- server/main.c | 3 +- src/alerts.c | 124 ++++++++++++++++++++++++++++-------------- src/client.c | 12 ++++ src/gkrellm-private.h | 3 +- src/gkrellm.h | 4 +- src/pixops.c | 17 +++++- src/utils.c | 5 ++ 9 files changed, 123 insertions(+), 51 deletions(-) diff --git a/Makefile b/Makefile index 40c6b44..f00f969 100644 --- a/Makefile +++ b/Makefile @@ -90,7 +90,7 @@ BINMODE = 755 #GTOP_LIBS_D = -L$(GTOP_PREFIX)/lib -lgtop -lgtop_common -lgtop_sysdeps #export GTOP_INCLUDE GTOP_LIBS GTOP_LIBS_D -VERSION = 2.3.6-RC1 +VERSION = 2.3.7 INSTALLROOT ?= $(DESTDIR)$(PREFIX) diff --git a/server/gkrellmd.h b/server/gkrellmd.h index b98c828..5a1782b 100644 --- a/server/gkrellmd.h +++ b/server/gkrellmd.h @@ -108,8 +108,8 @@ */ #define GKRELLMD_VERSION_MAJOR 2 #define GKRELLMD_VERSION_MINOR 3 -#define GKRELLMD_VERSION_REV 6 -#define GKRELLMD_EXTRAVERSION "-RC2" +#define GKRELLMD_VERSION_REV 7 +#define GKRELLMD_EXTRAVERSION "" #define GKRELLMD_CHECK_VERSION(major,minor,rev) \ (GKRELLMD_VERSION_MAJOR > (major) || \ diff --git a/server/main.c b/server/main.c index ef8a11d..8851e13 100644 --- a/server/main.c +++ b/server/main.c @@ -1319,8 +1319,9 @@ gkrellmd_run(gint argc, gchar **argv) if (!client) { #if defined(WIN32) - closesocket(client_fd); + closesocket(client_fd); #else + shutdown(client_fd, SHUT_WR); close(client_fd); #endif continue; diff --git a/src/alerts.c b/src/alerts.c index 16b53ff..4833325 100644 --- a/src/alerts.c +++ b/src/alerts.c @@ -1527,18 +1527,31 @@ gkrellm_load_alertconfig(GkrellmAlert **ap, gchar *config_line) /* ------------------------------------------------------------------- */ -/* gdk-pixbuf-csource --static alert_inline.png */ +/* gdk-pixbuf-csource --static --raw alert_inline.png */ /* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */ +/* +| pixdata = new GdkPixbuf.Pixdata({ +| magic +| length +| pixdata_type +| rowstride +| width +| height +| pixel_data +*/ + +/* GdkPixbuf RGBA C-Source image dump */ + static const guint8 alert_inline[] = { "" /* Pixbuf magic (0x47646b50) */ "GdkP" - /* length: header (24) + pixel_data (925) */ - "\0\0\3\265" - /* pixdata_type (0x2010002) */ - "\2\1\0\2" + /* length: header (24) + pixel_data (1296) */ + "\0\0\5(" + /* pixdata_type (0x1010002) */ + "\1\1\0\2" /* rowstride (72) */ "\0\0\0H" /* width (18) */ @@ -1546,49 +1559,76 @@ static const guint8 alert_inline[] = /* height (18) */ "\0\0\0\22" /* pixel_data: */ - "\227\0\0\0\0\10\204}{\377B89\377\20\24\20\377\10\2\10\377\0\2\0\377\30" - "\24\20\3779<9\377\214\212\204\377\211\0\0\0\0\12e`T\37732*\377\202]@" - "\377\251eF\377\267g?\377\265cF\377\243eG\377\202VG\37773$\377io`\377" - "\207\0\0\0\0\14PVG\377a<*\377\257^?\377\310\211q\377\333\262\241\377" - "\222\202t\377\311\254\234\377\333\262\233\377\310\211q\377\257^?\377" - "Z=+\377\\bM\377\205\0\0\0\0\16cfS\377Z=+\377\257^?\377\320\234\203\377" - "\333\270\241\377\252\217}\377\31\25\23\3772*%\377\342\274\251\377\333" - "\270\241\377\320\234\203\377\257^?\377Z=+\377|~k\377\203\0\0\0\0\17\204" - "\206{\37773$\377\251_?\377\301\202b\377\325\253\222\377\341\255\233\377" - "aNE\377\222tb\377\0\0\0\377\310\232\211\377\333\257\233\377\325\253\222" - "\377\302{h\377\251Z?\37773$\377\203\0\0\0\0\12JAB\377xQ1\377\257[?\377" - "\320\234\203\377\325\234\203\377\333\236\205\3770#\35\377\333\236\205" - "\377\30\21\17\377aF;\377\202\325\234\203\377\4\310\222u\377\257[?\377" - "tJ1\377kik\377\202\0\0\0\0\5\20\24\20\377\235[G\377\257[?\377\317\212" - "p\377\325\215u\377\202vOA\377\11\325\215u\377vM>\377\0\0\0\377\325\213" - "q\377\317\212p\377\317\213v\377\260T8\377\235[G\377)$)\377\202\0\0\0" - "\0\20\0\2\0\377\251Z?\377\267X?\377\310q\\\377\310{c\377.\32\25\377\270" - "lW\377\316z\\\377sA6\377\0\0\0\377sA6\377\317vb\377\301mV\377\257Q?\377" - "\245R8\377\10\2\10\377\202\0\0\0\0\6\0\2\0\377\251S?\377\260T8\377\277" - "N9\377\226M9\377,\25\21\377\202\205@4\377\10\200B4\377,\25\21\377+\26" - "\20\377\277N9\377\270K9\377\252M8\377\237N8\377\10\2\10\377\202\0\0\0" - "\0\20\30\24\30\377\230Y@\377\252S8\377\267R?\377T)\34\377\200>.\377\300" - "]F\377\307[F\377\300]F\377\200<.\377\0\0\0\377\221J<\377\260L8\377\245" - "J8\377\230VG\377!(!\377\202\0\0\0\0\7""9<1\377xO@\377\245J8\377\227D" - "1\377\0\0\0\377\266S8\377\302Q?\377\203\274S?\377\6\0\0\0\377N\37\31" - "\377\252F8\377\236F2\377~N@\377cic\377\202\0\0\0\0\12\234\216\224\377" - "73$\377\237G8\377\22\10\6\377\0\0\0\377N\40\26\377\242?1\377\257I2\377" - "\266G8\377N\40\26\377\202\0\0\0\377\3F\37\26\377\231D9\37773$\377\204" - "\0\0\0\0\5ii`\377T3#\377\231E2\377\237G8\377\252F8\377\203\251B2\377" - "\6\252F8\377\236@2\377\231@2\377\231E2\377N6#\377{\204q\377\205\0\0\0" - "\0\4baY\377T3#\377\223D2\377\231E2\377\202\236@2\377\6\237<6\377\231" - "E2\377\231@2\377\223@2\377T3#\377ii`\377\207\0\0\0\0\4t}j\377-4#\377" - "~N@\377\216K9\377\202\223@2\377\4\222K@\377xO@\37773$\377{\204q\377\212" - "\0\0\0\0\6kik\377!(!\377\10\2\10\377\0\2\0\377)$)\377kik\377\230\0\0" - "\0\0"}; + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\204}{\377B89\377\20" + "\24\20\377\10\2\10\377\0\2\0\377\30\24\20\3779<9\377\214\212\204\377" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0e`T\37732*\377\202]@\377\251eF\377\267g\77\377\265cF\377\243eG\377" + "\202VG\37773$\377io`\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0PVG\377a<*\377\257^\77\377\310\211q\377\333\262\241\377\222" + "\202t\377\311\254\234\377\333\262\233\377\310\211q\377\257^\77\377Z=" + "+\377\\bM\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0cfS\377Z=+\377\257" + "^\77\377\320\234\203\377\333\270\241\377\252\217}\377\31\25\23\3772*" + "%\377\342\274\251\377\333\270\241\377\320\234\203\377\257^\77\377Z=+" + "\377|~k\377\0\0\0\0\0\0\0\0\0\0\0\0\204\206{\37773$\377\251_\77\377\301" + "\202b\377\325\253\222\377\341\255\233\377aNE\377\222tb\377\0\0\0\377" + "\310\232\211\377\333\257\233\377\325\253\222\377\302{h\377\251Z\77\377" + "73$\377\0\0\0\0\0\0\0\0\0\0\0\0JAB\377xQ1\377\257[\77\377\320\234\203" + "\377\325\234\203\377\333\236\205\3770#\35\377\333\236\205\377\30\21\17" + "\377aF;\377\325\234\203\377\325\234\203\377\310\222u\377\257[\77\377" + "tJ1\377kik\377\0\0\0\0\0\0\0\0\20\24\20\377\235[G\377\257[\77\377\317" + "\212p\377\325\215u\377vOA\377vOA\377\325\215u\377vM>\377\0\0\0\377\325" + "\213q\377\317\212p\377\317\213v\377\260T8\377\235[G\377)$)\377\0\0\0" + "\0\0\0\0\0\0\2\0\377\251Z\77\377\267X\77\377\310q\\\377\310{c\377.\32" + "\25\377\270lW\377\316z\\\377sA6\377\0\0\0\377sA6\377\317vb\377\301mV" + "\377\257Q\77\377\245R8\377\10\2\10\377\0\0\0\0\0\0\0\0\0\2\0\377\251" + "S\77\377\260T8\377\277N9\377\226M9\377,\25\21\377\205@4\377\205@4\377" + "\200B4\377,\25\21\377+\26\20\377\277N9\377\270K9\377\252M8\377\237N8" + "\377\10\2\10\377\0\0\0\0\0\0\0\0\30\24\30\377\230Y@\377\252S8\377\267" + "R\77\377T)\34\377\200>.\377\300]F\377\307[F\377\300]F\377\200<.\377\0" + "\0\0\377\221J<\377\260L8\377\245J8\377\230VG\377!(!\377\0\0\0\0\0\0\0" + "\0""9<1\377xO@\377\245J8\377\227D1\377\0\0\0\377\266S8\377\302Q\77\377" + "\274S\77\377\274S\77\377\274S\77\377\0\0\0\377N\37\31\377\252F8\377\236" + "F2\377~N@\377cic\377\0\0\0\0\0\0\0\0\234\216\224\37773$\377\237G8\377" + "\22\10\6\377\0\0\0\377N\40\26\377\242\77""1\377\257I2\377\266G8\377N" + "\40\26\377\0\0\0\377\0\0\0\377F\37\26\377\231D9\37773$\377\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0ii`\377T3#\377\231E2\377\237G8\377\252F8\377\251" + "B2\377\251B2\377\251B2\377\252F8\377\236@2\377\231@2\377\231E2\377N6" + "#\377{\204q\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0baY\377T3#\377" + "\223D2\377\231E2\377\236@2\377\236@2\377\237<6\377\231E2\377\231@2\377" + "\223@2\377T3#\377ii`\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0t}j\377-4#\377~N@\377\216K9\377\223@2\377\223@2\377\222K" + "@\377xO@\37773$\377{\204q\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0kik\377!(!\377\10\2\10\377\0" + "\2\0\377)$)\377kik\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0"}; + static GdkPixbuf *alert_pixbuf; GdkPixbuf * gkrellm_alert_pixbuf(void) { + guint8 *data = (guint8 *) alert_inline; + guint width, height, stride; + gpointer pixels; + if (!alert_pixbuf) - alert_pixbuf = gdk_pixbuf_new_from_inline(-1, alert_inline, - FALSE, NULL); + { +// alert_pixbuf = gdk_pixbuf_new_from_inline(-1, alert_inline, +// FALSE, NULL); + stride = big_endian_uint(data + 12); + width = big_endian_uint(data + 16); + height = big_endian_uint(data + 20); + + pixels = g_memdup((gconstpointer)(data + 24), height * stride); + + alert_pixbuf = gdk_pixbuf_new_from_data(pixels, + GDK_COLORSPACE_RGB, TRUE, 8, width, height, stride, + (GdkPixbufDestroyNotify) g_free, pixels); + } return alert_pixbuf; } diff --git a/src/client.c b/src/client.c index 00374d0..e644eba 100644 --- a/src/client.c +++ b/src/client.c @@ -1418,6 +1418,18 @@ client_monitor_setup(gchar *line) static void client_server_error(gchar *line) { + GtkWidget *dlg; + + dlg = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, + "GKrellM - connection refused from gkrellmd at %s:%d\n" + "\t%s\n\n" + "Edit gkrellmd.conf on %s to set:\n" + "\tmax-clents, allow-host, etc\n", + _GK.server, _GK.server_port, line, _GK.server); + gtk_dialog_run(GTK_DIALOG(dlg)); + gtk_widget_destroy(dlg); + fprintf(stderr, "gkrellmd error: %s\n", line); exit(0); } diff --git a/src/gkrellm-private.h b/src/gkrellm-private.h index ac48379..6821837 100644 --- a/src/gkrellm-private.h +++ b/src/gkrellm-private.h @@ -513,5 +513,4 @@ enum GkrellmConnectState gkrellm_client_server_connect_state(void); void gkrellm_client_mode_connect_thread(void); gint gkrellm_client_server_get_net_timer(void); - - +guint big_endian_uint(guint8 *b); diff --git a/src/gkrellm.h b/src/gkrellm.h index b316e05..3489c3f 100644 --- a/src/gkrellm.h +++ b/src/gkrellm.h @@ -108,8 +108,8 @@ */ #define GKRELLM_VERSION_MAJOR 2 #define GKRELLM_VERSION_MINOR 3 -#define GKRELLM_VERSION_REV 6 -#define GKRELLM_EXTRAVERSION "-RC2" +#define GKRELLM_VERSION_REV 7 +#define GKRELLM_EXTRAVERSION "" #define GKRELLM_CHECK_VERSION(major,minor,rev) \ (GKRELLM_VERSION_MAJOR > (major) || \ diff --git a/src/pixops.c b/src/pixops.c index e765d06..1659c38 100644 --- a/src/pixops.c +++ b/src/pixops.c @@ -672,8 +672,23 @@ gkrellm_piximage_new_from_inline(const guint8 *data, gboolean copy_pixels) { GkrellmPiximage *piximage; GdkPixbuf *pixbuf; + guint width, height, stride; + guint8 *d = (guint8 *) data; + gpointer pixels; + + +// pixbuf = gdk_pixbuf_new_from_inline(-1, data, copy_pixels, NULL); + stride = big_endian_uint(d + 12); + width = big_endian_uint(d + 16); + height = big_endian_uint(d + 20); + + pixels = g_memdup((gconstpointer)(d + 24), height * stride); + + pixbuf = gdk_pixbuf_new_from_data(pixels, + GDK_COLORSPACE_RGB, TRUE, 8, width, height, stride, + (GdkPixbufDestroyNotify) g_free, pixels); + - pixbuf = gdk_pixbuf_new_from_inline(-1, data, copy_pixels, NULL); if (!pixbuf) return NULL; piximage = g_new0(GkrellmPiximage, 1); diff --git a/src/utils.c b/src/utils.c index 175158a..f6162e9 100644 --- a/src/utils.c +++ b/src/utils.c @@ -527,3 +527,8 @@ gkrellm_locale_dup_string(gchar **dst_utf8, gchar *src, gchar **dst_locale) return TRUE; } +guint +big_endian_uint(guint8 *b) + { + return ((b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3]); + }