VirtualBox

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

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

GuestHost/SharedClipboard.h: Got rid of all the leading underscores that I could spot. Shuffled the members of SHCLDATABLOCK so we save 8 bytes on 64-bit machines. bugref:9437

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.2 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/types.h>
33#include <iprt/list.h>
34
35/**
36 * Shared Clipboard transfer direction.
37 */
38typedef enum SHCLTRANSFERDIR
39{
40 /** Unknown transfer directory. */
41 SHCLTRANSFERDIR_UNKNOWN = 0,
42 /** Read transfer (from source). */
43 SHCLTRANSFERDIR_FROM_REMOTE,
44 /** Write transfer (to target). */
45 SHCLTRANSFERDIR_TO_REMOTE,
46 /** The usual 32-bit hack. */
47 SHCLTRANSFERDIR_32BIT_HACK = 0x7fffffff
48} SHCLTRANSFERDIR;
49/** Pointer to a shared clipboard transfer direction. */
50typedef SHCLTRANSFERDIR *PSHCLTRANSFERDIR;
51
52
53/** A single Shared Clipboard format. */
54typedef uint32_t SHCLFORMAT;
55/** Pointer to a single Shared Clipboard format. */
56typedef SHCLFORMAT *PSHCLFORMAT;
57
58/** Bit map of Shared Clipboard formats. */
59typedef uint32_t SHCLFORMATS;
60/** Pointer to a bit map of Shared Clipboard formats. */
61typedef SHCLFORMATS *PSHCLFORMATS;
62
63/** @name VBOX_SHCL_FMT_XXX - Data formats (flags) for Shared Clipboard.
64 * @todo r=bird: Wrong header, belongs in the host service!
65 * @{
66 */
67/** No format set. */
68#define VBOX_SHCL_FMT_NONE 0
69/** Shared Clipboard format is an Unicode text. */
70#define VBOX_SHCL_FMT_UNICODETEXT RT_BIT(0)
71/** Shared Clipboard format is bitmap (BMP / DIB). */
72#define VBOX_SHCL_FMT_BITMAP RT_BIT(1)
73/** Shared Clipboard format is HTML. */
74#define VBOX_SHCL_FMT_HTML RT_BIT(2)
75#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
76/** Shared Clipboard format is a transfer list. */
77# define VBOX_SHCL_FMT_URI_LIST RT_BIT(3)
78#endif
79/** @} */
80
81/**
82 * Generic Shared Clipboard data block.
83 */
84typedef struct SHCLDATABLOCK
85{
86 /** Clipboard format this data block represents. */
87 SHCLFORMAT uFormat;
88 /** Size (in bytes) of actual data block. */
89 uint32_t cbData;
90 /** Pointer to actual data block. */
91 void *pvData;
92} SHCLDATABLOCK;
93/** Pointer to a generic shared clipboard data block. */
94typedef SHCLDATABLOCK *PSHCLDATABLOCK;
95
96/**
97 * Shared Clipboard data read request.
98 */
99typedef struct SHCLDATAREQ
100{
101 /** In which format the data needs to be sent. */
102 SHCLFORMAT uFmt;
103 /** Read flags; currently unused. */
104 uint32_t fFlags;
105 /** Maximum data (in byte) can be sent. */
106 uint32_t cbSize;
107} SHCLDATAREQ;
108/** Pointer to a shared clipboard data request. */
109typedef SHCLDATAREQ *PSHCLDATAREQ;
110
111/**
112 * Shared Clipboard formats specification.
113 */
114typedef struct SHCLFORMATDATA
115{
116 /** Available format(s) as bit map. */
117 SHCLFORMATS Formats;
118 /** Formats flags. Currently unused. */
119 uint32_t fFlags;
120} SHCLFORMATDATA;
121/** Pointer to a shared clipboard formats specification. */
122typedef SHCLFORMATDATA *PSHCLFORMATDATA;
123
124/**
125 * Shared Clipboard event payload (optional).
126 */
127typedef struct SHCLEVENTPAYLOAD
128{
129 /** Payload ID; currently unused. */
130 uint32_t uID;
131 /** Size (in bytes) of actual payload data. */
132 uint32_t cbData;
133 /** Pointer to actual payload data. */
134 void *pvData;
135} SHCLEVENTPAYLOAD;
136/** Pointer to a shared clipboard event payload. */
137typedef SHCLEVENTPAYLOAD *PSHCLEVENTPAYLOAD;
138
139/** A shared clipboard event source ID. */
140typedef uint16_t SHCLEVENTSOURCEID;
141/** Pointer to a shared clipboard event source ID. */
142typedef SHCLEVENTSOURCEID *PSHCLEVENTSOURCEID;
143
144/** A shared clipboard session ID. */
145typedef uint16_t SHCLSESSIONID;
146/** Pointer to a shared clipboard session ID. */
147typedef SHCLSESSIONID *PSHCLSESSIONID;
148/** NIL shared clipboard session ID. */
149#define NIL_SHCLSESSIONID UINT16_MAX
150
151/** A shared clipboard transfer ID. */
152typedef uint16_t SHCLTRANSFERID;
153/** Pointer to a shared clipboard transfer ID. */
154typedef SHCLTRANSFERID *PSHCLTRANSFERID;
155/** NIL shared clipboardtransfer ID. */
156#define NIL_SHCLTRANSFERID UINT16_MAX
157
158/** A shared clipboard event ID. */
159typedef uint32_t SHCLEVENTID;
160/** Pointer to a shared clipboard event source ID. */
161typedef SHCLEVENTID *PSHCLEVENTID;
162/** NIL shared clipboard event ID. */
163#define NIL_SHCLEVENTID UINT32_MAX
164
165/** Maximum number of concurrent Shared Clipboard client sessions a VM can have. */
166#define VBOX_SHCL_MAX_SESSIONS (UINT16_MAX - 1)
167/** Maximum number of concurrent Shared Clipboard transfers a single client can have. */
168#define VBOX_SHCL_MAX_TRANSFERS (UINT16_MAX - 1)
169/** Maximum number of events a single Shared Clipboard transfer can have. */
170#define VBOX_SHCL_MAX_EVENTS (UINT32_MAX - 1)
171
172/**
173 * Creates a context ID out of a client ID, a transfer ID and an event ID (count).
174 */
175#define VBOX_SHCL_CONTEXTID_MAKE(a_idSession, a_idTransfer, a_idEvent) \
176 ( ((uint64_t)((a_idSession) & 0xffff) << 48) \
177 | ((uint64_t)((a_idTransfer) & 0xffff) << 32) \
178 | ((uint32_t) (a_idEvent)) \
179 )
180/** Creates a context ID out of a session ID. */
181#define VBOX_SHCL_CONTEXTID_MAKE_SESSION(a_idSession) VBOX_SHCL_CONTEXTID_MAKE(a_idSession, 0, 0)
182/** Gets the session ID out of a context ID. */
183#define VBOX_SHCL_CONTEXTID_GET_SESSION(a_idContext) ( (uint16_t)(((a_idContext) >> 48) & UINT16_MAX) )
184/** Gets the transfer ID out of a context ID. */
185#define VBOX_SHCL_CONTEXTID_GET_TRANSFER(a_idContext) ( (uint16_t)(((a_idContext) >> 32) & UINT16_MAX) )
186/** Gets the transfer event out of a context ID. */
187#define VBOX_SHCL_CONTEXTID_GET_EVENT(a_idContext) ( (uint32_t)( (a_idContext) & UINT32_MAX) )
188
189/**
190 * Shared Clipboard event.
191 */
192typedef struct SHCLEVENT
193{
194 /** List node. */
195 RTLISTNODE Node;
196 /** The event's ID, for self-reference. */
197 SHCLEVENTID uID;
198 /** Event semaphore for signalling the event. */
199 RTSEMEVENT hEventSem;
200 /** Payload to this event, optional (NULL). */
201 PSHCLEVENTPAYLOAD pPayload;
202} SHCLEVENT;
203/** Pointer to a shared clipboard event. */
204typedef SHCLEVENT *PSHCLEVENT;
205
206/**
207 * Shared Clipboard event source.
208 *
209 * Each event source maintains an own counter for events, so that it can be used
210 * in different contexts.
211 */
212typedef struct SHCLEVENTSOURCE
213{
214 /** The event source ID. */
215 SHCLEVENTSOURCEID uID;
216 /** Next upcoming event ID. */
217 SHCLEVENTID uEventIDNext;
218 /** List of events (PSHCLEVENT). */
219 RTLISTANCHOR lstEvents;
220} SHCLEVENTSOURCE;
221/** Pointer to a shared clipboard event source. */
222typedef SHCLEVENTSOURCE *PSHCLEVENTSOURCE;
223
224/** @name Shared Clipboard data payload functions.
225 * @{
226 */
227int ShClPayloadAlloc(uint32_t uID, const void *pvData, uint32_t cbData, PSHCLEVENTPAYLOAD *ppPayload);
228void ShClPayloadFree(PSHCLEVENTPAYLOAD pPayload);
229/** @} */
230
231/** @name Shared Clipboard event source functions.
232 * @{
233 */
234int ShClEventSourceCreate(PSHCLEVENTSOURCE pSource, SHCLEVENTSOURCEID idEvtSrc);
235void ShClEventSourceDestroy(PSHCLEVENTSOURCE pSource);
236void ShClEventSourceReset(PSHCLEVENTSOURCE pSource);
237/** @} */
238
239/** @name Shared Clipboard event functions.
240 * @{
241 */
242SHCLEVENTID ShClEventIDGenerate(PSHCLEVENTSOURCE pSource);
243SHCLEVENTID ShClEventGetLast(PSHCLEVENTSOURCE pSource);
244int ShClEventRegister(PSHCLEVENTSOURCE pSource, SHCLEVENTID idEvent);
245int ShClEventUnregister(PSHCLEVENTSOURCE pSource, SHCLEVENTID idEvent);
246int ShClEventWait(PSHCLEVENTSOURCE pSource, SHCLEVENTID idEvent, RTMSINTERVAL uTimeoutMs, PSHCLEVENTPAYLOAD *ppPayload);
247int ShClEventSignal(PSHCLEVENTSOURCE pSource, SHCLEVENTID idEvent, PSHCLEVENTPAYLOAD pPayload);
248void ShClEventPayloadDetach(PSHCLEVENTSOURCE pSource, SHCLEVENTID idEvent);
249/** @} */
250
251/**
252 * Shared Clipboard transfer source type.
253 */
254typedef enum SHCLSOURCE
255{
256 /** Invalid source type. */
257 SHCLSOURCE_INVALID = 0,
258 /** Source is local. */
259 SHCLSOURCE_LOCAL,
260 /** Source is remote. */
261 SHCLSOURCE_REMOTE,
262 /** The usual 32-bit hack. */
263 SHCLSOURCE_32BIT_HACK = 0x7fffffff
264} SHCLSOURCE;
265
266/** Opaque data structure for the X11/VBox frontend/glue code.
267 * @{ */
268struct SHCLCONTEXT;
269typedef struct SHCLCONTEXT SHCLCONTEXT;
270/** @} */
271/** Pointer to opaque data structure the X11/VBox frontend/glue code. */
272typedef SHCLCONTEXT *PSHCLCONTEXT;
273
274/** Opaque request structure for X11 clipboard data.
275 * @{ */
276struct CLIPREADCBREQ;
277typedef struct CLIPREADCBREQ CLIPREADCBREQ;
278/** @} */
279
280#endif /* !VBOX_INCLUDED_GuestHost_SharedClipboard_h */
281
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