Revision: 4798
          http://tigervnc.svn.sourceforge.net/tigervnc/?rev=4798&view=rev
Author:   ossman_
Date:     2011-11-14 15:44:11 +0000 (Mon, 14 Nov 2011)
Log Message:
-----------
Basic infrastructure to support fences.

Modified Paths:
--------------
    trunk/common/rfb/CConnection.cxx
    trunk/common/rfb/CConnection.h
    trunk/common/rfb/CMsgHandler.cxx
    trunk/common/rfb/CMsgHandler.h
    trunk/common/rfb/CMsgReaderV3.cxx
    trunk/common/rfb/CMsgReaderV3.h
    trunk/common/rfb/CMsgWriter.cxx
    trunk/common/rfb/CMsgWriter.h
    trunk/common/rfb/CMsgWriterV3.cxx
    trunk/common/rfb/CMsgWriterV3.h
    trunk/common/rfb/ConnParams.cxx
    trunk/common/rfb/ConnParams.h
    trunk/common/rfb/SConnection.cxx
    trunk/common/rfb/SConnection.h
    trunk/common/rfb/SMsgHandler.cxx
    trunk/common/rfb/SMsgHandler.h
    trunk/common/rfb/SMsgReaderV3.cxx
    trunk/common/rfb/SMsgReaderV3.h
    trunk/common/rfb/SMsgWriter.h
    trunk/common/rfb/SMsgWriterV3.cxx
    trunk/common/rfb/SMsgWriterV3.h
    trunk/common/rfb/encodings.h
    trunk/common/rfb/msgTypes.h

Added Paths:
-----------
    trunk/common/rfb/fenceTypes.h

Modified: trunk/common/rfb/CConnection.cxx
===================================================================
--- trunk/common/rfb/CConnection.cxx    2011-11-14 00:08:17 UTC (rev 4797)
+++ trunk/common/rfb/CConnection.cxx    2011-11-14 15:44:11 UTC (rev 4798)
@@ -18,6 +18,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <rfb/Exception.h>
+#include <rfb/fenceTypes.h>
 #include <rfb/CMsgReaderV3.h>
 #include <rfb/CMsgWriterV3.h>
 #include <rfb/CSecurity.h>
@@ -269,3 +270,16 @@
   state_ = RFBSTATE_NORMAL;
   vlog.debug("initialisation done");
 }
+
+void CConnection::fence(rdr::U32 flags, unsigned len, const char data[])
+{
+  CMsgHandler::fence(flags, len, data);
+
+  if (!(flags & fenceFlagRequest))
+    return;
+
+  // We cannot guarantee any synchronisation at this level
+  flags = 0;
+
+  writer()->writeFence(flags, len, data);
+}

Modified: trunk/common/rfb/CConnection.h
===================================================================
--- trunk/common/rfb/CConnection.h      2011-11-14 00:08:17 UTC (rev 4797)
+++ trunk/common/rfb/CConnection.h      2011-11-14 15:44:11 UTC (rev 4798)
@@ -137,6 +137,13 @@
     void setState(stateEnum s) { state_ = s; }
 
   private:
+    // This is a default implementation of fences that automatically
+    // responds to requests, stating no support for synchronisation.
+    // When overriding, call CMsgHandler::fence() directly in order to
+    // state correct support for fence flags.
+    virtual void fence(rdr::U32 flags, unsigned len, const char data[]);
+
+  private:
     void processVersionMsg();
     void processSecurityTypesMsg();
     void processSecurityMsg();

Modified: trunk/common/rfb/CMsgHandler.cxx
===================================================================
--- trunk/common/rfb/CMsgHandler.cxx    2011-11-14 00:08:17 UTC (rev 4797)
+++ trunk/common/rfb/CMsgHandler.cxx    2011-11-14 15:44:11 UTC (rev 4798)
@@ -1,5 +1,5 @@
 /* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
- * Copyright 2009 Pierre Ossman for Cendio AB
+ * Copyright 2009-2011 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
@@ -65,3 +65,7 @@
   cp.setName(name);
 }
 
+void CMsgHandler::fence(rdr::U32 flags, unsigned len, const char data[])
+{
+  cp.supportsFence = true;
+}

Modified: trunk/common/rfb/CMsgHandler.h
===================================================================
--- trunk/common/rfb/CMsgHandler.h      2011-11-14 00:08:17 UTC (rev 4797)
+++ trunk/common/rfb/CMsgHandler.h      2011-11-14 15:44:11 UTC (rev 4798)
@@ -1,5 +1,5 @@
 /* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
- * Copyright 2009 Pierre Ossman for Cendio AB
+ * Copyright 2009-2011 Pierre Ossman for Cendio AB
  * Copyright (C) 2011 D. R. Commander.  All Rights Reserved.
  * 
  * This is free software; you can redistribute it and/or modify
@@ -53,6 +53,7 @@
                            void* data, void* mask) = 0;
     virtual void setPixelFormat(const PixelFormat& pf);
     virtual void setName(const char* name);
+    virtual void fence(rdr::U32 flags, unsigned len, const char data[]);
     virtual void serverInit() = 0;
 
     virtual void framebufferUpdateStart() = 0;

Modified: trunk/common/rfb/CMsgReaderV3.cxx
===================================================================
--- trunk/common/rfb/CMsgReaderV3.cxx   2011-11-14 00:08:17 UTC (rev 4797)
+++ trunk/common/rfb/CMsgReaderV3.cxx   2011-11-14 15:44:11 UTC (rev 4798)
@@ -1,5 +1,5 @@
 /* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
- * Copyright 2009 Pierre Ossman for Cendio AB
+ * Copyright 2009-2011 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
@@ -60,6 +60,7 @@
     case msgTypeSetColourMapEntries: readSetColourMapEntries(); break;
     case msgTypeBell:                readBell(); break;
     case msgTypeServerCutText:       readServerCutText(); break;
+    case msgTypeServerFence:         readFence(); break;
 
     default:
       fprintf(stderr, "unknown message type %d\n", type);
@@ -144,3 +145,24 @@
   handler->setExtendedDesktopSize(x, y, w, h, layout);
 }
 
+void CMsgReaderV3::readFence()
+{
+  rdr::U32 flags;
+  rdr::U8 len;
+  char data[64];
+
+  is->skip(3);
+
+  flags = is->readU32();
+
+  len = is->readU8();
+  if (len > sizeof(data)) {
+    fprintf(stderr, "Ignoring fence with too large payload\n");
+    is->skip(len);
+    return;
+  }
+
+  is->readBytes(data, len);
+  
+  handler->fence(flags, len, data);
+}

Modified: trunk/common/rfb/CMsgReaderV3.h
===================================================================
--- trunk/common/rfb/CMsgReaderV3.h     2011-11-14 00:08:17 UTC (rev 4797)
+++ trunk/common/rfb/CMsgReaderV3.h     2011-11-14 15:44:11 UTC (rev 4798)
@@ -1,5 +1,5 @@
 /* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
- * Copyright 2009 Pierre Ossman for Cendio AB
+ * Copyright 2009-2011 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
@@ -32,6 +32,7 @@
     virtual void readFramebufferUpdate();
     virtual void readSetDesktopName(int x, int y, int w, int h);
     virtual void readExtendedDesktopSize(int x, int y, int w, int h);
+    virtual void readFence();
     int nUpdateRectsLeft;
   };
 }

Modified: trunk/common/rfb/CMsgWriter.cxx
===================================================================
--- trunk/common/rfb/CMsgWriter.cxx     2011-11-14 00:08:17 UTC (rev 4797)
+++ trunk/common/rfb/CMsgWriter.cxx     2011-11-14 15:44:11 UTC (rev 4798)
@@ -60,6 +60,7 @@
 {
   int nEncodings = 0;
   rdr::U32 encodings[encodingMax+3];
+
   if (cp->supportsLocalCursor)
     encodings[nEncodings++] = pseudoEncodingCursor;
   if (cp->supportsDesktopResize)
@@ -68,9 +69,14 @@
     encodings[nEncodings++] = pseudoEncodingExtendedDesktopSize;
   if (cp->supportsDesktopRename)
     encodings[nEncodings++] = pseudoEncodingDesktopName;
+
+  encodings[nEncodings++] = pseudoEncodingLastRect;
+  encodings[nEncodings++] = pseudoEncodingFence;
+
   if (Decoder::supported(preferredEncoding)) {
     encodings[nEncodings++] = preferredEncoding;
   }
+
   if (useCopyRect) {
     encodings[nEncodings++] = encodingCopyRect;
   }
@@ -106,7 +112,6 @@
     }
   }
 
-  encodings[nEncodings++] = pseudoEncodingLastRect;
   if (cp->customCompressLevel && cp->compressLevel >= 0 && cp->compressLevel 
<= 9)
       encodings[nEncodings++] = pseudoEncodingCompressLevel0 + 
cp->compressLevel;
   if (!cp->noJpeg && cp->qualityLevel >= 0 && cp->qualityLevel <= 9)

Modified: trunk/common/rfb/CMsgWriter.h
===================================================================
--- trunk/common/rfb/CMsgWriter.h       2011-11-14 00:08:17 UTC (rev 4797)
+++ trunk/common/rfb/CMsgWriter.h       2011-11-14 15:44:11 UTC (rev 4798)
@@ -1,4 +1,5 @@
 /* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
+ * Copyright 2009-2011 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
@@ -44,6 +45,7 @@
 
     virtual void writeSetDesktopSize(int width, int height,
                                      const ScreenSet& layout)=0;
+    virtual void writeFence(rdr::U32 flags, unsigned len, const char data[])=0;
 
     // CMsgWriter implemented methods
     virtual void writeSetPixelFormat(const PixelFormat& pf);

Modified: trunk/common/rfb/CMsgWriterV3.cxx
===================================================================
--- trunk/common/rfb/CMsgWriterV3.cxx   2011-11-14 00:08:17 UTC (rev 4797)
+++ trunk/common/rfb/CMsgWriterV3.cxx   2011-11-14 15:44:11 UTC (rev 4798)
@@ -1,4 +1,5 @@
 /* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
+ * Copyright 2009-2011 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
@@ -17,6 +18,7 @@
  */
 #include <rdr/OutStream.h>
 #include <rfb/msgTypes.h>
+#include <rfb/fenceTypes.h>
 #include <rfb/Exception.h>
 #include <rfb/ConnParams.h>
 #include <rfb/CMsgWriterV3.h>
@@ -75,3 +77,23 @@
 
   endMsg();
 }
+
+void CMsgWriterV3::writeFence(rdr::U32 flags, unsigned len, const char data[])
+{
+  if (!cp->supportsFence)
+    throw Exception("Server does not support fences");
+  if (len > 64)
+    throw Exception("Too large fence payload");
+  if ((flags & ~fenceFlagsSupported) != 0)
+    throw Exception("Unknown fence flags");
+
+  startMsg(msgTypeClientFence);
+  os->pad(3);
+
+  os->writeU32(flags);
+
+  os->writeU8(len);
+  os->writeBytes(data, len);
+
+  endMsg();
+}

Modified: trunk/common/rfb/CMsgWriterV3.h
===================================================================
--- trunk/common/rfb/CMsgWriterV3.h     2011-11-14 00:08:17 UTC (rev 4797)
+++ trunk/common/rfb/CMsgWriterV3.h     2011-11-14 15:44:11 UTC (rev 4798)
@@ -1,4 +1,5 @@
 /* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
+ * Copyright 2009-2011 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
@@ -32,6 +33,7 @@
 
     virtual void writeSetDesktopSize(int width, int height,
                                      const ScreenSet& layout);
+    virtual void writeFence(rdr::U32 flags, unsigned len, const char data[]);
   };
 }
 #endif

Modified: trunk/common/rfb/ConnParams.cxx
===================================================================
--- trunk/common/rfb/ConnParams.cxx     2011-11-14 00:08:17 UTC (rev 4797)
+++ trunk/common/rfb/ConnParams.cxx     2011-11-14 15:44:11 UTC (rev 4798)
@@ -33,7 +33,7 @@
     supportsLocalCursor(false), supportsLocalXCursor(false),
     supportsDesktopResize(false), supportsExtendedDesktopSize(false),
     supportsDesktopRename(false), supportsLastRect(false),
-    supportsSetDesktopSize(false),
+    supportsSetDesktopSize(false), supportsFence(false),
     customCompressLevel(false), compressLevel(6),
     noJpeg(false), qualityLevel(-1), fineQualityLevel(-1),
     subsampling(SUBSAMP_UNDEFINED),
@@ -125,6 +125,8 @@
       supportsDesktopRename = true;
     else if (encodings[i] == pseudoEncodingLastRect)
       supportsLastRect = true;
+    else if (encodings[i] == pseudoEncodingFence)
+      supportsFence = true;
     else if (encodings[i] >= pseudoEncodingCompressLevel0 &&
             encodings[i] <= pseudoEncodingCompressLevel9) {
       customCompressLevel = true;

Modified: trunk/common/rfb/ConnParams.h
===================================================================
--- trunk/common/rfb/ConnParams.h       2011-11-14 00:08:17 UTC (rev 4797)
+++ trunk/common/rfb/ConnParams.h       2011-11-14 15:44:11 UTC (rev 4798)
@@ -80,6 +80,7 @@
     bool supportsLastRect;
 
     bool supportsSetDesktopSize;
+    bool supportsFence;
 
     bool customCompressLevel;
     int compressLevel;

Modified: trunk/common/rfb/SConnection.cxx
===================================================================
--- trunk/common/rfb/SConnection.cxx    2011-11-14 00:08:17 UTC (rev 4797)
+++ trunk/common/rfb/SConnection.cxx    2011-11-14 15:44:11 UTC (rev 4798)
@@ -1,4 +1,5 @@
 /* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
+ * Copyright 2011 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
@@ -20,6 +21,7 @@
 #include <rfb/Exception.h>
 #include <rfb/Security.h>
 #include <rfb/msgTypes.h>
+#include <rfb/fenceTypes.h>
 #include <rfb/SMsgReaderV3.h>
 #include <rfb/SMsgWriterV3.h>
 #include <rfb/SConnection.h>
@@ -329,3 +331,14 @@
     }
   }
 }
+
+void SConnection::fence(rdr::U32 flags, unsigned len, const char data[])
+{
+  if (!(flags & fenceFlagRequest))
+    return;
+
+  // We cannot guarantee any synchronisation at this level
+  flags = 0;
+
+  writer()->writeFence(flags, len, data);
+}

Modified: trunk/common/rfb/SConnection.h
===================================================================
--- trunk/common/rfb/SConnection.h      2011-11-14 00:08:17 UTC (rev 4797)
+++ trunk/common/rfb/SConnection.h      2011-11-14 15:44:11 UTC (rev 4798)
@@ -1,4 +1,5 @@
 /* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
+ * Copyright 2011 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
@@ -106,6 +107,12 @@
     // accepts the server's default pixel format and it uses a colour map.
     virtual void setInitialColourMap();
 
+    // fence() is called when we get a fence request or response. By default
+    // it responds directly to requests (stating it doesn't support any
+    // synchronisation) and drops responses. Override to implement more proper
+    // support.
+    virtual void fence(rdr::U32 flags, unsigned len, const char data[]);
+
     // setAccessRights() allows a security package to limit the access rights
     // of a VNCSConnectionST to the server.  How the access rights are treated
     // is up to the derived class.

Modified: trunk/common/rfb/SMsgHandler.cxx
===================================================================
--- trunk/common/rfb/SMsgHandler.cxx    2011-11-14 00:08:17 UTC (rev 4797)
+++ trunk/common/rfb/SMsgHandler.cxx    2011-11-14 15:44:11 UTC (rev 4798)
@@ -1,5 +1,5 @@
 /* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
- * Copyright 2009 Pierre Ossman for Cendio AB
+ * Copyright 2009-2011 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
@@ -41,14 +41,26 @@
 
 void SMsgHandler::setEncodings(int nEncodings, rdr::S32* encodings)
 {
+  bool firstFence;
+
+  firstFence = !cp.supportsFence;
+
   cp.setEncodings(nEncodings, encodings);
+
   supportsLocalCursor();
+
+  if (cp.supportsFence && firstFence)
+    supportsFence();
 }
 
 void SMsgHandler::supportsLocalCursor()
 {
 }
 
+void SMsgHandler::supportsFence()
+{
+}
+
 void SMsgHandler::setDesktopSize(int fb_width, int fb_height,
                                  const ScreenSet& layout)
 {

Modified: trunk/common/rfb/SMsgHandler.h
===================================================================
--- trunk/common/rfb/SMsgHandler.h      2011-11-14 00:08:17 UTC (rev 4797)
+++ trunk/common/rfb/SMsgHandler.h      2011-11-14 15:44:11 UTC (rev 4798)
@@ -1,5 +1,5 @@
 /* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
- * Copyright 2009 Pierre Ossman for Cendio AB
+ * Copyright 2009-2011 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
@@ -50,6 +50,7 @@
     virtual void framebufferUpdateRequest(const Rect& r, bool incremental) = 0;
     virtual void setDesktopSize(int fb_width, int fb_height,
                                 const ScreenSet& layout) = 0;
+    virtual void fence(rdr::U32 flags, unsigned len, const char data[]) = 0;
 
     // InputHandler interface
     // The InputHandler methods will be called for the corresponding messages.
@@ -60,6 +61,11 @@
     // specially for this purpose.
     virtual void supportsLocalCursor();
 
+    // supportsFence() is called the first time we detect support for fences
+    // in the client. A fence message should be sent at this point to notify
+    // the client of server support.
+    virtual void supportsFence();
+
     ConnParams cp;
   };
 }

Modified: trunk/common/rfb/SMsgReaderV3.cxx
===================================================================
--- trunk/common/rfb/SMsgReaderV3.cxx   2011-11-14 00:08:17 UTC (rev 4797)
+++ trunk/common/rfb/SMsgReaderV3.cxx   2011-11-14 15:44:11 UTC (rev 4798)
@@ -1,5 +1,5 @@
 /* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
- * Copyright 2009 Pierre Ossman for Cendio AB
+ * Copyright 2009-2011 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
@@ -54,6 +54,7 @@
   case msgTypePointerEvent:             readPointerEvent(); break;
   case msgTypeClientCutText:            readClientCutText(); break;
   case msgTypeSetDesktopSize:           readSetDesktopSize(); break;
+  case msgTypeClientFence:              readFence(); break;
 
   default:
     fprintf(stderr, "unknown message type %d\n", msgType);
@@ -91,3 +92,24 @@
   handler->setDesktopSize(width, height, layout);
 }
 
+void SMsgReaderV3::readFence()
+{
+  rdr::U32 flags;
+  rdr::U8 len;
+  char data[64];
+
+  is->skip(3);
+
+  flags = is->readU32();
+
+  len = is->readU8();
+  if (len > sizeof(data)) {
+    fprintf(stderr, "Ignoring fence with too large payload\n");
+    is->skip(len);
+    return;
+  }
+
+  is->readBytes(data, len);
+  
+  handler->fence(flags, len, data);
+}

Modified: trunk/common/rfb/SMsgReaderV3.h
===================================================================
--- trunk/common/rfb/SMsgReaderV3.h     2011-11-14 00:08:17 UTC (rev 4797)
+++ trunk/common/rfb/SMsgReaderV3.h     2011-11-14 15:44:11 UTC (rev 4798)
@@ -1,5 +1,5 @@
 /* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
- * Copyright 2009 Pierre Ossman for Cendio AB
+ * Copyright 2009-2011 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
@@ -30,6 +30,7 @@
     virtual void readMsg();
   protected:
     virtual void readSetDesktopSize();
+    virtual void readFence();
   };
 }
 #endif

Modified: trunk/common/rfb/SMsgWriter.h
===================================================================
--- trunk/common/rfb/SMsgWriter.h       2011-11-14 00:08:17 UTC (rev 4797)
+++ trunk/common/rfb/SMsgWriter.h       2011-11-14 15:44:11 UTC (rev 4798)
@@ -1,4 +1,5 @@
 /* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
+ * Copyright 2009-2011 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
@@ -65,6 +66,9 @@
     virtual void writeBell();
     virtual void writeServerCutText(const char* str, int len);
 
+    // writeFence() sends a new fence request or response to the client.
+    virtual void writeFence(rdr::U32 flags, unsigned len, const char data[])=0;
+
     // setupCurrentEncoder() should be called before each framebuffer update,
     // prior to calling getNumRects() or writeFramebufferUpdateStart().
     void setupCurrentEncoder();

Modified: trunk/common/rfb/SMsgWriterV3.cxx
===================================================================
--- trunk/common/rfb/SMsgWriterV3.cxx   2011-11-14 00:08:17 UTC (rev 4797)
+++ trunk/common/rfb/SMsgWriterV3.cxx   2011-11-14 15:44:11 UTC (rev 4798)
@@ -1,5 +1,5 @@
 /* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
- * Copyright 2009 Pierre Ossman for Cendio AB
+ * Copyright 2009-2011 Pierre Ossman for Cendio AB
  * Copyright (C) 2011 D. R. Commander.  All Rights Reserved.
  * 
  * This is free software; you can redistribute it and/or modify
@@ -21,6 +21,7 @@
 #include <rdr/MemOutStream.h>
 #include <rfb/msgTypes.h>
 #include <rfb/screenTypes.h>
+#include <rfb/fenceTypes.h>
 #include <rfb/Exception.h>
 #include <rfb/ConnParams.h>
 #include <rfb/SMsgWriterV3.h>
@@ -61,6 +62,26 @@
   os->flush();
 }
 
+void SMsgWriterV3::writeFence(rdr::U32 flags, unsigned len, const char data[])
+{
+  if (!cp->supportsFence)
+    throw Exception("Client does not support fences");
+  if (len > 64)
+    throw Exception("Too large fence payload");
+  if ((flags & ~fenceFlagsSupported) != 0)
+    throw Exception("Unknown fence flags");
+
+  startMsg(msgTypeServerFence);
+  os->pad(3);
+
+  os->writeU32(flags);
+
+  os->writeU8(len);
+  os->writeBytes(data, len);
+
+  endMsg();
+}
+
 bool SMsgWriterV3::writeSetDesktopSize() {
   if (!cp->supportsDesktopResize) return false;
   needSetDesktopSize = true;

Modified: trunk/common/rfb/SMsgWriterV3.h
===================================================================
--- trunk/common/rfb/SMsgWriterV3.h     2011-11-14 00:08:17 UTC (rev 4797)
+++ trunk/common/rfb/SMsgWriterV3.h     2011-11-14 15:44:11 UTC (rev 4798)
@@ -1,5 +1,5 @@
 /* Copyright (C) 2002-2005 RealVNC Ltd.  All Rights Reserved.
- * Copyright 2009 Pierre Ossman for Cendio AB
+ * Copyright 2009-2011 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
@@ -35,6 +35,7 @@
     virtual void writeServerInit();
     virtual void startMsg(int type);
     virtual void endMsg();
+    virtual void writeFence(rdr::U32 flags, unsigned len, const char data[]);
     virtual bool writeSetDesktopSize();
     virtual bool writeExtendedDesktopSize();
     virtual bool writeExtendedDesktopSize(rdr::U16 reason, rdr::U16 result,

Modified: trunk/common/rfb/encodings.h
===================================================================
--- trunk/common/rfb/encodings.h        2011-11-14 00:08:17 UTC (rev 4797)
+++ trunk/common/rfb/encodings.h        2011-11-14 15:44:11 UTC (rev 4798)
@@ -36,6 +36,7 @@
   const int pseudoEncodingDesktopSize = -223;
   const int pseudoEncodingExtendedDesktopSize = -308;
   const int pseudoEncodingDesktopName = -307;
+  const int pseudoEncodingFence = -312;
 
   // TightVNC-specific
   const int pseudoEncodingLastRect = -224;

Added: trunk/common/rfb/fenceTypes.h
===================================================================
--- trunk/common/rfb/fenceTypes.h                               (rev 0)
+++ trunk/common/rfb/fenceTypes.h       2011-11-14 15:44:11 UTC (rev 4798)
@@ -0,0 +1,36 @@
+/* Copyright 2011 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+ * USA.
+ */
+#ifndef __RFB_FENCETYPES_H__
+#define __RFB_FENCETYPES_H__
+
+#include <rdr/types.h>
+
+namespace rfb {
+  const rdr::U32 fenceFlagBlockBefore = 1<<0;
+  const rdr::U32 fenceFlagBlockAfter  = 1<<1;
+  const rdr::U32 fenceFlagSyncNext    = 1<<2;
+
+  const rdr::U32 fenceFlagRequest     = 1<<31;
+
+  const rdr::U32 fenceFlagsSupported  = (fenceFlagBlockBefore |
+                                         fenceFlagBlockAfter |
+                                         fenceFlagSyncNext |
+                                         fenceFlagRequest);
+}
+
+#endif

Modified: trunk/common/rfb/msgTypes.h
===================================================================
--- trunk/common/rfb/msgTypes.h 2011-11-14 00:08:17 UTC (rev 4797)
+++ trunk/common/rfb/msgTypes.h 2011-11-14 15:44:11 UTC (rev 4798)
@@ -26,6 +26,8 @@
   const int msgTypeBell = 2;
   const int msgTypeServerCutText = 3;
 
+  const int msgTypeServerFence = 248;
+
   // client to server
 
   const int msgTypeSetPixelFormat = 0;
@@ -36,6 +38,8 @@
   const int msgTypePointerEvent = 5;
   const int msgTypeClientCutText = 6;
 
+  const int msgTypeClientFence = 248;
+
   const int msgTypeSetDesktopSize = 251;
 }
 #endif

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Tigervnc-commits mailing list
Tigervnc-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tigervnc-commits

Reply via email to