From 0f609cb666108493479310785d8e71d4aa262449 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Mon, 8 Jul 2013 13:03:04 -0700 Subject: [PATCH] Test for VNC repeater support and cairo_format_stride_for_width(). --- configure.ac | 28 ++++++++++++++++++++- src/protocols/rdp/rdp_glyph.c | 5 ++++ src/protocols/vnc/client.c | 42 ++++++++++++++++++++++++-------- src/protocols/vnc/vnc_handlers.c | 5 ++++ 4 files changed, 69 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index f0c28111..36b27b53 100644 --- a/configure.ac +++ b/configure.ac @@ -72,7 +72,8 @@ AC_SUBST(CUNIT_LIBS) # Library functions AC_FUNC_MALLOC AC_FUNC_REALLOC -AC_CHECK_FUNCS([clock_gettime gettimeofday memmove memset select strdup png_get_io_ptr nanosleep]) +AC_CHECK_FUNCS([clock_gettime gettimeofday memmove memset select strdup png_get_io_ptr \ + cairo_format_stride_for_width nanosleep]) # Typedefs AC_TYPE_SIZE_T @@ -134,6 +135,31 @@ AM_CONDITIONAL([ENABLE_VNC], [test "x${have_libvncserver}" = "xyes"]) AC_SUBST(VNC_LIBS) +# +# Repeater support within libVNCServer +# + +if test "x${have_libvncserver}" = "xyes" +then + + have_vnc_repeater=yes + AC_CHECK_MEMBERS([rfbClient.destHost, rfbClient.destPort], + [], [have_vnc_repeater=no], + [[#include ]]) + + if test "x${have_vnc_repeater}" = "xno" + then + AC_MSG_WARN([ + -------------------------------------------- + No repeater support found in libvncclient. + Support for VNC repeaters will not be built. + --------------------------------------------]) + else + AC_DEFINE([ENABLE_VNC_REPEATER]) + fi + +fi + # # FreeRDP # diff --git a/src/protocols/rdp/rdp_glyph.c b/src/protocols/rdp/rdp_glyph.c index 913d8a6b..92d9927f 100644 --- a/src/protocols/rdp/rdp_glyph.c +++ b/src/protocols/rdp/rdp_glyph.c @@ -45,6 +45,11 @@ #include "client.h" #include "rdp_glyph.h" +/* Define cairo_format_stride_for_width() if missing */ +#ifndef HAVE_CAIRO_FORMAT_STRIDE_FOR_WIDTH +#define cairo_format_stride_for_width(format, width) (width*4) +#endif + void guac_rdp_glyph_new(rdpContext* context, rdpGlyph* glyph) { int x, y, i; diff --git a/src/protocols/vnc/client.c b/src/protocols/vnc/client.c index cf0f2c96..7567d881 100644 --- a/src/protocols/vnc/client.c +++ b/src/protocols/vnc/client.c @@ -57,11 +57,30 @@ const char* GUAC_CLIENT_ARGS[] = { "password", "swap-red-blue", "color-depth", +#ifdef ENABLE_VNC_REPEATER "dest-host", "dest-port", +#endif NULL }; +enum VNC_ARGS_IDX { + + IDX_HOSTNAME, + IDX_PORT, + IDX_READ_ONLY, + IDX_ENCODINGS, + IDX_PASSWORD, + IDX_SWAP_RED_BLUE, + IDX_COLOR_DEPTH, +#ifdef ENABLE_VNC_REPEATER + IDX_DEST_HOST, + IDX_DEST_PORT, +#endif + VNC_ARGS_COUNT +}; + + char* __GUAC_CLIENT = "GUAC_CLIENT"; int guac_client_init(guac_client* client, int argc, char** argv) { @@ -78,7 +97,7 @@ int guac_client_init(guac_client* client, int argc, char** argv) { /*** PARSE ARGUMENTS ***/ - if (argc < 9) { + if (argc != VNC_ARGS_COUNT) { guac_protocol_send_error(client->socket, "Wrong argument count received."); guac_socket_flush(client->socket); return 1; @@ -89,13 +108,13 @@ int guac_client_init(guac_client* client, int argc, char** argv) { client->data = guac_client_data; /* Set read-only flag */ - read_only = (strcmp(argv[2], "true") == 0); + read_only = (strcmp(argv[IDX_READ_ONLY], "true") == 0); /* Set red/blue swap flag */ - guac_client_data->swap_red_blue = (strcmp(argv[5], "true") == 0); + guac_client_data->swap_red_blue = (strcmp(argv[IDX_SWAP_RED_BLUE], "true") == 0); /* Freed after use by libvncclient */ - guac_client_data->password = strdup(argv[4]); + guac_client_data->password = strdup(argv[IDX_PASSWORD]); /*** INIT RFB CLIENT ***/ @@ -133,16 +152,19 @@ int guac_client_init(guac_client* client, int argc, char** argv) { rfb_client->serverHost = strdup(argv[0]); rfb_client->serverPort = atoi(argv[1]); +#ifdef ENABLE_VNC_REPEATER /* Set repeater parameters if specified */ - if(argv[7][0] != '\0') - rfb_client->destHost = strdup(argv[7]); + if(argv[IDX_DEST_HOST][0] != '\0') + rfb_client->destHost = strdup(argv[IDX_DEST_HOST]); - if(argv[8][0] != '\0') - rfb_client->destPort = atoi(argv[8]); + if(argv[IDX_DEST_PORT][0] != '\0') + rfb_client->destPort = atoi(argv[IDX_DEST_PORT]); +#endif /* Set encodings if specified */ - if (argv[3][0] != '\0') - rfb_client->appData.encodingsString = guac_client_data->encodings = strdup(argv[3]); + if (argv[IDX_ENCODINGS][0] != '\0') + rfb_client->appData.encodingsString = guac_client_data->encodings + = strdup(argv[IDX_ENCODINGS]); else guac_client_data->encodings = NULL; diff --git a/src/protocols/vnc/vnc_handlers.c b/src/protocols/vnc/vnc_handlers.c index 6b593bd1..878e9a2e 100644 --- a/src/protocols/vnc/vnc_handlers.c +++ b/src/protocols/vnc/vnc_handlers.c @@ -51,6 +51,11 @@ #include "client.h" #include "convert.h" +/* Define cairo_format_stride_for_width() if missing */ +#ifndef HAVE_CAIRO_FORMAT_STRIDE_FOR_WIDTH +#define cairo_format_stride_for_width(format, width) (width*4) +#endif + void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp) { guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT);