1 | /** @file
|
---|
2 | * Shared Clipboard - Common guest and host Code.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2021 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). */
|
---|
55 | typedef uint32_t SHCLFORMAT;
|
---|
56 | /** Pointer to a single Shared Clipboard format (VBOX_SHCL_FMT_XXX). */
|
---|
57 | typedef SHCLFORMAT *PSHCLFORMAT;
|
---|
58 |
|
---|
59 | /** Bit map (flags) of Shared Clipboard formats (VBOX_SHCL_FMT_XXX). */
|
---|
60 | typedef uint32_t SHCLFORMATS;
|
---|
61 | /** Pointer to a bit map of Shared Clipboard formats (VBOX_SHCL_FMT_XXX). */
|
---|
62 | typedef SHCLFORMATS *PSHCLFORMATS;
|
---|
63 |
|
---|
64 |
|
---|
65 | /**
|
---|
66 | * Shared Clipboard transfer direction.
|
---|
67 | */
|
---|
68 | typedef 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. */
|
---|
80 | typedef SHCLTRANSFERDIR *PSHCLTRANSFERDIR;
|
---|
81 |
|
---|
82 |
|
---|
83 | /**
|
---|
84 | * Shared Clipboard data read request.
|
---|
85 | */
|
---|
86 | typedef 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. */
|
---|
96 | typedef SHCLDATAREQ *PSHCLDATAREQ;
|
---|
97 |
|
---|
98 | /**
|
---|
99 | * Shared Clipboard event payload (optional).
|
---|
100 | */
|
---|
101 | typedef 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. */
|
---|
111 | typedef SHCLEVENTPAYLOAD *PSHCLEVENTPAYLOAD;
|
---|
112 |
|
---|
113 | /** A shared clipboard event source ID. */
|
---|
114 | typedef uint16_t SHCLEVENTSOURCEID;
|
---|
115 | /** Pointer to a shared clipboard event source ID. */
|
---|
116 | typedef SHCLEVENTSOURCEID *PSHCLEVENTSOURCEID;
|
---|
117 |
|
---|
118 | /** A shared clipboard session ID. */
|
---|
119 | typedef uint16_t SHCLSESSIONID;
|
---|
120 | /** Pointer to a shared clipboard session ID. */
|
---|
121 | typedef SHCLSESSIONID *PSHCLSESSIONID;
|
---|
122 | /** NIL shared clipboard session ID. */
|
---|
123 | #define NIL_SHCLSESSIONID UINT16_MAX
|
---|
124 |
|
---|
125 | /** A shared clipboard transfer ID. */
|
---|
126 | typedef uint16_t SHCLTRANSFERID;
|
---|
127 | /** Pointer to a shared clipboard transfer ID. */
|
---|
128 | typedef SHCLTRANSFERID *PSHCLTRANSFERID;
|
---|
129 | /** NIL shared clipboardtransfer ID. */
|
---|
130 | #define NIL_SHCLTRANSFERID UINT16_MAX
|
---|
131 |
|
---|
132 | /** A shared clipboard event ID. */
|
---|
133 | typedef uint32_t SHCLEVENTID;
|
---|
134 | /** Pointer to a shared clipboard event source ID. */
|
---|
135 | typedef SHCLEVENTID *PSHCLEVENTID;
|
---|
136 | /** NIL shared clipboard event ID. */
|
---|
137 | #define NIL_SHCLEVENTID UINT32_MAX
|
---|
138 |
|
---|
139 | /* Forward declaration, needed for SHCLEVENT. */
|
---|
140 | struct SHCLEVENTSOURCE;
|
---|
141 |
|
---|
142 | /**
|
---|
143 | * Shared Clipboard event.
|
---|
144 | */
|
---|
145 | typedef struct SHCLEVENT
|
---|
146 | {
|
---|
147 | /** List node. */
|
---|
148 | RTLISTNODE Node;
|
---|
149 | /** Parent (source) this event belongs to. */
|
---|
150 | SHCLEVENTSOURCE *pParent;
|
---|
151 | /** The event's ID, for self-reference. */
|
---|
152 | SHCLEVENTID idEvent;
|
---|
153 | /** Reference count to this event. */
|
---|
154 | uint32_t cRefs;
|
---|
155 | /** Event semaphore for signalling the event. */
|
---|
156 | RTSEMEVENTMULTI hEvtMulSem;
|
---|
157 | /** Payload to this event, optional (NULL). */
|
---|
158 | PSHCLEVENTPAYLOAD pPayload;
|
---|
159 | } SHCLEVENT;
|
---|
160 | /** Pointer to a shared clipboard event. */
|
---|
161 | typedef SHCLEVENT *PSHCLEVENT;
|
---|
162 |
|
---|
163 | /**
|
---|
164 | * Shared Clipboard event source.
|
---|
165 | *
|
---|
166 | * Each event source maintains an own counter for events, so that it can be used
|
---|
167 | * in different contexts.
|
---|
168 | */
|
---|
169 | typedef struct SHCLEVENTSOURCE
|
---|
170 | {
|
---|
171 | /** The event source ID. */
|
---|
172 | SHCLEVENTSOURCEID uID;
|
---|
173 | /** Critical section for serializing access. */
|
---|
174 | RTCRITSECT CritSect;
|
---|
175 | /** Next upcoming event ID. */
|
---|
176 | SHCLEVENTID idNextEvent;
|
---|
177 | /** List of events (PSHCLEVENT). */
|
---|
178 | RTLISTANCHOR lstEvents;
|
---|
179 | } SHCLEVENTSOURCE;
|
---|
180 | /** Pointer to a shared clipboard event source. */
|
---|
181 | typedef SHCLEVENTSOURCE *PSHCLEVENTSOURCE;
|
---|
182 |
|
---|
183 | /** @name Shared Clipboard data payload functions.
|
---|
184 | * @{
|
---|
185 | */
|
---|
186 | int ShClPayloadAlloc(uint32_t uID, const void *pvData, uint32_t cbData, PSHCLEVENTPAYLOAD *ppPayload);
|
---|
187 | void ShClPayloadFree(PSHCLEVENTPAYLOAD pPayload);
|
---|
188 | /** @} */
|
---|
189 |
|
---|
190 | /** @name Shared Clipboard event source functions.
|
---|
191 | * @{
|
---|
192 | */
|
---|
193 | int ShClEventSourceCreate(PSHCLEVENTSOURCE pSource, SHCLEVENTSOURCEID idEvtSrc);
|
---|
194 | int ShClEventSourceDestroy(PSHCLEVENTSOURCE pSource);
|
---|
195 | void ShClEventSourceReset(PSHCLEVENTSOURCE pSource);
|
---|
196 | int ShClEventSourceGenerateAndRegisterEvent(PSHCLEVENTSOURCE pSource, PSHCLEVENT *ppEvent);
|
---|
197 | PSHCLEVENT ShClEventSourceGetFromId(PSHCLEVENTSOURCE pSource, SHCLEVENTID idEvent);
|
---|
198 | PSHCLEVENT ShClEventSourceGetLast(PSHCLEVENTSOURCE pSource);
|
---|
199 | /** @} */
|
---|
200 |
|
---|
201 | /** @name Shared Clipboard event functions.
|
---|
202 | * @{
|
---|
203 | */
|
---|
204 | uint32_t ShClEventGetRefs(PSHCLEVENT pEvent);
|
---|
205 | uint32_t ShClEventRetain(PSHCLEVENT pEvent);
|
---|
206 | uint32_t ShClEventRelease(PSHCLEVENT pEvent);
|
---|
207 | int ShClEventSignal(PSHCLEVENT pEvent, PSHCLEVENTPAYLOAD pPayload);
|
---|
208 | int ShClEventWait(PSHCLEVENT pEvent, RTMSINTERVAL uTimeoutMs, PSHCLEVENTPAYLOAD *ppPayload);
|
---|
209 | /** @} */
|
---|
210 |
|
---|
211 | /**
|
---|
212 | * Shared Clipboard transfer source type.
|
---|
213 | * @note Part of saved state!
|
---|
214 | */
|
---|
215 | typedef enum SHCLSOURCE
|
---|
216 | {
|
---|
217 | /** Invalid source type. */
|
---|
218 | SHCLSOURCE_INVALID = 0,
|
---|
219 | /** Source is local. */
|
---|
220 | SHCLSOURCE_LOCAL,
|
---|
221 | /** Source is remote. */
|
---|
222 | SHCLSOURCE_REMOTE,
|
---|
223 | /** The usual 32-bit hack. */
|
---|
224 | SHCLSOURCE_32BIT_HACK = 0x7fffffff
|
---|
225 | } SHCLSOURCE;
|
---|
226 |
|
---|
227 | /** Opaque data structure for the X11/VBox frontend/glue code.
|
---|
228 | * @{ */
|
---|
229 | struct SHCLCONTEXT;
|
---|
230 | typedef struct SHCLCONTEXT SHCLCONTEXT;
|
---|
231 | /** @} */
|
---|
232 | /** Pointer to opaque data structure the X11/VBox frontend/glue code. */
|
---|
233 | typedef SHCLCONTEXT *PSHCLCONTEXT;
|
---|
234 |
|
---|
235 | /** Opaque request structure for X11 clipboard data.
|
---|
236 | * @{ */
|
---|
237 | struct CLIPREADCBREQ;
|
---|
238 | typedef struct CLIPREADCBREQ CLIPREADCBREQ;
|
---|
239 | /** @} */
|
---|
240 |
|
---|
241 | #endif /* !VBOX_INCLUDED_GuestHost_SharedClipboard_h */
|
---|
242 |
|
---|