]> source.dussan.org Git - tigervnc.git/commitdiff
Log client/server clipboard capabilities
authorPierre Ossman <ossman@cendio.se>
Mon, 4 Jan 2021 12:01:55 +0000 (13:01 +0100)
committerPierre Ossman <ossman@cendio.se>
Mon, 4 Jan 2021 12:01:55 +0000 (13:01 +0100)
common/rfb/CMsgHandler.cxx
common/rfb/SMsgHandler.cxx

index 9dab5d94420061d4cf99b7a0c2a5037b413465ba..c6ab87ef1dc18b65e8f8844905af713f2d42ef85 100644 (file)
@@ -21,6 +21,7 @@
 #include <rfb/Exception.h>
 #include <rfb/LogWriter.h>
 #include <rfb/CMsgHandler.h>
+#include <rfb/clipboardTypes.h>
 #include <rfb/screenTypes.h>
 
 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);
 }
 
index 32b561e769394ae6303fa0e46b286a7281ac8ce4..972facb093bb395c60a0c5a58f4544c376a9f13e 100644 (file)
  * USA.
  */
 #include <rfb/Exception.h>
+#include <rfb/LogWriter.h>
 #include <rfb/SMsgHandler.h>
 #include <rfb/ScreenSet.h>
+#include <rfb/clipboardTypes.h>
 #include <rfb/encodings.h>
 
 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);
 }