VirtualBox

source: vbox/trunk/include/VBox/GuestHost/SharedClipboard.h@ 80846

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

Shared Clipboard/URI: Build fix.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.6 KB
Line 
1/** @file
2 * Shared Clipboard - Common guest and host Code.
3 */
4
5/*
6 * Copyright (C) 2006-2019 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef VBOX_INCLUDED_GuestHost_SharedClipboard_h
27#define VBOX_INCLUDED_GuestHost_SharedClipboard_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <iprt/cdefs.h>
33#include <iprt/list.h>
34#include <iprt/types.h>
35
36/** A single Shared Clipboard format. */
37typedef uint32_t SHCLFORMAT;
38/** Pointer to a single Shared Clipboard format. */
39typedef SHCLFORMAT *PSHCLFORMAT;
40
41/** Bit map of Shared Clipboard formats. */
42typedef uint32_t SHCLFORMATS;
43/** Pointer to a bit map of Shared Clipboard formats. */
44typedef SHCLFORMATS *PSHCLFORMATS;
45
46/**
47 * Supported data formats for Shared Clipboard. Bit mask.
48 */
49/** No format set. */
50#define VBOX_SHARED_CLIPBOARD_FMT_NONE 0
51/** Shared Clipboard format is an Unicode text. */
52#define VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT RT_BIT(0)
53/** Shared Clipboard format is bitmap (BMP / DIB). */
54#define VBOX_SHARED_CLIPBOARD_FMT_BITMAP RT_BIT(1)
55/** Shared Clipboard format is HTML. */
56#define VBOX_SHARED_CLIPBOARD_FMT_HTML RT_BIT(2)
57#ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
58/** Shared Clipboard format is an URI list. */
59#define VBOX_SHARED_CLIPBOARD_FMT_URI_LIST RT_BIT(3)
60#endif
61
62/**
63 * Structure for keeping a generic Shared Clipboard data block.
64 */
65typedef struct _SHCLDATABLOCK
66{
67 /** Clipboard format this data block represents. */
68 SHCLFORMAT uFormat;
69 /** Pointer to actual data block. */
70 void *pvData;
71 /** Size (in bytes) of actual data block. */
72 uint32_t cbData;
73} SHCLDATABLOCK, *PSHCLDATABLOCK;
74
75/**
76 * Structure for keeping a Shared Clipboard data read request.
77 */
78typedef struct _SHCLDATAREQ
79{
80 /** In which format the data needs to be sent. */
81 SHCLFORMAT uFmt;
82 /** Read flags; currently unused. */
83 uint32_t fFlags;
84 /** Maximum data (in byte) can be sent. */
85 uint32_t cbSize;
86} SHCLDATAREQ, *PSHCLDATAREQ;
87
88/**
89 * Structure for keeping Shared Clipboard formats specifications.
90 */
91typedef struct _SHCLFORMATDATA
92{
93 /** Available format(s) as bit map. */
94 SHCLFORMATS uFormats;
95 /** Formats flags. Currently unused. */
96 uint32_t fFlags;
97} SHCLFORMATDATA, *PSHCLFORMATDATA;
98
99/**
100 * Structure for an (optional) Shared Clipboard event payload.
101 */
102typedef struct _SHCLEVENTPAYLOAD
103{
104 /** Payload ID; currently unused. */
105 uint32_t uID;
106 /** Pointer to actual payload data. */
107 void *pvData;
108 /** Size (in bytes) of actual payload data. */
109 uint32_t cbData;
110} SHCLEVENTPAYLOAD, *PSHCLEVENTPAYLOAD;
111
112/** Defines an event source ID. */
113typedef uint16_t SHCLEVENTSOURCEID;
114/** Defines a pointer to a event source ID. */
115typedef SHCLEVENTSOURCEID *PSHCLEVENTSOURCEID;
116
117/** Defines an event ID. */
118typedef uint32_t SHCLEVENTID;
119/** Defines a pointer to a event source ID. */
120typedef SHCLEVENTID *PSHCLEVENTID;
121
122/** Maximum number of concurrent Shared Clipboard client sessions a VM can have. */
123#define VBOX_SHARED_CLIPBOARD_MAX_SESSIONS 32
124/** Maximum number of concurrent Shared Clipboard transfers a single
125 * client can have. */
126#define VBOX_SHARED_CLIPBOARD_MAX_TRANSFERS _2K
127/** Maximum number of events a single Shared Clipboard transfer can have. */
128#define VBOX_SHARED_CLIPBOARD_MAX_EVENTS _64K
129
130/**
131 * Creates a context ID out of a client ID, a transfer ID and a count.
132 */
133#define VBOX_SHARED_CLIPBOARD_CONTEXTID_MAKE(uSessionID, uTransferID, uEventID) \
134 ( (uint32_t)((uSessionID) & 0x1f) << 27 \
135 | (uint32_t)((uTransferID) & 0x7ff) << 16 \
136 | (uint32_t)((uEventID) & 0xffff) \
137 )
138/** Creates a context ID out of a session ID. */
139#define VBOX__SHARED_CLIPBOARD_CONTEXTID_MAKE_SESSION(uSessionID) \
140 ((uint32_t)((uSessionID) & 0x1f) << 27)
141/** Gets the session ID out of a context ID. */
142#define VBOX_SHARED_CLIPBOARD_CONTEXTID_GET_SESSION(uContextID) \
143 (((uContextID) >> 27) & 0x1f)
144/** Gets the transfer ID out of a context ID. */
145#define VBO_SHARED_CLIPBOARD_CONTEXTID_GET_TRANSFER(uContextID) \
146 (((uContextID) >> 16) & 0x7ff)
147/** Gets the transfer event out of a context ID. */
148#define VBOX_SHARED_CLIPBOARD_CONTEXTID_GET_EVENT(uContextID) \
149 ((uContextID) & 0xffff)
150
151/**
152 * Structure for maintaining a Shared Clipboard event.
153 */
154typedef struct _SHCLEVENT
155{
156 /** List node. */
157 RTLISTNODE Node;
158 /** The event's ID, for self-reference. */
159 SHCLEVENTID uID;
160 /** Event semaphore for signalling the event. */
161 RTSEMEVENT hEventSem;
162 /** Payload to this event. Optional and can be NULL. */
163 PSHCLEVENTPAYLOAD pPayload;
164} SHCLEVENT, *PSHCLEVENT;
165
166/**
167 * Structure for maintaining a Shared Clipboard event source.
168 *
169 * Each event source maintains an own counter for events, so that
170 * it can be used in different contexts.
171 */
172typedef struct _SHCLEVENTSOURCE
173{
174 /** The event source' ID. */
175 SHCLEVENTSOURCEID uID;
176 /** Next upcoming event ID. */
177 SHCLEVENTID uEventIDNext;
178 /** List of events (PSHCLEVENT). */
179 RTLISTANCHOR lstEvents;
180} SHCLEVENTSOURCE, *PSHCLEVENTSOURCE;
181
182int SharedClipboardPayloadAlloc(uint32_t uID, const void *pvData, uint32_t cbData,
183 PSHCLEVENTPAYLOAD *ppPayload);
184void SharedClipboardPayloadFree(PSHCLEVENTPAYLOAD pPayload);
185
186int SharedClipboardEventSourceCreate(PSHCLEVENTSOURCE pSource, SHCLEVENTSOURCEID uID);
187void SharedClipboardEventSourceDestroy(PSHCLEVENTSOURCE pSource);
188
189SHCLEVENTID SharedClipboardEventIDGenerate(PSHCLEVENTSOURCE pSource);
190SHCLEVENTID SharedClipboardEventGetLast(PSHCLEVENTSOURCE pSource);
191int SharedClipboardEventRegister(PSHCLEVENTSOURCE pSource, SHCLEVENTID uID);
192int SharedClipboardEventUnregister(PSHCLEVENTSOURCE pSource, SHCLEVENTID uID);
193int SharedClipboardEventWait(PSHCLEVENTSOURCE pSource, SHCLEVENTID uID, RTMSINTERVAL uTimeoutMs,
194 PSHCLEVENTPAYLOAD* ppPayload);
195int SharedClipboardEventSignal(PSHCLEVENTSOURCE pSource, SHCLEVENTID uID, PSHCLEVENTPAYLOAD pPayload);
196void SharedClipboardEventPayloadDetach(PSHCLEVENTSOURCE pSource, SHCLEVENTID uID);
197
198/**
199 * Enumeration to specify the Shared Clipboard URI source type.
200 */
201typedef enum SHCLSOURCE
202{
203 /** Invalid source type. */
204 SHCLSOURCE_INVALID = 0,
205 /** Source is local. */
206 SHCLSOURCE_LOCAL,
207 /** Source is remote. */
208 SHCLSOURCE_REMOTE,
209 /** The usual 32-bit hack. */
210 SHCLSOURCE_32Bit_Hack = 0x7fffffff
211} SHCLSOURCE;
212
213/** Opaque data structure for the X11/VBox frontend/glue code. */
214struct _SHCLCONTEXT;
215typedef struct _SHCLCONTEXT SHCLCONTEXT;
216typedef struct _SHCLCONTEXT *PSHCLCONTEXT;
217
218/** Opaque data structure for the X11/VBox backend code. */
219struct _CLIPBACKEND;
220typedef struct _CLIPBACKEND CLIPBACKEND;
221
222/** Opaque request structure for X11 clipboard data.
223 * @todo All use of single and double underscore prefixes is banned! */
224struct _CLIPREADCBREQ;
225typedef struct _CLIPREADCBREQ CLIPREADCBREQ;
226
227/* APIs exported by the X11 backend */
228extern CLIPBACKEND *ClipConstructX11(SHCLCONTEXT *pFrontend, bool fHeadless);
229extern void ClipDestructX11(CLIPBACKEND *pBackend);
230extern int ClipStartX11(CLIPBACKEND *pBackend, bool grab);
231extern int ClipStopX11(CLIPBACKEND *pBackend);
232extern int ClipAnnounceFormatToX11(CLIPBACKEND *pBackend, SHCLFORMATS vboxFormats);
233extern int ClipRequestDataFromX11(CLIPBACKEND *pBackend, SHCLFORMATS vboxFormat, CLIPREADCBREQ *pReq);
234
235/* APIs exported by the X11/VBox frontend */
236extern int ClipRequestDataForX11(SHCLCONTEXT *pCtx, uint32_t u32Format, void **ppv, uint32_t *pcb);
237extern void ClipReportX11Formats(SHCLCONTEXT *pCtx, uint32_t u32Formats);
238extern void ClipRequestFromX11CompleteCallback(SHCLCONTEXT *pCtx, int rc, CLIPREADCBREQ *pReq, void *pv, uint32_t cb);
239#endif /* !VBOX_INCLUDED_GuestHost_SharedClipboard_h */
240
Note: See TracBrowser for help on using the repository browser.

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