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 | /**
|
---|
36 | * Shared Clipboard transfer direction.
|
---|
37 | */
|
---|
38 | typedef 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. */
|
---|
50 | typedef SHCLTRANSFERDIR *PSHCLTRANSFERDIR;
|
---|
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 data read request.
|
---|
66 | */
|
---|
67 | typedef struct SHCLDATAREQ
|
---|
68 | {
|
---|
69 | /** In which format the data needs to be sent. */
|
---|
70 | SHCLFORMAT uFmt;
|
---|
71 | /** Read flags; currently unused. */
|
---|
72 | uint32_t fFlags;
|
---|
73 | /** Maximum data (in byte) can be sent. */
|
---|
74 | uint32_t cbSize;
|
---|
75 | } SHCLDATAREQ;
|
---|
76 | /** Pointer to a shared clipboard data request. */
|
---|
77 | typedef SHCLDATAREQ *PSHCLDATAREQ;
|
---|
78 |
|
---|
79 | /**
|
---|
80 | * Shared Clipboard formats specification.
|
---|
81 | * @todo r=bird: Pointless as we don't have any fFlags defined, so, unless
|
---|
82 | * someone can give me a plausible scenario where we will need flags here,
|
---|
83 | * this structure will be eliminated.
|
---|
84 | */
|
---|
85 | typedef struct SHCLFORMATDATA
|
---|
86 | {
|
---|
87 | /** Available format(s) as bit map. */
|
---|
88 | SHCLFORMATS Formats;
|
---|
89 | /** Formats flags. Currently unused. */
|
---|
90 | uint32_t fFlags;
|
---|
91 | } SHCLFORMATDATA;
|
---|
92 | /** Pointer to a shared clipboard formats specification. */
|
---|
93 | typedef SHCLFORMATDATA *PSHCLFORMATDATA;
|
---|
94 |
|
---|
95 | /**
|
---|
96 | * Shared Clipboard event payload (optional).
|
---|
97 | */
|
---|
98 | typedef struct SHCLEVENTPAYLOAD
|
---|
99 | {
|
---|
100 | /** Payload ID; currently unused. */
|
---|
101 | uint32_t uID;
|
---|
102 | /** Size (in bytes) of actual payload data. */
|
---|
103 | uint32_t cbData;
|
---|
104 | /** Pointer to actual payload data. */
|
---|
105 | void *pvData;
|
---|
106 | } SHCLEVENTPAYLOAD;
|
---|
107 | /** Pointer to a shared clipboard event payload. */
|
---|
108 | typedef SHCLEVENTPAYLOAD *PSHCLEVENTPAYLOAD;
|
---|
109 |
|
---|
110 | /** A shared clipboard event source ID. */
|
---|
111 | typedef uint16_t SHCLEVENTSOURCEID;
|
---|
112 | /** Pointer to a shared clipboard event source ID. */
|
---|
113 | typedef SHCLEVENTSOURCEID *PSHCLEVENTSOURCEID;
|
---|
114 |
|
---|
115 | /** A shared clipboard session ID. */
|
---|
116 | typedef uint16_t SHCLSESSIONID;
|
---|
117 | /** Pointer to a shared clipboard session ID. */
|
---|
118 | typedef SHCLSESSIONID *PSHCLSESSIONID;
|
---|
119 | /** NIL shared clipboard session ID. */
|
---|
120 | #define NIL_SHCLSESSIONID UINT16_MAX
|
---|
121 |
|
---|
122 | /** A shared clipboard transfer ID. */
|
---|
123 | typedef uint16_t SHCLTRANSFERID;
|
---|
124 | /** Pointer to a shared clipboard transfer ID. */
|
---|
125 | typedef SHCLTRANSFERID *PSHCLTRANSFERID;
|
---|
126 | /** NIL shared clipboardtransfer ID. */
|
---|
127 | #define NIL_SHCLTRANSFERID UINT16_MAX
|
---|
128 |
|
---|
129 | /** A shared clipboard event ID. */
|
---|
130 | typedef uint32_t SHCLEVENTID;
|
---|
131 | /** Pointer to a shared clipboard event source ID. */
|
---|
132 | typedef SHCLEVENTID *PSHCLEVENTID;
|
---|
133 | /** NIL shared clipboard event ID. */
|
---|
134 | #define NIL_SHCLEVENTID UINT32_MAX
|
---|
135 |
|
---|
136 | /**
|
---|
137 | * Shared Clipboard event.
|
---|
138 | */
|
---|
139 | typedef struct SHCLEVENT
|
---|
140 | {
|
---|
141 | /** List node. */
|
---|
142 | RTLISTNODE Node;
|
---|
143 | /** The event's ID, for self-reference. */
|
---|
144 | SHCLEVENTID idEvent;
|
---|
145 | /** Reference count to this event. */
|
---|
146 | uint32_t cRefs;
|
---|
147 | /** Event semaphore for signalling the event. */
|
---|
148 | RTSEMEVENTMULTI hEvtMulSem;
|
---|
149 | /** Payload to this event, optional (NULL). */
|
---|
150 | PSHCLEVENTPAYLOAD pPayload;
|
---|
151 | } SHCLEVENT;
|
---|
152 | /** Pointer to a shared clipboard event. */
|
---|
153 | typedef SHCLEVENT *PSHCLEVENT;
|
---|
154 |
|
---|
155 | /**
|
---|
156 | * Shared Clipboard event source.
|
---|
157 | *
|
---|
158 | * Each event source maintains an own counter for events, so that it can be used
|
---|
159 | * in different contexts.
|
---|
160 | */
|
---|
161 | typedef struct SHCLEVENTSOURCE
|
---|
162 | {
|
---|
163 | /** The event source ID. */
|
---|
164 | SHCLEVENTSOURCEID uID;
|
---|
165 | /** Next upcoming event ID. */
|
---|
166 | SHCLEVENTID idNextEvent;
|
---|
167 | /** List of events (PSHCLEVENT). */
|
---|
168 | RTLISTANCHOR lstEvents;
|
---|
169 | } SHCLEVENTSOURCE;
|
---|
170 | /** Pointer to a shared clipboard event source. */
|
---|
171 | typedef SHCLEVENTSOURCE *PSHCLEVENTSOURCE;
|
---|
172 |
|
---|
173 | /** @name Shared Clipboard data payload functions.
|
---|
174 | * @{
|
---|
175 | */
|
---|
176 | int ShClPayloadAlloc(uint32_t uID, const void *pvData, uint32_t cbData, PSHCLEVENTPAYLOAD *ppPayload);
|
---|
177 | void ShClPayloadFree(PSHCLEVENTPAYLOAD pPayload);
|
---|
178 | /** @} */
|
---|
179 |
|
---|
180 | /** @name Shared Clipboard event source functions.
|
---|
181 | * @{
|
---|
182 | */
|
---|
183 | int ShClEventSourceCreate(PSHCLEVENTSOURCE pSource, SHCLEVENTSOURCEID idEvtSrc);
|
---|
184 | void ShClEventSourceDestroy(PSHCLEVENTSOURCE pSource);
|
---|
185 | void ShClEventSourceReset(PSHCLEVENTSOURCE pSource);
|
---|
186 | /** @} */
|
---|
187 |
|
---|
188 | /** @name Shared Clipboard event functions.
|
---|
189 | * @{
|
---|
190 | */
|
---|
191 | SHCLEVENTID ShClEventIdGenerateAndRegister(PSHCLEVENTSOURCE pSource);
|
---|
192 | SHCLEVENTID ShClEventGetLast(PSHCLEVENTSOURCE pSource);
|
---|
193 | uint32_t ShClEventRetain(PSHCLEVENTSOURCE pSource, SHCLEVENTID idEvent);
|
---|
194 | uint32_t ShClEventRelease(PSHCLEVENTSOURCE pSource, SHCLEVENTID idEvent);
|
---|
195 | int ShClEventSignal(PSHCLEVENTSOURCE pSource, SHCLEVENTID idEvent, PSHCLEVENTPAYLOAD pPayload);
|
---|
196 | int ShClEventUnregister(PSHCLEVENTSOURCE pSource, SHCLEVENTID idEvent);
|
---|
197 | int ShClEventWait(PSHCLEVENTSOURCE pSource, SHCLEVENTID idEvent, RTMSINTERVAL uTimeoutMs, PSHCLEVENTPAYLOAD *ppPayload);
|
---|
198 |
|
---|
199 | void ShClEventPayloadDetach(PSHCLEVENTSOURCE pSource, SHCLEVENTID idEvent);
|
---|
200 | /** @} */
|
---|
201 |
|
---|
202 | /**
|
---|
203 | * Shared Clipboard transfer source type.
|
---|
204 | * @note Part of saved state!
|
---|
205 | */
|
---|
206 | typedef enum SHCLSOURCE
|
---|
207 | {
|
---|
208 | /** Invalid source type. */
|
---|
209 | SHCLSOURCE_INVALID = 0,
|
---|
210 | /** Source is local. */
|
---|
211 | SHCLSOURCE_LOCAL,
|
---|
212 | /** Source is remote. */
|
---|
213 | SHCLSOURCE_REMOTE,
|
---|
214 | /** The usual 32-bit hack. */
|
---|
215 | SHCLSOURCE_32BIT_HACK = 0x7fffffff
|
---|
216 | } SHCLSOURCE;
|
---|
217 |
|
---|
218 | /** Opaque data structure for the X11/VBox frontend/glue code.
|
---|
219 | * @{ */
|
---|
220 | struct SHCLCONTEXT;
|
---|
221 | typedef struct SHCLCONTEXT SHCLCONTEXT;
|
---|
222 | /** @} */
|
---|
223 | /** Pointer to opaque data structure the X11/VBox frontend/glue code. */
|
---|
224 | typedef SHCLCONTEXT *PSHCLCONTEXT;
|
---|
225 |
|
---|
226 | /** Opaque request structure for X11 clipboard data.
|
---|
227 | * @{ */
|
---|
228 | struct CLIPREADCBREQ;
|
---|
229 | typedef struct CLIPREADCBREQ CLIPREADCBREQ;
|
---|
230 | /** @} */
|
---|
231 |
|
---|
232 | #endif /* !VBOX_INCLUDED_GuestHost_SharedClipboard_h */
|
---|
233 |
|
---|