VirtualBox

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

Last change on this file since 93321 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.5 KB
Line 
1/** @file
2 * Shared Clipboard - Common guest and host Code.
3 */
4
5/*
6 * Copyright (C) 2006-2022 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/critsect.h>
33#include <iprt/types.h>
34#include <iprt/list.h>
35
36/** @name VBOX_SHCL_FMT_XXX - Data formats (flags) for Shared Clipboard.
37 * @{
38 */
39/** No format set. */
40#define VBOX_SHCL_FMT_NONE 0
41/** Shared Clipboard format is an Unicode text. */
42#define VBOX_SHCL_FMT_UNICODETEXT RT_BIT(0)
43/** Shared Clipboard format is bitmap (BMP / DIB). */
44#define VBOX_SHCL_FMT_BITMAP RT_BIT(1)
45/** Shared Clipboard format is HTML. */
46#define VBOX_SHCL_FMT_HTML RT_BIT(2)
47#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
48/** Shared Clipboard format is a transfer list. */
49# define VBOX_SHCL_FMT_URI_LIST RT_BIT(3)
50#endif
51/** @} */
52
53
54/** A single Shared Clipboard format (VBOX_SHCL_FMT_XXX). */
55typedef uint32_t SHCLFORMAT;
56/** Pointer to a single Shared Clipboard format (VBOX_SHCL_FMT_XXX). */
57typedef SHCLFORMAT *PSHCLFORMAT;
58
59/** Bit map (flags) of Shared Clipboard formats (VBOX_SHCL_FMT_XXX). */
60typedef uint32_t SHCLFORMATS;
61/** Pointer to a bit map of Shared Clipboard formats (VBOX_SHCL_FMT_XXX). */
62typedef SHCLFORMATS *PSHCLFORMATS;
63
64
65/**
66 * Shared Clipboard transfer direction.
67 */
68typedef enum SHCLTRANSFERDIR
69{
70 /** Unknown transfer directory. */
71 SHCLTRANSFERDIR_UNKNOWN = 0,
72 /** Read transfer (from source). */
73 SHCLTRANSFERDIR_FROM_REMOTE,
74 /** Write transfer (to target). */
75 SHCLTRANSFERDIR_TO_REMOTE,
76 /** The usual 32-bit hack. */
77 SHCLTRANSFERDIR_32BIT_HACK = 0x7fffffff
78} SHCLTRANSFERDIR;
79/** Pointer to a shared clipboard transfer direction. */
80typedef SHCLTRANSFERDIR *PSHCLTRANSFERDIR;
81
82
83/**
84 * Shared Clipboard data read request.
85 */
86typedef struct SHCLDATAREQ
87{
88 /** In which format the data needs to be sent. */
89 SHCLFORMAT uFmt;
90 /** Read flags; currently unused. */
91 uint32_t fFlags;
92 /** Maximum data (in byte) can be sent. */
93 uint32_t cbSize;
94} SHCLDATAREQ;
95/** Pointer to a shared clipboard data request. */
96typedef SHCLDATAREQ *PSHCLDATAREQ;
97
98/**
99 * Shared Clipboard event payload (optional).
100 */
101typedef struct SHCLEVENTPAYLOAD
102{
103 /** Payload ID; currently unused. */
104 uint32_t uID;
105 /** Size (in bytes) of actual payload data. */
106 uint32_t cbData;
107 /** Pointer to actual payload data. */
108 void *pvData;
109} SHCLEVENTPAYLOAD;
110/** Pointer to a shared clipboard event payload. */
111typedef SHCLEVENTPAYLOAD *PSHCLEVENTPAYLOAD;
112
113/** A shared clipboard event source ID. */
114typedef uint16_t SHCLEVENTSOURCEID;
115/** Pointer to a shared clipboard event source ID. */
116typedef SHCLEVENTSOURCEID *PSHCLEVENTSOURCEID;
117
118/** A shared clipboard session ID. */
119typedef uint16_t SHCLSESSIONID;
120/** Pointer to a shared clipboard session ID. */
121typedef SHCLSESSIONID *PSHCLSESSIONID;
122/** NIL shared clipboard session ID. */
123#define NIL_SHCLSESSIONID UINT16_MAX
124
125/** A shared clipboard transfer ID. */
126typedef uint16_t SHCLTRANSFERID;
127/** Pointer to a shared clipboard transfer ID. */
128typedef SHCLTRANSFERID *PSHCLTRANSFERID;
129/** NIL shared clipboardtransfer ID. */
130#define NIL_SHCLTRANSFERID UINT16_MAX
131
132/** A shared clipboard event ID. */
133typedef uint32_t SHCLEVENTID;
134/** Pointer to a shared clipboard event source ID. */
135typedef SHCLEVENTID *PSHCLEVENTID;
136/** NIL shared clipboard event ID. */
137#define NIL_SHCLEVENTID UINT32_MAX
138
139/** Pointer to a shared clipboard event source.
140 * Forward declaration, needed for SHCLEVENT. */
141typedef struct SHCLEVENTSOURCE *PSHCLEVENTSOURCE;
142
143/**
144 * Shared Clipboard event.
145 */
146typedef struct SHCLEVENT
147{
148 /** List node. */
149 RTLISTNODE Node;
150 /** Parent (source) this event belongs to. */
151 PSHCLEVENTSOURCE pParent;
152 /** The event's ID, for self-reference. */
153 SHCLEVENTID idEvent;
154 /** Reference count to this event. */
155 uint32_t cRefs;
156 /** Event semaphore for signalling the event. */
157 RTSEMEVENTMULTI hEvtMulSem;
158 /** Payload to this event, optional (NULL). */
159 PSHCLEVENTPAYLOAD pPayload;
160} SHCLEVENT;
161/** Pointer to a shared clipboard event. */
162typedef SHCLEVENT *PSHCLEVENT;
163
164/**
165 * Shared Clipboard event source.
166 *
167 * Each event source maintains an own counter for events, so that it can be used
168 * in different contexts.
169 */
170typedef struct SHCLEVENTSOURCE
171{
172 /** The event source ID. */
173 SHCLEVENTSOURCEID uID;
174 /** Critical section for serializing access. */
175 RTCRITSECT CritSect;
176 /** Next upcoming event ID. */
177 SHCLEVENTID idNextEvent;
178 /** List of events (PSHCLEVENT). */
179 RTLISTANCHOR lstEvents;
180} SHCLEVENTSOURCE;
181
182/** @name Shared Clipboard data payload functions.
183 * @{
184 */
185int ShClPayloadAlloc(uint32_t uID, const void *pvData, uint32_t cbData, PSHCLEVENTPAYLOAD *ppPayload);
186void ShClPayloadFree(PSHCLEVENTPAYLOAD pPayload);
187/** @} */
188
189/** @name Shared Clipboard event source functions.
190 * @{
191 */
192int ShClEventSourceCreate(PSHCLEVENTSOURCE pSource, SHCLEVENTSOURCEID idEvtSrc);
193int ShClEventSourceDestroy(PSHCLEVENTSOURCE pSource);
194void ShClEventSourceReset(PSHCLEVENTSOURCE pSource);
195int ShClEventSourceGenerateAndRegisterEvent(PSHCLEVENTSOURCE pSource, PSHCLEVENT *ppEvent);
196PSHCLEVENT ShClEventSourceGetFromId(PSHCLEVENTSOURCE pSource, SHCLEVENTID idEvent);
197PSHCLEVENT ShClEventSourceGetLast(PSHCLEVENTSOURCE pSource);
198/** @} */
199
200/** @name Shared Clipboard event functions.
201 * @{
202 */
203uint32_t ShClEventGetRefs(PSHCLEVENT pEvent);
204uint32_t ShClEventRetain(PSHCLEVENT pEvent);
205uint32_t ShClEventRelease(PSHCLEVENT pEvent);
206int ShClEventSignal(PSHCLEVENT pEvent, PSHCLEVENTPAYLOAD pPayload);
207int ShClEventWait(PSHCLEVENT pEvent, RTMSINTERVAL uTimeoutMs, PSHCLEVENTPAYLOAD *ppPayload);
208/** @} */
209
210/**
211 * Shared Clipboard transfer source type.
212 * @note Part of saved state!
213 */
214typedef enum SHCLSOURCE
215{
216 /** Invalid source type. */
217 SHCLSOURCE_INVALID = 0,
218 /** Source is local. */
219 SHCLSOURCE_LOCAL,
220 /** Source is remote. */
221 SHCLSOURCE_REMOTE,
222 /** The usual 32-bit hack. */
223 SHCLSOURCE_32BIT_HACK = 0x7fffffff
224} SHCLSOURCE;
225
226/** Opaque data structure for the X11/VBox frontend/glue code.
227 * @{ */
228struct SHCLCONTEXT;
229typedef struct SHCLCONTEXT SHCLCONTEXT;
230/** @} */
231/** Pointer to opaque data structure the X11/VBox frontend/glue code. */
232typedef SHCLCONTEXT *PSHCLCONTEXT;
233
234/** Opaque request structure for X11 clipboard data.
235 * @{ */
236struct CLIPREADCBREQ;
237typedef struct CLIPREADCBREQ CLIPREADCBREQ;
238/** @} */
239
240#endif /* !VBOX_INCLUDED_GuestHost_SharedClipboard_h */
241
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