VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-internal.h@ 80638

Last change on this file since 80638 was 80638, checked in by vboxsync, 5 years ago

Shared Clipboard: Build fix.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.0 KB
Line 
1/* $Id: VBoxSharedClipboardSvc-internal.h 80638 2019-09-06 17:06:51Z 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 <algorithm>
25#include <list>
26#include <map>
27
28#include <iprt/cpp/list.h> /* For RTCList. */
29#include <iprt/list.h>
30#include <iprt/semaphore.h>
31
32#include <VBox/hgcmsvc.h>
33#include <VBox/log.h>
34
35#include <VBox/HostServices/Service.h>
36#include <VBox/GuestHost/SharedClipboard.h>
37#include <VBox/GuestHost/SharedClipboard-uri.h>
38
39using namespace HGCM;
40
41#ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
42struct VBOXCLIPBOARDCLIENTSTATE;
43#endif /* VBOX_WITH_SHARED_CLIPBOARD_URI_LIST */
44
45/**
46 * Structure for keeping a Shared Clipboard HGCM message context.
47 */
48typedef struct _VBOXSHCLMSGCTX
49{
50 /** Context ID. */
51 uint32_t uContextID;
52} VBOXSHCLMSGCTX, *PVBOXSHCLMSGCTX;
53
54/**
55 * Structure for keeping a single HGCM message.
56 */
57typedef struct _VBOXCLIPBOARDCLIENTMSG
58{
59 /** Stored message type. */
60 uint32_t m_uMsg;
61 /** Number of stored HGCM parameters. */
62 uint32_t m_cParms;
63 /** Stored HGCM parameters. */
64 PVBOXHGCMSVCPARM m_paParms;
65 /** Message context. */
66 VBOXSHCLMSGCTX m_Ctx;
67} VBOXCLIPBOARDCLIENTMSG, *PVBOXCLIPBOARDCLIENTMSG;
68
69typedef struct VBOXCLIPBOARDCLIENTURISTATE
70{
71 /** Directory of the transfer to start. */
72 SHAREDCLIPBOARDURITRANSFERDIR enmTransferDir;
73} VBOXCLIPBOARDCLIENTURISTATE, *PVBOXCLIPBOARDCLIENTURISTATE;
74
75/**
76 * Structure for keeping generic client state data within the Shared Clipboard host service.
77 * This structure needs to be serializable by SSM (must be a POD type).
78 */
79typedef struct VBOXCLIPBOARDCLIENTSTATE
80{
81 struct VBOXCLIPBOARDCLIENTSTATE *pNext;
82 struct VBOXCLIPBOARDCLIENTSTATE *pPrev;
83
84 VBOXCLIPBOARDCONTEXT *pCtx;
85
86 /** The client's HGCM ID. */
87 uint32_t u32ClientID;
88 /** Optional protocol version the client uses. Set to 0 by default. */
89 uint32_t uProtocolVer;
90 /** Maximum chunk size to use for data transfers. Set to _64K by default. */
91 uint32_t cbChunkSize;
92 SHAREDCLIPBOARDSOURCE enmSource;
93 /** The client's URI state. */
94 VBOXCLIPBOARDCLIENTURISTATE URI;
95} VBOXCLIPBOARDCLIENTSTATE, *PVBOXCLIPBOARDCLIENTSTATE;
96
97typedef struct _VBOXCLIPBOARDCLIENTCMDCTX
98{
99 uint32_t uContextID;
100} VBOXCLIPBOARDCLIENTCMDCTX, *PVBOXCLIPBOARDCLIENTCMDCTX;
101
102typedef struct _VBOXCLIPBOARDCLIENT
103{
104 /** The client's HGCM client ID. */
105 uint32_t uClientID;
106 /** General client state data. */
107 VBOXCLIPBOARDCLIENTSTATE State;
108 /** The client's message queue (FIFO). */
109 RTCList<VBOXCLIPBOARDCLIENTMSG *> queueMsg;
110 /** The client's own event source. */
111 SHAREDCLIPBOARDEVENTSOURCE Events;
112#ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
113 /** URI context data. */
114 SHAREDCLIPBOARDURICTX URI;
115#endif
116 /** Structure for keeping the client's pending (deferred return) state.
117 * A client is in a deferred state when it asks for the next HGCM message,
118 * but the service can't provide it yet. That way a client will block (on the guest side, does not return)
119 * until the service can complete the call. */
120 struct
121 {
122 /** The client's HGCM call handle. Needed for completing a deferred call. */
123 VBOXHGCMCALLHANDLE hHandle;
124 /** Message type (function number) to use when completing the deferred call.
125 * A non-0 value means the client is in pending mode. */
126 uint32_t uType;
127 /** Parameter count to use when completing the deferred call. */
128 uint32_t cParms;
129 /** Parameters to use when completing the deferred call. */
130 PVBOXHGCMSVCPARM paParms;
131 } Pending;
132} VBOXCLIPBOARDCLIENT, *PVBOXCLIPBOARDCLIENT;
133
134/**
135 * Structure for keeping a single event source map entry.
136 * Currently empty.
137 */
138typedef struct _VBOXCLIPBOARDEVENTSOURCEMAPENTRY
139{
140} VBOXCLIPBOARDEVENTSOURCEMAPENTRY;
141
142/** Map holding information about connected HGCM clients. Key is the (unique) HGCM client ID.
143 * The value is a weak pointer to PVBOXCLIPBOARDCLIENT, which is owned by HGCM. */
144typedef std::map<uint32_t, PVBOXCLIPBOARDCLIENT> ClipboardClientMap;
145
146/** Map holding information about event sources. Key is the (unique) event source ID. */
147typedef std::map<VBOXCLIPBOARDEVENTSOURCEID, VBOXCLIPBOARDEVENTSOURCEMAPENTRY> ClipboardEventSourceMap;
148
149/** Simple queue (list) which holds deferred (waiting) clients. */
150typedef std::list<uint32_t> ClipboardClientQueue;
151
152/**
153 * Structure for keeping the Shared Clipboard service extension state.
154 *
155 * A service extension is optional, and can be installed by a host component
156 * to communicate with the Shared Clipboard host service.
157 */
158typedef struct _VBOXCLIPBOARDEXTSTATE
159{
160 /** Pointer to the actual service extension handle. */
161 PFNHGCMSVCEXT pfnExtension;
162 /** Opaque pointer to extension-provided data. Don't touch. */
163 void *pvExtension;
164 /** The HGCM client ID currently assigned to this service extension.
165 * At the moment only one HGCM client can be assigned per extension. */
166 uint32_t uClientID;
167 /** Whether the host service is reading clipboard data currently. */
168 bool fReadingData;
169 /** Whether the service extension has sent the clipboard formats while
170 * the the host service is reading clipboard data from it. */
171 bool fDelayedAnnouncement;
172 /** The actual clipboard formats announced while the host service
173 * is reading clipboard data from the extension. */
174 uint32_t uDelayedFormats;
175} VBOXCLIPBOARDEXTSTATE, *PVBOXCLIPBOARDEXTSTATE;
176
177/*
178 * The service functions. Locking is between the service thread and the platform-dependent (window) thread.
179 */
180int vboxSvcClipboardDataReadRequest(PVBOXCLIPBOARDCLIENT pClient, PSHAREDCLIPBOARDDATAREQ pDataReq, PVBOXCLIPBOARDEVENTID puEvent);
181int vboxSvcClipboardDataReadSignal(PVBOXCLIPBOARDCLIENT pClient, PVBOXCLIPBOARDCLIENTCMDCTX pCmdCtx, PSHAREDCLIPBOARDDATABLOCK pData);
182int vboxSvcClipboardFormatsReport(PVBOXCLIPBOARDCLIENT pClient, PSHAREDCLIPBOARDFORMATDATA pFormats);
183
184uint32_t vboxSvcClipboardGetMode(void);
185int vboxSvcClipboardSetSource(PVBOXCLIPBOARDCLIENT pClient, SHAREDCLIPBOARDSOURCE enmSource);
186
187void vboxSvcClipboardMsgQueueReset(PVBOXCLIPBOARDCLIENT pClient);
188PVBOXCLIPBOARDCLIENTMSG vboxSvcClipboardMsgAlloc(uint32_t uMsg, uint32_t cParms);
189void vboxSvcClipboardMsgFree(PVBOXCLIPBOARDCLIENTMSG pMsg);
190void vboxSvcClipboardMsgSetPeekReturn(PVBOXCLIPBOARDCLIENTMSG pMsg, PVBOXHGCMSVCPARM paDstParms, uint32_t cDstParms);
191int vboxSvcClipboardMsgAdd(PVBOXCLIPBOARDCLIENT pClient, PVBOXCLIPBOARDCLIENTMSG pMsg, bool fAppend);
192int vboxSvcClipboardMsgPeek(PVBOXCLIPBOARDCLIENT pClient, VBOXHGCMCALLHANDLE hCall, uint32_t cParms, VBOXHGCMSVCPARM paParms[], bool fWait);
193int vboxSvcClipboardMsgGet(PVBOXCLIPBOARDCLIENT pClient, VBOXHGCMCALLHANDLE hCall, uint32_t cParms, VBOXHGCMSVCPARM paParms[]);
194
195int vboxSvcClipboardClientWakeup(PVBOXCLIPBOARDCLIENT pClient);
196
197# ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
198int vboxSvcClipboardURITransferStart(PVBOXCLIPBOARDCLIENT pClient,
199 SHAREDCLIPBOARDURITRANSFERDIR enmDir, SHAREDCLIPBOARDSOURCE enmSource,
200 PSHAREDCLIPBOARDURITRANSFER *ppTransfer);
201bool vboxSvcClipboardURIMsgIsAllowed(uint32_t uMode, uint32_t uMsg);
202# endif /* VBOX_WITH_SHARED_CLIPBOARD_URI_LIST */
203
204/*
205 * Platform-dependent implementations.
206 */
207int VBoxClipboardSvcImplInit(void);
208void VBoxClipboardSvcImplDestroy(void);
209
210int VBoxClipboardSvcImplConnect(PVBOXCLIPBOARDCLIENT pClient, bool fHeadless);
211int VBoxClipboardSvcImplDisconnect(PVBOXCLIPBOARDCLIENT pClient);
212int VBoxClipboardSvcImplFormatAnnounce(PVBOXCLIPBOARDCLIENT pClient, PVBOXCLIPBOARDCLIENTCMDCTX pCmdCtx, PSHAREDCLIPBOARDFORMATDATA pFormats);
213/** @todo Document: Can return VINF_HGCM_ASYNC_EXECUTE to defer returning read data.*/
214int VBoxClipboardSvcImplReadData(PVBOXCLIPBOARDCLIENT pClient, PVBOXCLIPBOARDCLIENTCMDCTX pCmdCtx, PSHAREDCLIPBOARDDATABLOCK pData, uint32_t *pcbActual);
215int VBoxClipboardSvcImplWriteData(PVBOXCLIPBOARDCLIENT pClient, PVBOXCLIPBOARDCLIENTCMDCTX pCmdCtx, PSHAREDCLIPBOARDDATABLOCK pData);
216/**
217 * Synchronise the contents of the host clipboard with the guest, called by the HGCM layer
218 * after a save and restore of the guest.
219 */
220int VBoxClipboardSvcImplSync(PVBOXCLIPBOARDCLIENT pClient);
221
222#ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
223int vboxSvcClipboardURITransferOpen(PSHAREDCLIPBOARDPROVIDERCTX pCtx);
224DECLCALLBACK(int) vboxSvcClipboardURITransferClose(PSHAREDCLIPBOARDPROVIDERCTX pCtx);
225
226int vboxSvcClipboardURIGetRoots(PSHAREDCLIPBOARDPROVIDERCTX pCtx, PVBOXCLIPBOARDROOTLIST *ppRootList);
227
228int vboxSvcClipboardURIListOpen(PSHAREDCLIPBOARDPROVIDERCTX pCtx,
229 PVBOXCLIPBOARDLISTOPENPARMS pOpenParms, PSHAREDCLIPBOARDLISTHANDLE phList);
230int vboxSvcClipboardURIListClose(PSHAREDCLIPBOARDPROVIDERCTX pCtx, SHAREDCLIPBOARDLISTHANDLE hList);
231int vboxSvcClipboardURIListHdrRead(PSHAREDCLIPBOARDPROVIDERCTX pCtx, SHAREDCLIPBOARDLISTHANDLE hList,
232 PVBOXCLIPBOARDLISTHDR pListHdr);
233int vboxSvcClipboardURIListHdrWrite(PSHAREDCLIPBOARDPROVIDERCTX pCtx, SHAREDCLIPBOARDLISTHANDLE hList,
234 PVBOXCLIPBOARDLISTHDR pListHdr);
235int vboxSvcClipboardURIListEntryRead(PSHAREDCLIPBOARDPROVIDERCTX pCtx, SHAREDCLIPBOARDLISTHANDLE hList,
236 PVBOXCLIPBOARDLISTENTRY pListEntry);
237int vboxSvcClipboardURIListEntryWrite(PSHAREDCLIPBOARDPROVIDERCTX pCtx, SHAREDCLIPBOARDLISTHANDLE hList,
238 PVBOXCLIPBOARDLISTENTRY pListEntry);
239
240int vboxSvcClipboardURIObjOpen(PSHAREDCLIPBOARDPROVIDERCTX pCtx, PVBOXCLIPBOARDOBJOPENCREATEPARMS pCreateParms,
241 PSHAREDCLIPBOARDOBJHANDLE phObj);
242int vboxSvcClipboardURIObjClose(PSHAREDCLIPBOARDPROVIDERCTX pCtx, SHAREDCLIPBOARDOBJHANDLE hObj);
243int vboxSvcClipboardURIObjRead(PSHAREDCLIPBOARDPROVIDERCTX pCtx, SHAREDCLIPBOARDOBJHANDLE hObj,
244 void *pvData, uint32_t cbData, uint32_t fFlags, uint32_t *pcbRead);
245int vboxSvcClipboardURIObjWrite(PSHAREDCLIPBOARDPROVIDERCTX pCtx, SHAREDCLIPBOARDOBJHANDLE hObj,
246 void *pvData, uint32_t cbData, uint32_t fFlags, uint32_t *pcbWritten);
247
248DECLCALLBACK(void) VBoxSvcClipboardURITransferPrepareCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData);
249DECLCALLBACK(void) VBoxSvcClipboardURIDataHeaderCompleteCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData);
250DECLCALLBACK(void) VBoxSvcClipboardURIDataCompleteCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData);
251DECLCALLBACK(void) VBoxSvcClipboardURITransferCompleteCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData, int rc);
252DECLCALLBACK(void) VBoxSvcClipboardURITransferCanceledCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData);
253DECLCALLBACK(void) VBoxSvcClipboardURITransferErrorCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData, int rc);
254
255int VBoxClipboardSvcImplURITransferCreate(PVBOXCLIPBOARDCLIENT pClient, PSHAREDCLIPBOARDURITRANSFER pTransfer);
256int VBoxClipboardSvcImplURITransferDestroy(PVBOXCLIPBOARDCLIENT pClient, PSHAREDCLIPBOARDURITRANSFER pTransfer);
257#endif /*VBOX_WITH_SHARED_CLIPBOARD_URI_LIST */
258
259/* Host unit testing interface */
260#ifdef UNIT_TEST
261uint32_t TestClipSvcGetMode(void);
262#endif
263
264#endif /* !VBOX_INCLUDED_SRC_SharedClipboard_VBoxSharedClipboardSvc_internal_h */
265
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette