[86968] | 1 | /** $Id: clipboard.h 103365 2024-02-14 18:13:38Z vboxsync $ */
|
---|
| 2 | /** @file
|
---|
| 3 | * Guest Additions - X11 Shared Clipboard - Main header.
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2020-2023 Oracle and/or its affiliates.
|
---|
[86968] | 8 | *
|
---|
[96407] | 9 | * This file is part of VirtualBox base platform packages, as
|
---|
| 10 | * available from https://www.virtualbox.org.
|
---|
| 11 | *
|
---|
| 12 | * This program is free software; you can redistribute it and/or
|
---|
| 13 | * modify it under the terms of the GNU General Public License
|
---|
| 14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
| 15 | * License.
|
---|
| 16 | *
|
---|
| 17 | * This program is distributed in the hope that it will be useful, but
|
---|
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | * General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU General Public License
|
---|
| 23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 24 | *
|
---|
| 25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
[86968] | 26 | */
|
---|
| 27 |
|
---|
[86970] | 28 | #ifndef GA_INCLUDED_SRC_x11_VBoxClient_clipboard_h
|
---|
| 29 | #define GA_INCLUDED_SRC_x11_VBoxClient_clipboard_h
|
---|
| 30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 31 | # pragma once
|
---|
| 32 | #endif
|
---|
| 33 |
|
---|
[101680] | 34 | #include <VBox/GuestHost/SharedClipboard-x11.h>
|
---|
| 35 | #include <VBox/VBoxGuestLib.h>
|
---|
| 36 | #include <iprt/thread.h>
|
---|
| 37 |
|
---|
[86968] | 38 | /**
|
---|
[101680] | 39 | * Callback to notify guest that host has new clipboard data in the specified formats.
|
---|
| 40 | *
|
---|
| 41 | * @returns VBox status code.
|
---|
| 42 | * @param fFormats The formats available.
|
---|
| 43 | * Optional and can be NULL.
|
---|
| 44 | */
|
---|
| 45 | typedef DECLCALLBACKTYPE(int, FNHOSTCLIPREPORTFMTS, (SHCLFORMATS fFormats));
|
---|
| 46 | typedef FNHOSTCLIPREPORTFMTS *PFNHOSTCLIPREPORTFMTS;
|
---|
| 47 |
|
---|
| 48 | /**
|
---|
| 49 | * Callback to notify guest that host wants to read clipboard data in specified format.
|
---|
| 50 | *
|
---|
| 51 | * @returns VBox status code.
|
---|
| 52 | * @param uFmt The format in which the data should be read
|
---|
| 53 | * (VBOX_SHCL_FMT_XXX).
|
---|
| 54 | */
|
---|
| 55 | typedef DECLCALLBACKTYPE(int, FNHOSTCLIPREAD, (SHCLFORMAT uFmt));
|
---|
| 56 | typedef FNHOSTCLIPREAD *PFNHOSTCLIPREAD;
|
---|
| 57 |
|
---|
| 58 |
|
---|
| 59 | /**
|
---|
[100204] | 60 | * Struct keeping am X11 Shared Clipboard context.
|
---|
[86968] | 61 | */
|
---|
| 62 | struct SHCLCONTEXT
|
---|
| 63 | {
|
---|
| 64 | /** Client command context */
|
---|
[100272] | 65 | VBGLR3SHCLCMDCTX CmdCtx;
|
---|
[86968] | 66 | #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
|
---|
| 67 | /** Associated transfer data. */
|
---|
[100272] | 68 | SHCLTRANSFERCTX TransferCtx;
|
---|
[86968] | 69 | #endif
|
---|
[100272] | 70 | /** Event source for waiting for X11 request responses in the VbglR3 clipboard event loop. */
|
---|
| 71 | SHCLEVENTSOURCE EventSrc;
|
---|
[99590] | 72 | union
|
---|
| 73 | {
|
---|
| 74 | /** X11 clipboard context. */
|
---|
| 75 | SHCLX11CTX X11;
|
---|
[100272] | 76 | /** @todo Wayland clipboard context goes here. */
|
---|
[99590] | 77 | /* SHCLWAYLANDCTX Wl; */
|
---|
| 78 | };
|
---|
[86968] | 79 | };
|
---|
| 80 |
|
---|
[99590] | 81 | /** Shared Clipboard context.
|
---|
| 82 | * Only one context is supported at a time for now. */
|
---|
| 83 | extern SHCLCONTEXT g_Ctx;
|
---|
| 84 |
|
---|
[101680] | 85 | /**
|
---|
| 86 | * Create thread and wait until it started.
|
---|
| 87 | *
|
---|
| 88 | * @returns IPRT status code.
|
---|
| 89 | * @param pThread Pointer to thread data.
|
---|
| 90 | * @param pfnThread Pointer to thread main loop function.
|
---|
| 91 | * @param pszName Thread name.
|
---|
| 92 | * @param pvUser User data.
|
---|
| 93 | */
|
---|
[102027] | 94 | RTDECL(int) VBClClipboardThreadStart(PRTTHREAD pThread, PFNRTTHREAD pfnThread, const char *pszName, void *pvUser);
|
---|
[101680] | 95 |
|
---|
| 96 | /**
|
---|
| 97 | * Read and process one event from the host clipboard service.
|
---|
| 98 | *
|
---|
| 99 | * @returns VBox status code.
|
---|
[101681] | 100 | * @param pCtx Host Shared Clipboard service connection context.
|
---|
[101721] | 101 | * @param pfnHGClipReport A callback to notify guest about new content in host clipboard.
|
---|
| 102 | * @param pfnGHClipRead A callback to notify guest when host requests guest clipboard content.
|
---|
[101680] | 103 | */
|
---|
[102027] | 104 | RTDECL(int) VBClClipboardReadHostEvent(PSHCLCONTEXT pCtx, const PFNHOSTCLIPREPORTFMTS pfnHGClipReport,
|
---|
[101721] | 105 | const PFNHOSTCLIPREAD pfnGHClipRead);
|
---|
[101680] | 106 |
|
---|
| 107 | /**
|
---|
| 108 | * Read entire host clipboard buffer in given format.
|
---|
| 109 | *
|
---|
| 110 | * This function will allocate clipboard buffer of necessary size and
|
---|
| 111 | * place host clipboard content into it. Buffer needs to be freed by caller.
|
---|
| 112 | *
|
---|
| 113 | * @returns VBox status code.
|
---|
| 114 | * @param pCtx Host Shared Clipboard service connection context.
|
---|
[101681] | 115 | * @param uFmt Format in which data should be read.
|
---|
[103365] | 116 | * @param ppvData Newly allocated output buffer (should be freed by caller).
|
---|
| 117 | * @param pcbData Output buffer size.
|
---|
[101680] | 118 | */
|
---|
[103365] | 119 | RTDECL(int) VBClClipboardReadHostClipboard(PVBGLR3SHCLCMDCTX pCtx, SHCLFORMAT uFmt, void **ppvData, uint32_t *pcbData);
|
---|
[101680] | 120 |
|
---|
[86970] | 121 | #endif /* !GA_INCLUDED_SRC_x11_VBoxClient_clipboard_h */
|
---|