1 | /* $Id: ClipboardProvider.cpp 79036 2019-06-07 14:56:19Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Shared Clipboard - Provider implementation.
|
---|
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 |
|
---|
34 | #include <VBox/log.h>
|
---|
35 |
|
---|
36 |
|
---|
37 |
|
---|
38 | SharedClipboardProvider::SharedClipboardProvider(void)
|
---|
39 | : m_cRefs(0)
|
---|
40 | {
|
---|
41 | LogFlowFuncEnter();
|
---|
42 | }
|
---|
43 |
|
---|
44 | SharedClipboardProvider::~SharedClipboardProvider(void)
|
---|
45 | {
|
---|
46 | LogFlowFuncEnter();
|
---|
47 | Assert(m_cRefs == 0);
|
---|
48 | }
|
---|
49 |
|
---|
50 | /**
|
---|
51 | * Creates a Shared Clipboard provider.
|
---|
52 | *
|
---|
53 | * @returns New Shared Clipboard provider instance.
|
---|
54 | * @param pCtx Pointer to creation context.
|
---|
55 | */
|
---|
56 | /* static */
|
---|
57 | SharedClipboardProvider *SharedClipboardProvider::Create(PSHAREDCLIPBOARDPROVIDERCREATIONCTX pCtx)
|
---|
58 | {
|
---|
59 | AssertPtrReturn(pCtx, NULL);
|
---|
60 |
|
---|
61 | SharedClipboardProvider *pProvider = NULL;
|
---|
62 |
|
---|
63 | switch (pCtx->enmSource)
|
---|
64 | {
|
---|
65 | #ifdef VBOX_WITH_SHARED_CLIPBOARD_GUEST
|
---|
66 | case SHAREDCLIPBOARDPROVIDERSOURCE_VBGLR3:
|
---|
67 | pProvider = new SharedClipboardProviderVbglR3(pCtx->u.VBGLR3.uClientID);
|
---|
68 | break;
|
---|
69 | #endif
|
---|
70 |
|
---|
71 | #ifdef VBOX_WITH_SHARED_CLIPBOARD_HOST
|
---|
72 | case SHAREDCLIPBOARDPROVIDERSOURCE_HOSTSERVICE:
|
---|
73 | pProvider = new SharedClipboardProviderHostService();
|
---|
74 | break;
|
---|
75 | #endif
|
---|
76 | default:
|
---|
77 | AssertFailed();
|
---|
78 | break;
|
---|
79 | }
|
---|
80 |
|
---|
81 | return pProvider;
|
---|
82 | }
|
---|
83 |
|
---|
84 | /**
|
---|
85 | * Adds a reference to a Shared Clipboard provider.
|
---|
86 | *
|
---|
87 | * @returns New reference count.
|
---|
88 | */
|
---|
89 | uint32_t SharedClipboardProvider::AddRef(void)
|
---|
90 | {
|
---|
91 | LogFlowFuncEnter();
|
---|
92 | return ASMAtomicIncU32(&m_cRefs);
|
---|
93 | }
|
---|
94 |
|
---|
95 | /**
|
---|
96 | * Removes a reference from a Shared Clipboard cache.
|
---|
97 | *
|
---|
98 | * @returns New reference count.
|
---|
99 | */
|
---|
100 | uint32_t SharedClipboardProvider::Release(void)
|
---|
101 | {
|
---|
102 | LogFlowFuncEnter();
|
---|
103 | Assert(m_cRefs);
|
---|
104 | return ASMAtomicDecU32(&m_cRefs);
|
---|
105 | }
|
---|
106 |
|
---|
107 | /*
|
---|
108 | * Stubs.
|
---|
109 | */
|
---|
110 |
|
---|
111 | int SharedClipboardProvider::ReadDataHdr(PVBOXCLIPBOARDDATAHDR pDataHdr)
|
---|
112 | {
|
---|
113 | RT_NOREF(pDataHdr);
|
---|
114 | return VERR_NOT_IMPLEMENTED;
|
---|
115 | }
|
---|
116 |
|
---|
117 | int SharedClipboardProvider::WriteDataHdr(const PVBOXCLIPBOARDDATAHDR pDataHdr)
|
---|
118 | {
|
---|
119 | RT_NOREF(pDataHdr);
|
---|
120 | return VERR_NOT_IMPLEMENTED;
|
---|
121 | }
|
---|
122 |
|
---|
123 | int SharedClipboardProvider::ReadMetaData(const PVBOXCLIPBOARDDATAHDR pDataHdr, void *pvMeta, uint32_t cbMeta, uint32_t *pcbRead,
|
---|
124 | uint32_t fFlags /* = 0 */)
|
---|
125 | {
|
---|
126 | RT_NOREF(pDataHdr, pvMeta, cbMeta, pcbRead, fFlags);
|
---|
127 | return VERR_NOT_IMPLEMENTED;
|
---|
128 | }
|
---|
129 |
|
---|
130 | int SharedClipboardProvider::WriteMetaData(const PVBOXCLIPBOARDDATAHDR pDataHdr, const void *pvMeta, uint32_t cbMeta,
|
---|
131 | uint32_t *pcbWritten, uint32_t fFlags /* = 0 */)
|
---|
132 | {
|
---|
133 | RT_NOREF(pDataHdr, pvMeta, cbMeta, pcbWritten, fFlags);
|
---|
134 | return VERR_NOT_IMPLEMENTED;
|
---|
135 | }
|
---|
136 |
|
---|
137 | int SharedClipboardProvider::ReadDirectory(PVBOXCLIPBOARDDIRDATA pDirData)
|
---|
138 | {
|
---|
139 | RT_NOREF(pDirData);
|
---|
140 |
|
---|
141 | LogFlowFuncEnter();
|
---|
142 |
|
---|
143 | int rc = VERR_NOT_IMPLEMENTED;
|
---|
144 |
|
---|
145 | LogFlowFuncLeaveRC(rc);
|
---|
146 | return rc;
|
---|
147 | }
|
---|
148 |
|
---|
149 | int SharedClipboardProvider::WriteDirectory(const PVBOXCLIPBOARDDIRDATA pDirData)
|
---|
150 | {
|
---|
151 | RT_NOREF(pDirData);
|
---|
152 |
|
---|
153 | LogFlowFuncEnter();
|
---|
154 |
|
---|
155 | int rc = VERR_NOT_IMPLEMENTED;
|
---|
156 |
|
---|
157 | LogFlowFuncLeaveRC(rc);
|
---|
158 | return rc;
|
---|
159 | }
|
---|
160 |
|
---|
161 | int SharedClipboardProvider::ReadFileHdr(PVBOXCLIPBOARDFILEHDR pFileHdr)
|
---|
162 | {
|
---|
163 | RT_NOREF(pFileHdr);
|
---|
164 |
|
---|
165 | LogFlowFuncEnter();
|
---|
166 |
|
---|
167 | int rc = VERR_NOT_IMPLEMENTED;
|
---|
168 |
|
---|
169 | LogFlowFuncLeaveRC(rc);
|
---|
170 | return rc;
|
---|
171 | }
|
---|
172 |
|
---|
173 | int SharedClipboardProvider::WriteFileHdr(const PVBOXCLIPBOARDFILEHDR pFileHdr)
|
---|
174 | {
|
---|
175 | RT_NOREF(pFileHdr);
|
---|
176 |
|
---|
177 | LogFlowFuncEnter();
|
---|
178 |
|
---|
179 | int rc = VERR_NOT_IMPLEMENTED;
|
---|
180 |
|
---|
181 | LogFlowFuncLeaveRC(rc);
|
---|
182 | return rc;
|
---|
183 | }
|
---|
184 |
|
---|
185 | int SharedClipboardProvider::ReadFileData(PVBOXCLIPBOARDFILEDATA pFileData, uint32_t *pcbRead)
|
---|
186 | {
|
---|
187 | RT_NOREF(pFileData, pcbRead);
|
---|
188 |
|
---|
189 | LogFlowFuncEnter();
|
---|
190 |
|
---|
191 | int rc = VERR_NOT_IMPLEMENTED;
|
---|
192 |
|
---|
193 | LogFlowFuncLeaveRC(rc);
|
---|
194 | return rc;
|
---|
195 | }
|
---|
196 |
|
---|
197 | int SharedClipboardProvider::WriteFileData(const PVBOXCLIPBOARDFILEDATA pFileData, uint32_t *pcbWritten)
|
---|
198 | {
|
---|
199 | RT_NOREF(pFileData, pcbWritten);
|
---|
200 |
|
---|
201 | LogFlowFuncEnter();
|
---|
202 |
|
---|
203 | int rc = VERR_NOT_IMPLEMENTED;
|
---|
204 |
|
---|
205 | LogFlowFuncLeaveRC(rc);
|
---|
206 | return rc;
|
---|
207 | }
|
---|
208 |
|
---|
209 | void SharedClipboardProvider::Reset(void)
|
---|
210 | {
|
---|
211 | }
|
---|
212 |
|
---|