From 3a7fd223a2ea05f8781c6d3c3894ad33ef35b354 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Mon, 4 Jan 2021 13:01:55 +0100 Subject: [PATCH] Log client/server clipboard capabilities --- common/rfb/CMsgHandler.cxx | 41 +++++++++++++++++++++++++++++++++++ common/rfb/SMsgHandler.cxx | 44 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) diff --git a/common/rfb/CMsgHandler.cxx b/common/rfb/CMsgHandler.cxx index 9dab5d94..c6ab87ef 100644 --- a/common/rfb/CMsgHandler.cxx +++ b/common/rfb/CMsgHandler.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include static rfb::LogWriter vlog("CMsgHandler"); @@ -101,6 +102,46 @@ void CMsgHandler::setLEDState(unsigned int state) void CMsgHandler::handleClipboardCaps(rdr::U32 flags, const rdr::U32* lengths) { + int i; + + vlog.debug("Got server clipboard capabilities:"); + for (i = 0;i < 16;i++) { + if (flags & (1 << i)) { + const char *type; + + switch (1 << i) { + case clipboardUTF8: + type = "Plain text"; + break; + case clipboardRTF: + type = "Rich text"; + break; + case clipboardHTML: + type = "HTML"; + break; + case clipboardDIB: + type = "Images"; + break; + case clipboardFiles: + type = "Files"; + break; + default: + vlog.debug(" Unknown format 0x%x", 1 << i); + continue; + } + + if (lengths[i] == 0) + vlog.debug(" %s (only notify)", type); + else { + char bytes[1024]; + + iecPrefix(lengths[i], "B", bytes, sizeof(bytes)); + vlog.debug(" %s (automatically send up to %s)", + type, bytes); + } + } + } + server.setClipboardCaps(flags, lengths); } diff --git a/common/rfb/SMsgHandler.cxx b/common/rfb/SMsgHandler.cxx index 32b561e7..972facb0 100644 --- a/common/rfb/SMsgHandler.cxx +++ b/common/rfb/SMsgHandler.cxx @@ -17,12 +17,16 @@ * USA. */ #include +#include #include #include +#include #include using namespace rfb; +static LogWriter vlog("SMsgHandler"); + SMsgHandler::SMsgHandler() { } @@ -66,6 +70,46 @@ void SMsgHandler::setEncodings(int nEncodings, const rdr::S32* encodings) void SMsgHandler::handleClipboardCaps(rdr::U32 flags, const rdr::U32* lengths) { + int i; + + vlog.debug("Got client clipboard capabilities:"); + for (i = 0;i < 16;i++) { + if (flags & (1 << i)) { + const char *type; + + switch (1 << i) { + case clipboardUTF8: + type = "Plain text"; + break; + case clipboardRTF: + type = "Rich text"; + break; + case clipboardHTML: + type = "HTML"; + break; + case clipboardDIB: + type = "Images"; + break; + case clipboardFiles: + type = "Files"; + break; + default: + vlog.debug(" Unknown format 0x%x", 1 << i); + continue; + } + + if (lengths[i] == 0) + vlog.debug(" %s (only notify)", type); + else { + char bytes[1024]; + + iecPrefix(lengths[i], "B", bytes, sizeof(bytes)); + vlog.debug(" %s (automatically send up to %s)", + type, bytes); + } + } + } + client.setClipboardCaps(flags, lengths); } -- 2.39.5