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