1 | /* $Id: VBoxSharedClipboardSvc-internal.h 79120 2019-06-13 10:08:33Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Shared Clipboard Service - Internal header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2019 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef VBOX_INCLUDED_SRC_SharedClipboard_VBoxSharedClipboardSvc_internal_h
|
---|
19 | #define VBOX_INCLUDED_SRC_SharedClipboard_VBoxSharedClipboardSvc_internal_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #include <iprt/list.h>
|
---|
25 |
|
---|
26 | #include <VBox/hgcmsvc.h>
|
---|
27 | #include <VBox/log.h>
|
---|
28 |
|
---|
29 | #include <VBox/GuestHost/SharedClipboard.h>
|
---|
30 | #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
|
---|
31 | # include <VBox/GuestHost/SharedClipboard-uri.h>
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
|
---|
35 | /**
|
---|
36 | * Structure for handling a single URI object context.
|
---|
37 | */
|
---|
38 | typedef struct _VBOXCLIPBOARDCLIENTURIOBJCTX
|
---|
39 | {
|
---|
40 | /** Pointer to current object being processed. */
|
---|
41 | SharedClipboardURIObject *pObj;
|
---|
42 | } VBOXCLIPBOARDCLIENTURIOBJCTX, *PVBOXCLIPBOARDCLIENTURIOBJCTX;
|
---|
43 |
|
---|
44 | struct VBOXCLIPBOARDCLIENTSTATE;
|
---|
45 |
|
---|
46 | /**
|
---|
47 | * Structure for maintaining a single URI transfer.
|
---|
48 | * A transfer can contain one or multiple files / directories.
|
---|
49 | */
|
---|
50 | typedef struct _VBOXCLIPBOARDCLIENTURITRANSFER
|
---|
51 | {
|
---|
52 | /** Node for keeping this transfer in a RTList. */
|
---|
53 | RTLISTNODE Node;
|
---|
54 | /** Pointer to the client state (parent). */
|
---|
55 | VBOXCLIPBOARDCLIENTSTATE *pState;
|
---|
56 | /** The transfer's own (local) area.
|
---|
57 | * The area itself has a clipboard area ID assigned, which gets shared (maintained / locked) across all
|
---|
58 | * VMs via VBoxSVC. */
|
---|
59 | SharedClipboardArea Area;
|
---|
60 | /** The transfer's URI list, containing the fs object root entries. */
|
---|
61 | SharedClipboardURIList List;
|
---|
62 | /** Current object being handled. */
|
---|
63 | VBOXCLIPBOARDCLIENTURIOBJCTX ObjCtx;
|
---|
64 | /** The transfer header, needed for verification and accounting. */
|
---|
65 | VBOXCLIPBOARDDATAHDR Hdr;
|
---|
66 | /** Intermediate meta data object. */
|
---|
67 | SHAREDCLIPBOARDMETADATA Meta;
|
---|
68 | } VBOXCLIPBOARDCLIENTURITRANSFER, *PVBOXCLIPBOARDCLIENTURITRANSFER;
|
---|
69 | #endif /* VBOX_WITH_SHARED_CLIPBOARD_URI_LIST */
|
---|
70 |
|
---|
71 | /**
|
---|
72 | * Structure for keeping generic client state data within the Shared Clipboard host service.
|
---|
73 | * This structure needs to be serializable by SSM.
|
---|
74 | */
|
---|
75 | struct VBOXCLIPBOARDCLIENTSTATE
|
---|
76 | {
|
---|
77 | struct VBOXCLIPBOARDCLIENTSTATE *pNext;
|
---|
78 | struct VBOXCLIPBOARDCLIENTSTATE *pPrev;
|
---|
79 |
|
---|
80 | VBOXCLIPBOARDCONTEXT *pCtx;
|
---|
81 |
|
---|
82 | uint32_t u32ClientID;
|
---|
83 |
|
---|
84 | /** The guest is waiting for a message. */
|
---|
85 | bool fAsync;
|
---|
86 | /** The guest is waiting for data from the host */
|
---|
87 | bool fReadPending;
|
---|
88 | /** Whether the host host has sent a quit message. */
|
---|
89 | bool fHostMsgQuit;
|
---|
90 | /** Whether the host host has requested reading clipboard data from the guest. */
|
---|
91 | bool fHostMsgReadData;
|
---|
92 | /** Whether the host host has reported its available formats. */
|
---|
93 | bool fHostMsgFormats;
|
---|
94 |
|
---|
95 | struct {
|
---|
96 | VBOXHGCMCALLHANDLE callHandle;
|
---|
97 | VBOXHGCMSVCPARM *paParms;
|
---|
98 | } async;
|
---|
99 |
|
---|
100 | struct {
|
---|
101 | VBOXHGCMCALLHANDLE callHandle;
|
---|
102 | VBOXHGCMSVCPARM *paParms;
|
---|
103 | } asyncRead;
|
---|
104 |
|
---|
105 | struct {
|
---|
106 | void *pv;
|
---|
107 | uint32_t cb;
|
---|
108 | uint32_t u32Format;
|
---|
109 | } data;
|
---|
110 |
|
---|
111 | uint32_t u32AvailableFormats;
|
---|
112 | uint32_t u32RequestedFormat;
|
---|
113 | };
|
---|
114 | typedef struct VBOXCLIPBOARDCLIENTSTATE *PVBOXCLIPBOARDCLIENTSTATE;
|
---|
115 |
|
---|
116 | /**
|
---|
117 | * Structure for keeping a HGCM client state within the Shared Clipboard host service.
|
---|
118 | */
|
---|
119 | typedef struct _VBOXCLIPBOARDCLIENTDATA
|
---|
120 | {
|
---|
121 | /** General client state data. */
|
---|
122 | VBOXCLIPBOARDCLIENTSTATE State;
|
---|
123 | #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
|
---|
124 | SHAREDCLIPBOARDURICTX URI;
|
---|
125 | #endif
|
---|
126 | } VBOXCLIPBOARDCLIENTDATA, *PVBOXCLIPBOARDCLIENTDATA;
|
---|
127 |
|
---|
128 | /*
|
---|
129 | * The service functions. Locking is between the service thread and the platform-dependent (window) thread.
|
---|
130 | */
|
---|
131 | uint32_t vboxSvcClipboardGetMode(void);
|
---|
132 | int vboxSvcClipboardReportMsg(PVBOXCLIPBOARDCLIENTDATA pClientData, uint32_t uMsg, uint32_t uFormats);
|
---|
133 | int vboxSvcClipboardCompleteReadData(PVBOXCLIPBOARDCLIENTDATA pClientData, int rc, uint32_t cbActual);
|
---|
134 |
|
---|
135 | # ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
|
---|
136 | bool vboxSvcClipboardURIMsgIsAllowed(uint32_t uMode, uint32_t uMsg);
|
---|
137 | int vboxSvcClipboardURIReportMsg(PVBOXCLIPBOARDCLIENTDATA pClientData, uint32_t u32Msg, uint32_t u32Formats);
|
---|
138 | bool vboxSvcClipboardURIReturnMsg(PVBOXCLIPBOARDCLIENTDATA pClientData, uint32_t cParms, VBOXHGCMSVCPARM paParms[]);
|
---|
139 | # endif /* VBOX_WITH_SHARED_CLIPBOARD_URI_LIST */
|
---|
140 |
|
---|
141 | /*
|
---|
142 | * Platform-dependent implementations.
|
---|
143 | */
|
---|
144 | int VBoxClipboardSvcImplInit(void);
|
---|
145 | void VBoxClipboardSvcImplDestroy(void);
|
---|
146 |
|
---|
147 | int VBoxClipboardSvcImplConnect(PVBOXCLIPBOARDCLIENTDATA pClientData, bool fHeadless);
|
---|
148 | int VBoxClipboardSvcImplDisconnect(PVBOXCLIPBOARDCLIENTDATA pClientData);
|
---|
149 | int VBoxClipboardSvcImplFormatAnnounce(PVBOXCLIPBOARDCLIENTDATA pClientData, uint32_t u32Formats);
|
---|
150 | int VBoxClipboardSvcImplReadData(PVBOXCLIPBOARDCLIENTDATA pClientData, uint32_t u32Format, void *pv, uint32_t cb, uint32_t *pcbActual);
|
---|
151 | int VBoxClipboardSvcImplWriteData(PVBOXCLIPBOARDCLIENTDATA pClientData, void *pv, uint32_t cb, uint32_t u32Format);
|
---|
152 | /**
|
---|
153 | * Synchronise the contents of the host clipboard with the guest, called by the HGCM layer
|
---|
154 | * after a save and restore of the guest.
|
---|
155 | */
|
---|
156 | int VBoxClipboardSvcImplSync(PVBOXCLIPBOARDCLIENTDATA pClientData);
|
---|
157 |
|
---|
158 | #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
|
---|
159 | int VBoxClipboardSvcImplURIReadDir(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDDIRDATA pDirData);
|
---|
160 | int VBoxClipboardSvcImplURIWriteDir(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDDIRDATA pDirData);
|
---|
161 | int VBoxClipboardSvcImplURIReadFileHdr(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDFILEHDR pFileHdr);
|
---|
162 | int VBoxClipboardSvcImplURIWriteFileHdr(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDFILEHDR pFileHdr);
|
---|
163 | int VBoxClipboardSvcImplURIReadFileData(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDFILEDATA pFileData);
|
---|
164 | int VBoxClipboardSvcImplURIWriteFileData(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDFILEDATA pFileData);
|
---|
165 | #endif
|
---|
166 |
|
---|
167 | /* Host unit testing interface */
|
---|
168 | #ifdef UNIT_TEST
|
---|
169 | uint32_t TestClipSvcGetMode(void);
|
---|
170 | #endif
|
---|
171 |
|
---|
172 | #endif /* !VBOX_INCLUDED_SRC_SharedClipboard_VBoxSharedClipboardSvc_internal_h */
|
---|
173 |
|
---|