VirtualBox

source: vbox/trunk/src/VBox/GuestHost/SharedClipboard/ClipboardProvider-VbglR3.cpp@ 79212

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

Shared Clipboard/URI: Update.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.7 KB
Line 
1/* $Id: ClipboardProvider-VbglR3.cpp 79120 2019-06-13 10:08:33Z vboxsync $ */
2/** @file
3 * Shared Clipboard - Provider implementation for VbglR3 (guest 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#include <VBox/VBoxGuestLib.h>
25
26#include <iprt/asm.h>
27#include <iprt/assert.h>
28#include <iprt/dir.h>
29#include <iprt/errcore.h>
30#include <iprt/file.h>
31#include <iprt/path.h>
32#include <iprt/string.h>
33
34#include <VBox/log.h>
35
36
37SharedClipboardProviderVbglR3::SharedClipboardProviderVbglR3(uint32_t uClientID)
38 : m_uClientID(uClientID)
39{
40 LogFlowFunc(("m_uClientID=%RU32\n", m_uClientID));
41}
42
43SharedClipboardProviderVbglR3::~SharedClipboardProviderVbglR3(void)
44{
45}
46
47int SharedClipboardProviderVbglR3::ReadDataHdr(PVBOXCLIPBOARDDATAHDR pDataHdr)
48{
49 LogFlowFuncEnter();
50
51 int rc = VbglR3ClipboardReadDataHdr(m_uClientID, pDataHdr);
52
53 LogFlowFuncLeaveRC(rc);
54 return rc;
55}
56
57int SharedClipboardProviderVbglR3::WriteDataHdr(const PVBOXCLIPBOARDDATAHDR pDataHdr)
58{
59 LogFlowFuncEnter();
60
61 int rc = VbglR3ClipboardWriteDataHdr(m_uClientID, pDataHdr);
62
63 LogFlowFuncLeaveRC(rc);
64 return rc;
65}
66
67int SharedClipboardProviderVbglR3::ReadDataChunkk(const PVBOXCLIPBOARDDATAHDR pDataHdr, void *pvChunk, uint32_t cbChunk,
68 uint32_t *pcbRead, uint32_t fFlags /* = 0 */)
69{
70 RT_NOREF(fFlags);
71
72 LogFlowFuncEnter();
73
74 int rc = VINF_SUCCESS;
75
76 uint32_t cbReadTotal = 0;
77 uint32_t cbToRead = RT_MIN(pDataHdr->cbMeta, cbChunk);
78
79 while (cbToRead)
80 {
81 uint32_t cbRead;
82 rc = VbglR3ClipboardReadMetaData(m_uClientID, pDataHdr, (uint8_t *)pvChunk + cbReadTotal, cbToRead, &cbRead);
83 if (RT_FAILURE(rc))
84 break;
85
86 cbReadTotal += cbRead;
87 Assert(cbToRead >= cbRead);
88 cbToRead -= cbRead;
89 }
90
91 if (RT_SUCCESS(rc))
92 {
93 if (pcbRead)
94 *pcbRead = cbReadTotal;
95 }
96
97 LogFlowFuncLeaveRC(rc);
98 return rc;
99}
100
101int SharedClipboardProviderVbglR3::WriteDataChunk(const PVBOXCLIPBOARDDATAHDR pDataHdr, const void *pvChunk, uint32_t cbChunk,
102 uint32_t *pcbWritten, uint32_t fFlags /* = 0 */)
103{
104 RT_NOREF(fFlags);
105
106 LogFlowFuncEnter();
107
108 int rc = VINF_SUCCESS;
109
110 uint32_t cbWrittenTotal = 0;
111 uint32_t cbToWrite = RT_MIN(pDataHdr->cbMeta, cbChunk);
112
113 while (cbToWrite)
114 {
115 uint32_t cbWritten;
116 rc = VbglR3ClipboardWriteMetaData(m_uClientID, pDataHdr, (uint8_t *)pvChunk + cbWrittenTotal, cbToWrite, &cbWritten);
117 if (RT_FAILURE(rc))
118 break;
119
120 cbWrittenTotal += cbWritten;
121 Assert(cbToWrite >= cbWritten);
122 cbToWrite -= cbWritten;
123 }
124
125 if (RT_SUCCESS(rc))
126 {
127 if (pcbWritten)
128 *pcbWritten = cbWrittenTotal;
129 }
130
131 LogFlowFuncLeaveRC(rc);
132 return rc;
133}
134
135int SharedClipboardProviderVbglR3::ReadDirectory(PVBOXCLIPBOARDDIRDATA pDirData)
136{
137 LogFlowFuncEnter();
138
139 int rc = VbglR3ClipboardReadDir(m_uClientID, pDirData->pszPath, pDirData->cbPath, &pDirData->cbPath, &pDirData->fMode);
140
141 LogFlowFuncLeaveRC(rc);
142 return rc;
143}
144
145int SharedClipboardProviderVbglR3::WriteDirectory(const PVBOXCLIPBOARDDIRDATA pDirData)
146{
147 LogFlowFuncEnter();
148
149 int rc = VbglR3ClipboardWriteDir(m_uClientID, pDirData->pszPath, pDirData->cbPath, pDirData->fMode);
150
151 LogFlowFuncLeaveRC(rc);
152 return rc;
153}
154
155int SharedClipboardProviderVbglR3::ReadFileHdr(PVBOXCLIPBOARDFILEHDR pFileHdr)
156{
157 LogFlowFuncEnter();
158
159 int rc = VbglR3ClipboardReadFileHdr(m_uClientID, pFileHdr->pszFilePath, pFileHdr->cbFilePath,
160 &pFileHdr->fFlags, &pFileHdr->fMode, &pFileHdr->cbSize);
161 LogFlowFuncLeaveRC(rc);
162 return rc;
163}
164
165int SharedClipboardProviderVbglR3::WriteFileHdr(const PVBOXCLIPBOARDFILEHDR pFileHdr)
166{
167 LogFlowFuncEnter();
168
169 int rc = VbglR3ClipboardWriteFileHdr(m_uClientID, pFileHdr->pszFilePath, pFileHdr->cbFilePath,
170 pFileHdr->fFlags, pFileHdr->fMode, pFileHdr->cbSize);
171 LogFlowFuncLeaveRC(rc);
172 return rc;
173}
174
175int SharedClipboardProviderVbglR3::ReadFileData(PVBOXCLIPBOARDFILEDATA pFileData, uint32_t *pcbRead)
176{
177 AssertPtrReturn(pcbRead, VERR_INVALID_POINTER);
178
179 LogFlowFuncEnter();
180
181 int rc = VbglR3ClipboardReadFileData(m_uClientID, pFileData->pvData, pFileData->cbData, pcbRead);
182
183 LogFlowFuncLeaveRC(rc);
184 return rc;
185}
186
187int SharedClipboardProviderVbglR3::WriteFileData(const PVBOXCLIPBOARDFILEDATA pFileData, uint32_t *pcbWritten)
188{
189 AssertPtrReturn(pcbWritten, VERR_INVALID_POINTER);
190
191 LogFlowFuncEnter();
192
193 int rc = VbglR3ClipboardWriteFileData(m_uClientID, pFileData->pvData, pFileData->cbData, pcbWritten);
194
195 LogFlowFuncLeaveRC(rc);
196 return rc;
197}
198
199void SharedClipboardProviderVbglR3::Reset(void)
200{
201 LogFlowFuncEnter();
202
203 /* Don't clear the refcount here. */
204}
205
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