Index: /trunk/include/VBox/HostServices/VBoxClipboardSvc.h
===================================================================
--- /trunk/include/VBox/HostServices/VBoxClipboardSvc.h	(revision 82524)
+++ /trunk/include/VBox/HostServices/VBoxClipboardSvc.h	(revision 82525)
@@ -343,13 +343,12 @@
 #define VBOX_SHCL_GUEST_FN_DATA_WRITE             4
 
-/** Does the actual protocol handshake.
- *
- * If this message is not being sent by the guest, the host handles that
- * particular client with the legacy protocol (v0).
- *
- * @retval  VINF_SUCCESS on success.
- * @retval  VERR_INVALID_CLIENT_ID
- * @retval  VERR_WRONG_PARAMETER_COUNT
- * @retval  VERR_WRONG_PARAMETER_TYPE
+/** This is a left-over from the 6.1 dev cycle and will always fail.
+ *
+ * It used to take three 32-bit parameters, only one of which was actually used.
+ *
+ * It was replaced by VBOX_SHCL_GUEST_FN_REPORT_FEATURES and
+ * VBOX_SHCL_GUEST_FN_NEGOTIATE_CHUNK_SIZE.
+ *
+ * @retval  VERR_NOT_IMPLEMENTED
  * @since   6.1
  */
@@ -564,6 +563,24 @@
 #define VBOX_SHCL_GUEST_FN_ERROR                  27
 
+/** For negotiating a chunk size between the guest and host.
+ *
+ * Takes two 32-bit parameters both being byte counts, the first one gives the
+ * maximum chunk size the guest can handle and the second the preferred choice
+ * of the guest.  Upon return, the host will have updated both of them to
+ * reflect the maximum and default chunk sizes this client connect.  The guest
+ * may set the 2nd value to zero and let the host choose.
+ *
+ * @retval  VINF_SUCCESS on success.
+ * @retval  VERR_INVALID_CLIENT_ID
+ * @retval  VERR_WRONG_PARAMETER_COUNT
+ * @retval  VERR_WRONG_PARAMETER_TYPE
+ * @retval  VERR_INVALID_PARAMETER if the 2nd parameter is larger than the
+ *          first one
+ * @since   6.1
+ */
+#define VBOX_SHCL_GUEST_FN_NEGOTIATE_CHUNK_SIZE     28
+
 /** The last function number (used for validation/sanity).   */
-#define VBOX_SHCL_GUEST_FN_LAST                   VBOX_SHCL_GUEST_FN_ERROR
+#define VBOX_SHCL_GUEST_FN_LAST                   VBOX_SHCL_GUEST_FN_NEGOTIATE_CHUNK_SIZE
 /** @} */
 
@@ -579,6 +596,5 @@
 /** No flags set. */
 #define VBOX_SHCL_GF_NONE                         0
-/** Guest can handle context IDs (uint64_t, in paParam[0]).
- *  This is true for Guest Additions < 6.1. */
+/** The guest can handle context IDs where applicable. */
 #define VBOX_SHCL_GF_0_CONTEXT_ID                 RT_BIT_64(0)
 /** Bit that must be set in the 2nd parameter, will be cleared if the host reponds
@@ -592,4 +608,7 @@
 /** No flags set. */
 #define VBOX_SHCL_HF_NONE                         0
+/** The host can handle context IDs where applicable as well as the new
+ *  message handling functions. */
+#define VBOX_SHCL_HF_0_CONTEXT_ID                 RT_BIT_64(0)
 /** @} */
 
Index: /trunk/include/VBox/VBoxGuestLib.h
===================================================================
--- /trunk/include/VBox/VBoxGuestLib.h	(revision 82524)
+++ /trunk/include/VBox/VBoxGuestLib.h	(revision 82525)
@@ -576,43 +576,49 @@
  * @{ */
 
-#  ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
-/**
- * Structure containing context parameters for Shared Clipboard transfers.
- */
-typedef struct VBGLR3SHCLTRANSFERCMDCTX
-{
-    /** Callback table to use for all transfers. */
-    SHCLTRANSFERCALLBACKS Callbacks;
-} VBGLR3SHCLTRANSFERCMDCTX, *PVBGLR3SHCLTRANSFERCMDCTX;
-#  endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS */
-
 /**
  * The context required for either retrieving or sending a HGCM shared clipboard
  * commands from or to the host.
+ *
+ * @todo This struct could be handy if we want to implement a second
+ *       communication channel, e.g. via TCP/IP. Use a union for the HGCM stuff then.
  */
 typedef struct VBGLR3SHCLCMDCTX
 {
-    /** @todo This struct could be handy if we want to implement
-     *        a second communication channel, e.g. via TCP/IP.
-     *        Use a union for the HGCM stuff then. */
-
-    /** IN/OUT: Context ID to retrieve or to use. */
-    uint64_t                  uContextID;
-    /** IN: HGCM client ID to use for communication. */
-    uint32_t                  uClientID;
-    /** IN: Maximum chunk size (in bytes). */
-    uint32_t                  cbChunkSize;
-    /** IN: Host feature flags (of type VBOX_SHCL_HF_XXX). */
-    uint64_t                  fHostFeatures;
-    /** Flag indicating whether to use the legacy protocol (<= VBox 6.1) or not.
-     *  This is determined in VbglR3ClipboardConnectEx(). */
-    bool                      fUseLegacyProtocol;
+    /** HGCM client ID to use for communication.
+     * This is set by VbglR3ClipboardConnectEx(). */
+    uint32_t                    idClient;
+    /** This is @c false if both VBOX_SHCL_HF_0_CONTEXT_ID and
+     * VBOX_SHCL_GF_0_CONTEXT_ID are set, otherwise @c true and only the old
+     * protocol (< 6.1) should be used.
+     * This is set by VbglR3ClipboardConnectEx(). */
+    bool                        fUseLegacyProtocol;
+    /** Host feature flags (VBOX_SHCL_HF_XXX).
+     * This is set by VbglR3ClipboardConnectEx(). */
+    uint64_t                    fHostFeatures;
+    /** The guest feature flags reported to the host (VBOX_SHCL_GF_XXX).
+     * This is set by VbglR3ClipboardConnectEx().  */
+    uint64_t                    fGuestFeatures;
+#  ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
+    /** Default chunk size (in bytes).
+     * This is set by VbglR3ClipboardConnectEx(). */
+    uint32_t                    cbChunkSize;
+    /** Max chunk size (in bytes).
+     * This is set by VbglR3ClipboardConnectEx(). */
+    uint32_t                    cbMaxChunkSize;
+#  endif
+
+    /** The context ID - input or/and output depending on the operation. */
+    uint64_t                    idContext;
     /** OUT: Number of parameters retrieved.
-     * @todo r=bird: s/uNumParms/cParms/ !! */
-    uint32_t                  uNumParms;
+     * This is set by ??. */
+    uint32_t                    cParmsRecived;
+
 #  ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
-    VBGLR3SHCLTRANSFERCMDCTX  Transfers;
+    /** Callback table to use for all transfers. */
+    SHCLTRANSFERCALLBACKS       Callbacks;
 #  endif
-} VBGLR3SHCLCMDCTX, *PVBGLR3SHCLCMDCTX;
+} VBGLR3SHCLCMDCTX;
+/** Pointer to a shared clipboard context for Vbgl. */
+typedef VBGLR3SHCLCMDCTX *PVBGLR3SHCLCMDCTX;
 
 /**
@@ -680,5 +686,5 @@
 VBGLR3DECL(int)     VbglR3ClipboardReportFormats(HGCMCLIENTID idClient, uint32_t fFormats);
 
-VBGLR3DECL(int)     VbglR3ClipboardConnectEx(PVBGLR3SHCLCMDCTX pCtx);
+VBGLR3DECL(int)     VbglR3ClipboardConnectEx(PVBGLR3SHCLCMDCTX pCtx, uint64_t fGuestFeatures);
 VBGLR3DECL(int)     VbglR3ClipboardDisconnectEx(PVBGLR3SHCLCMDCTX pCtx);
 
Index: /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp	(revision 82524)
+++ /trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp	(revision 82525)
@@ -257,5 +257,5 @@
                     {
                         LogFunc(("WM_CLIPBOARDUPDATE: Reporting formats %#x\n", Formats.Formats));
-                        rc = VbglR3ClipboardReportFormats(pCtx->CmdCtx.uClientID, Formats.Formats);
+                        rc = VbglR3ClipboardReportFormats(pCtx->CmdCtx.idClient, Formats.Formats);
                     }
                 }
@@ -303,5 +303,5 @@
                     if (   RT_SUCCESS(rc)
                         && Formats.Formats != VBOX_SHCL_FMT_NONE)
-                        rc = VbglR3ClipboardReportFormats(pCtx->CmdCtx.uClientID, Formats.Formats);
+                        rc = VbglR3ClipboardReportFormats(pCtx->CmdCtx.idClient, Formats.Formats);
                 }
                 else
@@ -647,5 +647,5 @@
 
                     /* Requested clipboard format is not available, send empty data. */
-                    VbglR3ClipboardWriteData(pCtx->CmdCtx.uClientID, VBOX_SHCL_FMT_NONE, NULL, 0);
+                    VbglR3ClipboardWriteData(pCtx->CmdCtx.idClient, VBOX_SHCL_FMT_NONE, NULL, 0);
                 }
 
@@ -922,5 +922,5 @@
         rc = SharedClipboardWinCtxInit(&pCtx->Win);
         if (RT_SUCCESS(rc))
-            rc = VbglR3ClipboardConnectEx(&pCtx->CmdCtx);
+            rc = VbglR3ClipboardConnectEx(&pCtx->CmdCtx, VBOX_SHCL_GF_0_CONTEXT_ID);
         if (RT_SUCCESS(rc))
         {
@@ -1004,5 +1004,5 @@
         if (pCtx->CmdCtx.fUseLegacyProtocol)
         {
-            rc = VbglR3ClipboardGetHostMsgOld(pCtx->CmdCtx.uClientID, &uMsg, &uFormats);
+            rc = VbglR3ClipboardGetHostMsgOld(pCtx->CmdCtx.idClient, &uMsg, &uFormats);
             if (RT_FAILURE(rc))
             {
@@ -1179,6 +1179,6 @@
     /* Disconnect from the host service.
      * This will also send a VBOX_SHCL_HOST_MSG_QUIT from the host so that we can break out from our message worker. */
-    VbglR3ClipboardDisconnect(pCtx->CmdCtx.uClientID);
-    pCtx->CmdCtx.uClientID = 0;
+    VbglR3ClipboardDisconnect(pCtx->CmdCtx.idClient);
+    pCtx->CmdCtx.idClient = 0;
 
     LogFlowFuncLeaveRC(VINF_SUCCESS);
@@ -1194,5 +1194,5 @@
 
     /* Make sure that we are disconnected. */
-    Assert(pCtx->CmdCtx.uClientID == 0);
+    Assert(pCtx->CmdCtx.idClient == 0);
 
     vboxClipboardDestroy(pCtx);
Index: /trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibClipboard.cpp
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibClipboard.cpp	(revision 82524)
+++ /trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibClipboard.cpp	(revision 82525)
@@ -81,277 +81,93 @@
  *
  * @returns VBox status code.
- * @param   pCtx                Shared Clipboard command context to use for the connection.
- */
-VBGLR3DECL(int) VbglR3ClipboardConnectEx(PVBGLR3SHCLCMDCTX pCtx)
-{
-    int rc = VbglR3ClipboardConnect(&pCtx->uClientID);
-    if (RT_SUCCESS(rc))
-    {
-        VBoxShClConnect Msg;
-        RT_ZERO(Msg);
-
-        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
-                           VBOX_SHCL_GUEST_FN_CONNECT, VBOX_SHCL_CPARMS_CONNECT);
-
-        VbglHGCMParmUInt32Set(&Msg.cbChunkSize, 0);
-        VbglHGCMParmUInt32Set(&Msg.enmCompression, 0);
-        VbglHGCMParmUInt32Set(&Msg.enmChecksumType, 0);
-
-        rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
-        if (RT_SUCCESS(rc))
-        {
-            rc = VbglHGCMParmUInt32Get(&Msg.cbChunkSize, &pCtx->cbChunkSize);
-
-            /** @todo Add / handle checksum + compression type. */
-
-            if (RT_SUCCESS(rc))
+ * @param   pCtx            Command context.  This will be initialized by this
+ *                          call.
+ * @param   fGuestFeatures  The guest features supported by this client,
+ *                          VBOX_SHCL_GF_0_XXX.
+ */
+VBGLR3DECL(int) VbglR3ClipboardConnectEx(PVBGLR3SHCLCMDCTX pCtx, uint64_t fGuestFeatures)
+{
+    /*
+     * Intialize the context structure.
+     */
+    pCtx->idClient              = 0;
+    pCtx->fHostFeatures         = 0;
+    pCtx->fGuestFeatures        = 0;
+    pCtx->fUseLegacyProtocol    = true;
+    pCtx->cParmsRecived         = 0;
+    pCtx->idContext             = 0;
+#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
+    pCtx->cbChunkSize           = VBOX_SHCL_DEFAULT_MAX_CHUNK_SIZE;
+    pCtx->cbMaxChunkSize        = VMMDEV_MAX_HGCM_DATA_SIZE - _4K;
+# error todo
+#endif
+
+    /*
+     * First step is connecting to the HGCM service.
+     */
+    int rc = VbglR3ClipboardConnect(&pCtx->idClient);
+    if (RT_SUCCESS(rc))
+    {
+        /*
+         * Next is reporting our features.  If this fails, assume older host.
+         */
+        rc = VbglR3ClipboardReportFeatures(pCtx->idClient, fGuestFeatures, &pCtx->fHostFeatures);
+        if (RT_SUCCESS(rc))
+        {
+            LogRel2(("Shared Clipboard: Host features: %#RX64\n", pCtx->fHostFeatures));
+            if (   (pCtx->fHostFeatures & VBOX_SHCL_HF_0_CONTEXT_ID)
+                && (pCtx->fGuestFeatures & VBOX_SHCL_GF_0_CONTEXT_ID) )
             {
+                pCtx->fUseLegacyProtocol = false;
+
+#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
                 /*
-                 * Report features to the host.
+                 * Negotiate a chunk size (sketched, as I don't know what it is supposed to be for).
                  */
-                const uint64_t fGuestFeatures = VBOX_SHCL_GF_0_CONTEXT_ID;
-
-                rc = VbglR3ClipboardReportFeatures(pCtx->uClientID, fGuestFeatures,
-                                                   &pCtx->fHostFeatures);
+                struct
+                {
+                    VBGLIOCHGCMCALL                 Hdr;
+                    VBoxShClParmNegotiateChunkSize  Parms;
+                } Msg;
+                do
+                {
+                    VBGL_HGCM_HDR_INIT(&Msg.Hdr, pCtx->idClient, VBOX_SHCL_GUEST_FN_NEGOTIATE_CHUNK_SIZE,
+                                       VBOX_SHCL_GUEST_CPARM_NEGOTIATE_CHUNK_SIZE);
+                    Msg.Parsm.cb32MaxChunkSize = VMMDEV_MAX_HGCM_DATA_SIZE - _4K;
+                    Msg.Parsm.cb32ChunkSize    = 0;
+                    rc = VbglR3HGCMCall(&Msg.Hdr, sizeof(Msg));
+                } while (rc == VERR_INTERRUPTED);
                 if (RT_SUCCESS(rc))
-                    LogRel2(("Shared Clipboard: Host features: %#RX64\n", pCtx->fHostFeatures));
-                else
-                    LogRel(("Shared Clipboard: Warning! Feature reporing failed: %Rrc\n", rc));
-
-                pCtx->fUseLegacyProtocol = false;
+                {
+                    pCtx->cbChunkSize = RT_MIN(Msg.Parms.cb32ChunkSize, _4K);
+                    pCtx->cbMaxChunkSize = RT_MIN(Msg.Parms.cb32ChunkSize);
+                }
+# error todo
+                LogRel2(("Shared Clipboard: Client %RU32 connected (cbChunkSize=%RU32, fUseLegacyProtocol=%RTbool)\n",
+                         pCtx->idClient, pCtx->cbChunkSize, pCtx->fUseLegacyProtocol));
+#endif
             }
+            else
+            {
+                if (pCtx->fHostFeatures & VBOX_SHCL_HF_0_CONTEXT_ID)
+                    LogRel(("Shared Clipboard: Host does not expose VBOX_SHCL_HF_0_CONTEXT_ID (%RX64)\n", pCtx->fHostFeatures));
+                if (pCtx->fHostFeatures & VBOX_SHCL_HF_0_CONTEXT_ID)
+                    LogRel(("Shared Clipboard: Host does not expose VBOX_SHCL_HF_0_CONTEXT_ID (%RX64)\n", pCtx->fHostFeatures));
+
+                pCtx->fUseLegacyProtocol = true;
+            }
         }
         else
         {
-            /* If the above call fails, make sure to use some sane defaults for
-             * the old (legacy, VBox <= 6.1) protocol. */
+            AssertLogRelMsg(rc == VERR_NOT_SUPPORTED || rc == VERR_NOT_IMPLEMENTED,
+                            ("Reporting features failed: %Rrc\n", rc));
             pCtx->fUseLegacyProtocol = true;
-            pCtx->cbChunkSize        = _64K; /* Use 64KB as chunk size by default. */
-
-            rc = VINF_SUCCESS; /* Failing above is not fatal. */
-        }
-
-        LogFlowFunc(("fHostFeatures=%#RX64, cbChunkSize=%RU32\n", pCtx->fHostFeatures, pCtx->cbChunkSize));
-
-        LogRel2(("Shared Clipboard: Client %RU32 connected (cbChunkSize=%RU32, fUseLegacyProtocol=%RTbool)\n",
-                 pCtx->uClientID, pCtx->cbChunkSize, pCtx->fUseLegacyProtocol));
-    }
-
-    LogFlowFuncLeaveRC(rc);
-    return rc;
-}
-
-
-/**
- * Disconnects from the Shared Clipboard service, legacy version, do not use anymore.
- *
- * @returns VBox status code.
- * @param   idClient        The client id returned by VbglR3ClipboardConnect().
- */
-VBGLR3DECL(int) VbglR3ClipboardDisconnect(HGCMCLIENTID idClient)
-{
-    return VbglR3HGCMDisconnect(idClient);
-}
-
-
-/**
- * Disconnects from the Shared Clipboard service, extended version.
- *
- * @returns VBox status code.
- * @param   pCtx                Shared Clipboard command context to use for the connection.
- */
-VBGLR3DECL(int) VbglR3ClipboardDisconnectEx(PVBGLR3SHCLCMDCTX pCtx)
-{
-    int rc = VbglR3ClipboardDisconnect(pCtx->uClientID);
-    if (RT_SUCCESS(rc))
-    {
-        pCtx->uClientID = 0;
-    }
-
-    LogFlowFuncLeaveRC(rc);
-    return rc;
-}
-
-
-/**
- * Receives reported formats from the host.
- *
- * @returns VBox status code.
- * @param   pCtx                Shared Clipboard command context to use for the connection.
- * @param   pFormats            Where to store the received formats from the host.
- */
-VBGLR3DECL(int) VbglR3ClipboardFormatsReportRecv(PVBGLR3SHCLCMDCTX pCtx, PSHCLFORMATDATA pFormats)
-{
-    AssertPtrReturn(pCtx,     VERR_INVALID_POINTER);
-    AssertPtrReturn(pFormats, VERR_INVALID_POINTER);
-
-    VBoxShClFormatsMsg Msg;
-    RT_ZERO(Msg);
-
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, VBOX_SHCL_GUEST_FN_MSG_GET, 3);
-
-    Msg.u.v1.uContext.SetUInt64(VBOX_SHCL_HOST_MSG_FORMATS_REPORT);
-    Msg.u.v1.uFormats.SetUInt32(0);
-    Msg.u.v1.fFlags.SetUInt32(0);
-
-    int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
-    if (RT_SUCCESS(rc))
-    {
-        rc = Msg.u.v1.uContext.GetUInt64(&pCtx->uContextID);
-        if (RT_SUCCESS(rc))
-            rc = Msg.u.v1.uFormats.GetUInt32(&pFormats->Formats);
-        if (RT_SUCCESS(rc))
-            rc = Msg.u.v1.fFlags.GetUInt32(&pFormats->fFlags);
-    }
-
-    LogFlowFuncLeaveRC(rc);
-    return rc;
-}
-
-
-/**
- * Receives a host request to read clipboard data from the guest.
- *
- * @returns VBox status code.
- * @param   pCtx                Shared Clipboard command context to use for the connection.
- * @param   pDataReq            Where to store the read data request from the host.
- */
-VBGLR3DECL(int) VbglR3ClipboardReadDataRecv(PVBGLR3SHCLCMDCTX pCtx, PSHCLDATAREQ pDataReq)
-{
-    AssertPtrReturn(pCtx,     VERR_INVALID_POINTER);
-    AssertPtrReturn(pDataReq, VERR_INVALID_POINTER);
-
-    VBoxShClReadDataReqMsg Msg;
-
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
-                       VBOX_SHCL_GUEST_FN_MSG_GET, VBOX_SHCL_CPARMS_READ_DATA_REQ);
-
-    Msg.uContext.SetUInt64(VBOX_SHCL_HOST_MSG_READ_DATA);
-    Msg.fFlags.SetUInt32(0);
-    Msg.uFormat.SetUInt32(0);
-    Msg.cbSize.SetUInt32(0);
-
-    int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
-    if (RT_SUCCESS(rc))
-    {
-        rc = Msg.uContext.GetUInt64(&pCtx->uContextID);
-        if (RT_SUCCESS(rc))
-            rc = Msg.uFormat.GetUInt32(&pDataReq->uFmt);
-        if (RT_SUCCESS(rc))
-            rc = Msg.cbSize.GetUInt32(&pDataReq->cbSize);
-    }
-
-    LogFlowFuncLeaveRC(rc);
-    return rc;
-}
-
-
-/**
- * Get a host message, legacy version (which does not have VBOX_SHCL_GUEST_FN_MSG_GET). Do not use anymore.
- *
- * Note: This is the old message which still is being used for the non-URI Shared Clipboard transfers,
- *       to not break compatibility with older additions / VBox versions.
- *
- * This will block until a message becomes available.
- *
- * @returns VBox status code.
- * @param   idClient        The client id returned by VbglR3ClipboardConnect().
- * @param   pidMsg          Where to store the message id.
- * @param   pfFormats       Where to store the format(s) the message applies to.
- */
-VBGLR3DECL(int) VbglR3ClipboardGetHostMsgOld(HGCMCLIENTID idClient, uint32_t *pidMsg, uint32_t *pfFormats)
-{
-    VBoxShClGetHostMsgOld Msg;
-
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient,
-                       VBOX_SHCL_GUEST_FN_GET_HOST_MSG_OLD, VBOX_SHCL_CPARMS_GET_HOST_MSG_OLD);
-
-    VbglHGCMParmUInt32Set(&Msg.msg, 0);
-    VbglHGCMParmUInt32Set(&Msg.formats, 0);
-
-    int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
-    if (RT_SUCCESS(rc))
-    {
-        int rc2 = VbglHGCMParmUInt32Get(&Msg.msg, pidMsg);
-        if (RT_SUCCESS(rc))
-        {
-            rc2 = VbglHGCMParmUInt32Get(&Msg.formats, pfFormats);
-            if (RT_SUCCESS(rc2))
-                return rc;
-        }
-        rc = rc2;
-    }
-    *pidMsg    = UINT32_MAX - 1;
-    *pfFormats = UINT32_MAX;
-    return rc;
-}
-
-
-/**
- * Reads data from the host clipboard.
- *
- * Legacy function, do not use anymore.
- *
- * @returns VBox status code.
- * @retval  VINF_BUFFER_OVERFLOW    If there is more data available than the caller provided buffer space for.
- *
- * @param   idClient        The client id returned by VbglR3ClipboardConnect().
- * @param   fFormat         The format we're requesting the data in.
- * @param   pvData          Where to store the data.
- * @param   cbData          The size of the buffer pointed to by \a pvData.
- * @param   pcbRead         The actual size of the host clipboard data. May be larger than \a cbData.
- */
-VBGLR3DECL(int) VbglR3ClipboardReadData(HGCMCLIENTID idClient, uint32_t fFormat, void *pvData, uint32_t cbData,
-                                        uint32_t *pcbRead)
-{
-    LogFlowFuncEnter();
-
-    struct
-    {
-        VBGLIOCHGCMCALL      Hdr;
-        VBoxShClParmDataRead Parms;
-    } Msg;
-
-    VBGL_HGCM_HDR_INIT(&Msg.Hdr, idClient, VBOX_SHCL_GUEST_FN_DATA_READ, VBOX_SHCL_CPARMS_DATA_READ);
-    VbglHGCMParmUInt32Set(&Msg.Parms.f32Format,  fFormat);
-    VbglHGCMParmPtrSet(   &Msg.Parms.pData,      pvData, cbData);
-    VbglHGCMParmUInt32Set(&Msg.Parms.cb32Needed, 0);
-
-    int rc = VbglR3HGCMCall(&Msg.Hdr, sizeof(Msg));
-    if (RT_SUCCESS(rc))
-    {
-        uint32_t cbRead;
-        rc = VbglHGCMParmUInt32Get(&Msg.Parms.cb32Needed, &cbRead);
-        if (RT_SUCCESS(rc))
-        {
-            LogFlowFunc(("cbRead=%RU32\n", cbRead));
-
-            if (cbRead > cbData)
-                rc = VINF_BUFFER_OVERFLOW;
-
-            *pcbRead = cbRead;
-        }
-    }
-
-    LogFlowFuncLeaveRC(rc);
-    return rc;
-}
-
-/**
- * Reads clipboard data from the host clipboard.
- *
- * @returns VBox status code.
- * @retval  VINF_BUFFER_OVERFLOW    If there is more data available than the caller provided buffer space for.
- *
- * @param   pCtx                The command context returned by VbglR3ClipboardConnectEx().
- * @param   pData               Where to store the clipboard data read.
- * @param   pcbRead             The actual size of the host clipboard data.
- */
-VBGLR3DECL(int) VbglR3ClipboardReadDataEx(PVBGLR3SHCLCMDCTX pCtx, PSHCLDATABLOCK pData, uint32_t *pcbRead)
-{
-    AssertPtrReturn(pCtx,  VERR_INVALID_POINTER);
-    AssertPtrReturn(pData, VERR_INVALID_POINTER);
-    return VbglR3ClipboardReadData(pCtx->uClientID, pData->uFormat, pData->pvData, pData->cbData, pcbRead);
-}
+        }
+    }
+
+    LogFlowFuncLeaveRC(rc);
+    return rc;
+}
+
 
 /**
@@ -394,4 +210,219 @@
 }
 
+
+/**
+ * Disconnects from the Shared Clipboard service, legacy version, do not use anymore.
+ *
+ * @returns VBox status code.
+ * @param   idClient        The client id returned by VbglR3ClipboardConnect().
+ */
+VBGLR3DECL(int) VbglR3ClipboardDisconnect(HGCMCLIENTID idClient)
+{
+    return VbglR3HGCMDisconnect(idClient);
+}
+
+
+/**
+ * Disconnects from the Shared Clipboard service, extended version.
+ *
+ * @returns VBox status code.
+ * @param   pCtx                Shared Clipboard command context to use for the connection.
+ */
+VBGLR3DECL(int) VbglR3ClipboardDisconnectEx(PVBGLR3SHCLCMDCTX pCtx)
+{
+    int rc = VbglR3ClipboardDisconnect(pCtx->idClient);
+    if (RT_SUCCESS(rc))
+    {
+        pCtx->idClient = 0;
+    }
+
+    LogFlowFuncLeaveRC(rc);
+    return rc;
+}
+
+
+/**
+ * Receives reported formats from the host.
+ *
+ * @returns VBox status code.
+ * @param   pCtx                Shared Clipboard command context to use for the connection.
+ * @param   pFormats            Where to store the received formats from the host.
+ */
+VBGLR3DECL(int) VbglR3ClipboardFormatsReportRecv(PVBGLR3SHCLCMDCTX pCtx, PSHCLFORMATDATA pFormats)
+{
+    AssertPtrReturn(pCtx,     VERR_INVALID_POINTER);
+    AssertPtrReturn(pFormats, VERR_INVALID_POINTER);
+
+    VBoxShClFormatsMsg Msg;
+    RT_ZERO(Msg);
+
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient, VBOX_SHCL_GUEST_FN_MSG_GET, 3);
+
+    Msg.u.v1.uContext.SetUInt64(VBOX_SHCL_HOST_MSG_FORMATS_REPORT);
+    Msg.u.v1.uFormats.SetUInt32(0);
+    Msg.u.v1.fFlags.SetUInt32(0);
+
+    int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
+    if (RT_SUCCESS(rc))
+    {
+        rc = Msg.u.v1.uContext.GetUInt64(&pCtx->idContext);
+        if (RT_SUCCESS(rc))
+            rc = Msg.u.v1.uFormats.GetUInt32(&pFormats->Formats);
+        if (RT_SUCCESS(rc))
+            rc = Msg.u.v1.fFlags.GetUInt32(&pFormats->fFlags);
+    }
+
+    LogFlowFuncLeaveRC(rc);
+    return rc;
+}
+
+
+/**
+ * Receives a host request to read clipboard data from the guest.
+ *
+ * @returns VBox status code.
+ * @param   pCtx                Shared Clipboard command context to use for the connection.
+ * @param   pDataReq            Where to store the read data request from the host.
+ */
+VBGLR3DECL(int) VbglR3ClipboardReadDataRecv(PVBGLR3SHCLCMDCTX pCtx, PSHCLDATAREQ pDataReq)
+{
+    AssertPtrReturn(pCtx,     VERR_INVALID_POINTER);
+    AssertPtrReturn(pDataReq, VERR_INVALID_POINTER);
+
+    VBoxShClReadDataReqMsg Msg;
+
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
+                       VBOX_SHCL_GUEST_FN_MSG_GET, VBOX_SHCL_CPARMS_READ_DATA_REQ);
+
+    Msg.uContext.SetUInt64(VBOX_SHCL_HOST_MSG_READ_DATA);
+    Msg.fFlags.SetUInt32(0);
+    Msg.uFormat.SetUInt32(0);
+    Msg.cbSize.SetUInt32(0);
+
+    int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
+    if (RT_SUCCESS(rc))
+    {
+        rc = Msg.uContext.GetUInt64(&pCtx->idContext);
+        if (RT_SUCCESS(rc))
+            rc = Msg.uFormat.GetUInt32(&pDataReq->uFmt);
+        if (RT_SUCCESS(rc))
+            rc = Msg.cbSize.GetUInt32(&pDataReq->cbSize);
+    }
+
+    LogFlowFuncLeaveRC(rc);
+    return rc;
+}
+
+
+/**
+ * Get a host message, legacy version (which does not have VBOX_SHCL_GUEST_FN_MSG_GET). Do not use anymore.
+ *
+ * Note: This is the old message which still is being used for the non-URI Shared Clipboard transfers,
+ *       to not break compatibility with older additions / VBox versions.
+ *
+ * This will block until a message becomes available.
+ *
+ * @returns VBox status code.
+ * @param   idClient        The client id returned by VbglR3ClipboardConnect().
+ * @param   pidMsg          Where to store the message id.
+ * @param   pfFormats       Where to store the format(s) the message applies to.
+ */
+VBGLR3DECL(int) VbglR3ClipboardGetHostMsgOld(HGCMCLIENTID idClient, uint32_t *pidMsg, uint32_t *pfFormats)
+{
+    VBoxShClGetHostMsgOld Msg;
+
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient,
+                       VBOX_SHCL_GUEST_FN_GET_HOST_MSG_OLD, VBOX_SHCL_CPARMS_GET_HOST_MSG_OLD);
+
+    VbglHGCMParmUInt32Set(&Msg.msg, 0);
+    VbglHGCMParmUInt32Set(&Msg.formats, 0);
+
+    int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
+    if (RT_SUCCESS(rc))
+    {
+        int rc2 = VbglHGCMParmUInt32Get(&Msg.msg, pidMsg);
+        if (RT_SUCCESS(rc))
+        {
+            rc2 = VbglHGCMParmUInt32Get(&Msg.formats, pfFormats);
+            if (RT_SUCCESS(rc2))
+                return rc;
+        }
+        rc = rc2;
+    }
+    *pidMsg    = UINT32_MAX - 1;
+    *pfFormats = UINT32_MAX;
+    return rc;
+}
+
+
+/**
+ * Reads data from the host clipboard.
+ *
+ * Legacy function, do not use anymore.
+ *
+ * @returns VBox status code.
+ * @retval  VINF_BUFFER_OVERFLOW    If there is more data available than the caller provided buffer space for.
+ *
+ * @param   idClient        The client id returned by VbglR3ClipboardConnect().
+ * @param   fFormat         The format we're requesting the data in.
+ * @param   pvData          Where to store the data.
+ * @param   cbData          The size of the buffer pointed to by \a pvData.
+ * @param   pcbRead         The actual size of the host clipboard data. May be larger than \a cbData.
+ */
+VBGLR3DECL(int) VbglR3ClipboardReadData(HGCMCLIENTID idClient, uint32_t fFormat, void *pvData, uint32_t cbData,
+                                        uint32_t *pcbRead)
+{
+    LogFlowFuncEnter();
+
+    struct
+    {
+        VBGLIOCHGCMCALL      Hdr;
+        VBoxShClParmDataRead Parms;
+    } Msg;
+
+    VBGL_HGCM_HDR_INIT(&Msg.Hdr, idClient, VBOX_SHCL_GUEST_FN_DATA_READ, VBOX_SHCL_CPARMS_DATA_READ);
+    VbglHGCMParmUInt32Set(&Msg.Parms.f32Format,  fFormat);
+    VbglHGCMParmPtrSet(   &Msg.Parms.pData,      pvData, cbData);
+    VbglHGCMParmUInt32Set(&Msg.Parms.cb32Needed, 0);
+
+    int rc = VbglR3HGCMCall(&Msg.Hdr, sizeof(Msg));
+    if (RT_SUCCESS(rc))
+    {
+        uint32_t cbRead;
+        rc = VbglHGCMParmUInt32Get(&Msg.Parms.cb32Needed, &cbRead);
+        if (RT_SUCCESS(rc))
+        {
+            LogFlowFunc(("cbRead=%RU32\n", cbRead));
+
+            if (cbRead > cbData)
+                rc = VINF_BUFFER_OVERFLOW;
+
+            *pcbRead = cbRead;
+        }
+    }
+
+    LogFlowFuncLeaveRC(rc);
+    return rc;
+}
+
+
+/**
+ * Reads clipboard data from the host clipboard.
+ *
+ * @returns VBox status code.
+ * @retval  VINF_BUFFER_OVERFLOW    If there is more data available than the caller provided buffer space for.
+ *
+ * @param   pCtx                The command context returned by VbglR3ClipboardConnectEx().
+ * @param   pData               Where to store the clipboard data read.
+ * @param   pcbRead             The actual size of the host clipboard data.
+ */
+VBGLR3DECL(int) VbglR3ClipboardReadDataEx(PVBGLR3SHCLCMDCTX pCtx, PSHCLDATABLOCK pData, uint32_t *pcbRead)
+{
+    AssertPtrReturn(pCtx,  VERR_INVALID_POINTER);
+    AssertPtrReturn(pData, VERR_INVALID_POINTER);
+    return VbglR3ClipboardReadData(pCtx->idClient, pData->uFormat, pData->pvData, pData->cbData, pcbRead);
+}
+
+
 /**
  * Query the host features.
@@ -462,5 +493,5 @@
         HGCMFunctionParameter cParameters;
     } Msg;
-    VBGL_HGCM_HDR_INIT(&Msg.Hdr, pCtx->uClientID, VBOX_SHCL_GUEST_FN_MSG_PEEK_WAIT, 2);
+    VBGL_HGCM_HDR_INIT(&Msg.Hdr, pCtx->idClient, VBOX_SHCL_GUEST_FN_MSG_PEEK_WAIT, 2);
     VbglHGCMParmUInt64Set(&Msg.idMsg, pidRestoreCheck ? *pidRestoreCheck : 0);
     VbglHGCMParmUInt32Set(&Msg.cParameters, 0);
@@ -484,5 +515,5 @@
     if (rc == VERR_INTERRUPTED)
     {
-        VBGL_HGCM_HDR_INIT(&Msg.Hdr, pCtx->uClientID, VBOX_SHCL_GUEST_FN_CANCEL, 0);
+        VBGL_HGCM_HDR_INIT(&Msg.Hdr, pCtx->idClient, VBOX_SHCL_GUEST_FN_CANCEL, 0);
         int rc2 = VbglR3HGCMCall(&Msg.Hdr, sizeof(Msg.Hdr));
         AssertRC(rc2);
@@ -516,8 +547,8 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_ROOT_LIST_HDR_READ, VBOX_SHCL_CPARMS_ROOT_LIST_HDR_READ);
 
-    Msg.ReqParms.uContext.SetUInt64(pCtx->uContextID);
+    Msg.ReqParms.uContext.SetUInt64(pCtx->idContext);
     Msg.ReqParms.fRoots.SetUInt32(0);
 
@@ -552,8 +583,8 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_ROOT_LIST_ENTRY_READ, VBOX_SHCL_CPARMS_ROOT_LIST_ENTRY_READ);
 
-    Msg.Parms.uContext.SetUInt64(pCtx->uContextID);
+    Msg.Parms.uContext.SetUInt64(pCtx->idContext);
     Msg.Parms.fInfo.SetUInt32(pRootListEntry->fInfo);
     Msg.Parms.uIndex.SetUInt32(uIndex);
@@ -661,5 +692,5 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_MSG_GET, VBOX_SHCL_CPARMS_TRANSFER_STATUS);
 
@@ -673,5 +704,5 @@
     if (RT_SUCCESS(rc))
     {
-        rc = Msg.uContext.GetUInt64(&pCtx->uContextID); AssertRC(rc);
+        rc = Msg.uContext.GetUInt64(&pCtx->idContext); AssertRC(rc);
         if (RT_SUCCESS(rc))
             rc = Msg.enmDir.GetUInt32((uint32_t *)pEnmDir); AssertRC(rc);
@@ -708,8 +739,8 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_REPLY, VBOX_SHCL_CPARMS_REPLY_MIN + 1);
 
-    Msg.uContext.SetUInt64(pCtx->uContextID);
+    Msg.uContext.SetUInt64(pCtx->idContext);
     Msg.enmType.SetUInt32(VBOX_SHCL_REPLYMSGTYPE_TRANSFER_STATUS);
     Msg.rc.SetUInt32((uint32_t )rcTransfer); /* int vs. uint32_t */
@@ -742,5 +773,5 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_MSG_GET, VBOX_SHCL_CPARMS_ROOT_LIST_HDR_READ_REQ);
 
@@ -751,5 +782,5 @@
     if (RT_SUCCESS(rc))
     {
-        rc = Msg.ReqParms.uContext.GetUInt64(&pCtx->uContextID); AssertRC(rc);
+        rc = Msg.ReqParms.uContext.GetUInt64(&pCtx->idContext); AssertRC(rc);
         if (RT_SUCCESS(rc))
             rc = Msg.ReqParms.fRoots.GetUInt32(pfRoots); AssertRC(rc);
@@ -775,8 +806,8 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_ROOT_LIST_HDR_WRITE, VBOX_SHCL_CPARMS_ROOT_LIST_HDR_WRITE);
 
-    Msg.ReqParms.uContext.SetUInt64(pCtx->uContextID);
+    Msg.ReqParms.uContext.SetUInt64(pCtx->idContext);
     Msg.ReqParms.fRoots.SetUInt32(pRootListHdr->fRoots);
 
@@ -806,5 +837,5 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_MSG_GET, VBOX_SHCL_CPARMS_ROOT_LIST_ENTRY_READ_REQ);
 
@@ -816,5 +847,5 @@
     if (RT_SUCCESS(rc))
     {
-        rc = Msg.Parms.uContext.GetUInt64(&pCtx->uContextID); AssertRC(rc);
+        rc = Msg.Parms.uContext.GetUInt64(&pCtx->idContext); AssertRC(rc);
         if (RT_SUCCESS(rc))
             rc = Msg.Parms.fInfo.GetUInt32(pfInfo); AssertRC(rc);
@@ -843,8 +874,8 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_ROOT_LIST_ENTRY_WRITE, VBOX_SHCL_CPARMS_ROOT_LIST_ENTRY_WRITE);
 
-    Msg.Parms.uContext.SetUInt64(pCtx->uContextID);
+    Msg.Parms.uContext.SetUInt64(pCtx->idContext);
     Msg.Parms.fInfo.SetUInt32(0);
     Msg.Parms.uIndex.SetUInt32(uIndex);
@@ -878,8 +909,8 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_LIST_OPEN, VBOX_SHCL_CPARMS_LIST_OPEN);
 
-    Msg.uContext.SetUInt64(pCtx->uContextID);
+    Msg.uContext.SetUInt64(pCtx->idContext);
     Msg.fList.SetUInt32(0);
     Msg.cbFilter.SetUInt32(pOpenParms->cbFilter);
@@ -914,5 +945,5 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_MSG_GET, VBOX_SHCL_CPARMS_LIST_OPEN);
 
@@ -928,5 +959,5 @@
     if (RT_SUCCESS(rc))
     {
-        rc = Msg.uContext.GetUInt64(&pCtx->uContextID);
+        rc = Msg.uContext.GetUInt64(&pCtx->idContext);
         if (RT_SUCCESS(rc))
             rc = Msg.fList.GetUInt32(&pOpenParms->fList);
@@ -956,8 +987,8 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_REPLY, VBOX_SHCL_CPARMS_REPLY_MIN + 1);
 
-    Msg.uContext.SetUInt64(pCtx->uContextID);
+    Msg.uContext.SetUInt64(pCtx->idContext);
     Msg.enmType.SetUInt32(VBOX_SHCL_REPLYMSGTYPE_LIST_OPEN);
     Msg.rc.SetUInt32((uint32_t)rcReply); /** int vs. uint32_t */
@@ -988,5 +1019,5 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_MSG_GET, VBOX_SHCL_CPARMS_LIST_CLOSE);
 
@@ -997,5 +1028,5 @@
     if (RT_SUCCESS(rc))
     {
-        rc = Msg.uContext.GetUInt64(&pCtx->uContextID);
+        rc = Msg.uContext.GetUInt64(&pCtx->idContext);
         if (RT_SUCCESS(rc))
             rc = Msg.uHandle.GetUInt64(phList); AssertRC(rc);
@@ -1021,8 +1052,8 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_REPLY, VBOX_SHCL_CPARMS_REPLY_MIN + 1);
 
-    Msg.uContext.SetUInt64(pCtx->uContextID);
+    Msg.uContext.SetUInt64(pCtx->idContext);
     Msg.enmType.SetUInt32(VBOX_SHCL_REPLYMSGTYPE_LIST_CLOSE);
     Msg.rc.SetUInt32((uint32_t)rcReply); /** int vs. uint32_t */
@@ -1052,8 +1083,8 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_LIST_CLOSE, VBOX_SHCL_CPARMS_LIST_CLOSE);
 
-    Msg.uContext.SetUInt64(pCtx->uContextID);
+    Msg.uContext.SetUInt64(pCtx->idContext);
     Msg.uHandle.SetUInt64(hList);
 
@@ -1082,8 +1113,8 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_LIST_HDR_READ, VBOX_SHCL_CPARMS_LIST_HDR);
 
-    Msg.ReqParms.uContext.SetUInt64(pCtx->uContextID);
+    Msg.ReqParms.uContext.SetUInt64(pCtx->idContext);
     Msg.ReqParms.uHandle.SetUInt64(hList);
     Msg.ReqParms.fFlags.SetUInt32(fFlags);
@@ -1125,5 +1156,5 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_MSG_GET, VBOX_SHCL_CPARMS_LIST_HDR_READ_REQ);
 
@@ -1135,5 +1166,5 @@
     if (RT_SUCCESS(rc))
     {
-        rc = Msg.ReqParms.uContext.GetUInt64(&pCtx->uContextID);
+        rc = Msg.ReqParms.uContext.GetUInt64(&pCtx->idContext);
         if (RT_SUCCESS(rc))
             rc = Msg.ReqParms.uHandle.GetUInt64(phList);
@@ -1163,8 +1194,8 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_LIST_HDR_WRITE, VBOX_SHCL_CPARMS_LIST_HDR);
 
-    Msg.ReqParms.uContext.SetUInt64(pCtx->uContextID);
+    Msg.ReqParms.uContext.SetUInt64(pCtx->idContext);
     Msg.ReqParms.uHandle.SetUInt64(hList);
     Msg.ReqParms.fFlags.SetUInt32(0);
@@ -1198,8 +1229,8 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_LIST_ENTRY_READ, VBOX_SHCL_CPARMS_LIST_ENTRY);
 
-    Msg.ReqParms.uContext.SetUInt64(pCtx->uContextID);
+    Msg.ReqParms.uContext.SetUInt64(pCtx->idContext);
     Msg.ReqParms.uHandle.SetUInt64(hList);
     Msg.ReqParms.fInfo.SetUInt32(0);
@@ -1236,5 +1267,5 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_MSG_GET, VBOX_SHCL_CPARMS_LIST_ENTRY_READ);
 
@@ -1246,5 +1277,5 @@
     if (RT_SUCCESS(rc))
     {
-        rc = Msg.ReqParms.uContext.GetUInt64(&pCtx->uContextID);
+        rc = Msg.ReqParms.uContext.GetUInt64(&pCtx->idContext);
         if (RT_SUCCESS(rc))
             rc = Msg.ReqParms.uHandle.GetUInt64(phList); AssertRC(rc);
@@ -1274,8 +1305,8 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_LIST_ENTRY_WRITE, VBOX_SHCL_CPARMS_LIST_ENTRY);
 
-    Msg.ReqParms.uContext.SetUInt64(pCtx->uContextID);
+    Msg.ReqParms.uContext.SetUInt64(pCtx->idContext);
     Msg.ReqParms.uHandle.SetUInt64(hList);
     Msg.ReqParms.fInfo.SetUInt32(pListEntry->fInfo);
@@ -1306,5 +1337,5 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_MSG_GET, VBOX_SHCL_CPARMS_OBJ_OPEN);
 
@@ -1318,5 +1349,5 @@
     if (RT_SUCCESS(rc))
     {
-        rc = Msg.uContext.GetUInt64(&pCtx->uContextID);
+        rc = Msg.uContext.GetUInt64(&pCtx->idContext);
         if (RT_SUCCESS(rc))
             rc = Msg.cbPath.GetUInt32(&pCreateParms->cbPath);
@@ -1344,8 +1375,8 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_REPLY, VBOX_SHCL_CPARMS_REPLY_MIN + 1);
 
-    Msg.uContext.SetUInt64(pCtx->uContextID);
+    Msg.uContext.SetUInt64(pCtx->idContext);
     Msg.enmType.SetUInt32(VBOX_SHCL_REPLYMSGTYPE_OBJ_OPEN);
     Msg.rc.SetUInt32((uint32_t)rcReply); /** int vs. uint32_t */
@@ -1379,8 +1410,8 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_OBJ_OPEN, VBOX_SHCL_CPARMS_OBJ_OPEN);
 
-    Msg.uContext.SetUInt64(pCtx->uContextID);
+    Msg.uContext.SetUInt64(pCtx->idContext);
     Msg.uHandle.SetUInt64(0);
     Msg.cbPath.SetUInt32(pCreateParms->cbPath);
@@ -1413,5 +1444,5 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_MSG_GET, VBOX_SHCL_CPARMS_OBJ_CLOSE);
 
@@ -1422,5 +1453,5 @@
     if (RT_SUCCESS(rc))
     {
-        rc = Msg.uContext.GetUInt64(&pCtx->uContextID);
+        rc = Msg.uContext.GetUInt64(&pCtx->idContext);
         if (RT_SUCCESS(rc))
             rc = Msg.uHandle.GetUInt64(phObj);
@@ -1446,8 +1477,8 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_REPLY, VBOX_SHCL_CPARMS_REPLY_MIN + 1);
 
-    Msg.uContext.SetUInt64(pCtx->uContextID);
+    Msg.uContext.SetUInt64(pCtx->idContext);
     Msg.enmType.SetUInt32(VBOX_SHCL_REPLYMSGTYPE_OBJ_CLOSE);
     Msg.rc.SetUInt32((uint32_t)rcReply); /** int vs. uint32_t */
@@ -1477,8 +1508,8 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_OBJ_CLOSE, VBOX_SHCL_CPARMS_OBJ_CLOSE);
 
-    Msg.uContext.SetUInt64(pCtx->uContextID);
+    Msg.uContext.SetUInt64(pCtx->idContext);
     Msg.uHandle.SetUInt64(hObj);
 
@@ -1509,5 +1540,5 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_MSG_GET, VBOX_SHCL_CPARMS_OBJ_READ_REQ);
 
@@ -1520,5 +1551,5 @@
     if (RT_SUCCESS(rc))
     {
-        rc = Msg.ReqParms.uContext.GetUInt64(&pCtx->uContextID);
+        rc = Msg.ReqParms.uContext.GetUInt64(&pCtx->idContext);
         if (RT_SUCCESS(rc))
             rc = Msg.ReqParms.uHandle.GetUInt64(phObj);
@@ -1554,8 +1585,8 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_OBJ_READ, VBOX_SHCL_CPARMS_OBJ_READ);
 
-    Msg.uContext.SetUInt64(pCtx->uContextID);
+    Msg.uContext.SetUInt64(pCtx->idContext);
     Msg.uHandle.SetUInt64(hObj);
     Msg.cbData.SetUInt32(cbData);
@@ -1601,8 +1632,8 @@
     RT_ZERO(Msg);
 
-    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID,
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->idClient,
                        VBOX_SHCL_GUEST_FN_OBJ_WRITE, VBOX_SHCL_CPARMS_OBJ_WRITE);
 
-    Msg.uContext.SetUInt64(pCtx->uContextID);
+    Msg.uContext.SetUInt64(pCtx->idContext);
     Msg.uHandle.SetUInt64(hObj);
     Msg.pvData.SetPtr(pvData, cbData);
@@ -2282,5 +2313,5 @@
     {
         /* Report error back to the host. */
-        int rc2 = VbglR3ClipboardWriteError(pCtx->uClientID, rc);
+        int rc2 = VbglR3ClipboardWriteError(pCtx->idClient, rc);
         AssertRC(rc2);
     }
@@ -2393,5 +2424,5 @@
     if (pCtx->fUseLegacyProtocol)
     {
-        rc = VbglR3ClipboardWriteData(pCtx->uClientID, pData->uFormat, pData->pvData, pData->cbData);
+        rc = VbglR3ClipboardWriteData(pCtx->idClient, pData->uFormat, pData->pvData, pData->cbData);
     }
     else
@@ -2403,10 +2434,10 @@
         } Msg;
 
-        VBGL_HGCM_HDR_INIT(&Msg.Hdr, pCtx->uClientID, VBOX_SHCL_GUEST_FN_DATA_WRITE, VBOX_SHCL_CPARMS_DATA_WRITE);
-        Msg.Parms.id64Context.SetUInt64(pCtx->uContextID);
+        VBGL_HGCM_HDR_INIT(&Msg.Hdr, pCtx->idClient, VBOX_SHCL_GUEST_FN_DATA_WRITE, VBOX_SHCL_CPARMS_DATA_WRITE);
+        Msg.Parms.id64Context.SetUInt64(pCtx->idContext);
         Msg.Parms.f32Format.SetUInt32(pData->uFormat);
         Msg.Parms.pData.SetPtr(pData->pvData, pData->cbData);
 
-        LogFlowFunc(("CID=%RU32\n", pCtx->uContextID));
+        LogFlowFunc(("CID=%RU32\n", pCtx->idContext));
 
         rc = VbglR3HGCMCall(&Msg.Hdr, sizeof(Msg));
Index: /trunk/src/VBox/Additions/x11/VBoxClient/clipboard.cpp
===================================================================
--- /trunk/src/VBox/Additions/x11/VBoxClient/clipboard.cpp	(revision 82524)
+++ /trunk/src/VBox/Additions/x11/VBoxClient/clipboard.cpp	(revision 82525)
@@ -184,5 +184,5 @@
     LogFlowFunc(("Formats=0x%x\n", fFormats));
 
-    int rc2 = VbglR3ClipboardReportFormats(pCtx->CmdCtx.uClientID, fFormats);
+    int rc2 = VbglR3ClipboardReportFormats(pCtx->CmdCtx.idClient, fFormats);
     RT_NOREF(rc2);
     LogFlowFuncLeaveRC(rc2);
@@ -240,5 +240,5 @@
         if (RT_SUCCESS(rc))
         {
-            rc = VbglR3ClipboardConnectEx(&g_Ctx.CmdCtx);
+            rc = VbglR3ClipboardConnectEx(&g_Ctx.CmdCtx, VBOX_SHCL_GF_0_CONTEXT_ID);
             if (RT_FAILURE(rc))
                 ShClX11ThreadStop(&g_Ctx.X11);
@@ -286,8 +286,8 @@
             uint32_t uFormats;
 
-            rc = VbglR3ClipboardGetHostMsgOld(pCtx->CmdCtx.uClientID, &uMsg, &uFormats);
+            rc = VbglR3ClipboardGetHostMsgOld(pCtx->CmdCtx.idClient, &uMsg, &uFormats);
             if (RT_FAILURE(rc))
             {
-                if (rc == VERR_INTERRUPTED)
+                if (rc == VERR_INTERRUPTED) /** @todo r=bird: What on earth is the meaning of this?!?!?!?!?!?!? */
                     break;
 
Index: /trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp	(revision 82524)
+++ /trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp	(revision 82525)
@@ -293,6 +293,7 @@
 ClipboardClientQueue g_listClientsDeferred;
 
-/** Host feature mask for VBOX_SHCL_GUEST_FN_REPORT_FEATURES/VBOX_SHCL_GUEST_FN_QUERY_FEATURES. */
-static uint64_t const g_fHostFeatures0 = VBOX_SHCL_HF_NONE;
+/** Host feature mask (VBOX_SHCL_HF_0_XXX) for VBOX_SHCL_GUEST_FN_REPORT_FEATURES
+ * and VBOX_SHCL_GUEST_FN_QUERY_FEATURES. */
+static uint64_t const g_fHostFeatures0 = VBOX_SHCL_HF_0_CONTEXT_ID;
 
 
@@ -1849,28 +1850,7 @@
 
         case VBOX_SHCL_GUEST_FN_CONNECT:
-        {
-            if (cParms != VBOX_SHCL_CPARMS_CONNECT)
-            {
-                rc = VERR_INVALID_PARAMETER;
-            }
-            else if (   paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT  /* cbChunkSize */
-                     || paParms[1].type != VBOX_HGCM_SVC_PARM_32BIT  /* enmCompression */
-                     || paParms[2].type != VBOX_HGCM_SVC_PARM_32BIT) /* enmChecksumType */
-            {
-                rc = VERR_INVALID_PARAMETER;
-            }
-            else if (ShClSvcGetMode() == VBOX_SHCL_MODE_OFF)
-            {
-                rc = VERR_ACCESS_DENIED;
-            }
-            else
-            {
-                /* Report back supported chunk size to the guest. */
-                HGCMSvcSetU32(&paParms[0], _64K); /* Chunk size */ /** @todo Make chunk size dynamic. */
-
-                rc = VINF_SUCCESS;
-            }
+            LogRel(("6.1.0 beta or rc additions detected. Please upgrade!\n"));
+            rc = VERR_NOT_IMPLEMENTED;
             break;
-        }
 
         case VBOX_SHCL_GUEST_FN_REPORT_FEATURES:
