Changeset 79366 in vbox for trunk/include
- Timestamp:
- Jun 26, 2019 3:59:30 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/GuestHost/SharedClipboard-uri.h
r79350 r79366 536 536 SHAREDCLIPBOARDURITRANSFERDIR_WRITE, 537 537 /** The usual 32-bit hack. */ 538 SHAREDCLIPBOARDURITRANSFERDIR_ _32BIT_HACK = 0x7fffffff538 SHAREDCLIPBOARDURITRANSFERDIR_32BIT_HACK = 0x7fffffff 539 539 } SHAREDCLIPBOARDURITRANSFERDIR; 540 540 … … 560 560 SHAREDCLIPBOARDURITRANSFERSTATUS_NONE = 0, 561 561 /** The transfer has been announced but is not running yet. */ 562 SHAREDCLIPBOARDURITRANSFERSTATUS_ ANNOUNCED,562 SHAREDCLIPBOARDURITRANSFERSTATUS_READY, 563 563 /** The transfer is active and running. */ 564 SHAREDCLIPBOARDURITRANSFERSTATUS_RUNNING 564 SHAREDCLIPBOARDURITRANSFERSTATUS_RUNNING, 565 /** The usual 32-bit hack. */ 566 SHAREDCLIPBOARDURITRANSFERSTATUS_32BIT_HACK = 0x7fffffff 565 567 } SHAREDCLIPBOARDURITRANSFERSTATUS; 568 569 typedef struct _SHAREDCLIPBOARDURITRANSFERPAYLOAD 570 { 571 uint32_t uID; 572 void *pvData; 573 uint32_t cbData; 574 } SHAREDCLIPBOARDURITRANSFERPAYLOAD, *PSHAREDCLIPBOARDURITRANSFERPAYLOAD; 575 576 typedef struct _SHAREDCLIPBOARDURITRANSFEREVENT 577 { 578 RTSEMEVENT hEventSem; 579 PSHAREDCLIPBOARDURITRANSFERPAYLOAD pPayload; 580 } SHAREDCLIPBOARDURITRANSFEREVENT, *PSHAREDCLIPBOARDURITRANSFEREVENT; 581 582 typedef enum _SHAREDCLIPBOARDURITRANSFEREVENTTYPE 583 { 584 SHAREDCLIPBOARDURITRANSFEREVENTTYPE_UNKNOWN, 585 SHAREDCLIPBOARDURITRANSFEREVENTTYPE_METADATA_HDR, 586 SHAREDCLIPBOARDURITRANSFEREVENTTYPE_METADATA_CHUNK, 587 /** Marks the end of the event list. */ 588 SHAREDCLIPBOARDURITRANSFEREVENTTYPE_LAST, 589 /** The usual 32-bit hack. */ 590 SHAREDCLIPBOARDURITRANSFEREVENTTYPE_32BIT_HACK = 0x7fffffff 591 } SHAREDCLIPBOARDURITRANSFEREVENTTYPE; 592 593 typedef std::map<uint32_t, SHAREDCLIPBOARDURITRANSFEREVENT *> SharedClipboardURITransferEventMap; 594 595 typedef struct _SHAREDCLIPBOARDURITRANSFEREVENTS 596 { 597 SharedClipboardURITransferEventMap *pMap; 598 } SHAREDCLIPBOARDURITRANSFEREVENTS, *PSHAREDCLIPBOARDURITRANSFEREVENTS; 566 599 567 600 /** … … 593 626 typedef struct _SHAREDCLIPBOARDURITRANSFER *PSHAREDCLIPBOARDURITRANSFER; 594 627 628 /** 629 * Structure maintaining URI clipboard provider context data. 630 * This is handed in to the provider implementation callbacks. 631 */ 595 632 typedef struct _SHAREDCLIPBOARDPROVIDERCTX 596 633 { 634 /** Pointer to the related URI transfer. */ 597 635 PSHAREDCLIPBOARDURITRANSFER pTransfer; 636 /** User-defined data pointer. Can be NULL if not needed. */ 598 637 void *pvUser; 599 638 } SHAREDCLIPBOARDPROVIDERCTX, *PSHAREDCLIPBOARDPROVIDERCTX; 600 639 640 /** Defines an URI clipboard provider function declaration with additional parameters. */ 601 641 #define SHAREDCLIPBOARDPROVIDERFUNCDECL(a_Name, ...) \ 602 642 typedef DECLCALLBACK(int) RT_CONCAT(FNSHAREDCLIPBOARDPROVIDER, a_Name)(PSHAREDCLIPBOARDPROVIDERCTX, __VA_ARGS__); \ 603 643 typedef RT_CONCAT(FNSHAREDCLIPBOARDPROVIDER, a_Name) RT_CONCAT(*PFNSHAREDCLIPBOARDPROVIDER, a_Name); 604 644 645 /** Defines an URI clipboard provider function declaration (no additional parameters). */ 605 646 #define SHAREDCLIPBOARDPROVIDERFUNCDECLVOID(a_Name) \ 606 647 typedef DECLCALLBACK(int) RT_CONCAT(FNSHAREDCLIPBOARDPROVIDER, a_Name)(PSHAREDCLIPBOARDPROVIDERCTX); \ 607 648 typedef RT_CONCAT(FNSHAREDCLIPBOARDPROVIDER, a_Name) RT_CONCAT(*PFNSHAREDCLIPBOARDPROVIDER, a_Name); 608 649 650 /** Declares a URI clipboard provider function member. */ 609 651 #define SHAREDCLIPBOARDPROVIDERFUNCMEMBER(a_Name, a_Member) \ 610 652 RT_CONCAT(PFNSHAREDCLIPBOARDPROVIDER, a_Name) a_Member; … … 624 666 SHAREDCLIPBOARDPROVIDERFUNCDECLVOID(RESET) 625 667 668 /** 669 * Shared Clipboard URI provider interface table. 670 */ 626 671 typedef struct _SHAREDCLIPBOARDPROVIDERINTERFACE 627 672 { … … 648 693 /** Specifies what the source of the provider is. */ 649 694 SHAREDCLIPBOARDSOURCE enmSource; 695 /** The provider interface table. */ 650 696 SHAREDCLIPBOARDPROVIDERINTERFACE Interface; 697 /** Provider callback data. */ 651 698 void *pvUser; 652 union653 {654 struct655 {656 /** HGCM client ID to use. */657 uint32_t uClientID;658 } VbglR3;659 struct660 {661 SharedClipboardArea *pArea;662 } HostService;663 } u;664 699 } SHAREDCLIPBOARDPROVIDERCREATIONCTX, *PSHAREDCLIPBOARDPROVIDERCREATIONCTX; 665 700 … … 693 728 } SHAREDCLIPBOARDPROVIDERWRITEPARMS, *PSHAREDCLIPBOARDPROVIDERWRITEPARMS; 694 729 695 #if 0696 /**697 * Interface class acting as a lightweight proxy for abstracting reading / writing clipboard data.698 *699 * This is needed because various implementations can run on the host *or* on the guest side,700 * requiring different methods for handling the actual data.701 */702 class SharedClipboardProvider703 {704 705 public:706 707 static SharedClipboardProvider *Create(PSHAREDCLIPBOARDPROVIDERCREATIONCTX pCtx);708 709 virtual ~SharedClipboardProvider(void);710 711 public:712 713 uint32_t AddRef(void);714 uint32_t Release(void);715 716 public:717 718 void SetCallbacks(PSHAREDCLIPBOARDPROVIDERCALLBACKS pCallbacks);719 720 public: /* Interface to be implemented. */721 722 virtual int Prepare(void);723 724 virtual int ReadDataHdr(PVBOXCLIPBOARDDATAHDR *ppDataHdr);725 virtual int WriteDataHdr(const PVBOXCLIPBOARDDATAHDR pDataHdr);726 727 virtual int ReadDataChunk(const PVBOXCLIPBOARDDATAHDR pDataHdr, void *pvChunk, uint32_t cbChunk, uint32_t fFlags = 0,728 uint32_t *pcbRead = NULL);729 virtual int WriteDataChunk(const PVBOXCLIPBOARDDATAHDR pDataHdr, const void *pvChunk, uint32_t cbChunk, uint32_t fFlags = 0,730 uint32_t *pcbWritten = NULL);731 732 virtual int ReadDirectory(PVBOXCLIPBOARDDIRDATA *ppDirData);733 virtual int WriteDirectory(const PVBOXCLIPBOARDDIRDATA pDirData);734 735 virtual int ReadFileHdr(PVBOXCLIPBOARDFILEHDR *ppFileHdr);736 virtual int WriteFileHdr(const PVBOXCLIPBOARDFILEHDR pFileHdr);737 738 virtual int ReadFileData(void *pvData, uint32_t cbData, uint32_t fFlags = 0, uint32_t *pcbRead = NULL);739 virtual int WriteFileData(void *pvData, uint32_t cbData, uint32_t fFlags = 0, uint32_t *pcbWritten = NULL);740 741 virtual void Reset(void);742 743 public: /* Optional callback handling. */744 745 /*virtual int SetCallbacks();*/746 747 virtual int OnRead(PSHAREDCLIPBOARDPROVIDERREADPARMS pParms);748 virtual int OnWrite(PSHAREDCLIPBOARDPROVIDERWRITEPARMS pParms);749 750 protected:751 752 SharedClipboardProvider(void);753 754 protected:755 756 /**757 * Structure for maintaining an internal event.758 */759 struct Event760 {761 Event(uint32_t uMsg);762 virtual ~Event();763 764 void *DataAdopt(void);765 uint32_t DataSize(void);766 void *DataRaw(void);767 void Reset(void);768 int SetData(const void *pvData, uint32_t cbData);769 int Wait(RTMSINTERVAL uTimeoutMs);770 771 /** The event's associated message ID (guest function number). */772 uint32_t mMsg;773 /** The event's own event semaphore. */774 RTSEMEVENT mEvent;775 /** User-provided data buffer associated to this event. Optional. */776 void *mpvData;777 /** Size (in bytes) of user-provided data buffer associated to this event. */778 uint32_t mcbData;779 };780 781 /** Map of events; the key is the guest function number (VBOX_SHARED_CLIPBOARD_GUEST_FN_XXX). */782 typedef std::map<uint32_t, Event *> EventMap;783 784 int eventRegister(uint32_t uMsg);785 int eventUnregister(uint32_t uMsg);786 int eventUnregisterAll(void);787 int eventSignal(uint32_t uMsg);788 int eventWait(uint32_t uMsg, PFNSSHAREDCLIPBOARDPROVIDERCALLBACK pfnCallback, RTMSINTERVAL uTimeoutMs,789 void **ppvData, uint32_t *pcbData = NULL);790 SharedClipboardProvider::Event *eventGet(uint32_t uMsg);791 792 protected:793 794 /** Number of references to this instance. */795 volatile uint32_t m_cRefs;796 /** The provider's transfer direction. */797 SHAREDCLIPBOARDURITRANSFERDIR m_enmDir;798 /** The provider's callback table. */799 SHAREDCLIPBOARDPROVIDERCALLBACKS m_Callbacks;800 /** Default timeout (in ms) for waiting for events. */801 RTMSINTERVAL m_uTimeoutMs;802 /** Map of (internal) events to provide asynchronous reads / writes. */803 EventMap m_mapEvents;804 };805 806 /**807 * Shared Clipboard provider implementation for VbglR3 (guest side).808 */809 class SharedClipboardProviderVbglR3 : protected SharedClipboardProvider810 {811 friend class SharedClipboardProvider;812 813 public:814 815 virtual ~SharedClipboardProviderVbglR3(void);816 817 public:818 819 int ReadDataHdr(PVBOXCLIPBOARDDATAHDR *ppDataHdr);820 int WriteDataHdr(const PVBOXCLIPBOARDDATAHDR pDataHdr);821 822 int ReadDataChunk(const PVBOXCLIPBOARDDATAHDR pDataHdr, void *pvChunk, uint32_t cbChunk, uint32_t fFlags = 0,823 uint32_t *pcbRead = NULL);824 int WriteDataChunk(const PVBOXCLIPBOARDDATAHDR pDataHdr, const void *pvChunk, uint32_t cbChunk, uint32_t fFlags = 0,825 uint32_t *pcbWritten = NULL);826 827 int ReadDirectory(PVBOXCLIPBOARDDIRDATA *ppDirData);828 int WriteDirectory(const PVBOXCLIPBOARDDIRDATA pDirData);829 830 int ReadFileHdr(PVBOXCLIPBOARDFILEHDR *ppFileHdr);831 int WriteFileHdr(const PVBOXCLIPBOARDFILEHDR pFileHdr);832 833 int ReadFileData(void *pvData, uint32_t cbData, uint32_t fFlags = 0, uint32_t *pcbRead = NULL);834 int WriteFileData(void *pvData, uint32_t cbData, uint32_t fFlags = 0, uint32_t *pcbWritten = NULL);835 836 void Reset(void);837 838 protected:839 840 SharedClipboardProviderVbglR3(uint32_t uClientID);841 842 /** HGCM client ID to use. */843 uint32_t m_uClientID;844 };845 846 #ifdef VBOX_WITH_SHARED_CLIPBOARD_HOST847 /**848 * Shared Clipboard provider implementation for host service (host side).849 */850 class SharedClipboardProviderHostService : protected SharedClipboardProvider851 {852 friend class SharedClipboardProvider;853 854 public:855 856 virtual ~SharedClipboardProviderHostService();857 858 public:859 860 int Prepare(void);861 862 int ReadDataHdr(PVBOXCLIPBOARDDATAHDR *ppDataHdr);863 int WriteDataHdr(const PVBOXCLIPBOARDDATAHDR pDataHdr);864 865 int ReadDataChunk(const PVBOXCLIPBOARDDATAHDR pDataHdr, void *pvChunk, uint32_t cbChunk, uint32_t fFlags = 0,866 uint32_t *pcbRead = NULL);867 int WriteDataChunk(const PVBOXCLIPBOARDDATAHDR pDataHdr, const void *pvChunk, uint32_t cbChunk, uint32_t fFlags = 0,868 uint32_t *pcbWritten = NULL);869 870 int ReadDirectory(PVBOXCLIPBOARDDIRDATA *ppDirData);871 int WriteDirectory(const PVBOXCLIPBOARDDIRDATA pDirData);872 873 int ReadFileHdr(PVBOXCLIPBOARDFILEHDR *ppFileHdr);874 int WriteFileHdr(const PVBOXCLIPBOARDFILEHDR pFileHdr);875 876 int ReadFileData(void *pvData, uint32_t cbData, uint32_t fFlags = 0, uint32_t *pcbRead = NULL);877 int WriteFileData(void *pvData, uint32_t cbData, uint32_t fFlags = 0, uint32_t *pcbWritten = NULL);878 879 void Reset(void);880 881 public:882 883 int OnWrite(PSHAREDCLIPBOARDPROVIDERWRITEPARMS pParms);884 885 protected:886 887 SharedClipboardProviderHostService(SharedClipboardArea *pArea);888 889 protected:890 891 /** Pointer to associated clipboard area. */892 SharedClipboardArea *m_pArea;893 };894 #endif /* VBOX_WITH_SHARED_CLIPBOARD_HOST */895 #endif896 897 730 struct _SHAREDCLIPBOARDURITRANSFER; 898 731 typedef _SHAREDCLIPBOARDURITRANSFER *PSHAREDCLIPBOARDURITRANSFER; … … 922 755 SHAREDCLIPBOARDTRANSFERCALLBACKDECLVOID(TRANSFERPREPARE) 923 756 SHAREDCLIPBOARDTRANSFERCALLBACKDECLVOID(TRANSFERSTARTED) 924 SHAREDCLIPBOARDTRANSFERCALLBACKDECLVOID(DATAH DRCOMPLETE)757 SHAREDCLIPBOARDTRANSFERCALLBACKDECLVOID(DATAHEADERCOMPLETE) 925 758 SHAREDCLIPBOARDTRANSFERCALLBACKDECLVOID(DATACHUNKCOMPLETE) 759 SHAREDCLIPBOARDTRANSFERCALLBACKDECL (TRANSFERCOMPLETE, int rc) 926 760 SHAREDCLIPBOARDTRANSFERCALLBACKDECLVOID(TRANSFERCANCELED) 927 SHAREDCLIPBOARDTRANSFERCALLBACKDECL (TRANSFERCOMPLETE, int rc)928 761 SHAREDCLIPBOARDTRANSFERCALLBACKDECL (TRANSFERERROR, int rc) 929 762 … … 941 774 SHAREDCLIPBOARDTRANSFERCALLBACKMEMBER(TRANSFERSTARTED, pfnTransferStarted); 942 775 /** Function pointer, called when reading / writing the meta data header is complete. */ 943 SHAREDCLIPBOARDTRANSFERCALLBACKMEMBER(DATAH DRCOMPLETE, pfnDataHeaderComplete);776 SHAREDCLIPBOARDTRANSFERCALLBACKMEMBER(DATAHEADERCOMPLETE, pfnDataHeaderComplete); 944 777 /** Function pointer, called when reading / writing the meta data is complete. */ 945 778 SHAREDCLIPBOARDTRANSFERCALLBACKMEMBER(DATACHUNKCOMPLETE, pfnDataComplete); … … 979 812 /** The transfer's state (for SSM, later). */ 980 813 SHAREDCLIPBOARDURITRANSFERSTATE State; 814 SHAREDCLIPBOARDURITRANSFEREVENTS Events; 981 815 /** The transfer's own (local) area, if any (can be NULL if not needed). 982 816 * The area itself has a clipboard area ID assigned. … … 1005 839 /** Critical section for serializing access. */ 1006 840 RTCRITSECT CritSect; 1007 /** List of active transfers. 1008 * Use a list or something lateron. */ 1009 RTLISTANCHOR List; 841 /** List of transfers. */ 842 RTLISTANCHOR List; 1010 843 /** Number of running (concurrent) transfers. 1011 844 * At the moment we only support only one transfer per client at a time. */ … … 1014 847 * At the moment we only support only one transfer per client at a time. */ 1015 848 uint32_t cMaxRunning; 1016 #ifdef DEBUG 1017 uint32_t cTransfer; 1018 #endif 849 /** Number of total transfers (in list). */ 850 uint32_t cTransfers; 1019 851 } SHAREDCLIPBOARDURICTX, *PSHAREDCLIPBOARDURICTX; 1020 852 … … 1040 872 void SharedClipboardURITransferSetCallbacks(PSHAREDCLIPBOARDURITRANSFER pTransfer, 1041 873 PSHAREDCLIPBOARDURITRANSFERCALLBACKS pCallbacks); 1042 int SharedClipboardURITransferSetDataHeader(PSHAREDCLIPBOARDURITRANSFER pTransfer, PVBOXCLIPBOARDDATAHDR pDataHdr); 1043 int SharedClipboardURITransferSetDataChunk(PSHAREDCLIPBOARDURITRANSFER pTransfer, PVBOXCLIPBOARDDATACHUNK pDataChunk); 874 875 int SharedClipboardURITransferPayloadAlloc(uint32_t uID, const void *pvData, uint32_t cbData, 876 PSHAREDCLIPBOARDURITRANSFERPAYLOAD *ppPayload); 877 void SharedClipboardURITransferPayloadFree(PSHAREDCLIPBOARDURITRANSFERPAYLOAD pPayload); 878 879 int SharedClipboardURITransferEventRegister(PSHAREDCLIPBOARDURITRANSFER pTransfer, uint32_t uID); 880 int SharedClipboardURITransferEventUnregister(PSHAREDCLIPBOARDURITRANSFER pTransfer, uint32_t uID); 881 int SharedClipboardURITransferEventWait(PSHAREDCLIPBOARDURITRANSFER pTransfer, uint32_t uID, RTMSINTERVAL uTimeoutMs, 882 PSHAREDCLIPBOARDURITRANSFERPAYLOAD *ppPayload); 883 int SharedClipboardURITransferEventSignal(PSHAREDCLIPBOARDURITRANSFER pTransfer, uint32_t uID, PSHAREDCLIPBOARDURITRANSFERPAYLOAD pPayload); 1044 884 1045 885 int SharedClipboardURITransferMetaDataAdd(PSHAREDCLIPBOARDURITRANSFER pTransfer, const void *pvMeta, uint32_t cbMeta); … … 1059 899 PSHAREDCLIPBOARDURITRANSFER SharedClipboardURICtxGetTransfer(PSHAREDCLIPBOARDURICTX pURI, uint32_t uIdx); 1060 900 uint32_t SharedClipboardURICtxGetRunningTransfers(PSHAREDCLIPBOARDURICTX pURI); 901 uint32_t SharedClipboardURICtxGetTotalTransfers(PSHAREDCLIPBOARDURICTX pURI); 1061 902 void SharedClipboardURICtxTransfersCleanup(PSHAREDCLIPBOARDURICTX pURI); 1062 903 bool SharedClipboardURICtxTransfersMaximumReached(PSHAREDCLIPBOARDURICTX pURI);
Note:
See TracChangeset
for help on using the changeset viewer.