Index: trunk/include/VBox/GuestHost/SharedClipboard-uri.h
===================================================================
--- trunk/include/VBox/GuestHost/SharedClipboard-uri.h	(revision 79115)
+++ trunk/include/VBox/GuestHost/SharedClipboard-uri.h	(revision 79120)
@@ -29,4 +29,8 @@
 #ifndef RT_WITHOUT_PRAGMA_ONCE
 # pragma once
+#endif
+
+#ifdef VBOX_WITH_SHARED_CLIPBOARD_HOST
+#include <map> /* Needed for host provider. */
 #endif
 
@@ -378,6 +382,14 @@
 };
 
-int SharedClipboardDataHeaderInit(PVBOXCLIPBOARDDATAHDR pDataHdr);
-void SharedClipboardDataHeaderDestroy(PVBOXCLIPBOARDDATAHDR pDataHdr);
+int SharedClipboardURIDataHdrInit(PVBOXCLIPBOARDDATAHDR pDataHdr);
+void SharedClipboardURIDataHdrDestroy(PVBOXCLIPBOARDDATAHDR pDataHdr);
+bool SharedClipboardURIDataHdrIsValid(PVBOXCLIPBOARDDATAHDR pDataHdr);
+bool SharedClipboardURIDataChunkIsValid(PVBOXCLIPBOARDDATACHUNK pDataChunk);
+void SharedClipboardURIDirDataDestroy(PVBOXCLIPBOARDDIRDATA pDirData);
+bool SharedClipboardURIDirDataIsValid(PVBOXCLIPBOARDDIRDATA pDirData);
+void SharedClipboardURIFileHdrDestroy(PVBOXCLIPBOARDFILEHDR pFileHdr);
+bool SharedClipboardURIFileHdrIsValid(PVBOXCLIPBOARDFILEHDR pFileHdr, PVBOXCLIPBOARDDATAHDR pDataHdr);
+void SharedClipboardURIFileDataDestroy(PVBOXCLIPBOARDFILEDATA pFileData);
+bool SharedClipboardURIFileDataIsValid(PVBOXCLIPBOARDFILEDATA pFileData, PVBOXCLIPBOARDDATAHDR pDataHdr);
 
 /**
@@ -405,4 +417,15 @@
 void *SharedClipboardMetaDataMutableRaw(PSHAREDCLIPBOARDMETADATA pMeta);
 const void *SharedClipboardMetaDataRaw(PSHAREDCLIPBOARDMETADATA pMeta);
+
+/**
+ * Structure for maintaining an URI transfer cache.
+ */
+typedef struct _SHAREDCLIPBOARDURITRANSFERCACHE
+{
+    /** The transfer's cached data header. */
+    VBOXCLIPBOARDDATAHDR        Header;
+    /** The transfer's cached meta data. */
+    SHAREDCLIPBOARDMETADATA     Meta;
+} SHAREDCLIPBOARDURITRANSFERCACHE, *PSHAREDCLIPBOARDURITRANSFERCACHE;
 
 /**
@@ -436,4 +459,34 @@
 
 /**
+ * Structure for read parameters.
+ */
+typedef struct _SHAREDCLIPBOARDPROVIDERREADPARMS
+{
+    union
+    {
+        struct
+        {
+
+        } HostService;
+    } u;
+} SHAREDCLIPBOARDPROVIDERREADPARMS, *PSHAREDCLIPBOARDPROVIDERREADPARMS;
+
+/**
+ * Structure for write parameters.
+ */
+typedef struct _SHAREDCLIPBOARDPROVIDERWRITEPARMS
+{
+    union
+    {
+        struct
+        {
+            uint32_t         uMsg;
+            uint32_t         cParms;
+            VBOXHGCMSVCPARM *paParms;
+        } HostService;
+    } u;
+} SHAREDCLIPBOARDPROVIDERWRITEPARMS, *PSHAREDCLIPBOARDPROVIDERWRITEPARMS;
+
+/**
  * Interface class acting as a lightweight proxy for abstracting reading / writing clipboard data.
  *
@@ -460,7 +513,8 @@
     virtual int WriteDataHdr(const PVBOXCLIPBOARDDATAHDR pDataHdr);
 
-    virtual int ReadMetaData(const PVBOXCLIPBOARDDATAHDR pDataHdr, void *pvMeta, uint32_t cbMeta, uint32_t *pcbRead, uint32_t fFlags = 0);
-    virtual int WriteMetaData(const PVBOXCLIPBOARDDATAHDR pDataHdr, const void *pvMeta, uint32_t cbMeta, uint32_t *pcbWritten,
+    virtual int ReadDataChunk(const PVBOXCLIPBOARDDATAHDR pDataHdr, void *pvChunk, uint32_t cbChunk, uint32_t *pcbRead,
                               uint32_t fFlags = 0);
+    virtual int WriteDataChunk(const PVBOXCLIPBOARDDATAHDR pDataHdr, const void *pvChunk, uint32_t cbChunk, uint32_t *pcbWritten,
+                               uint32_t fFlags = 0);
 
     virtual int ReadDirectory(PVBOXCLIPBOARDDIRDATA pDirData);
@@ -474,4 +528,11 @@
 
     virtual void Reset(void);
+
+public: /* Optional callback handling. */
+
+    /*virtual int SetCallbacks();*/
+
+    virtual int OnRead(PSHAREDCLIPBOARDPROVIDERREADPARMS pParms);
+    virtual int OnWrite(PSHAREDCLIPBOARDPROVIDERWRITEPARMS pParms);
 
 protected:
@@ -501,7 +562,8 @@
     int WriteDataHdr(const PVBOXCLIPBOARDDATAHDR pDataHdr);
 
-    int ReadMetaData(const PVBOXCLIPBOARDDATAHDR pDataHdr, void *pvMeta, uint32_t cbMeta, uint32_t *pcbRead, uint32_t fFlags = 0);
-    int WriteMetaData(const PVBOXCLIPBOARDDATAHDR pDataHdr, const void *pvMeta, uint32_t cbMeta, uint32_t *pcbWritten,
-                      uint32_t fFlags = 0);
+    int ReadDataChunkk(const PVBOXCLIPBOARDDATAHDR pDataHdr, void *pvChunk, uint32_t cbChunk, uint32_t *pcbRead,
+                       uint32_t fFlags = 0);
+    int WriteDataChunk(const PVBOXCLIPBOARDDATAHDR pDataHdr, const void *pvChunk, uint32_t cbChunk, uint32_t *pcbWritten,
+                       uint32_t fFlags = 0);
 
     int ReadDirectory(PVBOXCLIPBOARDDIRDATA pDirData);
@@ -524,4 +586,5 @@
 };
 
+#ifdef VBOX_WITH_SHARED_CLIPBOARD_HOST
 /**
  * Shared Clipboard provider implementation for host service (host side).
@@ -540,7 +603,7 @@
     int WriteDataHdr(const PVBOXCLIPBOARDDATAHDR pDataHdr);
 
-    int ReadMetaData(const PVBOXCLIPBOARDDATAHDR pDataHdr, void *pvMeta, uint32_t cbMeta, uint32_t *pcbRead, uint32_t fFlags = 0);
-    int WriteMetaData(const PVBOXCLIPBOARDDATAHDR pDataHdr, const void *pvMeta, uint32_t cbMeta, uint32_t *pcbWritten,
-                      uint32_t fFlags = 0);
+    int ReaaDataChunk(const PVBOXCLIPBOARDDATAHDR pDataHdr, void *pvMeta, uint32_t cbMeta, uint32_t *pcbRead, uint32_t fFlags = 0);
+    int WriteDataChunk(const PVBOXCLIPBOARDDATAHDR pDataHdr, const void *pvMeta, uint32_t cbMeta, uint32_t *pcbWritten,
+                       uint32_t fFlags = 0);
 
     int ReadDirectory(PVBOXCLIPBOARDDIRDATA pDirData);
@@ -555,8 +618,50 @@
     void Reset(void);
 
+public:
+
+    int OnRead(PSHAREDCLIPBOARDPROVIDERREADPARMS pParms);
+    int OnWrite(PSHAREDCLIPBOARDPROVIDERWRITEPARMS pParms);
+
 protected:
 
     SharedClipboardProviderHostService(void);
+
+    /**
+     * Structure for maintaining an internal event.
+     */
+    struct Event
+    {
+        Event(uint32_t uMsg);
+        virtual ~Event();
+
+        uint32_t DataSize(void);
+        void *DataRaw(void);
+        int SetData(const void *pvData, uint32_t cbData);
+        int Wait(RTMSINTERVAL uTimeoutMs);
+
+        /** The event's associated message ID (guest function number). */
+        uint32_t    mMsg;
+        /** The event's own event semaphore. */
+        RTSEMEVENT  mEvent;
+        void       *mpvData;
+        uint32_t    mcbData;
+    };
+
+    /** Map of events; the key is the guest function number (VBOX_SHARED_CLIPBOARD_GUEST_FN_XXX). */
+    typedef std::map<uint32_t, Event *> EventMap;
+
+    int eventRegister(uint32_t uMsg);
+    int eventUnregister(uint32_t uMsg);
+    int eventSignal(uint32_t uMsg);
+    SharedClipboardProviderHostService::Event *eventGet(uint32_t uMsg);
+
+protected:
+
+    RTMSINTERVAL                    m_uTimeoutMs;
+    SHAREDCLIPBOARDURITRANSFERCACHE m_Cache;
+    EventMap                        m_mapEvents;
+
 };
+#endif /* VBOX_WITH_SHARED_CLIPBOARD_HOST */
 
 struct _SHAREDCLIPBOARDURITRANSFER;
@@ -659,8 +764,6 @@
     /** The transfer's direction. */
     SHAREDCLIPBOARDURITRANSFERDIR       enmDir;
-    /** The transfer's meta data cache. */
-    VBOXCLIPBOARDDATAHDR                Header;
-    /** The transfer's meta data cache. */
-    SHAREDCLIPBOARDMETADATA             Meta;
+    /** The transfer's cache. */
+    SHAREDCLIPBOARDURITRANSFERCACHE     Cache;
     /** The transfer's own (local) area, if any (can be NULL if not needed).
      *  The area itself has a clipboard area ID assigned.
Index: trunk/include/VBox/HostServices/VBoxClipboardSvc.h
===================================================================
--- trunk/include/VBox/HostServices/VBoxClipboardSvc.h	(revision 79115)
+++ trunk/include/VBox/HostServices/VBoxClipboardSvc.h	(revision 79120)
@@ -65,45 +65,45 @@
  */
 /** Calls the host and waits (blocking) for an host event VBOX_SHARED_CLIPBOARD_HOST_MSG_*. */
-#define VBOX_SHARED_CLIPBOARD_FN_GET_HOST_MSG      1
+#define VBOX_SHARED_CLIPBOARD_GUEST_FN_GET_HOST_MSG      1
 /** Sends a list of available formats to the host. */
-#define VBOX_SHARED_CLIPBOARD_FN_REPORT_FORMATS    2
+#define VBOX_SHARED_CLIPBOARD_GUEST_FN_REPORT_FORMATS    2
 /** Reads data in specified format from the host. */
-#define VBOX_SHARED_CLIPBOARD_FN_READ_DATA         3
+#define VBOX_SHARED_CLIPBOARD_GUEST_FN_READ_DATA         3
 /** Writes data in requested format to the host. */
-#define VBOX_SHARED_CLIPBOARD_FN_WRITE_DATA        4
+#define VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_DATA        4
 /** Reads the data header at the beginning of a (new) data transfer from the host.
  *  New since URI handling was implemented. */
-#define VBOX_SHARED_CLIPBOARD_FN_READ_DATA_HDR     5
+#define VBOX_SHARED_CLIPBOARD_GUEST_FN_READ_DATA_HDR     5
 /** Writes data in requested format to the host. */
-#define VBOX_SHARED_CLIPBOARD_FN_READ_DATA_CHUNK   6
+#define VBOX_SHARED_CLIPBOARD_GUEST_FN_READ_DATA_CHUNK   6
 /** Writes the data header at the beginning of a (new) data transfer to the host.
  *  New since URI handling was implemented. */
-#define VBOX_SHARED_CLIPBOARD_FN_WRITE_DATA_HDR    7
+#define VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_DATA_HDR    7
 /** Writes data in requested format to the host. */
-#define VBOX_SHARED_CLIPBOARD_FN_WRITE_DATA_CHUNK  8
+#define VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_DATA_CHUNK  8
 /** Reads a new directory entry from the host.
  *  New since URI handling was implemented. */
-#define VBOX_SHARED_CLIPBOARD_FN_READ_DIR          9
+#define VBOX_SHARED_CLIPBOARD_GUEST_FN_READ_DIR          9
 /** Writes a new directory entry to the host.
  *  New since URI handling was implemented. */
-#define VBOX_SHARED_CLIPBOARD_FN_WRITE_DIR         10
+#define VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_DIR         10
 /** Reads a new file header entry from the host.
  *  New since URI handling was implemented. */
-#define VBOX_SHARED_CLIPBOARD_FN_READ_FILE_HDR     11
+#define VBOX_SHARED_CLIPBOARD_GUEST_FN_READ_FILE_HDR     11
 /** Writes a new file header entry to the host.
      *  New since URI handling was implemented. */
-#define VBOX_SHARED_CLIPBOARD_FN_WRITE_FILE_HDR    12
+#define VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_FILE_HDR    12
 /** Reads a new file data chunk entry from the host.
  *  New since URI handling was implemented. */
-#define VBOX_SHARED_CLIPBOARD_FN_READ_FILE_DATA    13
+#define VBOX_SHARED_CLIPBOARD_GUEST_FN_READ_FILE_DATA    13
 /** Writes a new file data chunk entry to the host.
  *  New since URI handling was implemented. */
-#define VBOX_SHARED_CLIPBOARD_FN_WRITE_FILE_DATA   14
+#define VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_FILE_DATA   14
 /** Reports cancellation of the current operation to the host.
  *  New since URI handling was implemented. */
-#define VBOX_SHARED_CLIPBOARD_FN_WRITE_CANCEL      15
+#define VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_CANCEL      15
 /** Reports an error to the host.
  *  New since URI handling was implemented. */
-#define VBOX_SHARED_CLIPBOARD_FN_WRITE_ERROR       16
+#define VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_ERROR       16
 
 /** The maximum default chunk size for a single data transfer. */
@@ -347,10 +347,10 @@
 enum eVBoxClipboardCallbackMagics
 {
-    CB_MAGIC_CLIPBOARD_WRITE_DATA_HDR   = VBOX_CLIPBOARD_CB_MAGIC_MAKE(VBOX_SHARED_CLIPBOARD_FN_WRITE_DATA_HDR, 0),
-    CB_MAGIC_CLIPBOARD_WRITE_DATA_CHUNK = VBOX_CLIPBOARD_CB_MAGIC_MAKE(VBOX_SHARED_CLIPBOARD_FN_WRITE_DATA_CHUNK, 0),
-    CB_MAGIC_CLIPBOARD_WRITE_DIR        = VBOX_CLIPBOARD_CB_MAGIC_MAKE(VBOX_SHARED_CLIPBOARD_FN_WRITE_DIR, 0),
-    CB_MAGIC_CLIPBOARD_WRITE_FILE_HDR   = VBOX_CLIPBOARD_CB_MAGIC_MAKE(VBOX_SHARED_CLIPBOARD_FN_WRITE_FILE_HDR, 0),
-    CB_MAGIC_CLIPBOARD_WRITE_FILE_DATA  = VBOX_CLIPBOARD_CB_MAGIC_MAKE(VBOX_SHARED_CLIPBOARD_FN_WRITE_FILE_DATA, 0),
-    CB_MAGIC_CLIPBOARD_WRITE_ERROR      = VBOX_CLIPBOARD_CB_MAGIC_MAKE(VBOX_SHARED_CLIPBOARD_FN_WRITE_ERROR, 0)
+    CB_MAGIC_CLIPBOARD_WRITE_DATA_HDR   = VBOX_CLIPBOARD_CB_MAGIC_MAKE(VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_DATA_HDR, 0),
+    CB_MAGIC_CLIPBOARD_WRITE_DATA_CHUNK = VBOX_CLIPBOARD_CB_MAGIC_MAKE(VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_DATA_CHUNK, 0),
+    CB_MAGIC_CLIPBOARD_WRITE_DIR        = VBOX_CLIPBOARD_CB_MAGIC_MAKE(VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_DIR, 0),
+    CB_MAGIC_CLIPBOARD_WRITE_FILE_HDR   = VBOX_CLIPBOARD_CB_MAGIC_MAKE(VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_FILE_HDR, 0),
+    CB_MAGIC_CLIPBOARD_WRITE_FILE_DATA  = VBOX_CLIPBOARD_CB_MAGIC_MAKE(VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_FILE_DATA, 0),
+    CB_MAGIC_CLIPBOARD_WRITE_ERROR      = VBOX_CLIPBOARD_CB_MAGIC_MAKE(VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_ERROR, 0)
 };
 
@@ -445,4 +445,12 @@
 void VBoxSvcClipboardUnlock(void);
 
+#ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
+int VBoxSvcClipboardURIReadDataHdr(uint32_t cParms, VBOXHGCMSVCPARM paParms[], PVBOXCLIPBOARDDATAHDR pDataHdr);
+int VBoxSvcClipboardURIReadDataChunk(uint32_t cParms, VBOXHGCMSVCPARM paParms[], PVBOXCLIPBOARDDATACHUNK pDataChunk);
+int VBoxSvcClipboardURIReadDir(uint32_t cParms, VBOXHGCMSVCPARM paParms[], PVBOXCLIPBOARDDIRDATA pDirData);
+int VBoxSvcClipboardURIReadFileHdr(uint32_t cParms, VBOXHGCMSVCPARM paParms[], PVBOXCLIPBOARDFILEHDR pFileHdr);
+int VBoxSvcClipboardURIReadFileData(uint32_t cParms, VBOXHGCMSVCPARM paParms[], PVBOXCLIPBOARDFILEDATA pFileData);
+#endif
+
 #endif /* !VBOX_INCLUDED_HostServices_VBoxClipboardSvc_h */
 
