]> source.dussan.org Git - tigervnc.git/commitdiff
Initial implementation of continuous updates in the server code. This code does not...
authorConstantin Kaplinsky <const@tightvnc.com>
Thu, 5 Apr 2007 08:43:25 +0000 (08:43 +0000)
committerConstantin Kaplinsky <const@tightvnc.com>
Thu, 5 Apr 2007 08:43:25 +0000 (08:43 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2251 3789f03b-4d11-0410-bbf8-ca57d06f2519

common/rfb/SConnection.cxx
common/rfb/SMsgHandler.cxx
common/rfb/SMsgHandler.h
common/rfb/SMsgReader.cxx
common/rfb/SMsgReader.h
common/rfb/SMsgReaderV3.cxx
common/rfb/VNCSConnectionST.cxx
common/rfb/VNCSConnectionST.h
common/rfb/msgTypes.h

index 9e47900ea912f2c1161f5152e5ca2260bb751979..bede90e4786d98b82b87e74792009bc030561a91 100644 (file)
@@ -19,6 +19,7 @@
 #include <string.h>
 #include <rfb/Exception.h>
 #include <rfb/secTypes.h>
+#include <rfb/msgTypes.h>
 #include <rfb/CapsList.h>
 #include <rfb/SMsgReaderV3.h>
 #include <rfb/SMsgWriterV3.h>
@@ -422,14 +423,50 @@ void SConnection::clientInit(bool shared)
 // FIXME: Move sendInteractionCaps() to a class derived from SMsgWriterV3?
 void SConnection::sendInteractionCaps()
 {
+  //
   // Advertise support for non-standard server-to-client messages
-  // (this version has nothing to advertise).
+  //
+
   CapsList scaps;
 
+  // File transfer:
+  /* FIXME: File transfers are not finished yet: 
+  scaps.addTightExt(msgTypeFileListData,            "FTS_LSDT");
+  scaps.addTightExt(msgTypeFileDownloadData,        "FTS_DNDT");
+  scaps.addTightExt(msgTypeFileUploadCancel,        "FTS_UPCN");
+  scaps.addTightExt(msgTypeFileDownloadFailed,      "FTS_DNFL");
+  scaps.addTightExt(msgTypeFileDirSizeData,         "FTS_DSDT");
+  scaps.addTightExt(msgTypeFileLastRequestFailed,   "FTS_RQFL");
+  */
+
+  // Continuous updates:
+  /* FIXME: EndOfContinuousUpdates message is not supported yet:
+  scaps.addTightExt(msgTypeEndOfContinuousUpdates,  "CUS_EOCU");
+  */
+
+  //
   // Advertise support for non-standard client-to-server messages
-  // (this version has nothing to advertise).
+  //
+
   CapsList ccaps;
 
+  // File transfer:
+  /* FIXME: File transfers are not finished yet: 
+  ccaps.addTightExt(msgTypeFileListRequest,         "FTC_LSRQ");
+  ccaps.addTightExt(msgTypeFileDownloadRequest,     "FTC_DNRQ");
+  ccaps.addTightExt(msgTypeFileUploadRequest,       "FTC_UPRQ");
+  ccaps.addTightExt(msgTypeFileUploadRequest,       "FTC_UPDT");
+  ccaps.addTightExt(msgTypeFileDownloadCancel,      "FTC_DNCN");
+  ccaps.addTightExt(msgTypeFileUploadFailed,        "FTC_UPFL");
+  ccaps.addTightExt(msgTypeFileCreateDirRequest,    "FTC_FCDR");
+  ccaps.addTightExt(msgTypeFileDirSizeRequest,      "FTC_DSRQ");
+  ccaps.addTightExt(msgTypeFileRenameRequest,       "FTC_RNRQ");
+  ccaps.addTightExt(msgTypeFileDeleteRequest,       "FTC_RMRQ");
+  */
+
+  // Continuous updates:
+  ccaps.addTightExt(msgTypeEnableContinuousUpdates, "CUC_ENCU");
+
   // Advertise all supported encoding types (except raw encoding).
   CapsList ecaps;
 
index ccc97ad00855ade5e6eaaec5c86fe5b04928fd69..f18a0489530c6b36f857e92d89a4ead158743eaf 100644 (file)
@@ -50,3 +50,11 @@ void SMsgHandler::framebufferUpdateRequest(const Rect& r, bool incremental)
 void SMsgHandler::supportsLocalCursor()
 {
 }
+
+void SMsgHandler::enableContinuousUpdates(const Rect& r)
+{
+}
+
+void SMsgHandler::disableContinuousUpdates()
+{
+}
index cf3377d52fa297a530595d66d301038a3f63d8ea..ff7424656885553caa1cd15507104c9a80af0c11 100644 (file)
@@ -47,6 +47,9 @@ namespace rfb {
     virtual void setEncodings(int nEncodings, rdr::U32* encodings);
     virtual void framebufferUpdateRequest(const Rect& r, bool incremental);
 
+    virtual void enableContinuousUpdates(const Rect& r);
+    virtual void disableContinuousUpdates();
+
     // InputHandler interface
     // The InputHandler methods will be called for the corresponding messages.
 
index f89e0f4f4714ce6e926b6d259dfbe7549f610481..0e57ea76bbffb1e5854211c2a664c9784043ba80 100644 (file)
@@ -95,3 +95,18 @@ void SMsgReader::readClientCutText()
   is->readBytes(ca.buf, len);
   handler->clientCutText(ca.buf, len);
 }
+
+void SMsgReader::readEnableContinuousUpdates()
+{
+  bool enable = is->readU8();
+  int x = is->readU16();
+  int y = is->readU16();
+  int w = is->readU16();
+  int h = is->readU16();
+  if (enable) {
+    handler->enableContinuousUpdates(Rect(x, y, x+w, y+h));
+  } else {
+    handler->disableContinuousUpdates();
+  }
+}
+
index e6e40448c3f57d93242abdbb0346abd037f83706..958c03a72a36fb7509f70c065d4c906fa1a586c3 100644 (file)
@@ -47,6 +47,9 @@ namespace rfb {
     virtual void readPointerEvent();
     virtual void readClientCutText();
 
+    // Read TightVNC-specific protocol messages.
+    virtual void readEnableContinuousUpdates();
+
     SMsgReader(SMsgHandler* handler, rdr::InStream* is);
 
     SMsgHandler* handler;
index be01b5db1351cdafe6ec643290a150d419fa055e..e9b020bb1bb614f8aa21d69765438fdd2f64270f 100644 (file)
@@ -61,6 +61,8 @@ void SMsgReaderV3::readMsg()
   case msgTypeFileRenameRequest:
   case msgTypeFileDeleteRequest:        handler->processFTMsg(msgType); break;
 
+  case msgTypeEnableContinuousUpdates:  readEnableContinuousUpdates(); break;
+
   default:
     fprintf(stderr, "unknown message type %d\n", msgType);
     throw Exception("unknown message type");
index fe60e431da0d2113d0b188f4ac3acf1e9c4f09a5..bd067be212bbc4660f8e5600a6c3e094362ba724 100644 (file)
@@ -35,6 +35,7 @@ VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s,
   : SConnection(server_->securityFactory, reverse), sock(s), server(server_),
     updates(false), image_getter(server->useEconomicTranslate),
     drawRenderedCursor(false), removeRenderedCursor(false),
+    autoUpdatesActive(false),
     pointerEventTime(0), accessRights(AccessDefault),
     startTime(time(0)), m_pFileTransfer(0)
 {
@@ -480,6 +481,35 @@ void VNCSConnectionST::framebufferUpdateRequest(const Rect& r,bool incremental)
   writeFramebufferUpdate();
 }
 
+void VNCSConnectionST::enableContinuousUpdates(const Rect& r)
+{
+  // TightVNC-specific EnableContinuousUpdates message is very much like
+  // incremental FramebufferUpdateRequest. So here we copy some code from
+  // VNCSConnectionST::framebufferUpdateRequest().
+
+  if (!(accessRights & AccessView)) return;
+
+  SConnection::framebufferUpdateRequest(r, true);
+
+  autoUpdatesActive = true;
+  autoUpdatedRect = r;
+
+  Region reqRgn(autoUpdatedRect);
+  requested.assign_union(reqRgn);
+
+  writeFramebufferUpdate();
+}
+
+void VNCSConnectionST::disableContinuousUpdates()
+{
+  autoUpdatesActive = false;
+  autoUpdatedRect.clear();
+
+  writeFramebufferUpdate();
+
+  // FIXME: Send EndOfContinuousUpdates message.
+}
+
 void VNCSConnectionST::setInitialColourMap()
 {
   setColourMapEntries(0, 0);
@@ -615,6 +645,15 @@ void VNCSConnectionST::writeFramebufferUpdate()
     if (drawRenderedCursor)
       writeRenderedCursorRect();
     writer()->writeFramebufferUpdateEnd();
+    resetRequestedRegion();
+  }
+}
+
+void VNCSConnectionST::resetRequestedRegion()
+{
+  if (autoUpdatesActive) {
+    requested.reset(autoUpdatedRect);
+  } else {
     requested.clear();
   }
 }
index a04296d3b7a804401282c344c07b64809334b8be..7fe2e323ac88ac3ce01cb9d78e81a8448b73d620 100644 (file)
@@ -129,6 +129,9 @@ namespace rfb {
     virtual void setInitialColourMap();
     virtual void supportsLocalCursor();
 
+    virtual void enableContinuousUpdates(const Rect& r);
+    virtual void disableContinuousUpdates();
+
     // setAccessRights() allows a security package to limit the access rights
     // of a VNCSConnectioST to the server.  These access rights are applied
     // such that the actual rights granted are the minimum of the server's
@@ -150,6 +153,8 @@ namespace rfb {
     void setCursor();
     void setSocketTimeouts();
 
+    void resetRequestedRegion();
+
     network::Socket* sock;
     CharArray peerEndpoint;
     VNCServerST* server;
@@ -159,6 +164,9 @@ namespace rfb {
     bool drawRenderedCursor, removeRenderedCursor;
     Rect renderedCursorRect;
 
+    bool autoUpdatesActive;       // continuous updates enabled
+    Rect autoUpdatedRect;         // continuously updated area
+
     std::set<rdr::U32> pressedKeys;
 
     time_t lastEventTime;
index f6f8d5cf3e9dc1d9fa9e7a5e2244bf6c8210b35e..ec26adc7507f8c1cb41bedd6bb5148c21d455f2e 100644 (file)
@@ -33,6 +33,8 @@ namespace rfb {
   const int msgTypeFileDirSizeData = 134;
   const int msgTypeFileLastRequestFailed = 135;
 
+  const int msgTypeEndOfContinuousUpdates = 150;
+
   // client to server
 
   const int msgTypeSetPixelFormat = 0;
@@ -53,5 +55,7 @@ namespace rfb {
   const int msgTypeFileDirSizeRequest = 137;
   const int    msgTypeFileRenameRequest = 138;
   const int msgTypeFileDeleteRequest = 139;
+
+  const int msgTypeEnableContinuousUpdates = 150;
 }
 #endif