Index: trunk/include/VBox/HostServices/DragAndDropSvc.h
===================================================================
--- trunk/include/VBox/HostServices/DragAndDropSvc.h	(revision 58283)
+++ trunk/include/VBox/HostServices/DragAndDropSvc.h	(revision 58329)
@@ -32,24 +32,25 @@
  * Protocol changelog:
  *
- *     Protocol v1 (VBox < 5.0):
- *         - Initial implementation which only implemented host to guest transfers.
- *         - For file transfers all file information such as the file name and file size were
+ *     Protocol v1 (VBox < 5.0, deprecated):
+ *         | Initial implementation which only implemented host to guest transfers.
+ *         | For file transfers all file information such as the file name and file size were
  *           transferred with every file data chunk being sent.
  *
- *     Protocol v2 (VBox 5.0):
- *         - Added support for guest to host transfers.
- *         - Added protocol version support through VBOXDNDCONNECTMSG. The host takes the installed
+ *     Protocol v2 (VBox 5.0 - VBox 5.0.8, deprecated):
+ *         + Added support for guest to host transfers.
+ *         + Added protocol version support through VBOXDNDCONNECTMSG. The host takes the installed
  *           Guest Additions version as indicator which protocol to use for communicating with the guest.
  *           The guest itself uses VBOXDNDCONNECTMSG to report its supported protocol version to the DnD service.
  *
- *     Protocol v3 (VBox 5.0+):
-             Added context IDs for every HGCM message. Not used yet and must be 0.
- *         - Added VBOXDNDSNDDATAHDR and VBOXDNDCBSNDDATAHDRDATA to support (simple) accounting of objects
+ *     Protocol v3 (VBox 5.0.10 and up, current):
+ *         + Added VBOXDNDDISCONNECTMSG for being able to track client disconnects on host side (Main).
+ *         + Added context IDs for every HGCM message. Not used yet and must be 0.
+ *         + Added VBOXDNDSNDDATAHDR and VBOXDNDCBSNDDATAHDRDATA to support (simple) accounting of objects
  *           being transferred, along with supplying separate meta data size (which is part of the total size being sent).
- *         - Added new HOST_DND_HG_SND_DATA_HDR + GUEST_DND_GH_SND_DATA_HDR commands which now allow specifying an optional
+ *         + Added new HOST_DND_HG_SND_DATA_HDR + GUEST_DND_GH_SND_DATA_HDR commands which now allow specifying an optional
  *           compression type and defining a checksum for the overall data transfer.
- *         - Enhannced VBOXDNDGHSENDDATAMSG to support (rolling) checksums for the supplied data block.
- *         - VBOXDNDHGSENDFILEDATAMSG and VBOXDNDGHSENDFILEDATAMSG are now sharing the same HGCM mesasge.
- *         - VBOXDNDHGSENDDATAMSG and VBOXDNDGHSENDDATAMSG can now contain an optional checksum for the current data block.
+ *         + Enhannced VBOXDNDGHSENDDATAMSG to support (rolling) checksums for the supplied data block.
+ *         + VBOXDNDHGSENDDATAMSG and VBOXDNDGHSENDDATAMSG can now contain an optional checksum for the current data block.
+ *         | VBOXDNDHGSENDFILEDATAMSG and VBOXDNDGHSENDFILEDATAMSG are now sharing the same HGCM mesasge.
  *         - Removed unused HOST_DND_GH_RECV_DIR, HOST_DND_GH_RECV_FILE_DATA and HOST_DND_GH_RECV_FILE_HDR commands.
  */
@@ -184,7 +185,12 @@
 enum eGuestFn
 {
-    /* Guest sends a connection request to the HGCM service.
+    /* Guest sends a connection request to the HGCM service,
+     * along with some additional information like supported
+     * protocol version and flags.
      * Note: New since protocol version 2. */
     GUEST_DND_CONNECT                  = 10,
+
+    /* Sent when a guest client disconnected from the HGCM service. */
+    GUEST_DND_DISCONNECT               = 11,
 
     /**
@@ -287,5 +293,5 @@
             HGCMFunctionParameter uAllActions;  /* OUT uint32_t */
             HGCMFunctionParameter pvFormats;    /* OUT ptr */
-            HGCMFunctionParameter cFormats;     /* OUT uint32_t */
+            HGCMFunctionParameter cbFormats;    /* OUT uint32_t */
         } v1;
         struct
@@ -299,5 +305,5 @@
             HGCMFunctionParameter uAllActions;  /* OUT uint32_t */
             HGCMFunctionParameter pvFormats;    /* OUT ptr */
-            HGCMFunctionParameter cFormats;     /* OUT uint32_t */
+            HGCMFunctionParameter cbFormats;    /* OUT uint32_t */
         } v3;
     } u;
@@ -680,5 +686,6 @@
 
 /**
- * HG Acknowledge Operation event.
+ * Acknowledges a host operation along with the allowed
+ * action(s) on the guest.
  *
  * Used by:
@@ -923,4 +930,10 @@
     uint32_t                    uFlags;
 } VBOXDNDCBCONNECTMSGDATA, *PVBOXDNDCBCONNECTMSGDATA;
+
+typedef struct VBOXDNDCBDISCONNECTMSGDATA
+{
+    /** Callback data header. */
+    VBOXDNDCBHEADERDATA         hdr;
+} VBOXDNDCBDISCONNECTMSGDATA, *PVBOXDNDCBDISCONNECTMSGDATA;
 
 typedef struct VBOXDNDCBHGGETNEXTHOSTMSG
Index: trunk/include/VBox/HostServices/Service.h
===================================================================
--- trunk/include/VBox/HostServices/Service.h	(revision 58283)
+++ trunk/include/VBox/HostServices/Service.h	(revision 58329)
@@ -300,5 +300,5 @@
     }
 
-private:
+protected:
 
     uint32_t m_uClientId;
@@ -310,4 +310,20 @@
     PVBOXHGCMSVCPARM m_paParms;
 };
+
+/**
+ * Structure for keeping a HGCM service context.
+ */
+typedef struct VBOXHGCMSVCTX
+{
+    /** HGCM helper functions. */
+    PVBOXHGCMSVCHELPERS pHelpers;
+    /*
+     * Callback function supplied by the host for notification of updates
+     * to properties.
+     */
+    PFNHGCMSVCEXT       pfnHostCallback;
+    /** User data pointer to be supplied to the host callback function. */
+    void               *pvHostData;
+} VBOXHGCMSVCTX, *PVBOXHGCMSVCTX;
 
 template <class T>
@@ -383,8 +399,8 @@
 protected:
     explicit AbstractService(PVBOXHGCMSVCHELPERS pHelpers)
-        : m_pHelpers(pHelpers)
-        , m_pfnHostCallback(NULL)
-        , m_pvHostData(NULL)
-    {}
+    {
+        RT_ZERO(m_SvcCtx);
+        m_SvcCtx.pHelpers = pHelpers;
+    }
     virtual int  init(VBOXHGCMSVCFNTABLE *ptable) { return VINF_SUCCESS; }
     virtual int  uninit() { return VINF_SUCCESS; }
@@ -396,13 +412,6 @@
     /** Type definition for use in callback functions. */
     typedef AbstractService SELF;
-    /** HGCM helper functions. */
-    PVBOXHGCMSVCHELPERS m_pHelpers;
-    /*
-     * Callback function supplied by the host for notification of updates
-     * to properties.
-     */
-    PFNHGCMSVCEXT m_pfnHostCallback;
-    /** User data pointer to be supplied to the host callback function. */
-    void *m_pvHostData;
+    /** The HGCM service context this service is bound to. */
+    VBOXHGCMSVCTX m_SvcCtx;
 
     /**
@@ -500,6 +509,6 @@
         LogFlowFunc(("pvService=%p, pfnExtension=%p, pvExtention=%p\n", pvService, pfnExtension, pvExtension));
         SELF *pSelf = reinterpret_cast<SELF *>(pvService);
-        pSelf->m_pfnHostCallback = pfnExtension;
-        pSelf->m_pvHostData = pvExtension;
+        pSelf->m_SvcCtx.pfnHostCallback = pfnExtension;
+        pSelf->m_SvcCtx.pvHostData      = pvExtension;
         return VINF_SUCCESS;
     }
