Improved clipboard API

Change the internal clipboard API to use a request based model in
order to be prepared for more advanced clipboard transfers.
diff --git a/common/rfb/CConnection.cxx b/common/rfb/CConnection.cxx
index d6960dd..ce2741e 100644
--- a/common/rfb/CConnection.cxx
+++ b/common/rfb/CConnection.cxx
@@ -1,5 +1,5 @@
 /* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
- * Copyright 2011-2017 Pierre Ossman for Cendio AB
+ * Copyright 2011-2019 Pierre Ossman for Cendio AB
  * 
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -52,7 +52,8 @@
     formatChange(false), encodingChange(false),
     firstUpdate(true), pendingUpdate(false), continuousUpdates(false),
     forceNonincremental(true),
-    framebuffer(NULL), decoder(this)
+    framebuffer(NULL), decoder(this),
+    serverClipboard(NULL)
 {
 }
 
@@ -65,6 +66,7 @@
   reader_ = 0;
   delete writer_;
   writer_ = 0;
+  strFree(serverClipboard);
 }
 
 void CConnection::setStreams(rdr::InStream* is_, rdr::OutStream* os_)
@@ -463,6 +465,16 @@
   decoder.decodeRect(r, encoding, framebuffer);
 }
 
+void CConnection::serverCutText(const char* str)
+{
+  strFree(serverClipboard);
+  serverClipboard = NULL;
+
+  serverClipboard = strDup(str);
+
+  handleClipboardAnnounce(true);
+}
+
 void CConnection::authSuccess()
 {
 }
@@ -476,6 +488,37 @@
   assert(false);
 }
 
+void CConnection::handleClipboardRequest()
+{
+}
+
+void CConnection::handleClipboardAnnounce(bool available)
+{
+}
+
+void CConnection::handleClipboardData(const char* data)
+{
+}
+
+void CConnection::requestClipboard()
+{
+  if (serverClipboard != NULL) {
+    handleClipboardData(serverClipboard);
+    return;
+  }
+}
+
+void CConnection::announceClipboard(bool available)
+{
+  if (available)
+    handleClipboardRequest();
+}
+
+void CConnection::sendClipboardData(const char* data)
+{
+  writer()->writeClientCutText(data);
+}
+
 void CConnection::refreshFramebuffer()
 {
   forceNonincremental = true;