VirtualBox

source: vbox/trunk/src/VBox/GuestHost/SharedClipboard/ClipboardProvider-HostService.cpp@ 79366

Last change on this file since 79366 was 79347, checked in by vboxsync, 5 years ago

Shared Clipboard/URI: Update.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.9 KB
Line 
1/* $Id: ClipboardProvider-HostService.cpp 79347 2019-06-26 09:15:29Z vboxsync $ */
2/** @file
3 * Shared Clipboard - Provider implementation for host service (host side).
4 */
5
6/*
7 * Copyright (C) 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
19/*********************************************************************************************************************************
20* Header Files *
21*********************************************************************************************************************************/
22#define LOG_GROUP LOG_GROUP_SHARED_CLIPBOARD
23#include <VBox/GuestHost/SharedClipboard-uri.h>
24
25#include <iprt/asm.h>
26#include <iprt/assert.h>
27#include <iprt/dir.h>
28#include <iprt/errcore.h>
29#include <iprt/file.h>
30#include <iprt/path.h>
31#include <iprt/string.h>
32
33#include <VBox/log.h>
34
35
36
37
38SharedClipboardProviderHostService::SharedClipboardProviderHostService(SharedClipboardArea *pArea)
39 : m_pArea(pArea)
40{
41 LogFlowFuncEnter();
42
43 Reset();
44
45 m_pArea->AddRef();
46}
47
48SharedClipboardProviderHostService::~SharedClipboardProviderHostService(void)
49{
50 m_pArea->Release();
51}
52
53int SharedClipboardProviderHostService::Prepare(void)
54{
55 LogFlowFuncEnter();
56
57 return VINF_SUCCESS;
58}
59
60int SharedClipboardProviderHostService::ReadDataHdr(PVBOXCLIPBOARDDATAHDR *ppDataHdr)
61{
62 AssertPtrReturn(ppDataHdr, VERR_INVALID_POINTER);
63
64 LogFlowFuncEnter();
65
66 return VERR_NOT_IMPLEMENTED;
67}
68
69int SharedClipboardProviderHostService::WriteDataHdr(const PVBOXCLIPBOARDDATAHDR pDataHdr)
70{
71 AssertPtrReturn(pDataHdr, VERR_INVALID_POINTER);
72
73 LogFlowFuncEnter();
74
75 return VERR_NOT_IMPLEMENTED;
76}
77
78int SharedClipboardProviderHostService::ReadDataChunk(const PVBOXCLIPBOARDDATAHDR pDataHdr, void *pvChunk, uint32_t cbChunk,
79 uint32_t fFlags /* = 0 */, uint32_t *pcbRead /* = NULL*/)
80{
81 RT_NOREF(pDataHdr, pvChunk, cbChunk, fFlags, pcbRead);
82 return VERR_NOT_IMPLEMENTED;
83}
84
85int SharedClipboardProviderHostService::WriteDataChunk(const PVBOXCLIPBOARDDATAHDR pDataHdr, const void *pvChunk, uint32_t cbChunk,
86 uint32_t fFlags /* = 0 */, uint32_t *pcbWritten /* = NULL */)
87{
88 RT_NOREF(pDataHdr, pvChunk, cbChunk, fFlags, pcbWritten);
89 return VERR_NOT_IMPLEMENTED;
90}
91
92int SharedClipboardProviderHostService::ReadDirectory(PVBOXCLIPBOARDDIRDATA *ppDirData)
93{
94 RT_NOREF(ppDirData);
95 return VERR_NOT_IMPLEMENTED;
96}
97
98int SharedClipboardProviderHostService::WriteDirectory(const PVBOXCLIPBOARDDIRDATA pDirData)
99{
100 RT_NOREF(pDirData);
101
102 LogFlowFuncEnter();
103
104 int rc = VERR_NOT_IMPLEMENTED;
105
106 LogFlowFuncLeaveRC(rc);
107 return rc;
108}
109
110int SharedClipboardProviderHostService::ReadFileHdr(PVBOXCLIPBOARDFILEHDR *ppFileHdr)
111{
112 RT_NOREF(ppFileHdr);
113 return VERR_NOT_IMPLEMENTED;
114}
115
116int SharedClipboardProviderHostService::WriteFileHdr(const PVBOXCLIPBOARDFILEHDR pFileHdr)
117{
118 RT_NOREF(pFileHdr);
119
120 LogFlowFuncEnter();
121
122 int rc = VERR_NOT_IMPLEMENTED;
123
124 LogFlowFuncLeaveRC(rc);
125 return rc;
126}
127
128int SharedClipboardProviderHostService::ReadFileData(void *pvData, uint32_t cbData, uint32_t fFlags /* = 0 */,
129 uint32_t *pcbRead /* = NULL */)
130{
131 RT_NOREF(pvData, cbData, fFlags, pcbRead);
132 return VERR_NOT_IMPLEMENTED;
133}
134
135int SharedClipboardProviderHostService::WriteFileData(void *pvData, uint32_t cbData, uint32_t fFlags /* = 0 */,
136 uint32_t *pcbWritten /* = NULL */)
137{
138 RT_NOREF(pvData, cbData, fFlags, pcbWritten);
139
140 LogFlowFuncEnter();
141
142 int rc = VERR_NOT_IMPLEMENTED;
143
144 LogFlowFuncLeaveRC(rc);
145 return rc;
146}
147void SharedClipboardProviderHostService::Reset(void)
148{
149 LogFlowFuncEnter();
150
151 eventUnregisterAll();
152
153 uint32_t aMsgIDs[] = { VBOX_SHARED_CLIPBOARD_GUEST_FN_READ_DATA_HDR,
154 VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_DATA_HDR,
155 VBOX_SHARED_CLIPBOARD_GUEST_FN_READ_DATA_CHUNK,
156 VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_DATA_CHUNK,
157 VBOX_SHARED_CLIPBOARD_GUEST_FN_READ_DIR,
158 VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_DIR,
159 VBOX_SHARED_CLIPBOARD_GUEST_FN_READ_FILE_HDR,
160 VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_FILE_HDR,
161 VBOX_SHARED_CLIPBOARD_GUEST_FN_READ_FILE_DATA,
162 VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_FILE_DATA };
163
164 for (unsigned i = 0; i < RT_ELEMENTS(aMsgIDs); i++)
165 {
166 int rc2 = eventRegister(aMsgIDs[i]);
167 AssertRC(rc2);
168 }
169}
170
171int SharedClipboardProviderHostService::OnWrite(PSHAREDCLIPBOARDPROVIDERWRITEPARMS pParms)
172{
173 RT_NOREF(pParms);
174
175 LogFlowFuncEnter();
176
177 int rc = VERR_NOT_SUPPORTED;
178
179#if 0
180 switch (pParms->u.HostService.uMsg)
181 {
182 case VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_DATA_HDR:
183 {
184 VBOXCLIPBOARDDATAHDR dataHdr;
185 rc = VBoxSvcClipboardURIReadDataHdr(pParms->u.HostService.cParms, pParms->u.HostService.paParms, &dataHdr);
186 if (RT_SUCCESS(rc))
187 {
188 /** @todo Handle compression type. */
189 /** @todo Handle checksum type. */
190 #if 0
191 Event *pEvent = eventGet(pParms->u.HostService.uMsg);
192 if (pEvent)
193 rc = pEvent->SetData(SharedClipboardURIDataHdrDup(&dataHdr),
194 sizeof(dataHdr) + dataHdr.cbMetaFmt + dataHdr.cbChecksum);
195 #endif
196 }
197 break;
198 }
199
200 case VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_DATA_CHUNK:
201 {
202 VBOXCLIPBOARDDATACHUNK dataChunk;
203 rc = VBoxSvcClipboardURIReadDataChunk(pParms->u.HostService.cParms, pParms->u.HostService.paParms, &dataChunk);
204 if (RT_SUCCESS(rc))
205 {
206 Event *pEvent = eventGet(pParms->u.HostService.uMsg);
207 if (pEvent)
208 rc = pEvent->SetData(SharedClipboardURIDataChunkDup(&dataChunk),
209 sizeof(dataChunk) + dataChunk.cbData + dataChunk.cbChecksum);
210 }
211 break;
212 }
213
214 case VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_DIR:
215 {
216 VBOXCLIPBOARDDIRDATA dirData;
217 rc = VBoxSvcClipboardURIReadDir(pParms->u.HostService.cParms, pParms->u.HostService.paParms, &dirData);
218 if (RT_SUCCESS(rc))
219 {
220 Event *pEvent = eventGet(pParms->u.HostService.uMsg);
221 if (pEvent)
222 rc = pEvent->SetData(SharedClipboardURIDirDataDup(&dirData),
223 sizeof(dirData) + dirData.cbPath);
224 }
225 break;
226 }
227
228 case VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_FILE_HDR:
229 {
230 VBOXCLIPBOARDFILEHDR fileHdr;
231 rc = VBoxSvcClipboardURIReadFileHdr(pParms->u.HostService.cParms, pParms->u.HostService.paParms, &fileHdr);
232 if (RT_SUCCESS(rc))
233 {
234 Event *pEvent = eventGet(pParms->u.HostService.uMsg);
235 if (pEvent)
236 rc = pEvent->SetData(SharedClipboardURIFileHdrDup(&fileHdr),
237 sizeof(fileHdr) + fileHdr.cbFilePath);
238 }
239 break;
240 }
241
242 case VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_FILE_DATA:
243 {
244 VBOXCLIPBOARDFILEDATA fileData;
245 rc = VBoxSvcClipboardURIReadFileData(pParms->u.HostService.cParms, pParms->u.HostService.paParms, &fileData);
246 if (RT_SUCCESS(rc))
247 {
248 Event *pEvent = eventGet(pParms->u.HostService.uMsg);
249 if (pEvent)
250 rc = pEvent->SetData(SharedClipboardURIFileDataDup(&fileData),
251 sizeof(fileData) + fileData.cbData + fileData.cbChecksum);
252 }
253 break;
254 }
255
256 case VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_CANCEL:
257 {
258 AssertFailedStmt(rc = VERR_NOT_IMPLEMENTED);
259 break;
260 }
261
262 case VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_ERROR:
263 {
264 AssertFailedStmt(rc = VERR_NOT_IMPLEMENTED);
265 break;
266 }
267
268 default:
269 break;
270 }
271
272 if (RT_SUCCESS(rc))
273 {
274 rc = eventSignal(pParms->u.HostService.uMsg);
275 if (rc == VERR_NOT_FOUND) /* Having an event is optional, so don't fail here. */
276 rc = VINF_SUCCESS;
277 }
278#endif
279
280 LogFlowFuncLeaveRC(rc);
281 return rc;
282}
283
Note: See TracBrowser for help on using the repository browser.

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