1 | /* $Id: VBoxSharedClipboardSvc-internal.h 79366 2019-06-26 15:59:30Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Shared Clipboard Service - Internal header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2019 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef VBOX_INCLUDED_SRC_SharedClipboard_VBoxSharedClipboardSvc_internal_h
|
---|
19 | #define VBOX_INCLUDED_SRC_SharedClipboard_VBoxSharedClipboardSvc_internal_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #include <iprt/list.h>
|
---|
25 |
|
---|
26 | #include <VBox/hgcmsvc.h>
|
---|
27 | #include <VBox/log.h>
|
---|
28 |
|
---|
29 | #include <VBox/GuestHost/SharedClipboard.h>
|
---|
30 | #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
|
---|
31 | # include <iprt/semaphore.h>
|
---|
32 | # include <VBox/GuestHost/SharedClipboard-uri.h>
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
|
---|
36 | /**
|
---|
37 | * Structure for handling a single URI object context.
|
---|
38 | */
|
---|
39 | typedef struct _VBOXCLIPBOARDCLIENTURIOBJCTX
|
---|
40 | {
|
---|
41 | /** Pointer to current object being processed. */
|
---|
42 | SharedClipboardURIObject *pObj;
|
---|
43 | } VBOXCLIPBOARDCLIENTURIOBJCTX, *PVBOXCLIPBOARDCLIENTURIOBJCTX;
|
---|
44 |
|
---|
45 | struct VBOXCLIPBOARDCLIENTSTATE;
|
---|
46 | #endif /* VBOX_WITH_SHARED_CLIPBOARD_URI_LIST */
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * Structure for keeping generic client state data within the Shared Clipboard host service.
|
---|
50 | * This structure needs to be serializable by SSM.
|
---|
51 | */
|
---|
52 | struct VBOXCLIPBOARDCLIENTSTATE
|
---|
53 | {
|
---|
54 | struct VBOXCLIPBOARDCLIENTSTATE *pNext;
|
---|
55 | struct VBOXCLIPBOARDCLIENTSTATE *pPrev;
|
---|
56 |
|
---|
57 | VBOXCLIPBOARDCONTEXT *pCtx;
|
---|
58 |
|
---|
59 | uint32_t u32ClientID;
|
---|
60 |
|
---|
61 | SHAREDCLIPBOARDSOURCE enmSource;
|
---|
62 |
|
---|
63 | /** The guest is waiting for a message. */
|
---|
64 | bool fAsync;
|
---|
65 | /** The guest is waiting for data from the host */
|
---|
66 | bool fReadPending;
|
---|
67 | /** Whether the host host has sent a quit message. */
|
---|
68 | bool fHostMsgQuit;
|
---|
69 | /** Whether the host host has requested reading clipboard data from the guest. */
|
---|
70 | bool fHostMsgReadData;
|
---|
71 | /** Whether the host host has reported its available formats. */
|
---|
72 | bool fHostMsgFormats;
|
---|
73 |
|
---|
74 | struct {
|
---|
75 | VBOXHGCMCALLHANDLE callHandle;
|
---|
76 | uint32_t cParms;
|
---|
77 | VBOXHGCMSVCPARM *paParms;
|
---|
78 | } async;
|
---|
79 |
|
---|
80 | struct {
|
---|
81 | VBOXHGCMCALLHANDLE callHandle;
|
---|
82 | uint32_t cParms;
|
---|
83 | VBOXHGCMSVCPARM *paParms;
|
---|
84 | } asyncRead;
|
---|
85 |
|
---|
86 | struct {
|
---|
87 | void *pv;
|
---|
88 | uint32_t cb;
|
---|
89 | uint32_t u32Format;
|
---|
90 | } data;
|
---|
91 |
|
---|
92 | uint32_t u32AvailableFormats;
|
---|
93 | uint32_t u32RequestedFormat;
|
---|
94 | };
|
---|
95 | typedef struct VBOXCLIPBOARDCLIENTSTATE *PVBOXCLIPBOARDCLIENTSTATE;
|
---|
96 |
|
---|
97 | /**
|
---|
98 | * Structure for keeping a HGCM client state within the Shared Clipboard host service.
|
---|
99 | */
|
---|
100 | typedef struct _VBOXCLIPBOARDCLIENTDATA
|
---|
101 | {
|
---|
102 | /** General client state data. */
|
---|
103 | VBOXCLIPBOARDCLIENTSTATE State;
|
---|
104 | #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
|
---|
105 | SHAREDCLIPBOARDURICTX URI;
|
---|
106 | #endif
|
---|
107 | } VBOXCLIPBOARDCLIENTDATA, *PVBOXCLIPBOARDCLIENTDATA;
|
---|
108 |
|
---|
109 | /*
|
---|
110 | * The service functions. Locking is between the service thread and the platform-dependent (window) thread.
|
---|
111 | */
|
---|
112 | int vboxSvcClipboardCompleteReadData(PVBOXCLIPBOARDCLIENTDATA pClientData, int rc, uint32_t cbActual);
|
---|
113 | uint32_t vboxSvcClipboardGetMode(void);
|
---|
114 | int vboxSvcClipboardReportMsg(PVBOXCLIPBOARDCLIENTDATA pClientData, uint32_t uMsg, uint32_t uFormats);
|
---|
115 | int vboxSvcClipboardSetSource(PVBOXCLIPBOARDCLIENTDATA pClientData, SHAREDCLIPBOARDSOURCE enmSource);
|
---|
116 |
|
---|
117 | # ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
|
---|
118 | bool vboxSvcClipboardURIMsgIsAllowed(uint32_t uMode, uint32_t uMsg);
|
---|
119 | int vboxSvcClipboardURIReportMsg(PVBOXCLIPBOARDCLIENTDATA pClientData, uint32_t u32Msg, uint32_t u32Formats);
|
---|
120 | bool vboxSvcClipboardURIReturnMsg(PVBOXCLIPBOARDCLIENTDATA pClientData, uint32_t cParms, VBOXHGCMSVCPARM paParms[]);
|
---|
121 | # endif /* VBOX_WITH_SHARED_CLIPBOARD_URI_LIST */
|
---|
122 |
|
---|
123 | /*
|
---|
124 | * Platform-dependent implementations.
|
---|
125 | */
|
---|
126 | int VBoxClipboardSvcImplInit(void);
|
---|
127 | void VBoxClipboardSvcImplDestroy(void);
|
---|
128 |
|
---|
129 | int VBoxClipboardSvcImplConnect(PVBOXCLIPBOARDCLIENTDATA pClientData, bool fHeadless);
|
---|
130 | int VBoxClipboardSvcImplDisconnect(PVBOXCLIPBOARDCLIENTDATA pClientData);
|
---|
131 | int VBoxClipboardSvcImplFormatAnnounce(PVBOXCLIPBOARDCLIENTDATA pClientData, uint32_t u32Formats);
|
---|
132 | int VBoxClipboardSvcImplReadData(PVBOXCLIPBOARDCLIENTDATA pClientData, uint32_t u32Format, void *pv, uint32_t cb, uint32_t *pcbActual);
|
---|
133 | int VBoxClipboardSvcImplWriteData(PVBOXCLIPBOARDCLIENTDATA pClientData, void *pv, uint32_t cb, uint32_t u32Format);
|
---|
134 | /**
|
---|
135 | * Synchronise the contents of the host clipboard with the guest, called by the HGCM layer
|
---|
136 | * after a save and restore of the guest.
|
---|
137 | */
|
---|
138 | int VBoxClipboardSvcImplSync(PVBOXCLIPBOARDCLIENTDATA pClientData);
|
---|
139 |
|
---|
140 | #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
|
---|
141 | int VBoxSvcClipboardProviderImplURIReadDataHdr(PSHAREDCLIPBOARDPROVIDERCTX pCtx, PVBOXCLIPBOARDDATAHDR *ppDataHdr);
|
---|
142 | int VBoxSvcClipboardProviderImplURIWriteDataHdr(PSHAREDCLIPBOARDPROVIDERCTX pCtx, const PVBOXCLIPBOARDDATAHDR pDataHdr);
|
---|
143 | int VBoxSvcClipboardProviderImplURIReadDataChunk(PSHAREDCLIPBOARDPROVIDERCTX pCtx, const PVBOXCLIPBOARDDATAHDR pDataHdr, void *pvChunk, uint32_t cbChunk, uint32_t fFlags, uint32_t *pcbRead);
|
---|
144 | int VBoxSvcClipboardProviderImplURIWriteDataChunk(PSHAREDCLIPBOARDPROVIDERCTX pCtx, const PVBOXCLIPBOARDDATAHDR pDataHdr, const void *pvChunk, uint32_t cbChunk, uint32_t fFlags, uint32_t *pcbWritten);
|
---|
145 | int VBoxSvcClipboardProviderImplURIReadDir(PSHAREDCLIPBOARDPROVIDERCTX pCtx, PVBOXCLIPBOARDDIRDATA *ppDirData);
|
---|
146 | int VBoxSvcClipboardProviderImplURIWriteDir(PSHAREDCLIPBOARDPROVIDERCTX pCtx, const PVBOXCLIPBOARDDIRDATA pDirData);
|
---|
147 | int VBoxSvcClipboardProviderImplURIReadFileHdr(PSHAREDCLIPBOARDPROVIDERCTX pCtx, PVBOXCLIPBOARDFILEHDR *ppFileHdr);
|
---|
148 | int VBoxSvcClipboardProviderImplURIWriteFileHdr(PSHAREDCLIPBOARDPROVIDERCTX pCtx, const PVBOXCLIPBOARDFILEHDR pFileHdr);
|
---|
149 | int VBoxSvcClipboardProviderImplURIReadFileData(PSHAREDCLIPBOARDPROVIDERCTX pCtx, void *pvData, uint32_t cbData, uint32_t fFlags, uint32_t *pcbRead);
|
---|
150 | int VBoxSvcClipboardProviderImplURIWriteFileData(PSHAREDCLIPBOARDPROVIDERCTX pCtx, void *pvData, uint32_t cbData, uint32_t fFlags, uint32_t *pcbWritten);
|
---|
151 |
|
---|
152 | DECLCALLBACK(void) VBoxSvcClipboardURITransferPrepareCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData);
|
---|
153 | DECLCALLBACK(void) VBoxSvcClipboardURIDataHeaderCompleteCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData);
|
---|
154 | DECLCALLBACK(void) VBoxSvcClipboardURIDataCompleteCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData);
|
---|
155 | DECLCALLBACK(void) VBoxSvcClipboardURITransferCompleteCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData, int rc);
|
---|
156 | DECLCALLBACK(void) VBoxSvcClipboardURITransferCanceledCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData);
|
---|
157 | DECLCALLBACK(void) VBoxSvcClipboardURITransferErrorCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData, int rc);
|
---|
158 |
|
---|
159 | int VBoxClipboardSvcImplURITransferCreate(PVBOXCLIPBOARDCLIENTDATA pClientData, PSHAREDCLIPBOARDURITRANSFER pTransfer);
|
---|
160 | int VBoxClipboardSvcImplURITransferDestroy(PVBOXCLIPBOARDCLIENTDATA pClientData, PSHAREDCLIPBOARDURITRANSFER pTransfer);
|
---|
161 |
|
---|
162 | void VBoxClipboardSvcImplURIOnDataHeaderComplete(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData);
|
---|
163 | #endif
|
---|
164 |
|
---|
165 | /* Host unit testing interface */
|
---|
166 | #ifdef UNIT_TEST
|
---|
167 | uint32_t TestClipSvcGetMode(void);
|
---|
168 | #endif
|
---|
169 |
|
---|
170 | #endif /* !VBOX_INCLUDED_SRC_SharedClipboard_VBoxSharedClipboardSvc_internal_h */
|
---|
171 |
|
---|