VirtualBox

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

Last change on this file since 80662 was 80662, checked in by vboxsync, 6 years ago

Shared Clipboard: Renaming (SHAREDCLIPBOARD -> SHCL and VBOXCLIPBOARD -> SHCL).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.8 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/cdefs.h>
33#include <iprt/list.h>
34#include <iprt/types.h>
35
36/** A single Shared Clipboard format. */
37typedef uint32_t SHCLFORMAT;
38/** Pointer to a single Shared Clipboard format. */
39typedef SHCLFORMAT *PSHCLFORMAT;
40
41/** Bit map of Shared Clipboard formats. */
42typedef uint32_t SHCLFORMATS;
43/** Pointer to a bit map of Shared Clipboard formats. */
44typedef SHCLFORMATS *PSHCLFORMATS;
45
46/**
47 * Supported data formats for Shared Clipboard. Bit mask.
48 */
49/** No format set. */
50#define VBOX_SHARED_CLIPBOARD_FMT_NONE 0
51/** Shared Clipboard format is an Unicode text. */
52#define VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT RT_BIT(0)
53/** Shared Clipboard format is bitmap (BMP / DIB). */
54#define VBOX_SHARED_CLIPBOARD_FMT_BITMAP RT_BIT(1)
55/** Shared Clipboard format is HTML. */
56#define VBOX_SHARED_CLIPBOARD_FMT_HTML RT_BIT(2)
57#ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
58/** Shared Clipboard format is an URI list. */
59#define VBOX_SHARED_CLIPBOARD_FMT_URI_LIST RT_BIT(3)
60#endif
61
62/**
63 * Structure for keeping a generic Shared Clipboard data block.
64 */
65typedef struct _SHCLDATABLOCK
66{
67 /** Clipboard format this data block represents. */
68 SHCLFORMAT uFormat;
69 /** Pointer to actual data block. */
70 void *pvData;
71 /** Size (in bytes) of actual data block. */
72 uint32_t cbData;
73} SHCLDATABLOCK, *PSHCLDATABLOCK;
74
75/**
76 * Structure for keeping a Shared Clipboard data read request.
77 */
78typedef struct _SHCLDATAREQ
79{
80 /** In which format the data needs to be sent. */
81 SHCLFORMAT uFmt;
82 /** Read flags; currently unused. */
83 uint32_t fFlags;
84 /** Maximum data (in byte) can be sent. */
85 uint32_t cbSize;
86} SHCLDATAREQ, *PSHCLDATAREQ;
87
88/**
89 * Structure for keeping Shared Clipboard formats specifications.
90 */
91typedef struct _SHCLFORMATDATA
92{
93 /** Available format(s) as bit map. */
94 SHCLFORMATS uFormats;
95 /** Formats flags. Currently unused. */
96 uint32_t fFlags;
97} SHCLFORMATDATA, *PSHCLFORMATDATA;
98
99/**
100 * Structure for an (optional) Shared Clipboard event payload.
101 */
102typedef struct _SHCLEVENTPAYLOAD
103{
104 /** Payload ID; currently unused. */
105 uint32_t uID;
106 /** Pointer to actual payload data. */
107 void *pvData;
108 /** Size (in bytes) of actual payload data. */
109 uint32_t cbData;
110} SHCLEVENTPAYLOAD, *PSHCLEVENTPAYLOAD;
111
112/** Defines an event source ID. */
113typedef uint16_t SHCLEVENTSOURCEID;
114/** Defines a pointer to a event source ID. */
115typedef SHCLEVENTSOURCEID *PSHCLEVENTSOURCEID;
116
117/** Defines an event ID. */
118typedef uint16_t SHCLEVENTID;
119/** Defines a pointer to a event source ID. */
120typedef SHCLEVENTID *PSHCLEVENTID;
121
122/** Maximum number of concurrent Shared Clipboard transfers a VM can have.
123 * Number 0 always is reserved for the client itself. */
124#define VBOX_SHARED_CLIPBOARD_MAX_TRANSFERS UINT16_MAX - 1
125/** Maximum number of concurrent event sources. */
126#define VBOX_SHARED_CLIPBOARD_MAX_EVENT_SOURCES UINT16_MAX
127/** Maximum number of concurrent events a single event source can have. */
128#define VBOX_SHARED_CLIPBOARD_MAX_EVENTS UINT16_MAX
129
130/**
131 * Structure for maintaining a Shared Clipboard event.
132 */
133typedef struct _SHCLEVENT
134{
135 /** List node. */
136 RTLISTNODE Node;
137 /** The event's ID, for self-reference. */
138 SHCLEVENTID uID;
139 /** Event semaphore for signalling the event. */
140 RTSEMEVENT hEventSem;
141 /** Payload to this event. Optional and can be NULL. */
142 PSHCLEVENTPAYLOAD pPayload;
143} SHCLEVENT, *PSHCLEVENT;
144
145/**
146 * Structure for maintaining a Shared Clipboard event source.
147 *
148 * Each event source maintains an own counter for events, so that
149 * it can be used in different contexts.
150 */
151typedef struct _SHCLEVENTSOURCE
152{
153 /** The event source' ID. */
154 SHCLEVENTSOURCEID uID;
155 /** Next upcoming event ID. */
156 SHCLEVENTID uEventIDNext;
157 /** List of events (PSHCLEVENT). */
158 RTLISTANCHOR lstEvents;
159} SHCLEVENTSOURCE, *PSHCLEVENTSOURCE;
160
161int SharedClipboardPayloadAlloc(uint32_t uID, const void *pvData, uint32_t cbData,
162 PSHCLEVENTPAYLOAD *ppPayload);
163void SharedClipboardPayloadFree(PSHCLEVENTPAYLOAD pPayload);
164
165int SharedClipboardEventSourceCreate(PSHCLEVENTSOURCE pSource, SHCLEVENTSOURCEID uID);
166void SharedClipboardEventSourceDestroy(PSHCLEVENTSOURCE pSource);
167
168SHCLEVENTID SharedClipboardEventIDGenerate(PSHCLEVENTSOURCE pSource);
169SHCLEVENTID SharedClipboardEventGetLast(PSHCLEVENTSOURCE pSource);
170int SharedClipboardEventRegister(PSHCLEVENTSOURCE pSource, SHCLEVENTID uID);
171int SharedClipboardEventUnregister(PSHCLEVENTSOURCE pSource, SHCLEVENTID uID);
172int SharedClipboardEventWait(PSHCLEVENTSOURCE pSource, SHCLEVENTID uID, RTMSINTERVAL uTimeoutMs,
173 PSHCLEVENTPAYLOAD* ppPayload);
174int SharedClipboardEventSignal(PSHCLEVENTSOURCE pSource, SHCLEVENTID uID, PSHCLEVENTPAYLOAD pPayload);
175void SharedClipboardEventPayloadDetach(PSHCLEVENTSOURCE pSource, SHCLEVENTID uID);
176
177/**
178 * Enumeration to specify the Shared Clipboard URI source type.
179 */
180typedef enum SHCLSOURCE
181{
182 /** Invalid source type. */
183 SHCLSOURCE_INVALID = 0,
184 /** Source is local. */
185 SHCLSOURCE_LOCAL,
186 /** Source is remote. */
187 SHCLSOURCE_REMOTE,
188 /** The usual 32-bit hack. */
189 SHCLSOURCE_32Bit_Hack = 0x7fffffff
190} SHCLSOURCE;
191
192/** Opaque data structure for the X11/VBox frontend/glue code. */
193struct _SHCLCONTEXT;
194typedef struct _SHCLCONTEXT SHCLCONTEXT;
195typedef struct _SHCLCONTEXT *PSHCLCONTEXT;
196
197/** Opaque data structure for the X11/VBox backend code. */
198struct _CLIPBACKEND;
199typedef struct _CLIPBACKEND CLIPBACKEND;
200
201/** Opaque request structure for X11 clipboard data.
202 * @todo All use of single and double underscore prefixes is banned! */
203struct _CLIPREADCBREQ;
204typedef struct _CLIPREADCBREQ CLIPREADCBREQ;
205
206/* APIs exported by the X11 backend */
207extern CLIPBACKEND *ClipConstructX11(SHCLCONTEXT *pFrontend, bool fHeadless);
208extern void ClipDestructX11(CLIPBACKEND *pBackend);
209extern int ClipStartX11(CLIPBACKEND *pBackend, bool grab);
210extern int ClipStopX11(CLIPBACKEND *pBackend);
211extern int ClipAnnounceFormatToX11(CLIPBACKEND *pBackend, SHCLFORMATS vboxFormats);
212extern int ClipRequestDataFromX11(CLIPBACKEND *pBackend, SHCLFORMATS vboxFormat, CLIPREADCBREQ *pReq);
213
214/* APIs exported by the X11/VBox frontend */
215extern int ClipRequestDataForX11(SHCLCONTEXT *pCtx, uint32_t u32Format, void **ppv, uint32_t *pcb);
216extern void ClipReportX11Formats(SHCLCONTEXT *pCtx, uint32_t u32Formats);
217extern void ClipRequestFromX11CompleteCallback(SHCLCONTEXT *pCtx, int rc, CLIPREADCBREQ *pReq, void *pv, uint32_t cb);
218#endif /* !VBOX_INCLUDED_GuestHost_SharedClipboard_h */
219
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette