1 | /* $Id: clipboard-uri.cpp 80283 2019-08-15 08:47:23Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Shared Clipboard: Common URI transfer handling code.
|
---|
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.alldomusa.eu.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 | #define LOG_GROUP LOG_GROUP_SHARED_CLIPBOARD
|
---|
19 | #include <VBox/log.h>
|
---|
20 |
|
---|
21 | #include <iprt/dir.h>
|
---|
22 | #include <iprt/file.h>
|
---|
23 | #include <iprt/path.h>
|
---|
24 | #include <iprt/semaphore.h>
|
---|
25 |
|
---|
26 | #include <VBox/err.h>
|
---|
27 | #include <VBox/HostServices/VBoxClipboardSvc.h>
|
---|
28 | #include <VBox/GuestHost/SharedClipboard-uri.h>
|
---|
29 |
|
---|
30 |
|
---|
31 | #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
|
---|
32 | static int sharedClipboardURITransferThreadCreate(PSHAREDCLIPBOARDURITRANSFER pTransfer, PFNRTTHREAD pfnThreadFunc, void *pvUser);
|
---|
33 | static int sharedClipboardURITransferThreadDestroy(PSHAREDCLIPBOARDURITRANSFER pTransfer, RTMSINTERVAL uTimeoutMs);
|
---|
34 | static int sharedClipboardURITransferWriteThread(RTTHREAD hThread, void *pvUser);
|
---|
35 | static PSHAREDCLIPBOARDURITRANSFER sharedClipboardURICtxGetTransferInternal(PSHAREDCLIPBOARDURICTX pURI, uint32_t uIdx);
|
---|
36 | #endif
|
---|
37 |
|
---|
38 | /** @todo Split this file up in different modules. */
|
---|
39 |
|
---|
40 | /**
|
---|
41 | * Allocates a new URI root list.
|
---|
42 | *
|
---|
43 | * @returns Allocated URI root list on success, or NULL on failure.
|
---|
44 | */
|
---|
45 | PVBOXCLIPBOARDROOTLIST SharedClipboardURIRootListAlloc(void)
|
---|
46 | {
|
---|
47 | PVBOXCLIPBOARDROOTLIST pRootList = (PVBOXCLIPBOARDROOTLIST)RTMemAllocZ(sizeof(VBOXCLIPBOARDROOTLIST));
|
---|
48 |
|
---|
49 | return pRootList;
|
---|
50 | }
|
---|
51 |
|
---|
52 | /**
|
---|
53 | * Frees an URI root list.
|
---|
54 | *
|
---|
55 | * @param pRootList URI root list to free. The pointer will be
|
---|
56 | * invalid after returning from this function.
|
---|
57 | */
|
---|
58 | void SharedClipboardURIRootListFree(PVBOXCLIPBOARDROOTLIST pRootList)
|
---|
59 | {
|
---|
60 | if (!pRootList)
|
---|
61 | return;
|
---|
62 |
|
---|
63 | for (uint32_t i = 0; i < pRootList->Hdr.cRoots; i++)
|
---|
64 | SharedClipboardURIListEntryDestroy(&pRootList->paEntries[i]);
|
---|
65 |
|
---|
66 | RTMemFree(pRootList);
|
---|
67 | pRootList = NULL;
|
---|
68 | }
|
---|
69 |
|
---|
70 | /**
|
---|
71 | * Initializes an URI root list header.
|
---|
72 | *
|
---|
73 | * @returns VBox status code.
|
---|
74 | * @param pRootLstHdr Root list header to initialize.
|
---|
75 | */
|
---|
76 | int SharedClipboardURIRootListHdrInit(PVBOXCLIPBOARDROOTLISTHDR pRootLstHdr)
|
---|
77 | {
|
---|
78 | AssertPtrReturn(pRootLstHdr, VERR_INVALID_POINTER);
|
---|
79 |
|
---|
80 | RT_BZERO(pRootLstHdr, sizeof(VBOXCLIPBOARDROOTLISTHDR));
|
---|
81 |
|
---|
82 | return VINF_SUCCESS;
|
---|
83 | }
|
---|
84 |
|
---|
85 | /**
|
---|
86 | * Destroys an URI root list header.
|
---|
87 | *
|
---|
88 | * @param pRootLstHdr Root list header to destroy.
|
---|
89 | */
|
---|
90 | void SharedClipboardURIRootListHdrDestroy(PVBOXCLIPBOARDROOTLISTHDR pRootLstHdr)
|
---|
91 | {
|
---|
92 | if (!pRootLstHdr)
|
---|
93 | return;
|
---|
94 |
|
---|
95 | pRootLstHdr->fRoots = 0;
|
---|
96 | pRootLstHdr->cRoots = 0;
|
---|
97 | }
|
---|
98 |
|
---|
99 | /**
|
---|
100 | * Duplicates an URI list header.
|
---|
101 | *
|
---|
102 | * @returns Duplicated URI list header on success, or NULL on failure.
|
---|
103 | * @param pRootLstHdr Root list header to duplicate.
|
---|
104 | */
|
---|
105 | PVBOXCLIPBOARDROOTLISTHDR SharedClipboardURIRootListHdrDup(PVBOXCLIPBOARDROOTLISTHDR pRootLstHdr)
|
---|
106 | {
|
---|
107 | AssertPtrReturn(pRootLstHdr, NULL);
|
---|
108 |
|
---|
109 | int rc = VINF_SUCCESS;
|
---|
110 |
|
---|
111 | PVBOXCLIPBOARDROOTLISTHDR pRootsDup = (PVBOXCLIPBOARDROOTLISTHDR)RTMemAllocZ(sizeof(VBOXCLIPBOARDROOTLISTHDR));
|
---|
112 | if (pRootsDup)
|
---|
113 | {
|
---|
114 | *pRootsDup = *pRootLstHdr;
|
---|
115 | }
|
---|
116 | else
|
---|
117 | rc = VERR_NO_MEMORY;
|
---|
118 |
|
---|
119 | if (RT_FAILURE(rc))
|
---|
120 | {
|
---|
121 | SharedClipboardURIRootListHdrDestroy(pRootsDup);
|
---|
122 | pRootsDup = NULL;
|
---|
123 | }
|
---|
124 |
|
---|
125 | return pRootsDup;
|
---|
126 | }
|
---|
127 |
|
---|
128 | /**
|
---|
129 | * (Deep) Copies a clipboard root list entry structure.
|
---|
130 | *
|
---|
131 | * @returns VBox status code.
|
---|
132 | * @param pListEntry Clipboard root list entry to copy.
|
---|
133 | */
|
---|
134 | int SharedClipboardURIRootListEntryCopy(PVBOXCLIPBOARDROOTLISTENTRY pDst, PVBOXCLIPBOARDROOTLISTENTRY pSrc)
|
---|
135 | {
|
---|
136 | return SharedClipboardURIListEntryCopy(pDst, pSrc);
|
---|
137 | }
|
---|
138 |
|
---|
139 | /**
|
---|
140 | * Duplicates (allocates) a clipboard root list entry structure.
|
---|
141 | *
|
---|
142 | * @returns Duplicated clipboard root list entry structure on success.
|
---|
143 | * @param pListEntry Clipboard root list entry to duplicate.
|
---|
144 | */
|
---|
145 | PVBOXCLIPBOARDROOTLISTENTRY SharedClipboardURIRootListEntryDup(PVBOXCLIPBOARDROOTLISTENTRY pRootListEntry)
|
---|
146 | {
|
---|
147 | return SharedClipboardURIListEntryDup(pRootListEntry);
|
---|
148 | }
|
---|
149 |
|
---|
150 | /**
|
---|
151 | * Destroys a clipboard root list entry structure.
|
---|
152 | *
|
---|
153 | * @param pListEntry Clipboard root list entry structure to destroy.
|
---|
154 | */
|
---|
155 | void SharedClipboardURIRootListEntryDestroy(PVBOXCLIPBOARDROOTLISTENTRY pRootListEntry)
|
---|
156 | {
|
---|
157 | return SharedClipboardURIListEntryDestroy(pRootListEntry);
|
---|
158 | }
|
---|
159 |
|
---|
160 | /**
|
---|
161 | * Allocates a URI list header structure.
|
---|
162 | *
|
---|
163 | * @returns VBox status code.
|
---|
164 | * @param ppListHdr Where to store the allocated URI list header structure on success.
|
---|
165 | */
|
---|
166 | int SharedClipboardURIListHdrAlloc(PVBOXCLIPBOARDLISTHDR *ppListHdr)
|
---|
167 | {
|
---|
168 | int rc;
|
---|
169 |
|
---|
170 | PVBOXCLIPBOARDLISTHDR pListHdr = (PVBOXCLIPBOARDLISTHDR)RTMemAllocZ(sizeof(VBOXCLIPBOARDLISTHDR));
|
---|
171 | if (pListHdr)
|
---|
172 | {
|
---|
173 | *ppListHdr = pListHdr;
|
---|
174 | rc = VINF_SUCCESS;
|
---|
175 | }
|
---|
176 | else
|
---|
177 | rc = VERR_NO_MEMORY;
|
---|
178 |
|
---|
179 | LogFlowFuncLeaveRC(rc);
|
---|
180 | return rc;
|
---|
181 | }
|
---|
182 |
|
---|
183 | /**
|
---|
184 | * Frees an URI list header structure.
|
---|
185 | *
|
---|
186 | * @param pListEntry URI list header structure to free.
|
---|
187 | */
|
---|
188 | void SharedClipboardURIListHdrFree(PVBOXCLIPBOARDLISTHDR pListHdr)
|
---|
189 | {
|
---|
190 | if (!pListHdr)
|
---|
191 | return;
|
---|
192 |
|
---|
193 | LogFlowFuncEnter();
|
---|
194 |
|
---|
195 | SharedClipboardURIListHdrDestroy(pListHdr);
|
---|
196 |
|
---|
197 | RTMemFree(pListHdr);
|
---|
198 | pListHdr = NULL;
|
---|
199 | }
|
---|
200 |
|
---|
201 | /**
|
---|
202 | * Duplicates (allocates) an URI list header structure.
|
---|
203 | *
|
---|
204 | * @returns Duplicated URI list header structure on success.
|
---|
205 | * @param pListHdr URI list header to duplicate.
|
---|
206 | */
|
---|
207 | PVBOXCLIPBOARDLISTHDR SharedClipboardURIListHdrDup(PVBOXCLIPBOARDLISTHDR pListHdr)
|
---|
208 | {
|
---|
209 | AssertPtrReturn(pListHdr, NULL);
|
---|
210 |
|
---|
211 | PVBOXCLIPBOARDLISTHDR pListHdrDup = (PVBOXCLIPBOARDLISTHDR)RTMemAlloc(sizeof(VBOXCLIPBOARDLISTHDR));
|
---|
212 | if (pListHdrDup)
|
---|
213 | {
|
---|
214 | *pListHdrDup = *pListHdr;
|
---|
215 | }
|
---|
216 |
|
---|
217 | return pListHdrDup;
|
---|
218 | }
|
---|
219 |
|
---|
220 | /**
|
---|
221 | * Initializes an URI data header struct.
|
---|
222 | *
|
---|
223 | * @returns VBox status code.
|
---|
224 | * @param pListHdr Data header struct to initialize.
|
---|
225 | */
|
---|
226 | int SharedClipboardURIListHdrInit(PVBOXCLIPBOARDLISTHDR pListHdr)
|
---|
227 | {
|
---|
228 | AssertPtrReturn(pListHdr, VERR_INVALID_POINTER);
|
---|
229 |
|
---|
230 | LogFlowFuncEnter();
|
---|
231 |
|
---|
232 | SharedClipboardURIListHdrReset(pListHdr);
|
---|
233 |
|
---|
234 | return VINF_SUCCESS;
|
---|
235 | }
|
---|
236 |
|
---|
237 | /**
|
---|
238 | * Destroys an URI data header struct.
|
---|
239 | *
|
---|
240 | * @param pListHdr Data header struct to destroy.
|
---|
241 | */
|
---|
242 | void SharedClipboardURIListHdrDestroy(PVBOXCLIPBOARDLISTHDR pListHdr)
|
---|
243 | {
|
---|
244 | if (!pListHdr)
|
---|
245 | return;
|
---|
246 |
|
---|
247 | LogFlowFuncEnter();
|
---|
248 | }
|
---|
249 |
|
---|
250 | /**
|
---|
251 | * Resets a VBOXCLIPBOARDListHdr structture.
|
---|
252 | *
|
---|
253 | * @returns VBox status code.
|
---|
254 | * @param pListHdr VBOXCLIPBOARDListHdr structture to reset.
|
---|
255 | */
|
---|
256 | void SharedClipboardURIListHdrReset(PVBOXCLIPBOARDLISTHDR pListHdr)
|
---|
257 | {
|
---|
258 | AssertPtrReturnVoid(pListHdr);
|
---|
259 |
|
---|
260 | LogFlowFuncEnter();
|
---|
261 |
|
---|
262 | RT_BZERO(pListHdr, sizeof(VBOXCLIPBOARDLISTHDR));
|
---|
263 | }
|
---|
264 |
|
---|
265 | /**
|
---|
266 | * Returns whether a given clipboard data header is valid or not.
|
---|
267 | *
|
---|
268 | * @returns \c true if valid, \c false if not.
|
---|
269 | * @param pListHdr Clipboard data header to validate.
|
---|
270 | */
|
---|
271 | bool SharedClipboardURIListHdrIsValid(PVBOXCLIPBOARDLISTHDR pListHdr)
|
---|
272 | {
|
---|
273 | RT_NOREF(pListHdr);
|
---|
274 | return true; /** @todo Implement this. */
|
---|
275 | }
|
---|
276 |
|
---|
277 | int SharedClipboardURIListOpenParmsCopy(PVBOXCLIPBOARDLISTOPENPARMS pDst, PVBOXCLIPBOARDLISTOPENPARMS pSrc)
|
---|
278 | {
|
---|
279 | AssertPtrReturn(pDst, VERR_INVALID_POINTER);
|
---|
280 | AssertPtrReturn(pSrc, VERR_INVALID_POINTER);
|
---|
281 |
|
---|
282 | int rc = VINF_SUCCESS;
|
---|
283 |
|
---|
284 | if (pSrc->pszFilter)
|
---|
285 | {
|
---|
286 | pDst->pszFilter = RTStrDup(pSrc->pszFilter);
|
---|
287 | if (!pDst->pszFilter)
|
---|
288 | rc = VERR_NO_MEMORY;
|
---|
289 | }
|
---|
290 |
|
---|
291 | if ( RT_SUCCESS(rc)
|
---|
292 | && pSrc->pszPath)
|
---|
293 | {
|
---|
294 | pDst->pszPath = RTStrDup(pSrc->pszPath);
|
---|
295 | if (!pDst->pszPath)
|
---|
296 | rc = VERR_NO_MEMORY;
|
---|
297 | }
|
---|
298 |
|
---|
299 | if (RT_SUCCESS(rc))
|
---|
300 | {
|
---|
301 | pDst->fList = pDst->fList;
|
---|
302 | pDst->cbFilter = pSrc->cbFilter;
|
---|
303 | pDst->cbPath = pSrc->cbPath;
|
---|
304 | }
|
---|
305 |
|
---|
306 | return rc;
|
---|
307 | }
|
---|
308 |
|
---|
309 | /**
|
---|
310 | * Duplicates an URI list open parameters structure.
|
---|
311 | *
|
---|
312 | * @returns Duplicated URI list open parameters structure on success, or NULL on failure.
|
---|
313 | * @param pParms URI list open parameters structure to duplicate.
|
---|
314 | */
|
---|
315 | PVBOXCLIPBOARDLISTOPENPARMS SharedClipboardURIListOpenParmsDup(PVBOXCLIPBOARDLISTOPENPARMS pParms)
|
---|
316 | {
|
---|
317 | AssertPtrReturn(pParms, NULL);
|
---|
318 |
|
---|
319 | PVBOXCLIPBOARDLISTOPENPARMS pParmsDup = (PVBOXCLIPBOARDLISTOPENPARMS)RTMemAllocZ(sizeof(VBOXCLIPBOARDLISTOPENPARMS));
|
---|
320 | if (!pParmsDup)
|
---|
321 | return NULL;
|
---|
322 |
|
---|
323 | int rc = SharedClipboardURIListOpenParmsCopy(pParmsDup, pParms);
|
---|
324 | if (RT_FAILURE(rc))
|
---|
325 | {
|
---|
326 | SharedClipboardURIListOpenParmsDestroy(pParmsDup);
|
---|
327 |
|
---|
328 | RTMemFree(pParmsDup);
|
---|
329 | pParmsDup = NULL;
|
---|
330 | }
|
---|
331 |
|
---|
332 | return pParmsDup;
|
---|
333 | }
|
---|
334 |
|
---|
335 | /**
|
---|
336 | * Initializes an URI list open parameters structure.
|
---|
337 | *
|
---|
338 | * @returns VBox status code.
|
---|
339 | * @param pParms URI list open parameters structure to initialize.
|
---|
340 | */
|
---|
341 | int SharedClipboardURIListOpenParmsInit(PVBOXCLIPBOARDLISTOPENPARMS pParms)
|
---|
342 | {
|
---|
343 | AssertPtrReturn(pParms, VERR_INVALID_POINTER);
|
---|
344 |
|
---|
345 | RT_BZERO(pParms, sizeof(VBOXCLIPBOARDLISTOPENPARMS));
|
---|
346 |
|
---|
347 | pParms->cbFilter = 64; /** @todo Make this dynamic. */
|
---|
348 | pParms->pszFilter = RTStrAlloc(pParms->cbFilter);
|
---|
349 |
|
---|
350 | pParms->cbPath = RTPATH_MAX;
|
---|
351 | pParms->pszPath = RTStrAlloc(pParms->cbPath);
|
---|
352 |
|
---|
353 | LogFlowFuncLeave();
|
---|
354 | return VINF_SUCCESS;
|
---|
355 | }
|
---|
356 |
|
---|
357 | /**
|
---|
358 | * Destroys an URI list open parameters structure.
|
---|
359 | *
|
---|
360 | * @param pParms URI list open parameters structure to destroy.
|
---|
361 | */
|
---|
362 | void SharedClipboardURIListOpenParmsDestroy(PVBOXCLIPBOARDLISTOPENPARMS pParms)
|
---|
363 | {
|
---|
364 | if (!pParms)
|
---|
365 | return;
|
---|
366 |
|
---|
367 | if (pParms->pszFilter)
|
---|
368 | {
|
---|
369 | RTStrFree(pParms->pszFilter);
|
---|
370 | pParms->pszFilter = NULL;
|
---|
371 | }
|
---|
372 |
|
---|
373 | if (pParms->pszPath)
|
---|
374 | {
|
---|
375 | RTStrFree(pParms->pszPath);
|
---|
376 | pParms->pszPath = NULL;
|
---|
377 | }
|
---|
378 | }
|
---|
379 |
|
---|
380 | /**
|
---|
381 | * Creates (allocates) and initializes a clipboard list entry structure.
|
---|
382 | *
|
---|
383 | * @param ppDirData Where to return the created clipboard list entry structure on success.
|
---|
384 | */
|
---|
385 | int SharedClipboardURIListEntryAlloc(PVBOXCLIPBOARDLISTENTRY *ppListEntry)
|
---|
386 | {
|
---|
387 | PVBOXCLIPBOARDLISTENTRY pListEntry = (PVBOXCLIPBOARDLISTENTRY)RTMemAlloc(sizeof(VBOXCLIPBOARDLISTENTRY));
|
---|
388 | if (!pListEntry)
|
---|
389 | return VERR_NO_MEMORY;
|
---|
390 |
|
---|
391 | int rc = SharedClipboardURIListEntryInit(pListEntry);
|
---|
392 | if (RT_SUCCESS(rc))
|
---|
393 | *ppListEntry = pListEntry;
|
---|
394 |
|
---|
395 | return rc;
|
---|
396 | }
|
---|
397 |
|
---|
398 | /**
|
---|
399 | * Frees a clipboard list entry structure.
|
---|
400 | *
|
---|
401 | * @param pListEntry Clipboard list entry structure to free.
|
---|
402 | */
|
---|
403 | void SharedClipboardURIListEntryFree(PVBOXCLIPBOARDLISTENTRY pListEntry)
|
---|
404 | {
|
---|
405 | if (!pListEntry)
|
---|
406 | return;
|
---|
407 |
|
---|
408 | SharedClipboardURIListEntryDestroy(pListEntry);
|
---|
409 | RTMemFree(pListEntry);
|
---|
410 | }
|
---|
411 |
|
---|
412 | /**
|
---|
413 | * (Deep) Copies a clipboard list entry structure.
|
---|
414 | *
|
---|
415 | * @returns VBox status code.
|
---|
416 | * @param pListEntry Clipboard list entry to copy.
|
---|
417 | */
|
---|
418 | int SharedClipboardURIListEntryCopy(PVBOXCLIPBOARDLISTENTRY pDst, PVBOXCLIPBOARDLISTENTRY pSrc)
|
---|
419 | {
|
---|
420 | AssertPtrReturn(pDst, VERR_INVALID_POINTER);
|
---|
421 | AssertPtrReturn(pSrc, VERR_INVALID_POINTER);
|
---|
422 |
|
---|
423 | int rc = VINF_SUCCESS;
|
---|
424 |
|
---|
425 | *pDst = *pSrc;
|
---|
426 |
|
---|
427 | if (pSrc->pszName)
|
---|
428 | {
|
---|
429 | pDst->pszName = RTStrDup(pSrc->pszName);
|
---|
430 | if (!pDst->pszName)
|
---|
431 | rc = VERR_NO_MEMORY;
|
---|
432 | }
|
---|
433 |
|
---|
434 | if ( RT_SUCCESS(rc)
|
---|
435 | && pSrc->pvInfo)
|
---|
436 | {
|
---|
437 | pDst->pvInfo = RTMemDup(pSrc->pvInfo, pSrc->cbInfo);
|
---|
438 | if (pDst->pvInfo)
|
---|
439 | {
|
---|
440 | pDst->cbInfo = pSrc->cbInfo;
|
---|
441 | }
|
---|
442 | else
|
---|
443 | rc = VERR_NO_MEMORY;
|
---|
444 | }
|
---|
445 |
|
---|
446 | if (RT_FAILURE(rc))
|
---|
447 | {
|
---|
448 | if (pDst->pvInfo)
|
---|
449 | {
|
---|
450 | RTMemFree(pDst->pvInfo);
|
---|
451 | pDst->pvInfo = NULL;
|
---|
452 | pDst->cbInfo = 0;
|
---|
453 | }
|
---|
454 | }
|
---|
455 |
|
---|
456 | return rc;
|
---|
457 | }
|
---|
458 |
|
---|
459 | /**
|
---|
460 | * Duplicates (allocates) a clipboard list entry structure.
|
---|
461 | *
|
---|
462 | * @returns Duplicated clipboard list entry structure on success.
|
---|
463 | * @param pListEntry Clipboard list entry to duplicate.
|
---|
464 | */
|
---|
465 | PVBOXCLIPBOARDLISTENTRY SharedClipboardURIListEntryDup(PVBOXCLIPBOARDLISTENTRY pListEntry)
|
---|
466 | {
|
---|
467 | AssertPtrReturn(pListEntry, NULL);
|
---|
468 |
|
---|
469 | int rc = VINF_SUCCESS;
|
---|
470 |
|
---|
471 | PVBOXCLIPBOARDLISTENTRY pListEntryDup = (PVBOXCLIPBOARDLISTENTRY)RTMemAllocZ(sizeof(VBOXCLIPBOARDLISTENTRY));
|
---|
472 | if (pListEntryDup)
|
---|
473 | rc = SharedClipboardURIListEntryCopy(pListEntryDup, pListEntry);
|
---|
474 |
|
---|
475 | if (RT_FAILURE(rc))
|
---|
476 | {
|
---|
477 | SharedClipboardURIListEntryDestroy(pListEntryDup);
|
---|
478 |
|
---|
479 | RTMemFree(pListEntryDup);
|
---|
480 | pListEntryDup = NULL;
|
---|
481 | }
|
---|
482 |
|
---|
483 | return pListEntryDup;
|
---|
484 | }
|
---|
485 |
|
---|
486 | /**
|
---|
487 | * Initializes a clipboard list entry structure.
|
---|
488 | *
|
---|
489 | * @returns VBox status code.
|
---|
490 | * @param pListEntry Clipboard list entry structure to initialize.
|
---|
491 | */
|
---|
492 | int SharedClipboardURIListEntryInit(PVBOXCLIPBOARDLISTENTRY pListEntry)
|
---|
493 | {
|
---|
494 | RT_BZERO(pListEntry, sizeof(VBOXCLIPBOARDLISTENTRY));
|
---|
495 |
|
---|
496 | pListEntry->pszName = RTStrAlloc(VBOXCLIPBOARDLISTENTRY_MAX_NAME);
|
---|
497 | if (!pListEntry->pszName)
|
---|
498 | return VERR_NO_MEMORY;
|
---|
499 |
|
---|
500 | pListEntry->cbName = VBOXCLIPBOARDLISTENTRY_MAX_NAME;
|
---|
501 | pListEntry->pvInfo = NULL;
|
---|
502 | pListEntry->cbInfo = 0;
|
---|
503 | pListEntry->fInfo = 0;
|
---|
504 |
|
---|
505 | return VINF_SUCCESS;
|
---|
506 | }
|
---|
507 |
|
---|
508 | /**
|
---|
509 | * Destroys a clipboard list entry structure.
|
---|
510 | *
|
---|
511 | * @param pListEntry Clipboard list entry structure to destroy.
|
---|
512 | */
|
---|
513 | void SharedClipboardURIListEntryDestroy(PVBOXCLIPBOARDLISTENTRY pListEntry)
|
---|
514 | {
|
---|
515 | if (!pListEntry)
|
---|
516 | return;
|
---|
517 |
|
---|
518 | if (pListEntry->pszName)
|
---|
519 | {
|
---|
520 | RTStrFree(pListEntry->pszName);
|
---|
521 |
|
---|
522 | pListEntry->pszName = NULL;
|
---|
523 | pListEntry->cbName = 0;
|
---|
524 | }
|
---|
525 |
|
---|
526 | if (pListEntry->pvInfo)
|
---|
527 | {
|
---|
528 | RTMemFree(pListEntry->pvInfo);
|
---|
529 | pListEntry->pvInfo = NULL;
|
---|
530 | pListEntry->cbInfo = 0;
|
---|
531 | }
|
---|
532 | }
|
---|
533 |
|
---|
534 | /**
|
---|
535 | * Returns whether a given clipboard data chunk is valid or not.
|
---|
536 | *
|
---|
537 | * @returns \c true if valid, \c false if not.
|
---|
538 | * @param pListEntry Clipboard data chunk to validate.
|
---|
539 | */
|
---|
540 | bool SharedClipboardURIListEntryIsValid(PVBOXCLIPBOARDLISTENTRY pListEntry)
|
---|
541 | {
|
---|
542 | RT_NOREF(pListEntry);
|
---|
543 |
|
---|
544 | /** @todo Verify checksum. */
|
---|
545 |
|
---|
546 | return true; /** @todo Implement this. */
|
---|
547 | }
|
---|
548 |
|
---|
549 | /**
|
---|
550 | * Initializes an URI object context.
|
---|
551 | *
|
---|
552 | * @returns VBox status code.
|
---|
553 | * @param pObjCtx URI object context to initialize.
|
---|
554 | */
|
---|
555 | int SharedClipboardURIObjCtxInit(PSHAREDCLIPBOARDCLIENTURIOBJCTX pObjCtx)
|
---|
556 | {
|
---|
557 | AssertPtrReturn(pObjCtx, VERR_INVALID_POINTER);
|
---|
558 |
|
---|
559 | LogFlowFuncEnter();
|
---|
560 |
|
---|
561 | pObjCtx->uHandle = SHAREDCLIPBOARDOBJHANDLE_INVALID;
|
---|
562 |
|
---|
563 | return VINF_SUCCESS;
|
---|
564 | }
|
---|
565 |
|
---|
566 | /**
|
---|
567 | * Destroys an URI object context.
|
---|
568 | *
|
---|
569 | * @param pObjCtx URI object context to destroy.
|
---|
570 | */
|
---|
571 | void SharedClipboardURIObjCtxDestroy(PSHAREDCLIPBOARDCLIENTURIOBJCTX pObjCtx)
|
---|
572 | {
|
---|
573 | AssertPtrReturnVoid(pObjCtx);
|
---|
574 |
|
---|
575 | LogFlowFuncEnter();
|
---|
576 | }
|
---|
577 |
|
---|
578 | /**
|
---|
579 | * Returns if an URI object context is valid or not.
|
---|
580 | *
|
---|
581 | * @returns \c true if valid, \c false if not.
|
---|
582 | * @param pObjCtx URI object context to check.
|
---|
583 | */
|
---|
584 | bool SharedClipboardURIObjCtxIsValid(PSHAREDCLIPBOARDCLIENTURIOBJCTX pObjCtx)
|
---|
585 | {
|
---|
586 | return ( pObjCtx
|
---|
587 | && pObjCtx->uHandle != SHAREDCLIPBOARDOBJHANDLE_INVALID);
|
---|
588 | }
|
---|
589 |
|
---|
590 | int SharedClipboardURIObjectOpen(PSHAREDCLIPBOARDURITRANSFER pTransfer, PVBOXCLIPBOARDOBJOPENCREATEPARMS pOpenCreateParms,
|
---|
591 | PSHAREDCLIPBOARDOBJHANDLE phObj)
|
---|
592 | {
|
---|
593 | RT_NOREF(pTransfer, pOpenCreateParms, phObj);
|
---|
594 | return 0;
|
---|
595 | }
|
---|
596 |
|
---|
597 | int SharedClipboardURIObjectClose(SHAREDCLIPBOARDOBJHANDLE hObj)
|
---|
598 | {
|
---|
599 | RT_NOREF(hObj);
|
---|
600 | return 0;
|
---|
601 | }
|
---|
602 |
|
---|
603 | int SharedClipboardURIObjectRead(SHAREDCLIPBOARDOBJHANDLE hObj, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead, uint32_t fFlags)
|
---|
604 | {
|
---|
605 | RT_NOREF(hObj, pvBuf, cbBuf, pcbRead, fFlags);
|
---|
606 | return 0;
|
---|
607 | }
|
---|
608 |
|
---|
609 | int SharedClipboardURIObjectWrite(SHAREDCLIPBOARDOBJHANDLE hObj, void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten,
|
---|
610 | uint32_t fFlags)
|
---|
611 | {
|
---|
612 | RT_NOREF(hObj, pvBuf, cbBuf, pcbWritten, fFlags);
|
---|
613 | return 0;
|
---|
614 | }
|
---|
615 |
|
---|
616 | int SharedClipboardURIObjectQueryInfo(SHAREDCLIPBOARDOBJHANDLE hObj, PSHAREDCLIPBOARDFSOBJINFO pObjInfo)
|
---|
617 | {
|
---|
618 | RT_NOREF(hObj, pObjInfo);
|
---|
619 | return 0;
|
---|
620 | }
|
---|
621 |
|
---|
622 | /**
|
---|
623 | * Initializes an URI clipboard transfer struct.
|
---|
624 | *
|
---|
625 | * @returns VBox status code.
|
---|
626 | * @param enmDir Specifies the transfer direction of this transfer.
|
---|
627 | * @param enmSource Specifies the data source of the transfer.
|
---|
628 | * @param ppTransfer Where to return the created URI transfer struct.
|
---|
629 | * Must be destroyed by SharedClipboardURITransferDestroy().
|
---|
630 | */
|
---|
631 | int SharedClipboardURITransferCreate(SHAREDCLIPBOARDURITRANSFERDIR enmDir, SHAREDCLIPBOARDSOURCE enmSource,
|
---|
632 | PSHAREDCLIPBOARDURITRANSFER *ppTransfer)
|
---|
633 | {
|
---|
634 | AssertPtrReturn(ppTransfer, VERR_INVALID_POINTER);
|
---|
635 |
|
---|
636 | LogFlowFuncEnter();
|
---|
637 |
|
---|
638 | PSHAREDCLIPBOARDURITRANSFER pTransfer = (PSHAREDCLIPBOARDURITRANSFER)RTMemAlloc(sizeof(SHAREDCLIPBOARDURITRANSFER));
|
---|
639 | if (!pTransfer)
|
---|
640 | return VERR_NO_MEMORY;
|
---|
641 |
|
---|
642 | int rc = VINF_SUCCESS;
|
---|
643 |
|
---|
644 | pTransfer->State.uID = 0;
|
---|
645 | pTransfer->State.enmStatus = SHAREDCLIPBOARDURITRANSFERSTATUS_NONE;
|
---|
646 | pTransfer->State.enmDir = enmDir;
|
---|
647 | pTransfer->State.enmSource = enmSource;
|
---|
648 |
|
---|
649 | LogFlowFunc(("enmDir=%RU32, enmSource=%RU32\n", pTransfer->State.enmDir, pTransfer->State.enmSource));
|
---|
650 |
|
---|
651 | pTransfer->pArea = NULL; /* Will be created later if needed. */
|
---|
652 |
|
---|
653 | pTransfer->Thread.hThread = NIL_RTTHREAD;
|
---|
654 | pTransfer->Thread.fCancelled = false;
|
---|
655 | pTransfer->Thread.fStarted = false;
|
---|
656 | pTransfer->Thread.fStop = false;
|
---|
657 |
|
---|
658 | pTransfer->uListHandleNext = 1;
|
---|
659 | pTransfer->uObjHandleNext = 1;
|
---|
660 | pTransfer->uEventIDNext = 1;
|
---|
661 |
|
---|
662 | pTransfer->uTimeoutMs = 30 * 1000; /* 30s timeout by default. */
|
---|
663 | pTransfer->cbMaxChunkSize = _64K; /** @todo Make this configurable. */
|
---|
664 |
|
---|
665 | pTransfer->pvUser = NULL;
|
---|
666 | pTransfer->cbUser = 0;
|
---|
667 |
|
---|
668 | RT_ZERO(pTransfer->Callbacks);
|
---|
669 |
|
---|
670 | pTransfer->pMapEvents = new SharedClipboardURITransferEventMap();
|
---|
671 | if (pTransfer->pMapEvents)
|
---|
672 | {
|
---|
673 | pTransfer->pMapLists = new SharedClipboardURIListMap();
|
---|
674 | if (pTransfer->pMapLists)
|
---|
675 | {
|
---|
676 | *ppTransfer = pTransfer;
|
---|
677 | }
|
---|
678 | }
|
---|
679 | else
|
---|
680 | rc = VERR_NO_MEMORY;
|
---|
681 |
|
---|
682 | if (RT_FAILURE(rc))
|
---|
683 | {
|
---|
684 | RTMemFree(pTransfer);
|
---|
685 | }
|
---|
686 |
|
---|
687 | LogFlowFuncLeaveRC(rc);
|
---|
688 | return rc;
|
---|
689 | }
|
---|
690 |
|
---|
691 | /**
|
---|
692 | * Destroys an URI clipboard transfer context struct.
|
---|
693 | *
|
---|
694 | * @returns VBox status code.
|
---|
695 | * @param pURI URI clipboard transfer to destroy.
|
---|
696 | */
|
---|
697 | int SharedClipboardURITransferDestroy(PSHAREDCLIPBOARDURITRANSFER pTransfer)
|
---|
698 | {
|
---|
699 | if (!pTransfer)
|
---|
700 | return VINF_SUCCESS;
|
---|
701 |
|
---|
702 | LogFlowFuncEnter();
|
---|
703 |
|
---|
704 | int rc = sharedClipboardURITransferThreadDestroy(pTransfer, 30 * 1000 /* Timeout in ms */);
|
---|
705 | if (RT_FAILURE(rc))
|
---|
706 | return rc;
|
---|
707 |
|
---|
708 | if (pTransfer->pMapEvents)
|
---|
709 | {
|
---|
710 | delete pTransfer->pMapEvents;
|
---|
711 | pTransfer->pMapEvents = NULL;
|
---|
712 | }
|
---|
713 |
|
---|
714 | if (pTransfer->pMapLists)
|
---|
715 | {
|
---|
716 | delete pTransfer->pMapLists;
|
---|
717 | pTransfer->pMapLists = NULL;
|
---|
718 | }
|
---|
719 |
|
---|
720 | LogFlowFuncLeave();
|
---|
721 | return VINF_SUCCESS;
|
---|
722 | }
|
---|
723 |
|
---|
724 | int SharedClipboardURITransferOpen(PSHAREDCLIPBOARDURITRANSFER pTransfer)
|
---|
725 | {
|
---|
726 | int rc = VINF_SUCCESS;
|
---|
727 |
|
---|
728 | if (pTransfer->ProviderIface.pfnTransferOpen)
|
---|
729 | rc = pTransfer->ProviderIface.pfnTransferOpen(&pTransfer->ProviderCtx);
|
---|
730 |
|
---|
731 | LogFlowFuncLeaveRC(rc);
|
---|
732 | return rc;
|
---|
733 | }
|
---|
734 |
|
---|
735 | int SharedClipboardURITransferClose(PSHAREDCLIPBOARDURITRANSFER pTransfer)
|
---|
736 | {
|
---|
737 | int rc = VINF_SUCCESS;
|
---|
738 |
|
---|
739 | if (pTransfer->ProviderIface.pfnTransferClose)
|
---|
740 | rc = pTransfer->ProviderIface.pfnTransferClose(&pTransfer->ProviderCtx);
|
---|
741 |
|
---|
742 | LogFlowFuncLeaveRC(rc);
|
---|
743 | return rc;
|
---|
744 | }
|
---|
745 |
|
---|
746 | /**
|
---|
747 | * Creates a new list handle (local only).
|
---|
748 | *
|
---|
749 | * @returns New List handle on success, or SHAREDCLIPBOARDLISTHANDLE_INVALID on error.
|
---|
750 | * @param pTransfer URI clipboard transfer to create new list handle for.
|
---|
751 | */
|
---|
752 | static SHAREDCLIPBOARDLISTHANDLE sharedClipboardURITransferListHandleNew(PSHAREDCLIPBOARDURITRANSFER pTransfer)
|
---|
753 | {
|
---|
754 | return pTransfer->uListHandleNext++; /** @todo Good enough for now. Improve this later. */
|
---|
755 | }
|
---|
756 |
|
---|
757 | /**
|
---|
758 | * Opens a list.
|
---|
759 | *
|
---|
760 | * @returns VBox status code.
|
---|
761 | * @param pTransfer URI clipboard transfer to handle.
|
---|
762 | * @param pOpenParms List open parameters to use for opening.
|
---|
763 | * @param phList Where to store the List handle of opened list on success.
|
---|
764 | */
|
---|
765 | int SharedClipboardURITransferListOpen(PSHAREDCLIPBOARDURITRANSFER pTransfer, PVBOXCLIPBOARDLISTOPENPARMS pOpenParms,
|
---|
766 | PSHAREDCLIPBOARDLISTHANDLE phList)
|
---|
767 | {
|
---|
768 | AssertPtrReturn(pTransfer, VERR_INVALID_POINTER);
|
---|
769 | AssertPtrReturn(pOpenParms, VERR_INVALID_POINTER);
|
---|
770 | AssertPtrReturn(phList, VERR_INVALID_POINTER);
|
---|
771 |
|
---|
772 | int rc;
|
---|
773 |
|
---|
774 | SHAREDCLIPBOARDLISTHANDLE hList = SHAREDCLIPBOARDLISTHANDLE_INVALID;
|
---|
775 |
|
---|
776 | if (pTransfer->State.enmSource == SHAREDCLIPBOARDSOURCE_LOCAL)
|
---|
777 | {
|
---|
778 | PSHAREDCLIPBOARDURILISTHANDLEINFO pInfo
|
---|
779 | = (PSHAREDCLIPBOARDURILISTHANDLEINFO)RTMemAlloc(sizeof(SHAREDCLIPBOARDURILISTHANDLEINFO));
|
---|
780 | if (pInfo)
|
---|
781 | {
|
---|
782 | LogFlowFunc(("pszPath=%s\n", pOpenParms->pszPath));
|
---|
783 |
|
---|
784 | RTFSOBJINFO objInfo;
|
---|
785 | rc = RTPathQueryInfo(pOpenParms->pszPath, &objInfo, RTFSOBJATTRADD_NOTHING);
|
---|
786 | if (RT_SUCCESS(rc))
|
---|
787 | {
|
---|
788 | if (RTFS_IS_DIRECTORY(objInfo.Attr.fMode))
|
---|
789 | {
|
---|
790 | rc = RTDirOpen(&pInfo->u.Local.hDirRoot, pOpenParms->pszPath);
|
---|
791 | }
|
---|
792 | else if (RTFS_IS_FILE(objInfo.Attr.fMode))
|
---|
793 | {
|
---|
794 | rc = RTFileOpen(&pInfo->u.Local.hFile, pOpenParms->pszPath,
|
---|
795 | RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE);
|
---|
796 | }
|
---|
797 | else if (RTFS_IS_SYMLINK(objInfo.Attr.fMode))
|
---|
798 | {
|
---|
799 | rc = VERR_NOT_IMPLEMENTED; /** @todo */
|
---|
800 | }
|
---|
801 | else
|
---|
802 | AssertFailedStmt(rc = VERR_NOT_SUPPORTED);
|
---|
803 |
|
---|
804 | if (RT_SUCCESS(rc))
|
---|
805 | rc = SharedClipboardURIListOpenParmsCopy(&pInfo->OpenParms, pOpenParms);
|
---|
806 |
|
---|
807 | if (RT_SUCCESS(rc))
|
---|
808 | {
|
---|
809 | pInfo->fMode = objInfo.Attr.fMode;
|
---|
810 |
|
---|
811 | hList = sharedClipboardURITransferListHandleNew(pTransfer);
|
---|
812 |
|
---|
813 | pTransfer->pMapLists->insert(
|
---|
814 | std::pair<SHAREDCLIPBOARDLISTHANDLE, PSHAREDCLIPBOARDURILISTHANDLEINFO>(hList, pInfo));
|
---|
815 | }
|
---|
816 | else
|
---|
817 | {
|
---|
818 | if (RTFS_IS_DIRECTORY(objInfo.Attr.fMode))
|
---|
819 | {
|
---|
820 | if (RTDirIsValid(pInfo->u.Local.hDirRoot))
|
---|
821 | RTDirClose(pInfo->u.Local.hDirRoot);
|
---|
822 | }
|
---|
823 | else if (RTFS_IS_FILE(objInfo.Attr.fMode))
|
---|
824 | {
|
---|
825 | if (RTFileIsValid(pInfo->u.Local.hFile))
|
---|
826 | RTFileClose(pInfo->u.Local.hFile);
|
---|
827 | }
|
---|
828 |
|
---|
829 | RTMemFree(pInfo);
|
---|
830 | pInfo = NULL;
|
---|
831 | }
|
---|
832 | }
|
---|
833 | }
|
---|
834 | else
|
---|
835 | rc = VERR_NO_MEMORY;
|
---|
836 | }
|
---|
837 | else if (pTransfer->State.enmSource == SHAREDCLIPBOARDSOURCE_REMOTE)
|
---|
838 | {
|
---|
839 | if (pTransfer->ProviderIface.pfnListOpen)
|
---|
840 | {
|
---|
841 | rc = pTransfer->ProviderIface.pfnListOpen(&pTransfer->ProviderCtx, pOpenParms, &hList);
|
---|
842 | }
|
---|
843 | else
|
---|
844 | rc = VERR_NOT_SUPPORTED;
|
---|
845 | }
|
---|
846 | else
|
---|
847 | AssertFailedStmt(rc = VERR_NOT_IMPLEMENTED);
|
---|
848 |
|
---|
849 | if (RT_SUCCESS(rc))
|
---|
850 | *phList = hList;
|
---|
851 |
|
---|
852 | LogFlowFuncLeaveRC(rc);
|
---|
853 | return rc;
|
---|
854 | }
|
---|
855 |
|
---|
856 | /**
|
---|
857 | * Closes a list.
|
---|
858 | *
|
---|
859 | * @returns VBox status code.
|
---|
860 | * @param pTransfer URI clipboard transfer to handle.
|
---|
861 | * @param hList Handle of list to close.
|
---|
862 | */
|
---|
863 | int SharedClipboardURITransferListClose(PSHAREDCLIPBOARDURITRANSFER pTransfer, SHAREDCLIPBOARDLISTHANDLE hList)
|
---|
864 | {
|
---|
865 | AssertPtrReturn(pTransfer, VERR_INVALID_POINTER);
|
---|
866 |
|
---|
867 | if (hList == SHAREDCLIPBOARDLISTHANDLE_INVALID)
|
---|
868 | return VINF_SUCCESS;
|
---|
869 |
|
---|
870 | int rc = VINF_SUCCESS;
|
---|
871 |
|
---|
872 | if (pTransfer->State.enmSource == SHAREDCLIPBOARDSOURCE_LOCAL)
|
---|
873 | {
|
---|
874 | SharedClipboardURIListMap::iterator itList = pTransfer->pMapLists->find(hList);
|
---|
875 | if (itList != pTransfer->pMapLists->end())
|
---|
876 | {
|
---|
877 | PSHAREDCLIPBOARDURILISTHANDLEINFO pInfo = itList->second;
|
---|
878 | AssertPtr(pInfo);
|
---|
879 |
|
---|
880 | if (RTDirIsValid(pInfo->u.Local.hDirRoot))
|
---|
881 | RTDirClose(pInfo->u.Local.hDirRoot);
|
---|
882 |
|
---|
883 | RTMemFree(pInfo);
|
---|
884 |
|
---|
885 | pTransfer->pMapLists->erase(itList);
|
---|
886 | }
|
---|
887 | else
|
---|
888 | rc = VERR_NOT_FOUND;
|
---|
889 | }
|
---|
890 | else if (pTransfer->State.enmSource == SHAREDCLIPBOARDSOURCE_REMOTE)
|
---|
891 | {
|
---|
892 | if (pTransfer->ProviderIface.pfnListClose)
|
---|
893 | {
|
---|
894 | rc = pTransfer->ProviderIface.pfnListClose(&pTransfer->ProviderCtx, hList);
|
---|
895 | }
|
---|
896 | else
|
---|
897 | rc = VERR_NOT_SUPPORTED;
|
---|
898 | }
|
---|
899 |
|
---|
900 | LogFlowFuncLeaveRC(rc);
|
---|
901 | return rc;
|
---|
902 | }
|
---|
903 |
|
---|
904 | /**
|
---|
905 | * Adds a file to a list heaer.
|
---|
906 | *
|
---|
907 | * @returns VBox status code.
|
---|
908 | * @param pHdr List header to add file to.
|
---|
909 | * @param pszPath Path of file to add.
|
---|
910 | */
|
---|
911 | static int sharedClipboardURITransferListHdrAddFile(PVBOXCLIPBOARDLISTHDR pHdr, const char *pszPath)
|
---|
912 | {
|
---|
913 | uint64_t cbSize = 0;
|
---|
914 | int rc = RTFileQuerySize(pszPath, &cbSize);
|
---|
915 | if (RT_SUCCESS(rc))
|
---|
916 | {
|
---|
917 | pHdr->cbTotalSize += cbSize;
|
---|
918 | pHdr->cTotalObjects++;
|
---|
919 | }
|
---|
920 |
|
---|
921 | LogFlowFuncLeaveRC(rc);
|
---|
922 | return rc;
|
---|
923 | }
|
---|
924 |
|
---|
925 | /**
|
---|
926 | * Builds a list header, internal version.
|
---|
927 | *
|
---|
928 | * @returns VBox status code.
|
---|
929 | * @param pHdr Where to store the build list header.
|
---|
930 | * @param pcszSrcPath Source path of list.
|
---|
931 | * @param pcszDstPath Destination path of list.
|
---|
932 | * @param pcszDstBase Destination base path.
|
---|
933 | * @param cchDstBase Number of charaters of destination base path.
|
---|
934 | */
|
---|
935 | static int sharedClipboardURITransferListHdrFromDir(PVBOXCLIPBOARDLISTHDR pHdr,
|
---|
936 | const char *pcszSrcPath, const char *pcszDstPath,
|
---|
937 | const char *pcszDstBase, size_t cchDstBase)
|
---|
938 | {
|
---|
939 | AssertPtrReturn(pcszSrcPath, VERR_INVALID_POINTER);
|
---|
940 | AssertPtrReturn(pcszDstBase, VERR_INVALID_POINTER);
|
---|
941 | AssertPtrReturn(pcszDstPath, VERR_INVALID_POINTER);
|
---|
942 |
|
---|
943 | LogFlowFunc(("pcszSrcPath=%s, pcszDstPath=%s, pcszDstBase=%s, cchDstBase=%zu\n",
|
---|
944 | pcszSrcPath, pcszDstPath, pcszDstBase, cchDstBase));
|
---|
945 |
|
---|
946 | RTFSOBJINFO objInfo;
|
---|
947 | int rc = RTPathQueryInfo(pcszSrcPath, &objInfo, RTFSOBJATTRADD_NOTHING);
|
---|
948 | if (RT_SUCCESS(rc))
|
---|
949 | {
|
---|
950 | if (RTFS_IS_DIRECTORY(objInfo.Attr.fMode))
|
---|
951 | {
|
---|
952 | pHdr->cTotalObjects++; /* Add directory itself. */
|
---|
953 |
|
---|
954 | if (RT_SUCCESS(rc))
|
---|
955 | {
|
---|
956 | RTDIR hDir;
|
---|
957 | rc = RTDirOpen(&hDir, pcszSrcPath);
|
---|
958 | if (RT_SUCCESS(rc))
|
---|
959 | {
|
---|
960 | size_t cbDirEntry = 0;
|
---|
961 | PRTDIRENTRYEX pDirEntry = NULL;
|
---|
962 | do
|
---|
963 | {
|
---|
964 | /* Retrieve the next directory entry. */
|
---|
965 | rc = RTDirReadExA(hDir, &pDirEntry, &cbDirEntry, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK);
|
---|
966 | if (RT_FAILURE(rc))
|
---|
967 | {
|
---|
968 | if (rc == VERR_NO_MORE_FILES)
|
---|
969 | rc = VINF_SUCCESS;
|
---|
970 | break;
|
---|
971 | }
|
---|
972 |
|
---|
973 | switch (pDirEntry->Info.Attr.fMode & RTFS_TYPE_MASK)
|
---|
974 | {
|
---|
975 | #if 0 /* No recursion here (yet). */
|
---|
976 | case RTFS_TYPE_DIRECTORY:
|
---|
977 | {
|
---|
978 | /* Skip "." and ".." entries. */
|
---|
979 | if (RTDirEntryExIsStdDotLink(pDirEntry))
|
---|
980 | break;
|
---|
981 |
|
---|
982 | char *pszSrc = RTPathJoinA(pcszSrcPath, pDirEntry->szName);
|
---|
983 | if (pszSrc)
|
---|
984 | {
|
---|
985 | char *pszDst = RTPathJoinA(pcszDstPath, pDirEntry->szName);
|
---|
986 | if (pszDst)
|
---|
987 | {
|
---|
988 | rc = sharedClipboardURITransferListHdrFromDir(pHdr, pszSrc, pszDst,
|
---|
989 | pcszDstBase, cchDstBase);
|
---|
990 | RTStrFree(pszDst);
|
---|
991 | }
|
---|
992 | else
|
---|
993 | rc = VERR_NO_MEMORY;
|
---|
994 |
|
---|
995 | RTStrFree(pszSrc);
|
---|
996 | }
|
---|
997 | else
|
---|
998 | rc = VERR_NO_MEMORY;
|
---|
999 | break;
|
---|
1000 | }
|
---|
1001 | #endif
|
---|
1002 | case RTFS_TYPE_FILE:
|
---|
1003 | {
|
---|
1004 | char *pszSrc = RTPathJoinA(pcszSrcPath, pDirEntry->szName);
|
---|
1005 | if (pszSrc)
|
---|
1006 | {
|
---|
1007 | rc = sharedClipboardURITransferListHdrAddFile(pHdr, pszSrc);
|
---|
1008 | RTStrFree(pszSrc);
|
---|
1009 | }
|
---|
1010 | else
|
---|
1011 | rc = VERR_NO_MEMORY;
|
---|
1012 | break;
|
---|
1013 | }
|
---|
1014 | case RTFS_TYPE_SYMLINK:
|
---|
1015 | {
|
---|
1016 | /** @todo Not implemented yet. */
|
---|
1017 | }
|
---|
1018 |
|
---|
1019 | default:
|
---|
1020 | break;
|
---|
1021 | }
|
---|
1022 |
|
---|
1023 | } while (RT_SUCCESS(rc));
|
---|
1024 |
|
---|
1025 | RTDirReadExAFree(&pDirEntry, &cbDirEntry);
|
---|
1026 | RTDirClose(hDir);
|
---|
1027 | }
|
---|
1028 | }
|
---|
1029 | }
|
---|
1030 | else if (RTFS_IS_FILE(objInfo.Attr.fMode))
|
---|
1031 | {
|
---|
1032 | rc = sharedClipboardURITransferListHdrAddFile(pHdr, pcszSrcPath);
|
---|
1033 | }
|
---|
1034 | else if (RTFS_IS_SYMLINK(objInfo.Attr.fMode))
|
---|
1035 | {
|
---|
1036 | /** @todo Not implemented yet. */
|
---|
1037 | }
|
---|
1038 | else
|
---|
1039 | rc = VERR_NOT_SUPPORTED;
|
---|
1040 | }
|
---|
1041 |
|
---|
1042 | LogFlowFuncLeaveRC(rc);
|
---|
1043 | return rc;
|
---|
1044 | }
|
---|
1045 |
|
---|
1046 | /**
|
---|
1047 | * Retrieves the header of a Shared Clipboard list.
|
---|
1048 | *
|
---|
1049 | * @returns VBox status code.
|
---|
1050 | * @param pTransfer URI clipboard transfer to handle.
|
---|
1051 | * @param hList Handle of list to get header for.
|
---|
1052 | * @param pHdr Where to store the returned list header information.
|
---|
1053 | */
|
---|
1054 | int SharedClipboardURITransferListGetHeader(PSHAREDCLIPBOARDURITRANSFER pTransfer, SHAREDCLIPBOARDLISTHANDLE hList,
|
---|
1055 | PVBOXCLIPBOARDLISTHDR pHdr)
|
---|
1056 | {
|
---|
1057 | AssertPtrReturn(pTransfer, VERR_INVALID_POINTER);
|
---|
1058 | AssertPtrReturn(pHdr, VERR_INVALID_POINTER);
|
---|
1059 |
|
---|
1060 | int rc;
|
---|
1061 |
|
---|
1062 | LogFlowFunc(("hList=%RU64\n", hList));
|
---|
1063 |
|
---|
1064 | if (pTransfer->State.enmSource == SHAREDCLIPBOARDSOURCE_LOCAL)
|
---|
1065 | {
|
---|
1066 | SharedClipboardURIListMap::iterator itList = pTransfer->pMapLists->find(hList);
|
---|
1067 | if (itList != pTransfer->pMapLists->end())
|
---|
1068 | {
|
---|
1069 | rc = SharedClipboardURIListHdrInit(pHdr);
|
---|
1070 | if (RT_SUCCESS(rc))
|
---|
1071 | {
|
---|
1072 | PSHAREDCLIPBOARDURILISTHANDLEINFO pInfo = itList->second;
|
---|
1073 | AssertPtr(pInfo);
|
---|
1074 |
|
---|
1075 | if (RTFS_IS_DIRECTORY(pInfo->fMode))
|
---|
1076 | {
|
---|
1077 | char *pszSrcPath = RTStrDup(pInfo->OpenParms.pszPath);
|
---|
1078 | if (pszSrcPath)
|
---|
1079 | {
|
---|
1080 | size_t cbSrcPathLen = RTPathStripTrailingSlash(pszSrcPath);
|
---|
1081 | if (cbSrcPathLen)
|
---|
1082 | {
|
---|
1083 | char *pszFileName = RTPathFilename(pszSrcPath);
|
---|
1084 | if (pszFileName)
|
---|
1085 | {
|
---|
1086 | Assert(pszFileName >= pszSrcPath);
|
---|
1087 | size_t cchDstBase = pszFileName - pszSrcPath;
|
---|
1088 | #ifdef VBOX_STRICT
|
---|
1089 | char *pszDstPath = &pszSrcPath[cchDstBase];
|
---|
1090 | LogFlowFunc(("pszSrcPath=%s, pszFileName=%s, pszDstPath=%s\n",
|
---|
1091 | pszSrcPath, pszFileName, pszDstPath));
|
---|
1092 | #endif
|
---|
1093 | rc = sharedClipboardURITransferListHdrFromDir(pHdr,
|
---|
1094 | pszSrcPath, pszSrcPath, pszSrcPath, cchDstBase);
|
---|
1095 | }
|
---|
1096 | else
|
---|
1097 | rc = VERR_PATH_NOT_FOUND;
|
---|
1098 | }
|
---|
1099 | else
|
---|
1100 | rc = VERR_INVALID_PARAMETER;
|
---|
1101 |
|
---|
1102 | RTStrFree(pszSrcPath);
|
---|
1103 | }
|
---|
1104 | else
|
---|
1105 | rc = VERR_NO_MEMORY;
|
---|
1106 | }
|
---|
1107 | else if (RTFS_IS_FILE(pInfo->fMode))
|
---|
1108 | {
|
---|
1109 | pHdr->cTotalObjects = 1;
|
---|
1110 |
|
---|
1111 | RTFSOBJINFO objInfo;
|
---|
1112 | rc = RTFileQueryInfo(pInfo->u.Local.hFile, &objInfo, RTFSOBJATTRADD_NOTHING);
|
---|
1113 | if (RT_SUCCESS(rc))
|
---|
1114 | {
|
---|
1115 | pHdr->cbTotalSize = objInfo.cbObject;
|
---|
1116 | }
|
---|
1117 | }
|
---|
1118 | else if (RTFS_IS_SYMLINK(pInfo->fMode))
|
---|
1119 | {
|
---|
1120 | rc = VERR_NOT_IMPLEMENTED; /** @todo */
|
---|
1121 | }
|
---|
1122 | else
|
---|
1123 | AssertFailedStmt(rc = VERR_NOT_SUPPORTED);
|
---|
1124 | }
|
---|
1125 | }
|
---|
1126 | else
|
---|
1127 | rc = VERR_NOT_FOUND;
|
---|
1128 | }
|
---|
1129 | else if (pTransfer->State.enmSource == SHAREDCLIPBOARDSOURCE_REMOTE)
|
---|
1130 | {
|
---|
1131 | if (pTransfer->ProviderIface.pfnListHdrRead)
|
---|
1132 | {
|
---|
1133 | rc = pTransfer->ProviderIface.pfnListHdrRead(&pTransfer->ProviderCtx, hList, pHdr);
|
---|
1134 | }
|
---|
1135 | else
|
---|
1136 | rc = VERR_NOT_SUPPORTED;
|
---|
1137 | }
|
---|
1138 | else
|
---|
1139 | AssertFailedStmt(rc = VERR_NOT_IMPLEMENTED);
|
---|
1140 |
|
---|
1141 | LogFlowFuncLeaveRC(rc);
|
---|
1142 | return rc;
|
---|
1143 | }
|
---|
1144 |
|
---|
1145 | /**
|
---|
1146 | * Returns the current URI object for a clipboard URI transfer list.
|
---|
1147 | *
|
---|
1148 | * @returns Pointer to URI object.
|
---|
1149 | * @param pTransfer URI clipboard transfer to return URI object for.
|
---|
1150 | */
|
---|
1151 | PSHAREDCLIPBOARDURITRANSFEROBJ SharedClipboardURITransferListGetObj(PSHAREDCLIPBOARDURITRANSFER pTransfer,
|
---|
1152 | SHAREDCLIPBOARDLISTHANDLE hList, uint64_t uIdx)
|
---|
1153 | {
|
---|
1154 | AssertPtrReturn(pTransfer, NULL);
|
---|
1155 |
|
---|
1156 | RT_NOREF(hList, uIdx);
|
---|
1157 |
|
---|
1158 | LogFlowFunc(("hList=%RU64\n", hList));
|
---|
1159 |
|
---|
1160 | return NULL;
|
---|
1161 | }
|
---|
1162 |
|
---|
1163 | /**
|
---|
1164 | * Reads a single Shared Clipboard list entry.
|
---|
1165 | *
|
---|
1166 | * @returns VBox status code or VERR_NO_MORE_FILES if the end of the list has been reached.
|
---|
1167 | * @param pTransfer URI clipboard transfer to handle.
|
---|
1168 | * @param hList List handle of list to read from.
|
---|
1169 | * @param pEntry Where to store the read information.
|
---|
1170 | */
|
---|
1171 | int SharedClipboardURITransferListRead(PSHAREDCLIPBOARDURITRANSFER pTransfer, SHAREDCLIPBOARDLISTHANDLE hList,
|
---|
1172 | PVBOXCLIPBOARDLISTENTRY pEntry)
|
---|
1173 | {
|
---|
1174 | AssertPtrReturn(pTransfer, VERR_INVALID_POINTER);
|
---|
1175 | AssertPtrReturn(pEntry, VERR_INVALID_POINTER);
|
---|
1176 |
|
---|
1177 | int rc = VINF_SUCCESS;
|
---|
1178 |
|
---|
1179 | LogFlowFunc(("hList=%RU64\n", hList));
|
---|
1180 |
|
---|
1181 | if (pTransfer->State.enmSource == SHAREDCLIPBOARDSOURCE_LOCAL)
|
---|
1182 | {
|
---|
1183 | SharedClipboardURIListMap::iterator itList = pTransfer->pMapLists->find(hList);
|
---|
1184 | if (itList != pTransfer->pMapLists->end())
|
---|
1185 | {
|
---|
1186 | PSHAREDCLIPBOARDURILISTHANDLEINFO pInfo = itList->second;
|
---|
1187 | AssertPtr(pInfo);
|
---|
1188 |
|
---|
1189 | LogFlowFunc(("\tfMode=%RU32, pszPath=%s\n", pInfo->fMode, pInfo->OpenParms.pszPath));
|
---|
1190 |
|
---|
1191 | if (RTFS_IS_DIRECTORY(pInfo->fMode))
|
---|
1192 | {
|
---|
1193 | for (;;)
|
---|
1194 | {
|
---|
1195 | bool fSkipEntry = false; /* Whether to skip an entry in the enumeration. */
|
---|
1196 |
|
---|
1197 | size_t cbDirEntry = 0;
|
---|
1198 | PRTDIRENTRYEX pDirEntry = NULL;
|
---|
1199 | rc = RTDirReadExA(pInfo->u.Local.hDirRoot, &pDirEntry, &cbDirEntry, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK);
|
---|
1200 | if (RT_SUCCESS(rc))
|
---|
1201 | {
|
---|
1202 | switch (pDirEntry->Info.Attr.fMode & RTFS_TYPE_MASK)
|
---|
1203 | {
|
---|
1204 | case RTFS_TYPE_DIRECTORY:
|
---|
1205 | {
|
---|
1206 | /* Skip "." and ".." entries. */
|
---|
1207 | if (RTDirEntryExIsStdDotLink(pDirEntry))
|
---|
1208 | {
|
---|
1209 | fSkipEntry = true;
|
---|
1210 | break;
|
---|
1211 | }
|
---|
1212 |
|
---|
1213 | LogFlowFunc(("Directory: %s\n", pDirEntry->szName));
|
---|
1214 | break;
|
---|
1215 | }
|
---|
1216 |
|
---|
1217 | case RTFS_TYPE_FILE:
|
---|
1218 | {
|
---|
1219 | LogFlowFunc(("File: %s\n", pDirEntry->szName));
|
---|
1220 | break;
|
---|
1221 | }
|
---|
1222 |
|
---|
1223 | case RTFS_TYPE_SYMLINK:
|
---|
1224 | {
|
---|
1225 | rc = VERR_NOT_IMPLEMENTED; /** @todo Not implemented yet. */
|
---|
1226 | break;
|
---|
1227 | }
|
---|
1228 |
|
---|
1229 | default:
|
---|
1230 | break;
|
---|
1231 | }
|
---|
1232 |
|
---|
1233 | if ( RT_SUCCESS(rc)
|
---|
1234 | && !fSkipEntry)
|
---|
1235 | {
|
---|
1236 | pEntry->pvInfo = (PSHAREDCLIPBOARDFSOBJINFO)RTMemAlloc(sizeof(SHAREDCLIPBOARDFSOBJINFO));
|
---|
1237 | if (pEntry->pvInfo)
|
---|
1238 | {
|
---|
1239 | rc = RTStrCopy(pEntry->pszName, pEntry->cbName, pDirEntry->szName);
|
---|
1240 | if (RT_SUCCESS(rc))
|
---|
1241 | {
|
---|
1242 | SharedClipboardFsObjFromIPRT(PSHAREDCLIPBOARDFSOBJINFO(pEntry->pvInfo), &pDirEntry->Info);
|
---|
1243 |
|
---|
1244 | pEntry->cbInfo = sizeof(SHAREDCLIPBOARDFSOBJINFO);
|
---|
1245 | pEntry->fInfo = VBOX_SHAREDCLIPBOARD_INFO_FLAG_FSOBJINFO;
|
---|
1246 | }
|
---|
1247 | }
|
---|
1248 | else
|
---|
1249 | rc = VERR_NO_MEMORY;
|
---|
1250 | }
|
---|
1251 |
|
---|
1252 | RTDirReadExAFree(&pDirEntry, &cbDirEntry);
|
---|
1253 | }
|
---|
1254 |
|
---|
1255 | if ( !fSkipEntry /* Do we have a valid entry? Bail out. */
|
---|
1256 | || RT_FAILURE(rc))
|
---|
1257 | {
|
---|
1258 | break;
|
---|
1259 | }
|
---|
1260 | }
|
---|
1261 | }
|
---|
1262 | else if (RTFS_IS_FILE(pInfo->fMode))
|
---|
1263 | {
|
---|
1264 | LogFlowFunc(("\tSingle file: %s\n", pInfo->OpenParms.pszPath));
|
---|
1265 |
|
---|
1266 | RTFSOBJINFO objInfo;
|
---|
1267 | rc = RTFileQueryInfo(pInfo->u.Local.hFile, &objInfo, RTFSOBJATTRADD_NOTHING);
|
---|
1268 | if (RT_SUCCESS(rc))
|
---|
1269 | {
|
---|
1270 | pEntry->pvInfo = (PSHAREDCLIPBOARDFSOBJINFO)RTMemAlloc(sizeof(SHAREDCLIPBOARDFSOBJINFO));
|
---|
1271 | if (pEntry->pvInfo)
|
---|
1272 | {
|
---|
1273 | rc = RTStrCopy(pEntry->pszName, pEntry->cbName, pInfo->OpenParms.pszPath);
|
---|
1274 | if (RT_SUCCESS(rc))
|
---|
1275 | {
|
---|
1276 | SharedClipboardFsObjFromIPRT(PSHAREDCLIPBOARDFSOBJINFO(pEntry->pvInfo), &objInfo);
|
---|
1277 |
|
---|
1278 | pEntry->cbInfo = sizeof(SHAREDCLIPBOARDFSOBJINFO);
|
---|
1279 | pEntry->fInfo = VBOX_SHAREDCLIPBOARD_INFO_FLAG_FSOBJINFO;
|
---|
1280 | }
|
---|
1281 | }
|
---|
1282 | else
|
---|
1283 | rc = VERR_NO_MEMORY;
|
---|
1284 | }
|
---|
1285 | }
|
---|
1286 | else if (RTFS_IS_SYMLINK(pInfo->fMode))
|
---|
1287 | {
|
---|
1288 | rc = VERR_NOT_IMPLEMENTED;
|
---|
1289 | }
|
---|
1290 | else
|
---|
1291 | AssertFailedStmt(rc = VERR_NOT_SUPPORTED);
|
---|
1292 | }
|
---|
1293 | else
|
---|
1294 | rc = VERR_NOT_FOUND;
|
---|
1295 | }
|
---|
1296 | else if (pTransfer->State.enmSource == SHAREDCLIPBOARDSOURCE_REMOTE)
|
---|
1297 | {
|
---|
1298 | if (pTransfer->ProviderIface.pfnListEntryRead)
|
---|
1299 | rc = pTransfer->ProviderIface.pfnListEntryRead(&pTransfer->ProviderCtx, hList, pEntry);
|
---|
1300 | else
|
---|
1301 | rc = VERR_NOT_SUPPORTED;
|
---|
1302 | }
|
---|
1303 |
|
---|
1304 | LogFlowFuncLeaveRC(rc);
|
---|
1305 | return rc;
|
---|
1306 | }
|
---|
1307 |
|
---|
1308 | int SharedClipboardURITransferListWrite(PSHAREDCLIPBOARDURITRANSFER pTransfer, SHAREDCLIPBOARDLISTHANDLE hList,
|
---|
1309 | PVBOXCLIPBOARDLISTENTRY pEntry)
|
---|
1310 | {
|
---|
1311 | RT_NOREF(pTransfer, hList, pEntry);
|
---|
1312 |
|
---|
1313 | int rc = VINF_SUCCESS;
|
---|
1314 |
|
---|
1315 | #if 0
|
---|
1316 | if (pTransfer->ProviderIface.pfnListEntryWrite)
|
---|
1317 | rc = pTransfer->ProviderIface.pfnListEntryWrite(&pTransfer->ProviderCtx, hList, pEntry);
|
---|
1318 | #endif
|
---|
1319 |
|
---|
1320 | LogFlowFuncLeaveRC(rc);
|
---|
1321 | return rc;
|
---|
1322 | }
|
---|
1323 |
|
---|
1324 | /**
|
---|
1325 | * Returns whether a given list handle is valid or not.
|
---|
1326 | *
|
---|
1327 | * @returns \c true if list handle is valid, \c false if not.
|
---|
1328 | * @param pTransfer URI clipboard transfer to handle.
|
---|
1329 | * @param hList List handle to check.
|
---|
1330 | */
|
---|
1331 | bool SharedClipboardURITransferListHandleIsValid(PSHAREDCLIPBOARDURITRANSFER pTransfer, SHAREDCLIPBOARDLISTHANDLE hList)
|
---|
1332 | {
|
---|
1333 | bool fIsValid = false;
|
---|
1334 |
|
---|
1335 | if (pTransfer->State.enmSource == SHAREDCLIPBOARDSOURCE_LOCAL)
|
---|
1336 | {
|
---|
1337 | SharedClipboardURIListMap::iterator itList = pTransfer->pMapLists->find(hList);
|
---|
1338 | fIsValid = itList != pTransfer->pMapLists->end();
|
---|
1339 | }
|
---|
1340 | else if (pTransfer->State.enmSource == SHAREDCLIPBOARDSOURCE_REMOTE)
|
---|
1341 | {
|
---|
1342 | AssertFailed(); /** @todo Implement. */
|
---|
1343 | }
|
---|
1344 |
|
---|
1345 | return fIsValid;
|
---|
1346 | }
|
---|
1347 |
|
---|
1348 | /**
|
---|
1349 | * Prepares everything needed for a read / write transfer to begin.
|
---|
1350 | *
|
---|
1351 | * @returns VBox status code.
|
---|
1352 | * @param pTransfer URI clipboard transfer to prepare.
|
---|
1353 | */
|
---|
1354 | int SharedClipboardURITransferPrepare(PSHAREDCLIPBOARDURITRANSFER pTransfer)
|
---|
1355 | {
|
---|
1356 | AssertPtrReturn(pTransfer, VERR_INVALID_POINTER);
|
---|
1357 |
|
---|
1358 | LogFlowFuncEnter();
|
---|
1359 |
|
---|
1360 | int rc = VINF_SUCCESS;
|
---|
1361 |
|
---|
1362 | AssertMsgReturn(pTransfer->State.enmStatus == SHAREDCLIPBOARDURITRANSFERSTATUS_NONE,
|
---|
1363 | ("Transfer has wrong state (%RU32)\n", pTransfer->State.enmStatus), VERR_WRONG_ORDER);
|
---|
1364 |
|
---|
1365 | LogFlowFunc(("pTransfer=%p, enmDir=%RU32\n", pTransfer, pTransfer->State.enmDir));
|
---|
1366 |
|
---|
1367 | if (pTransfer->Callbacks.pfnTransferPrepare)
|
---|
1368 | {
|
---|
1369 | SHAREDCLIPBOARDURITRANSFERCALLBACKDATA callbackData = { pTransfer, pTransfer->Callbacks.pvUser };
|
---|
1370 | pTransfer->Callbacks.pfnTransferPrepare(&callbackData);
|
---|
1371 | }
|
---|
1372 |
|
---|
1373 | if (RT_SUCCESS(rc))
|
---|
1374 | {
|
---|
1375 | pTransfer->State.enmStatus = SHAREDCLIPBOARDURITRANSFERSTATUS_READY;
|
---|
1376 |
|
---|
1377 | /** @todo Add checksum support. */
|
---|
1378 | }
|
---|
1379 |
|
---|
1380 | LogFlowFuncLeaveRC(rc);
|
---|
1381 | return rc;
|
---|
1382 | }
|
---|
1383 |
|
---|
1384 | /**
|
---|
1385 | * Sets the URI provider interface for a given transfer.
|
---|
1386 | *
|
---|
1387 | * @returns VBox status code.
|
---|
1388 | * @param pTransfer Transfer to create URI provider for.
|
---|
1389 | * @param pCreationCtx Provider creation context to use for provider creation.
|
---|
1390 | */
|
---|
1391 | int SharedClipboardURITransferSetInterface(PSHAREDCLIPBOARDURITRANSFER pTransfer,
|
---|
1392 | PSHAREDCLIPBOARDPROVIDERCREATIONCTX pCreationCtx)
|
---|
1393 | {
|
---|
1394 | AssertPtrReturn(pTransfer, VERR_INVALID_POINTER);
|
---|
1395 | AssertPtrReturn(pCreationCtx, VERR_INVALID_POINTER);
|
---|
1396 |
|
---|
1397 | LogFlowFuncEnter();
|
---|
1398 |
|
---|
1399 | int rc = VINF_SUCCESS;
|
---|
1400 |
|
---|
1401 | pTransfer->ProviderIface = pCreationCtx->Interface;
|
---|
1402 |
|
---|
1403 | pTransfer->ProviderCtx.pTransfer = pTransfer;
|
---|
1404 | pTransfer->ProviderCtx.pvUser = pCreationCtx->pvUser;
|
---|
1405 |
|
---|
1406 | LogFlowFuncLeaveRC(rc);
|
---|
1407 | return rc;
|
---|
1408 | }
|
---|
1409 |
|
---|
1410 | /**
|
---|
1411 | * Clears (resets) the root list of an URI transfer.
|
---|
1412 | *
|
---|
1413 | * @param pTransfer Transfer to clear URI root list for.
|
---|
1414 | */
|
---|
1415 | static void sharedClipboardURIListTransferRootsClear(PSHAREDCLIPBOARDURITRANSFER pTransfer)
|
---|
1416 | {
|
---|
1417 | AssertPtrReturnVoid(pTransfer);
|
---|
1418 |
|
---|
1419 | pTransfer->lstRootEntries.clear();
|
---|
1420 | }
|
---|
1421 |
|
---|
1422 | /**
|
---|
1423 | * Sets URI root list entries for a given transfer.
|
---|
1424 | *
|
---|
1425 | * @returns VBox status code.
|
---|
1426 | * @param pTransfer Transfer to set URI list entries for.
|
---|
1427 | * @param pszRoots String list (separated by CRLF) of root entries to set.
|
---|
1428 | * @param cbRoots Size (in bytes) of string list.
|
---|
1429 | */
|
---|
1430 | int SharedClipboardURILTransferSetRoots(PSHAREDCLIPBOARDURITRANSFER pTransfer, const char *pszRoots, size_t cbRoots)
|
---|
1431 | {
|
---|
1432 | AssertPtrReturn(pTransfer, VERR_INVALID_POINTER);
|
---|
1433 | AssertPtrReturn(pszRoots, VERR_INVALID_POINTER);
|
---|
1434 | AssertReturn(cbRoots, VERR_INVALID_PARAMETER);
|
---|
1435 |
|
---|
1436 | if (!RTStrIsValidEncoding(pszRoots))
|
---|
1437 | return VERR_INVALID_PARAMETER;
|
---|
1438 |
|
---|
1439 | int rc = VINF_SUCCESS;
|
---|
1440 |
|
---|
1441 | sharedClipboardURIListTransferRootsClear(pTransfer);
|
---|
1442 |
|
---|
1443 | RTCList<RTCString> lstRootEntries = RTCString(pszRoots, cbRoots - 1).split("\r\n");
|
---|
1444 | for (size_t i = 0; i < lstRootEntries.size(); ++i)
|
---|
1445 | {
|
---|
1446 | SHAREDCLIPBOARDURILISTROOT listRoot;
|
---|
1447 |
|
---|
1448 | listRoot.strPathAbs = lstRootEntries.at(i);
|
---|
1449 |
|
---|
1450 | pTransfer->lstRootEntries.append(listRoot);
|
---|
1451 | }
|
---|
1452 |
|
---|
1453 | LogFlowFunc(("cRoots=%RU32\n", pTransfer->lstRootEntries.size()));
|
---|
1454 |
|
---|
1455 | LogFlowFuncLeaveRC(rc);
|
---|
1456 | return rc;
|
---|
1457 | }
|
---|
1458 |
|
---|
1459 | /**
|
---|
1460 | * Resets an clipboard URI transfer.
|
---|
1461 | *
|
---|
1462 | * @param pTransfer URI clipboard transfer to reset.
|
---|
1463 | */
|
---|
1464 | void SharedClipboardURITransferReset(PSHAREDCLIPBOARDURITRANSFER pTransfer)
|
---|
1465 | {
|
---|
1466 | AssertPtrReturnVoid(pTransfer);
|
---|
1467 |
|
---|
1468 | LogFlowFuncEnter();
|
---|
1469 |
|
---|
1470 | sharedClipboardURIListTransferRootsClear(pTransfer);
|
---|
1471 | }
|
---|
1472 |
|
---|
1473 | /**
|
---|
1474 | * Returns the clipboard area for a clipboard URI transfer.
|
---|
1475 | *
|
---|
1476 | * @returns Current clipboard area, or NULL if none.
|
---|
1477 | * @param pTransfer URI clipboard transfer to return clipboard area for.
|
---|
1478 | */
|
---|
1479 | SharedClipboardArea *SharedClipboardURITransferGetArea(PSHAREDCLIPBOARDURITRANSFER pTransfer)
|
---|
1480 | {
|
---|
1481 | AssertPtrReturn(pTransfer, NULL);
|
---|
1482 |
|
---|
1483 | return pTransfer->pArea;
|
---|
1484 | }
|
---|
1485 |
|
---|
1486 | /**
|
---|
1487 | * Returns the number of URI root list entries.
|
---|
1488 | *
|
---|
1489 | * @returns Root list entry count.
|
---|
1490 | * @param pTransfer URI clipboard transfer to return root entry count for.
|
---|
1491 | */
|
---|
1492 | uint32_t SharedClipboardURILTransferRootsCount(PSHAREDCLIPBOARDURITRANSFER pTransfer)
|
---|
1493 | {
|
---|
1494 | AssertPtrReturn(pTransfer, 0);
|
---|
1495 |
|
---|
1496 | return (uint32_t)pTransfer->lstRootEntries.size();
|
---|
1497 | }
|
---|
1498 |
|
---|
1499 | /**
|
---|
1500 | * Get a specific root list entry.
|
---|
1501 | *
|
---|
1502 | * @returns VBox status code.
|
---|
1503 | * @param pTransfer URI clipboard transfer to get root list entry of.
|
---|
1504 | * @param uIndex Index (zero-based) of entry to get.
|
---|
1505 | * @param pEntry Where to store the returned entry on success.
|
---|
1506 | */
|
---|
1507 | int SharedClipboardURILTransferRootsEntry(PSHAREDCLIPBOARDURITRANSFER pTransfer,
|
---|
1508 | uint32_t uIndex, PVBOXCLIPBOARDROOTLISTENTRY pEntry)
|
---|
1509 | {
|
---|
1510 | AssertPtrReturn(pTransfer, VERR_INVALID_POINTER);
|
---|
1511 | AssertPtrReturn(pEntry, VERR_INVALID_POINTER);
|
---|
1512 |
|
---|
1513 | if (uIndex >= pTransfer->lstRootEntries.size())
|
---|
1514 | return VERR_INVALID_PARAMETER;
|
---|
1515 |
|
---|
1516 | int rc;
|
---|
1517 |
|
---|
1518 | PSHAREDCLIPBOARDURILISTROOT pRoot = &pTransfer->lstRootEntries.at(uIndex);
|
---|
1519 | AssertPtrReturn(pRoot, VERR_INVALID_POINTER);
|
---|
1520 |
|
---|
1521 | /* Make sure that we only advertise relative source paths, not absolute ones. */
|
---|
1522 | const char *pcszSrcPath = pRoot->strPathAbs.c_str();
|
---|
1523 |
|
---|
1524 | char *pszFileName = RTPathFilename(pcszSrcPath);
|
---|
1525 | if (pszFileName)
|
---|
1526 | {
|
---|
1527 | Assert(pszFileName >= pcszSrcPath);
|
---|
1528 | size_t cchDstBase = pszFileName - pcszSrcPath;
|
---|
1529 | const char *pszDstPath = &pcszSrcPath[cchDstBase];
|
---|
1530 |
|
---|
1531 | LogFlowFunc(("pcszSrcPath=%s, pszDstPath=%s\n", pcszSrcPath, pszDstPath));
|
---|
1532 |
|
---|
1533 | rc = SharedClipboardURIListEntryInit(pEntry);
|
---|
1534 | if (RT_SUCCESS(rc))
|
---|
1535 | {
|
---|
1536 | rc = RTStrCopy(pEntry->pszName, pEntry->cbName, pszDstPath);
|
---|
1537 | if (RT_SUCCESS(rc))
|
---|
1538 | {
|
---|
1539 | pEntry->cbInfo = sizeof(SHAREDCLIPBOARDFSOBJINFO);
|
---|
1540 | pEntry->pvInfo = (PSHAREDCLIPBOARDFSOBJINFO)RTMemAlloc(pEntry->cbInfo);
|
---|
1541 | if (pEntry->pvInfo)
|
---|
1542 | {
|
---|
1543 | RTFSOBJINFO fsObjInfo;
|
---|
1544 | rc = RTPathQueryInfo(pcszSrcPath, & fsObjInfo, RTFSOBJATTRADD_NOTHING);
|
---|
1545 | if (RT_SUCCESS(rc))
|
---|
1546 | {
|
---|
1547 | SharedClipboardFsObjFromIPRT(PSHAREDCLIPBOARDFSOBJINFO(pEntry->pvInfo), &fsObjInfo);
|
---|
1548 |
|
---|
1549 | pEntry->fInfo = VBOX_SHAREDCLIPBOARD_INFO_FLAG_FSOBJINFO;
|
---|
1550 | }
|
---|
1551 | }
|
---|
1552 | else
|
---|
1553 | rc = VERR_NO_MEMORY;
|
---|
1554 | }
|
---|
1555 | }
|
---|
1556 | }
|
---|
1557 | else
|
---|
1558 | rc = VERR_INVALID_POINTER;
|
---|
1559 |
|
---|
1560 | LogFlowFuncLeaveRC(rc);
|
---|
1561 | return rc;
|
---|
1562 | }
|
---|
1563 |
|
---|
1564 | /**
|
---|
1565 | * Returns the root entries of an URI transfer.
|
---|
1566 | *
|
---|
1567 | * @returns VBox status code.
|
---|
1568 | * @param pTransfer URI clipboard transfer to return root entries for.
|
---|
1569 | * @param ppRootList Where to store the root list on success.
|
---|
1570 | */
|
---|
1571 | int SharedClipboardURILTransferRootsAsList(PSHAREDCLIPBOARDURITRANSFER pTransfer, PVBOXCLIPBOARDROOTLIST *ppRootList)
|
---|
1572 | {
|
---|
1573 | AssertPtrReturn(pTransfer, VERR_INVALID_POINTER);
|
---|
1574 | AssertPtrReturn(ppRootList, VERR_INVALID_POINTER);
|
---|
1575 |
|
---|
1576 | int rc = VINF_SUCCESS;
|
---|
1577 |
|
---|
1578 | if (pTransfer->State.enmSource == SHAREDCLIPBOARDSOURCE_LOCAL)
|
---|
1579 | {
|
---|
1580 | PVBOXCLIPBOARDROOTLIST pRootList = SharedClipboardURIRootListAlloc();
|
---|
1581 | if (!pRootList)
|
---|
1582 | return VERR_NO_MEMORY;
|
---|
1583 |
|
---|
1584 | const uint32_t cRoots = (uint32_t)pTransfer->lstRootEntries.size();
|
---|
1585 |
|
---|
1586 | LogFlowFunc(("cRoots=%RU32\n", cRoots));
|
---|
1587 |
|
---|
1588 | if (cRoots)
|
---|
1589 | {
|
---|
1590 | PVBOXCLIPBOARDROOTLISTENTRY paRootListEntries
|
---|
1591 | = (PVBOXCLIPBOARDROOTLISTENTRY)RTMemAllocZ(cRoots * sizeof(VBOXCLIPBOARDROOTLISTENTRY));
|
---|
1592 | if (paRootListEntries)
|
---|
1593 | {
|
---|
1594 | for (uint32_t i = 0; i < cRoots; ++i)
|
---|
1595 | {
|
---|
1596 | rc = SharedClipboardURILTransferRootsEntry(pTransfer, i, &paRootListEntries[i]);
|
---|
1597 | if (RT_FAILURE(rc))
|
---|
1598 | break;
|
---|
1599 | }
|
---|
1600 |
|
---|
1601 | if (RT_SUCCESS(rc))
|
---|
1602 | pRootList->paEntries = paRootListEntries;
|
---|
1603 | }
|
---|
1604 | else
|
---|
1605 | rc = VERR_NO_MEMORY;
|
---|
1606 | }
|
---|
1607 | else
|
---|
1608 | rc = VERR_NOT_FOUND;
|
---|
1609 |
|
---|
1610 | if (RT_SUCCESS(rc))
|
---|
1611 | {
|
---|
1612 | pRootList->Hdr.cRoots = cRoots;
|
---|
1613 | pRootList->Hdr.fRoots = 0; /** @todo Implement this. */
|
---|
1614 |
|
---|
1615 | *ppRootList = pRootList;
|
---|
1616 | }
|
---|
1617 | }
|
---|
1618 | else if (pTransfer->State.enmSource == SHAREDCLIPBOARDSOURCE_REMOTE)
|
---|
1619 | {
|
---|
1620 | if (pTransfer->ProviderIface.pfnGetRoots)
|
---|
1621 | rc = pTransfer->ProviderIface.pfnGetRoots(&pTransfer->ProviderCtx, ppRootList);
|
---|
1622 | else
|
---|
1623 | rc = VERR_NOT_SUPPORTED;
|
---|
1624 | }
|
---|
1625 |
|
---|
1626 | LogFlowFuncLeaveRC(rc);
|
---|
1627 | return rc;
|
---|
1628 | }
|
---|
1629 |
|
---|
1630 | /**
|
---|
1631 | * Returns the transfer's source.
|
---|
1632 | *
|
---|
1633 | * @returns The transfer's source.
|
---|
1634 | * @param pTransfer URI clipboard transfer to return source for.
|
---|
1635 | */
|
---|
1636 | SHAREDCLIPBOARDSOURCE SharedClipboardURITransferGetSource(PSHAREDCLIPBOARDURITRANSFER pTransfer)
|
---|
1637 | {
|
---|
1638 | AssertPtrReturn(pTransfer, SHAREDCLIPBOARDSOURCE_INVALID);
|
---|
1639 |
|
---|
1640 | return pTransfer->State.enmSource;
|
---|
1641 | }
|
---|
1642 |
|
---|
1643 | /**
|
---|
1644 | * Returns the current transfer status.
|
---|
1645 | *
|
---|
1646 | * @returns Current transfer status.
|
---|
1647 | * @param pTransfer URI clipboard transfer to return status for.
|
---|
1648 | */
|
---|
1649 | SHAREDCLIPBOARDURITRANSFERSTATUS SharedClipboardURITransferGetStatus(PSHAREDCLIPBOARDURITRANSFER pTransfer)
|
---|
1650 | {
|
---|
1651 | AssertPtrReturn(pTransfer, SHAREDCLIPBOARDURITRANSFERSTATUS_NONE);
|
---|
1652 |
|
---|
1653 | return pTransfer->State.enmStatus;
|
---|
1654 | }
|
---|
1655 |
|
---|
1656 | /**
|
---|
1657 | * Runs (starts) an URI transfer thread.
|
---|
1658 | *
|
---|
1659 | * @returns VBox status code.
|
---|
1660 | * @param pTransfer URI clipboard transfer to run.
|
---|
1661 | * @param pfnThreadFunc Pointer to thread function to use.
|
---|
1662 | * @param pvUser Pointer to user-provided data.
|
---|
1663 | */
|
---|
1664 | int SharedClipboardURITransferRun(PSHAREDCLIPBOARDURITRANSFER pTransfer, PFNRTTHREAD pfnThreadFunc, void *pvUser)
|
---|
1665 | {
|
---|
1666 | AssertPtrReturn(pTransfer, VERR_INVALID_POINTER);
|
---|
1667 |
|
---|
1668 | AssertMsgReturn(pTransfer->State.enmStatus == SHAREDCLIPBOARDURITRANSFERSTATUS_READY,
|
---|
1669 | ("Wrong status (currently is %RU32)\n", pTransfer->State.enmStatus), VERR_WRONG_ORDER);
|
---|
1670 |
|
---|
1671 | int rc = sharedClipboardURITransferThreadCreate(pTransfer, pfnThreadFunc, pvUser);
|
---|
1672 |
|
---|
1673 | LogFlowFuncLeaveRC(rc);
|
---|
1674 | return rc;
|
---|
1675 | }
|
---|
1676 |
|
---|
1677 | /**
|
---|
1678 | * Sets or unsets the callback table to be used for a clipboard URI transfer.
|
---|
1679 | *
|
---|
1680 | * @returns VBox status code.
|
---|
1681 | * @param pTransfer URI clipboard transfer to set callbacks for.
|
---|
1682 | * @param pCallbacks Pointer to callback table to set.
|
---|
1683 | */
|
---|
1684 | void SharedClipboardURITransferSetCallbacks(PSHAREDCLIPBOARDURITRANSFER pTransfer,
|
---|
1685 | PSHAREDCLIPBOARDURITRANSFERCALLBACKS pCallbacks)
|
---|
1686 | {
|
---|
1687 | AssertPtrReturnVoid(pTransfer);
|
---|
1688 | AssertPtrReturnVoid(pCallbacks);
|
---|
1689 |
|
---|
1690 | LogFlowFunc(("pCallbacks=%p\n", pCallbacks));
|
---|
1691 |
|
---|
1692 | #define SET_CALLBACK(a_pfnCallback) \
|
---|
1693 | if (pCallbacks->a_pfnCallback) \
|
---|
1694 | pTransfer->Callbacks.a_pfnCallback = pCallbacks->a_pfnCallback
|
---|
1695 |
|
---|
1696 | SET_CALLBACK(pfnTransferPrepare);
|
---|
1697 | SET_CALLBACK(pfnTransferStarted);
|
---|
1698 | SET_CALLBACK(pfnListHeaderComplete);
|
---|
1699 | SET_CALLBACK(pfnListEntryComplete);
|
---|
1700 | SET_CALLBACK(pfnTransferCanceled);
|
---|
1701 | SET_CALLBACK(pfnTransferError);
|
---|
1702 | SET_CALLBACK(pfnTransferStarted);
|
---|
1703 |
|
---|
1704 | #undef SET_CALLBACK
|
---|
1705 |
|
---|
1706 | pTransfer->Callbacks.pvUser = pCallbacks->pvUser;
|
---|
1707 | }
|
---|
1708 |
|
---|
1709 | /**
|
---|
1710 | * Allocates a new event payload.
|
---|
1711 | *
|
---|
1712 | * @returns VBox status code.
|
---|
1713 | * @param uID Event ID to associate payload to.
|
---|
1714 | * @param pvData Data block to associate to this payload.
|
---|
1715 | * @param cbData Size (in bytes) of data block to associate.
|
---|
1716 | * @param ppPayload Where to store the allocated event payload on success.
|
---|
1717 | */
|
---|
1718 | int SharedClipboardURITransferPayloadAlloc(uint32_t uID, const void *pvData, uint32_t cbData,
|
---|
1719 | PSHAREDCLIPBOARDURITRANSFERPAYLOAD *ppPayload)
|
---|
1720 | {
|
---|
1721 | PSHAREDCLIPBOARDURITRANSFERPAYLOAD pPayload =
|
---|
1722 | (PSHAREDCLIPBOARDURITRANSFERPAYLOAD)RTMemAlloc(sizeof(SHAREDCLIPBOARDURITRANSFERPAYLOAD));
|
---|
1723 | if (!pPayload)
|
---|
1724 | return VERR_NO_MEMORY;
|
---|
1725 |
|
---|
1726 | pPayload->pvData = RTMemAlloc(cbData);
|
---|
1727 | if (pPayload->pvData)
|
---|
1728 | {
|
---|
1729 | memcpy(pPayload->pvData, pvData, cbData);
|
---|
1730 |
|
---|
1731 | pPayload->cbData = cbData;
|
---|
1732 | pPayload->uID = uID;
|
---|
1733 |
|
---|
1734 | *ppPayload = pPayload;
|
---|
1735 |
|
---|
1736 | return VINF_SUCCESS;
|
---|
1737 | }
|
---|
1738 |
|
---|
1739 | RTMemFree(pPayload);
|
---|
1740 | return VERR_NO_MEMORY;
|
---|
1741 | }
|
---|
1742 |
|
---|
1743 | /**
|
---|
1744 | * Frees an event payload.
|
---|
1745 | *
|
---|
1746 | * @returns VBox status code.
|
---|
1747 | * @param pPayload URI clipboard transfer event payload to free.
|
---|
1748 | */
|
---|
1749 | void SharedClipboardURITransferPayloadFree(PSHAREDCLIPBOARDURITRANSFERPAYLOAD pPayload)
|
---|
1750 | {
|
---|
1751 | if (!pPayload)
|
---|
1752 | return;
|
---|
1753 |
|
---|
1754 | if (pPayload->pvData)
|
---|
1755 | {
|
---|
1756 | Assert(pPayload->cbData);
|
---|
1757 | RTMemFree(pPayload->pvData);
|
---|
1758 | pPayload->pvData = NULL;
|
---|
1759 | }
|
---|
1760 |
|
---|
1761 | pPayload->cbData = 0;
|
---|
1762 |
|
---|
1763 | RTMemFree(pPayload);
|
---|
1764 | pPayload = NULL;
|
---|
1765 | }
|
---|
1766 |
|
---|
1767 | /**
|
---|
1768 | * Generates a new event ID for a specific URI transfer.
|
---|
1769 | *
|
---|
1770 | * @returns New event ID generated, or 0 on error.
|
---|
1771 | * @param pTransfer URI clipboard transfer to generate event for.
|
---|
1772 | */
|
---|
1773 | uint16_t SharedClipboardURITransferEventIDGenerate(PSHAREDCLIPBOARDURITRANSFER pTransfer)
|
---|
1774 | {
|
---|
1775 | LogFlowFunc(("New event %RU16\n", pTransfer->uEventIDNext));
|
---|
1776 | return pTransfer->uEventIDNext++; /** @todo Improve this. */
|
---|
1777 | }
|
---|
1778 |
|
---|
1779 | /**
|
---|
1780 | * Registers an URI transfer event.
|
---|
1781 | *
|
---|
1782 | * @returns VBox status code.
|
---|
1783 | * @param pTransfer URI clipboard transfer to register event for.
|
---|
1784 | * @param uID Event ID to register.
|
---|
1785 | */
|
---|
1786 | int SharedClipboardURITransferEventRegister(PSHAREDCLIPBOARDURITRANSFER pTransfer, uint16_t uID)
|
---|
1787 | {
|
---|
1788 | int rc;
|
---|
1789 |
|
---|
1790 | SharedClipboardURITransferEventMap::iterator itEvent = pTransfer->pMapEvents->find(uID);
|
---|
1791 | if (itEvent == pTransfer->pMapEvents->end())
|
---|
1792 | {
|
---|
1793 | PSHAREDCLIPBOARDURITRANSFEREVENT pEvent
|
---|
1794 | = (PSHAREDCLIPBOARDURITRANSFEREVENT)RTMemAllocZ(sizeof(SHAREDCLIPBOARDURITRANSFEREVENT));
|
---|
1795 | if (pEvent)
|
---|
1796 | {
|
---|
1797 | rc = RTSemEventCreate(&pEvent->hEventSem);
|
---|
1798 | if (RT_SUCCESS(rc))
|
---|
1799 | {
|
---|
1800 | pTransfer->pMapEvents->insert(std::pair<uint16_t, PSHAREDCLIPBOARDURITRANSFEREVENT>(uID, pEvent)); /** @todo Can this throw? */
|
---|
1801 |
|
---|
1802 | LogFlowFunc(("Event %RU16\n", uID));
|
---|
1803 | }
|
---|
1804 | }
|
---|
1805 | else
|
---|
1806 | rc = VERR_NO_MEMORY;
|
---|
1807 | }
|
---|
1808 | else
|
---|
1809 | rc = VERR_ALREADY_EXISTS;
|
---|
1810 |
|
---|
1811 | #ifdef DEBUG_andy
|
---|
1812 | AssertRC(rc);
|
---|
1813 | #endif
|
---|
1814 |
|
---|
1815 | LogFlowFuncLeaveRC(rc);
|
---|
1816 | return rc;
|
---|
1817 | }
|
---|
1818 |
|
---|
1819 | /**
|
---|
1820 | * Unregisters an URI transfer event.
|
---|
1821 | *
|
---|
1822 | * @returns VBox status code.
|
---|
1823 | * @param pTransfer URI clipboard transfer to unregister event for.
|
---|
1824 | * @param uID Event ID to unregister.
|
---|
1825 | */
|
---|
1826 | int SharedClipboardURITransferEventUnregister(PSHAREDCLIPBOARDURITRANSFER pTransfer, uint16_t uID)
|
---|
1827 | {
|
---|
1828 | int rc;
|
---|
1829 |
|
---|
1830 | SharedClipboardURITransferEventMap::const_iterator itEvent = pTransfer->pMapEvents->find(uID);
|
---|
1831 | if (itEvent != pTransfer->pMapEvents->end())
|
---|
1832 | {
|
---|
1833 | SharedClipboardURITransferPayloadFree(itEvent->second->pPayload);
|
---|
1834 |
|
---|
1835 | RTSemEventDestroy(itEvent->second->hEventSem);
|
---|
1836 |
|
---|
1837 | RTMemFree(itEvent->second);
|
---|
1838 |
|
---|
1839 | pTransfer->pMapEvents->erase(itEvent);
|
---|
1840 |
|
---|
1841 | LogFlowFunc(("Event %RU16\n", uID));
|
---|
1842 |
|
---|
1843 | rc = VINF_SUCCESS;
|
---|
1844 | }
|
---|
1845 | else
|
---|
1846 | rc = VERR_NOT_FOUND;
|
---|
1847 |
|
---|
1848 | AssertRC(rc);
|
---|
1849 |
|
---|
1850 | LogFlowFuncLeaveRC(rc);
|
---|
1851 | return rc;
|
---|
1852 | }
|
---|
1853 |
|
---|
1854 | /**
|
---|
1855 | * Waits for an URI transfer event to get signalled.
|
---|
1856 | *
|
---|
1857 | * @returns VBox status code.
|
---|
1858 | * @param pTransfer URI clipboard transfer that contains the event to wait for.
|
---|
1859 | * @param uID Event ID to wait for.
|
---|
1860 | * @param uTimeoutMs Timeout (in ms) to wait.
|
---|
1861 | * @param ppPayload Where to store the (allocated) event payload on success. Needs to be free'd with
|
---|
1862 | * SharedClipboardURITransferPayloadFree().
|
---|
1863 | */
|
---|
1864 | int SharedClipboardURITransferEventWait(PSHAREDCLIPBOARDURITRANSFER pTransfer, uint16_t uID, RTMSINTERVAL uTimeoutMs,
|
---|
1865 | PSHAREDCLIPBOARDURITRANSFERPAYLOAD *ppPayload)
|
---|
1866 | {
|
---|
1867 | LogFlowFuncEnter();
|
---|
1868 |
|
---|
1869 | int rc;
|
---|
1870 |
|
---|
1871 | SharedClipboardURITransferEventMap::const_iterator itEvent = pTransfer->pMapEvents->find(uID);
|
---|
1872 | if (itEvent != pTransfer->pMapEvents->end())
|
---|
1873 | {
|
---|
1874 | rc = RTSemEventWait(itEvent->second->hEventSem, uTimeoutMs);
|
---|
1875 | if (RT_SUCCESS(rc))
|
---|
1876 | {
|
---|
1877 | *ppPayload = itEvent->second->pPayload;
|
---|
1878 |
|
---|
1879 | itEvent->second->pPayload = NULL;
|
---|
1880 | }
|
---|
1881 | }
|
---|
1882 | else
|
---|
1883 | rc = VERR_NOT_FOUND;
|
---|
1884 |
|
---|
1885 | LogFlowFuncLeaveRC(rc);
|
---|
1886 | return rc;
|
---|
1887 | }
|
---|
1888 |
|
---|
1889 | /**
|
---|
1890 | * Signals an URI transfer event.
|
---|
1891 | *
|
---|
1892 | * @returns VBox status code.
|
---|
1893 | * @param pTransfer URI clipboard transfer of event to signal.
|
---|
1894 | * @param uID Event ID to signal.
|
---|
1895 | * @param pPayload Event payload to associate. Takes ownership. Optional.
|
---|
1896 | */
|
---|
1897 | int SharedClipboardURITransferEventSignal(PSHAREDCLIPBOARDURITRANSFER pTransfer, uint16_t uID,
|
---|
1898 | PSHAREDCLIPBOARDURITRANSFERPAYLOAD pPayload)
|
---|
1899 | {
|
---|
1900 | int rc;
|
---|
1901 |
|
---|
1902 | SharedClipboardURITransferEventMap::const_iterator itEvent = pTransfer->pMapEvents->find(uID);
|
---|
1903 | if (itEvent != pTransfer->pMapEvents->end())
|
---|
1904 | {
|
---|
1905 | Assert(itEvent->second->pPayload == NULL);
|
---|
1906 |
|
---|
1907 | itEvent->second->pPayload = pPayload;
|
---|
1908 |
|
---|
1909 | rc = RTSemEventSignal(itEvent->second->hEventSem);
|
---|
1910 | }
|
---|
1911 | else
|
---|
1912 | rc = VERR_NOT_FOUND;
|
---|
1913 |
|
---|
1914 | #ifdef DEBUG_andy
|
---|
1915 | AssertRC(rc);
|
---|
1916 | #endif
|
---|
1917 |
|
---|
1918 | LogFlowFuncLeaveRC(rc);
|
---|
1919 | return rc;
|
---|
1920 | }
|
---|
1921 |
|
---|
1922 | /**
|
---|
1923 | * Creates a thread for a clipboard URI transfer.
|
---|
1924 | *
|
---|
1925 | * @returns VBox status code.
|
---|
1926 | * @param pTransfer URI clipboard transfer to create thread for.
|
---|
1927 | * @param pfnThreadFunc Thread function to use for this transfer.
|
---|
1928 | * @param pvUser Pointer to user-provided data.
|
---|
1929 | */
|
---|
1930 | static int sharedClipboardURITransferThreadCreate(PSHAREDCLIPBOARDURITRANSFER pTransfer, PFNRTTHREAD pfnThreadFunc, void *pvUser)
|
---|
1931 |
|
---|
1932 | {
|
---|
1933 | AssertPtrReturn(pTransfer, VERR_INVALID_POINTER);
|
---|
1934 |
|
---|
1935 | /* Spawn a worker thread, so that we don't block the window thread for too long. */
|
---|
1936 | int rc = RTThreadCreate(&pTransfer->Thread.hThread, pfnThreadFunc,
|
---|
1937 | pvUser, 0, RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE,
|
---|
1938 | "shclp");
|
---|
1939 | if (RT_SUCCESS(rc))
|
---|
1940 | {
|
---|
1941 | int rc2 = RTThreadUserWait(pTransfer->Thread.hThread, 30 * 1000 /* Timeout in ms */);
|
---|
1942 | AssertRC(rc2);
|
---|
1943 |
|
---|
1944 | if (pTransfer->Thread.fStarted) /* Did the thread indicate that it started correctly? */
|
---|
1945 | {
|
---|
1946 | pTransfer->State.enmStatus = SHAREDCLIPBOARDURITRANSFERSTATUS_RUNNING;
|
---|
1947 | }
|
---|
1948 | else
|
---|
1949 | rc = VERR_GENERAL_FAILURE; /** @todo Find a better rc. */
|
---|
1950 | }
|
---|
1951 |
|
---|
1952 | LogFlowFuncLeaveRC(rc);
|
---|
1953 | return rc;
|
---|
1954 | }
|
---|
1955 |
|
---|
1956 | /**
|
---|
1957 | * Destroys a thread of a clipboard URI transfer.
|
---|
1958 | *
|
---|
1959 | * @returns VBox status code.
|
---|
1960 | * @param pTransfer URI clipboard transfer to destroy thread for.
|
---|
1961 | * @param uTimeoutMs Timeout (in ms) to wait for thread creation.
|
---|
1962 | */
|
---|
1963 | static int sharedClipboardURITransferThreadDestroy(PSHAREDCLIPBOARDURITRANSFER pTransfer, RTMSINTERVAL uTimeoutMs)
|
---|
1964 | {
|
---|
1965 | AssertPtrReturn(pTransfer, VERR_INVALID_POINTER);
|
---|
1966 |
|
---|
1967 | if (pTransfer->Thread.hThread == NIL_RTTHREAD)
|
---|
1968 | return VINF_SUCCESS;
|
---|
1969 |
|
---|
1970 | LogFlowFuncEnter();
|
---|
1971 |
|
---|
1972 | /* Set stop indicator. */
|
---|
1973 | pTransfer->Thread.fStop = true;
|
---|
1974 |
|
---|
1975 | int rcThread = VERR_WRONG_ORDER;
|
---|
1976 | int rc = RTThreadWait(pTransfer->Thread.hThread, uTimeoutMs, &rcThread);
|
---|
1977 |
|
---|
1978 | LogFlowFunc(("Waiting for thread resulted in %Rrc (thread exited with %Rrc)\n", rc, rcThread));
|
---|
1979 |
|
---|
1980 | return rc;
|
---|
1981 | }
|
---|
1982 |
|
---|
1983 | /**
|
---|
1984 | * Initializes a clipboard URI transfer.
|
---|
1985 | *
|
---|
1986 | * @returns VBox status code.
|
---|
1987 | * @param pURI URI clipboard context to initialize.
|
---|
1988 | */
|
---|
1989 | int SharedClipboardURICtxInit(PSHAREDCLIPBOARDURICTX pURI)
|
---|
1990 | {
|
---|
1991 | AssertPtrReturn(pURI, VERR_INVALID_POINTER);
|
---|
1992 |
|
---|
1993 | LogFlowFunc(("%p\n", pURI));
|
---|
1994 |
|
---|
1995 | int rc = RTCritSectInit(&pURI->CritSect);
|
---|
1996 | if (RT_SUCCESS(rc))
|
---|
1997 | {
|
---|
1998 | RTListInit(&pURI->List);
|
---|
1999 |
|
---|
2000 | pURI->cRunning = 0;
|
---|
2001 | pURI->cMaxRunning = 1; /* For now we only support one transfer per client at a time. */
|
---|
2002 |
|
---|
2003 | #ifdef DEBUG_andy
|
---|
2004 | pURI->cMaxRunning = UINT32_MAX;
|
---|
2005 | #endif
|
---|
2006 | SharedClipboardURICtxReset(pURI);
|
---|
2007 | }
|
---|
2008 |
|
---|
2009 | return VINF_SUCCESS;
|
---|
2010 | }
|
---|
2011 |
|
---|
2012 | /**
|
---|
2013 | * Destroys an URI clipboard information context struct.
|
---|
2014 | *
|
---|
2015 | * @param pURI URI clipboard context to destroy.
|
---|
2016 | */
|
---|
2017 | void SharedClipboardURICtxDestroy(PSHAREDCLIPBOARDURICTX pURI)
|
---|
2018 | {
|
---|
2019 | AssertPtrReturnVoid(pURI);
|
---|
2020 |
|
---|
2021 | LogFlowFunc(("%p\n", pURI));
|
---|
2022 |
|
---|
2023 | RTCritSectDelete(&pURI->CritSect);
|
---|
2024 |
|
---|
2025 | PSHAREDCLIPBOARDURITRANSFER pTransfer, pTransferNext;
|
---|
2026 | RTListForEachSafe(&pURI->List, pTransfer, pTransferNext, SHAREDCLIPBOARDURITRANSFER, Node)
|
---|
2027 | {
|
---|
2028 | SharedClipboardURITransferDestroy(pTransfer);
|
---|
2029 |
|
---|
2030 | RTListNodeRemove(&pTransfer->Node);
|
---|
2031 |
|
---|
2032 | RTMemFree(pTransfer);
|
---|
2033 | pTransfer = NULL;
|
---|
2034 | }
|
---|
2035 |
|
---|
2036 | pURI->cRunning = 0;
|
---|
2037 | pURI->cTransfers = 0;
|
---|
2038 | }
|
---|
2039 |
|
---|
2040 | /**
|
---|
2041 | * Resets an clipboard URI transfer.
|
---|
2042 | *
|
---|
2043 | * @param pURI URI clipboard context to reset.
|
---|
2044 | */
|
---|
2045 | void SharedClipboardURICtxReset(PSHAREDCLIPBOARDURICTX pURI)
|
---|
2046 | {
|
---|
2047 | AssertPtrReturnVoid(pURI);
|
---|
2048 |
|
---|
2049 | LogFlowFuncEnter();
|
---|
2050 |
|
---|
2051 | PSHAREDCLIPBOARDURITRANSFER pTransfer;
|
---|
2052 | RTListForEach(&pURI->List, pTransfer, SHAREDCLIPBOARDURITRANSFER, Node)
|
---|
2053 | SharedClipboardURITransferReset(pTransfer);
|
---|
2054 | }
|
---|
2055 |
|
---|
2056 | /**
|
---|
2057 | * Adds a new URI transfer to an clipboard URI transfer.
|
---|
2058 | *
|
---|
2059 | * @returns VBox status code.
|
---|
2060 | * @param pURI URI clipboard context to add transfer to.
|
---|
2061 | * @param pTransfer Pointer to URI clipboard transfer to add.
|
---|
2062 | */
|
---|
2063 | int SharedClipboardURICtxTransferAdd(PSHAREDCLIPBOARDURICTX pURI, PSHAREDCLIPBOARDURITRANSFER pTransfer)
|
---|
2064 | {
|
---|
2065 | AssertPtrReturn(pURI, VERR_INVALID_POINTER);
|
---|
2066 | AssertPtrReturn(pTransfer, VERR_INVALID_POINTER);
|
---|
2067 |
|
---|
2068 | LogFlowFuncEnter();
|
---|
2069 |
|
---|
2070 | if (pURI->cRunning == pURI->cMaxRunning)
|
---|
2071 | return VERR_SHCLPB_MAX_TRANSFERS_REACHED;
|
---|
2072 |
|
---|
2073 | RTListAppend(&pURI->List, &pTransfer->Node);
|
---|
2074 |
|
---|
2075 | pURI->cTransfers++;
|
---|
2076 | LogFlowFunc(("cTransfers=%RU32, cRunning=%RU32\n", pURI->cTransfers, pURI->cRunning));
|
---|
2077 |
|
---|
2078 | return VINF_SUCCESS;
|
---|
2079 | }
|
---|
2080 |
|
---|
2081 | /**
|
---|
2082 | * Removes an URI transfer from a clipboard URI transfer.
|
---|
2083 | *
|
---|
2084 | * @returns VBox status code.
|
---|
2085 | * @param pURI URI clipboard context to remove transfer from.
|
---|
2086 | * @param pTransfer Pointer to URI clipboard transfer to remove.
|
---|
2087 | */
|
---|
2088 | int SharedClipboardURICtxTransferRemove(PSHAREDCLIPBOARDURICTX pURI, PSHAREDCLIPBOARDURITRANSFER pTransfer)
|
---|
2089 | {
|
---|
2090 | AssertPtrReturn(pURI, VERR_INVALID_POINTER);
|
---|
2091 | AssertPtrReturn(pTransfer, VERR_INVALID_POINTER);
|
---|
2092 |
|
---|
2093 | LogFlowFuncEnter();
|
---|
2094 |
|
---|
2095 |
|
---|
2096 | int rc = SharedClipboardURITransferDestroy(pTransfer);
|
---|
2097 | if (RT_SUCCESS(rc))
|
---|
2098 | {
|
---|
2099 | RTListNodeRemove(&pTransfer->Node);
|
---|
2100 |
|
---|
2101 | RTMemFree(pTransfer);
|
---|
2102 | pTransfer = NULL;
|
---|
2103 | }
|
---|
2104 |
|
---|
2105 | LogFlowFuncLeaveRC(rc);
|
---|
2106 | return rc;
|
---|
2107 | }
|
---|
2108 |
|
---|
2109 | /**
|
---|
2110 | * Returns a specific URI transfer, internal version.
|
---|
2111 | *
|
---|
2112 | * @returns URI transfer, or NULL if not found.
|
---|
2113 | * @param pURI URI clipboard context to return transfer for.
|
---|
2114 | * @param uIdx Index of the transfer to return.
|
---|
2115 | */
|
---|
2116 | static PSHAREDCLIPBOARDURITRANSFER sharedClipboardURICtxGetTransferInternal(PSHAREDCLIPBOARDURICTX pURI, uint32_t uIdx)
|
---|
2117 | {
|
---|
2118 | AssertReturn(uIdx == 0, NULL); /* Only one transfer allowed at the moment. */
|
---|
2119 | return RTListGetFirst(&pURI->List, SHAREDCLIPBOARDURITRANSFER, Node);
|
---|
2120 | }
|
---|
2121 |
|
---|
2122 | /**
|
---|
2123 | * Returns a specific URI transfer.
|
---|
2124 | *
|
---|
2125 | * @returns URI transfer, or NULL if not found.
|
---|
2126 | * @param pURI URI clipboard context to return transfer for.
|
---|
2127 | * @param uIdx Index of the transfer to return.
|
---|
2128 | */
|
---|
2129 | PSHAREDCLIPBOARDURITRANSFER SharedClipboardURICtxGetTransfer(PSHAREDCLIPBOARDURICTX pURI, uint32_t uIdx)
|
---|
2130 | {
|
---|
2131 | return sharedClipboardURICtxGetTransferInternal(pURI, uIdx);
|
---|
2132 | }
|
---|
2133 |
|
---|
2134 | /**
|
---|
2135 | * Returns the number of running URI transfers.
|
---|
2136 | *
|
---|
2137 | * @returns Number of running transfers.
|
---|
2138 | * @param pURI URI clipboard context to return number for.
|
---|
2139 | */
|
---|
2140 | uint32_t SharedClipboardURICtxGetRunningTransfers(PSHAREDCLIPBOARDURICTX pURI)
|
---|
2141 | {
|
---|
2142 | AssertPtrReturn(pURI, 0);
|
---|
2143 | return pURI->cRunning;
|
---|
2144 | }
|
---|
2145 |
|
---|
2146 | /**
|
---|
2147 | * Returns the number of total URI transfers.
|
---|
2148 | *
|
---|
2149 | * @returns Number of total transfers.
|
---|
2150 | * @param pURI URI clipboard context to return number for.
|
---|
2151 | */
|
---|
2152 | uint32_t SharedClipboardURICtxGetTotalTransfers(PSHAREDCLIPBOARDURICTX pURI)
|
---|
2153 | {
|
---|
2154 | AssertPtrReturn(pURI, 0);
|
---|
2155 | return pURI->cTransfers;
|
---|
2156 | }
|
---|
2157 |
|
---|
2158 | /**
|
---|
2159 | * Cleans up all associated transfers which are not needed (anymore).
|
---|
2160 | * This can be due to transfers which only have been announced but not / never being run.
|
---|
2161 | *
|
---|
2162 | * @param pURI URI clipboard context to cleanup transfers for.
|
---|
2163 | */
|
---|
2164 | void SharedClipboardURICtxTransfersCleanup(PSHAREDCLIPBOARDURICTX pURI)
|
---|
2165 | {
|
---|
2166 | AssertPtrReturnVoid(pURI);
|
---|
2167 |
|
---|
2168 | LogFlowFunc(("cRunning=%RU32\n", pURI->cRunning));
|
---|
2169 |
|
---|
2170 | /* Remove all transfers which are not in a running state (e.g. only announced). */
|
---|
2171 | PSHAREDCLIPBOARDURITRANSFER pTransfer, pTransferNext;
|
---|
2172 | RTListForEachSafe(&pURI->List, pTransfer, pTransferNext, SHAREDCLIPBOARDURITRANSFER, Node)
|
---|
2173 | {
|
---|
2174 | if (SharedClipboardURITransferGetStatus(pTransfer) != SHAREDCLIPBOARDURITRANSFERSTATUS_RUNNING)
|
---|
2175 | {
|
---|
2176 | SharedClipboardURITransferDestroy(pTransfer);
|
---|
2177 | RTListNodeRemove(&pTransfer->Node);
|
---|
2178 |
|
---|
2179 | RTMemFree(pTransfer);
|
---|
2180 | pTransfer = NULL;
|
---|
2181 |
|
---|
2182 | Assert(pURI->cTransfers);
|
---|
2183 | pURI->cTransfers--;
|
---|
2184 |
|
---|
2185 | LogFlowFunc(("cTransfers=%RU32\n", pURI->cTransfers));
|
---|
2186 | }
|
---|
2187 | }
|
---|
2188 | }
|
---|
2189 |
|
---|
2190 | /**
|
---|
2191 | * Returns whether the maximum of concurrent transfers of a specific URI context has been reached or not.
|
---|
2192 | *
|
---|
2193 | * @returns \c if maximum has been reached, \c false if not.
|
---|
2194 | * @param pURI URI clipboard context to determine value for.
|
---|
2195 | */
|
---|
2196 | bool SharedClipboardURICtxTransfersMaximumReached(PSHAREDCLIPBOARDURICTX pURI)
|
---|
2197 | {
|
---|
2198 | AssertPtrReturn(pURI, true);
|
---|
2199 |
|
---|
2200 | LogFlowFunc(("cRunning=%RU32, cMaxRunning=%RU32\n", pURI->cRunning, pURI->cMaxRunning));
|
---|
2201 |
|
---|
2202 | Assert(pURI->cRunning <= pURI->cMaxRunning);
|
---|
2203 | return pURI->cRunning == pURI->cMaxRunning;
|
---|
2204 | }
|
---|
2205 |
|
---|
2206 | /**
|
---|
2207 | * Copies file system objinfo from IPRT to Shared Clipboard format.
|
---|
2208 | *
|
---|
2209 | * @param pDst The Shared Clipboard structure to convert data to.
|
---|
2210 | * @param pSrc The IPRT structure to convert data from.
|
---|
2211 | */
|
---|
2212 | void SharedClipboardFsObjFromIPRT(PSHAREDCLIPBOARDFSOBJINFO pDst, PCRTFSOBJINFO pSrc)
|
---|
2213 | {
|
---|
2214 | pDst->cbObject = pSrc->cbObject;
|
---|
2215 | pDst->cbAllocated = pSrc->cbAllocated;
|
---|
2216 | pDst->AccessTime = pSrc->AccessTime;
|
---|
2217 | pDst->ModificationTime = pSrc->ModificationTime;
|
---|
2218 | pDst->ChangeTime = pSrc->ChangeTime;
|
---|
2219 | pDst->BirthTime = pSrc->BirthTime;
|
---|
2220 | pDst->Attr.fMode = pSrc->Attr.fMode;
|
---|
2221 | /* Clear bits which we don't pass through for security reasons. */
|
---|
2222 | pDst->Attr.fMode &= ~(RTFS_UNIX_ISUID | RTFS_UNIX_ISGID | RTFS_UNIX_ISTXT);
|
---|
2223 | RT_ZERO(pDst->Attr.u);
|
---|
2224 | switch (pSrc->Attr.enmAdditional)
|
---|
2225 | {
|
---|
2226 | default:
|
---|
2227 | case RTFSOBJATTRADD_NOTHING:
|
---|
2228 | pDst->Attr.enmAdditional = SHAREDCLIPBOARDFSOBJATTRADD_NOTHING;
|
---|
2229 | break;
|
---|
2230 |
|
---|
2231 | case RTFSOBJATTRADD_UNIX:
|
---|
2232 | pDst->Attr.enmAdditional = SHAREDCLIPBOARDFSOBJATTRADD_UNIX;
|
---|
2233 | pDst->Attr.u.Unix.uid = pSrc->Attr.u.Unix.uid;
|
---|
2234 | pDst->Attr.u.Unix.gid = pSrc->Attr.u.Unix.gid;
|
---|
2235 | pDst->Attr.u.Unix.cHardlinks = pSrc->Attr.u.Unix.cHardlinks;
|
---|
2236 | pDst->Attr.u.Unix.INodeIdDevice = pSrc->Attr.u.Unix.INodeIdDevice;
|
---|
2237 | pDst->Attr.u.Unix.INodeId = pSrc->Attr.u.Unix.INodeId;
|
---|
2238 | pDst->Attr.u.Unix.fFlags = pSrc->Attr.u.Unix.fFlags;
|
---|
2239 | pDst->Attr.u.Unix.GenerationId = pSrc->Attr.u.Unix.GenerationId;
|
---|
2240 | pDst->Attr.u.Unix.Device = pSrc->Attr.u.Unix.Device;
|
---|
2241 | break;
|
---|
2242 |
|
---|
2243 | case RTFSOBJATTRADD_EASIZE:
|
---|
2244 | pDst->Attr.enmAdditional = SHAREDCLIPBOARDFSOBJATTRADD_EASIZE;
|
---|
2245 | pDst->Attr.u.EASize.cb = pSrc->Attr.u.EASize.cb;
|
---|
2246 | break;
|
---|
2247 | }
|
---|
2248 | }
|
---|
2249 |
|
---|