VirtualBox

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

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

Shared Clipboard: Removed old protocol handling cruft on the host side and added message translation support for serving older Guest Additions. Updated docs / protocol changelog.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.5 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 VBOXCLIPBOARDFORMAT;
38/** Pointer to a single Shared Clipboard format. */
39typedef VBOXCLIPBOARDFORMAT *PVBOXCLIPBOARDFORMAT;
40
41/** Bit map of Shared Clipboard formats. */
42typedef uint32_t VBOXCLIPBOARDFORMATS;
43/** Pointer to a bit map of Shared Clipboard formats. */
44typedef VBOXCLIPBOARDFORMATS *PVBOXCLIPBOARDFORMATS;
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 _SHAREDCLIPBOARDDATABLOCK
66{
67 /** Clipboard format this data block represents. */
68 VBOXCLIPBOARDFORMAT uFormat;
69 /** Pointer to actual data block. */
70 void *pvData;
71 /** Size (in bytes) of actual data block. */
72 uint32_t cbData;
73} SHAREDCLIPBOARDDATABLOCK, *PSHAREDCLIPBOARDDATABLOCK;
74
75/**
76 * Structure for keeping a Shared Clipboard data read request.
77 */
78typedef struct _SHAREDCLIPBOARDDATAREQ
79{
80 /** In which format the data needs to be sent. */
81 VBOXCLIPBOARDFORMAT uFmt;
82 /** Read flags; currently unused. */
83 uint32_t fFlags;
84 /** Maximum data (in byte) can be sent. */
85 uint32_t cbSize;
86} SHAREDCLIPBOARDDATAREQ, *PSHAREDCLIPBOARDDATAREQ;
87
88/**
89 * Structure for keeping Shared Clipboard formats specifications.
90 */
91typedef struct _SHAREDCLIPBOARDFORMATDATA
92{
93 /** Available format(s) as bit map. */
94 VBOXCLIPBOARDFORMATS uFormats;
95 /** Formats flags. Currently unused. */
96 uint32_t fFlags;
97} SHAREDCLIPBOARDFORMATDATA, *PSHAREDCLIPBOARDFORMATDATA;
98
99/**
100 * Structure for an (optional) Shared Clipboard event payload.
101 */
102typedef struct _SHAREDCLIPBOARDEVENTPAYLOAD
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} SHAREDCLIPBOARDEVENTPAYLOAD, *PSHAREDCLIPBOARDEVENTPAYLOAD;
111
112/** Defines an event source ID. */
113typedef uint16_t VBOXCLIPBOARDEVENTSOURCEID;
114/** Defines a pointer to a event source ID. */
115typedef VBOXCLIPBOARDEVENTSOURCEID *PVBOXCLIPBOARDEVENTSOURCEID;
116
117/** Defines an event ID. */
118typedef uint16_t VBOXCLIPBOARDEVENTID;
119/** Defines a pointer to a event source ID. */
120typedef VBOXCLIPBOARDEVENTID *PVBOXCLIPBOARDEVENTID;
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 _SHAREDCLIPBOARDEVENT
134{
135 /** List node. */
136 RTLISTNODE Node;
137 /** The event's ID, for self-reference. */
138 VBOXCLIPBOARDEVENTID uID;
139 /** Event semaphore for signalling the event. */
140 RTSEMEVENT hEventSem;
141 /** Payload to this event. Optional and can be NULL. */
142 PSHAREDCLIPBOARDEVENTPAYLOAD pPayload;
143} SHAREDCLIPBOARDEVENT, *PSHAREDCLIPBOARDEVENT;
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 _SHAREDCLIPBOARDEVENTSOURCE
152{
153 /** The event source' ID. */
154 VBOXCLIPBOARDEVENTSOURCEID uID;
155 /** Next upcoming event ID. */
156 VBOXCLIPBOARDEVENTID uEventIDNext;
157 /** List of events (PSHAREDCLIPBOARDEVENT). */
158 RTLISTANCHOR lstEvents;
159} SHAREDCLIPBOARDEVENTSOURCE, *PSHAREDCLIPBOARDEVENTSOURCE;
160
161int SharedClipboardPayloadAlloc(uint32_t uID, const void *pvData, uint32_t cbData,
162 PSHAREDCLIPBOARDEVENTPAYLOAD *ppPayload);
163void SharedClipboardPayloadFree(PSHAREDCLIPBOARDEVENTPAYLOAD pPayload);
164
165int SharedClipboardEventSourceCreate(PSHAREDCLIPBOARDEVENTSOURCE pSource, VBOXCLIPBOARDEVENTSOURCEID uID);
166void SharedClipboardEventSourceDestroy(PSHAREDCLIPBOARDEVENTSOURCE pSource);
167
168VBOXCLIPBOARDEVENTID SharedClipboardEventIDGenerate(PSHAREDCLIPBOARDEVENTSOURCE pSource);
169VBOXCLIPBOARDEVENTID SharedClipboardEventGetLast(PSHAREDCLIPBOARDEVENTSOURCE pSource);
170int SharedClipboardEventRegister(PSHAREDCLIPBOARDEVENTSOURCE pSource, VBOXCLIPBOARDEVENTID uID);
171int SharedClipboardEventUnregister(PSHAREDCLIPBOARDEVENTSOURCE pSource, VBOXCLIPBOARDEVENTID uID);
172int SharedClipboardEventWait(PSHAREDCLIPBOARDEVENTSOURCE pSource, VBOXCLIPBOARDEVENTID uID, RTMSINTERVAL uTimeoutMs,
173 PSHAREDCLIPBOARDEVENTPAYLOAD* ppPayload);
174int SharedClipboardEventSignal(PSHAREDCLIPBOARDEVENTSOURCE pSource, VBOXCLIPBOARDEVENTID uID, PSHAREDCLIPBOARDEVENTPAYLOAD pPayload);
175void SharedClipboardEventPayloadDetach(PSHAREDCLIPBOARDEVENTSOURCE pSource, VBOXCLIPBOARDEVENTID uID);
176
177/**
178 * Enumeration to specify the Shared Clipboard URI source type.
179 */
180typedef enum SHAREDCLIPBOARDSOURCE
181{
182 /** Invalid source type. */
183 SHAREDCLIPBOARDSOURCE_INVALID = 0,
184 /** Source is local. */
185 SHAREDCLIPBOARDSOURCE_LOCAL,
186 /** Source is remote. */
187 SHAREDCLIPBOARDSOURCE_REMOTE,
188 /** The usual 32-bit hack. */
189 SHAREDCLIPBOARDSOURCE_32Bit_Hack = 0x7fffffff
190} SHAREDCLIPBOARDSOURCE;
191
192/** Opaque data structure for the X11/VBox frontend/glue code. */
193struct _VBOXCLIPBOARDCONTEXT;
194typedef struct _VBOXCLIPBOARDCONTEXT VBOXCLIPBOARDCONTEXT;
195typedef struct _VBOXCLIPBOARDCONTEXT *PVBOXCLIPBOARDCONTEXT;
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(VBOXCLIPBOARDCONTEXT *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, VBOXCLIPBOARDFORMATS vboxFormats);
212extern int ClipRequestDataFromX11(CLIPBACKEND *pBackend, VBOXCLIPBOARDFORMATS vboxFormat, CLIPREADCBREQ *pReq);
213
214/* APIs exported by the X11/VBox frontend */
215extern int ClipRequestDataForX11(VBOXCLIPBOARDCONTEXT *pCtx, uint32_t u32Format, void **ppv, uint32_t *pcb);
216extern void ClipReportX11Formats(VBOXCLIPBOARDCONTEXT *pCtx, uint32_t u32Formats);
217extern void ClipRequestFromX11CompleteCallback(VBOXCLIPBOARDCONTEXT *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