VirtualBox

source: vbox/trunk/include/VBox/GuestHost/SharedClipboard-uri.h@ 78974

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

Shared Clipboard/URI: Update.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 23.2 KB
Line 
1/* $Id: SharedClipboard-uri.h 78974 2019-06-04 16:51:48Z vboxsync $ */
2/** @file
3 * Shared Clipboard - Shared URI functions between host and guest.
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 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef VBOX_INCLUDED_GuestHost_SharedClipboard_uri_h
28#define VBOX_INCLUDED_GuestHost_SharedClipboard_uri_h
29#ifndef RT_WITHOUT_PRAGMA_ONCE
30# pragma once
31#endif
32
33#include <iprt/assert.h>
34#include <iprt/critsect.h>
35#include <iprt/fs.h>
36#include <iprt/list.h>
37
38#include <iprt/cpp/list.h>
39#include <iprt/cpp/ministring.h>
40
41#include <VBox/HostServices/VBoxClipboardSvc.h>
42
43/** Clipboard area ID. A valid area is >= 1.
44 * If 0 is specified, the last (most recent) area is meant.
45 * Set to UINT32_MAX if not initialized. */
46typedef uint32_t SHAREDCLIPBOARDAREAID;
47
48/** Defines a non-initialized (nil) clipboard area. */
49#define NIL_SHAREDCLIPBOARDAREAID UINT32_MAX
50
51/** SharedClipboardArea open flags. */
52typedef uint32_t SHAREDCLIPBOARDAREAOPENFLAGS;
53
54/** No open flags specified. */
55#define SHAREDCLIPBOARDAREA_OPEN_FLAGS_NONE 0
56/** The clipboard area must not exist yet. */
57#define SHAREDCLIPBOARDAREA_OPEN_FLAGS_MUST_NOT_EXIST RT_BIT(0)
58
59/**
60 * Class for maintaining a Shared Clipboard area
61 * on the host or guest. This will contain all received files & directories
62 * for a single Shared Clipboard operation.
63 *
64 * In case of a failed Shared Clipboard operation this class can also
65 * perform a gentle rollback if required.
66 */
67class SharedClipboardArea
68{
69public:
70
71 SharedClipboardArea(void);
72 SharedClipboardArea(const char *pszPath, SHAREDCLIPBOARDAREAID uID = NIL_SHAREDCLIPBOARDAREAID,
73 SHAREDCLIPBOARDAREAOPENFLAGS fFlags = SHAREDCLIPBOARDAREA_OPEN_FLAGS_NONE);
74 virtual ~SharedClipboardArea(void);
75
76public:
77
78 uint32_t AddRef(void);
79 uint32_t Release(void);
80
81 int Lock(void);
82 int Unlock(void);
83
84 int AddFile(const char *pszFile);
85 int AddDir(const char *pszDir);
86 int Close(void);
87 bool IsOpen(void) const;
88 int OpenEx(const char *pszPath, SHAREDCLIPBOARDAREAID uID = NIL_SHAREDCLIPBOARDAREAID,
89 SHAREDCLIPBOARDAREAOPENFLAGS fFlags = SHAREDCLIPBOARDAREA_OPEN_FLAGS_NONE);
90 int OpenTemp(SHAREDCLIPBOARDAREAID uID = NIL_SHAREDCLIPBOARDAREAID,
91 SHAREDCLIPBOARDAREAOPENFLAGS fFlags = SHAREDCLIPBOARDAREA_OPEN_FLAGS_NONE);
92 SHAREDCLIPBOARDAREAID GetID(void) const;
93 const char *GetDirAbs(void) const;
94 uint32_t GetRefCount(void);
95 int Reopen(void);
96 int Reset(bool fDeleteContent);
97 int Rollback(void);
98
99public:
100
101 static int PathConstruct(const char *pszBase, SHAREDCLIPBOARDAREAID uID, char *pszPath, size_t cbPath);
102
103protected:
104
105 int initInternal(void);
106 int destroyInternal(void);
107 int closeInternal(void);
108
109protected:
110
111 /** Creation timestamp (in ms). */
112 uint64_t m_tsCreatedMs;
113 /** Number of references to this instance. */
114 volatile uint32_t m_cRefs;
115 /** Critical section for serializing access. */
116 RTCRITSECT m_CritSect;
117 /** Open flags. */
118 uint32_t m_fOpen;
119 /** Directory handle for drop directory. */
120 RTDIR m_hDir;
121 /** Absolute path to drop directory. */
122 RTCString m_strPathAbs;
123 /** List for holding created directories in the case of a rollback. */
124 RTCList<RTCString> m_lstDirs;
125 /** List for holding created files in the case of a rollback. */
126 RTCList<RTCString> m_lstFiles;
127 /** Associated clipboard area ID. */
128 SHAREDCLIPBOARDAREAID m_uID;
129};
130
131int SharedClipboardPathSanitizeFilename(char *pszPath, size_t cbPath);
132int SharedClipboardPathSanitize(char *pszPath, size_t cbPath);
133
134/** SharedClipboardURIObject flags. */
135typedef uint32_t SHAREDCLIPBOARDURIOBJECTFLAGS;
136
137/** No flags specified. */
138#define SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE 0
139
140/** Mask of all valid Shared Clipboard URI object flags. */
141#define SHAREDCLIPBOARDURIOBJECT_FLAGS_VALID_MASK UINT32_C(0x0)
142
143/**
144 * Class for handling Shared Clipboard URI objects.
145 * This class abstracts the access and handling objects when performing Shared Clipboard actions.
146 */
147class SharedClipboardURIObject
148{
149public:
150
151 /**
152 * Enumeration for specifying an URI object type.
153 */
154 enum Type
155 {
156 /** Unknown type, do not use. */
157 Type_Unknown = 0,
158 /** Object is a file. */
159 Type_File,
160 /** Object is a directory. */
161 Type_Directory,
162 /** The usual 32-bit hack. */
163 Type_32Bit_Hack = 0x7fffffff
164 };
165
166 /**
167 * Enumeration for specifying an URI object view
168 * for representing its data accordingly.
169 */
170 enum View
171 {
172 /** Unknown view, do not use. */
173 View_Unknown = 0,
174 /** Handle data from the source point of view. */
175 View_Source,
176 /** Handle data from the destination point of view. */
177 View_Target,
178 /** The usual 32-bit hack. */
179 View_Dest_32Bit_Hack = 0x7fffffff
180 };
181
182 SharedClipboardURIObject(void);
183 SharedClipboardURIObject(Type type, const RTCString &strSrcPathAbs = "", const RTCString &strDstPathAbs = "");
184 virtual ~SharedClipboardURIObject(void);
185
186public:
187
188 /**
189 * Returns the given absolute source path of the object.
190 *
191 * @return Absolute source path of the object.
192 */
193 const RTCString &GetSourcePathAbs(void) const { return m_strSrcPathAbs; }
194
195 /**
196 * Returns the given, absolute destination path of the object.
197 *
198 * @return Absolute destination path of the object.
199 */
200 const RTCString &GetDestPathAbs(void) const { return m_strTgtPathAbs; }
201
202 RTFMODE GetMode(void) const;
203
204 uint64_t GetProcessed(void) const;
205
206 uint64_t GetSize(void) const;
207
208 /**
209 * Returns the object's type.
210 *
211 * @return The object's type.
212 */
213 Type GetType(void) const { return m_enmType; }
214
215 /**
216 * Returns the object's view.
217 *
218 * @return The object's view.
219 */
220 View GetView(void) const { return m_enmView; }
221
222public:
223
224 int SetSize(uint64_t cbSize);
225
226public:
227
228 void Close(void);
229 bool IsComplete(void) const;
230 bool IsOpen(void) const;
231 int OpenDirectory(View enmView, uint32_t fCreate = 0, RTFMODE fMode = 0);
232 int OpenDirectoryEx(const RTCString &strPathAbs, View enmView,
233 uint32_t fCreate = 0, RTFMODE fMode = 0,
234 SHAREDCLIPBOARDURIOBJECTFLAGS fFlags = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE);
235 int OpenFile(View enmView, uint64_t fOpen = 0, RTFMODE fMode = 0);
236 int OpenFileEx(const RTCString &strPathAbs, View enmView,
237 uint64_t fOpen = 0, RTFMODE fMode = 0,
238 SHAREDCLIPBOARDURIOBJECTFLAGS fFlags = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE);
239 int QueryInfo(View enmView);
240 int Read(void *pvBuf, size_t cbBuf, uint32_t *pcbRead);
241 void Reset(void);
242 int SetDirectoryData(const RTCString &strPathAbs, View enmView, uint32_t fOpen = 0, RTFMODE fMode = 0,
243 SHAREDCLIPBOARDURIOBJECTFLAGS fFlags = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE);
244 int SetFileData(const RTCString &strPathAbs, View enmView, uint64_t fOpen = 0, RTFMODE fMode = 0,
245 SHAREDCLIPBOARDURIOBJECTFLAGS fFlags = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE);
246 int Write(const void *pvBuf, size_t cbBuf, uint32_t *pcbWritten);
247
248public:
249
250 static int RebaseURIPath(RTCString &strPath, const RTCString &strBaseOld = "", const RTCString &strBaseNew = "");
251
252protected:
253
254 void closeInternal(void);
255 int setDirectoryDataInternal(const RTCString &strPathAbs, View enmView, uint32_t fCreate = 0, RTFMODE fMode = 0,
256 SHAREDCLIPBOARDURIOBJECTFLAGS fFlags = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE);
257 int setFileDataInternal(const RTCString &strPathAbs, View enmView, uint64_t fOpen = 0, RTFMODE fMode = 0,
258 SHAREDCLIPBOARDURIOBJECTFLAGS fFlags = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE);
259 int queryInfoInternal(View enmView);
260
261protected:
262
263 /** The object's type. */
264 Type m_enmType;
265 /** The object's view. */
266 View m_enmView;
267 /** Absolute path (base) for the source. */
268 RTCString m_strSrcPathAbs;
269 /** Absolute path (base) for the target. */
270 RTCString m_strTgtPathAbs;
271 /** Saved SHAREDCLIPBOARDURIOBJECT_FLAGS. */
272 uint32_t m_fFlags;
273 /** Requested file mode.
274 * Note: The actual file mode of an opened file will be in objInfo. */
275 RTFMODE m_fModeRequested;
276
277 /** Union containing data depending on the object's type. */
278 union
279 {
280 /** Structure containing members for objects that
281 * are files. */
282 struct
283 {
284 /** File handle. */
285 RTFILE hFile;
286 /** File system object information of this file. */
287 RTFSOBJINFO objInfo;
288 /** Requested file open flags. */
289 uint32_t fOpenRequested;
290 /** Bytes to proces for reading/writing. */
291 uint64_t cbToProcess;
292 /** Bytes processed reading/writing. */
293 uint64_t cbProcessed;
294 } File;
295 struct
296 {
297 /** Directory handle. */
298 RTDIR hDir;
299 /** File system object information of this directory. */
300 RTFSOBJINFO objInfo;
301 /** Requested directory creation flags. */
302 uint32_t fCreateRequested;
303 } Dir;
304 } u;
305};
306
307/** SharedClipboardURIList flags. */
308typedef uint32_t SHAREDCLIPBOARDURILISTFLAGS;
309
310/** No flags specified. */
311#define SHAREDCLIPBOARDURILIST_FLAGS_NONE 0
312/** Keep the original paths, don't convert paths to relative ones. */
313#define SHAREDCLIPBOARDURILIST_FLAGS_ABSOLUTE_PATHS RT_BIT(0)
314/** Resolve all symlinks. */
315#define SHAREDCLIPBOARDURILIST_FLAGS_RESOLVE_SYMLINKS RT_BIT(1)
316/** Keep the files + directory entries open while
317 * being in this list. */
318#define SHAREDCLIPBOARDURILIST_FLAGS_KEEP_OPEN RT_BIT(2)
319/** Lazy loading: Only enumerate sub directories when needed.
320 ** @todo Implement lazy loading. */
321#define SHAREDCLIPBOARDURILIST_FLAGS_LAZY RT_BIT(3)
322
323/** Mask of all valid Shared Clipboard URI list flags. */
324#define SHAREDCLIPBOARDURILIST_FLAGS_VALID_MASK UINT32_C(0xF)
325
326class SharedClipboardURIList
327{
328public:
329
330 SharedClipboardURIList(void);
331 virtual ~SharedClipboardURIList(void);
332
333public:
334
335 int AppendNativePath(const char *pszPath, SHAREDCLIPBOARDURILISTFLAGS fFlags);
336 int AppendNativePathsFromList(const char *pszNativePaths, size_t cbNativePaths, SHAREDCLIPBOARDURILISTFLAGS fFlags);
337 int AppendNativePathsFromList(const RTCList<RTCString> &lstNativePaths, SHAREDCLIPBOARDURILISTFLAGS fFlags);
338 int AppendURIObject(SharedClipboardURIObject *pObject);
339 int AppendURIPath(const char *pszURI, SHAREDCLIPBOARDURILISTFLAGS fFlags);
340 int AppendURIPathsFromList(const char *pszURIPaths, size_t cbURIPaths, SHAREDCLIPBOARDURILISTFLAGS fFlags);
341 int AppendURIPathsFromList(const RTCList<RTCString> &lstURI, SHAREDCLIPBOARDURILISTFLAGS fFlags);
342
343 void Clear(void);
344 SharedClipboardURIObject *At(size_t i) const { return m_lstTree.at(i); }
345 SharedClipboardURIObject *First(void) const { return m_lstTree.first(); }
346 bool IsEmpty(void) const { return m_lstTree.isEmpty(); }
347 void RemoveFirst(void);
348 int SetFromURIData(const void *pvData, size_t cbData, SHAREDCLIPBOARDURILISTFLAGS fFlags);
349
350 RTCString GetRootEntries(const RTCString &strPathBase = "", const RTCString &strSeparator = "\r\n") const;
351 uint64_t GetRootCount(void) const { return m_lstRoot.size(); }
352 uint64_t GetTotalCount(void) const { return m_cTotal; }
353 uint64_t GetTotalBytes(void) const { return m_cbTotal; }
354
355protected:
356
357 int appendEntry(const char *pcszSource, const char *pcszTarget, SHAREDCLIPBOARDURILISTFLAGS fFlags);
358 int appendObject(SharedClipboardURIObject *pObject);
359 int appendPathRecursive(const char *pcszSrcPath, const char *pcszDstPath, const char *pcszDstBase, size_t cchDstBase, SHAREDCLIPBOARDURILISTFLAGS fFlags);
360
361protected:
362
363 /** List of all top-level file/directory entries.
364 * Note: All paths are kept internally as UNIX paths for
365 * easier conversion/handling! */
366 RTCList<RTCString> m_lstRoot;
367 /** List of all URI objects added. The list's content
368 * might vary depending on how the objects are being
369 * added (lazy or not). */
370 RTCList<SharedClipboardURIObject *> m_lstTree;
371 /** Total number of all URI objects. */
372 uint64_t m_cTotal;
373 /** Total size of all URI objects, that is, the file
374 * size of all objects (in bytes).
375 * Note: Do *not* size_t here, as we also want to support large files
376 * on 32-bit guests. */
377 uint64_t m_cbTotal;
378};
379
380/**
381 * Structure for keeping Shared Clipboard meta data.
382 *
383 * For URI transfers this represents a string list with the file object root entries in it.
384 */
385typedef struct _SHAREDCLIPBOARDMETADATA
386{
387 /** Actual meta data block. */
388 void *pvMeta;
389 /** Total size (in bytes) of the allocated meta data block .*/
390 size_t cbMeta;
391 /** How many bytes are being used in the meta data block. */
392 size_t cbUsed;
393} SHAREDCLIPBOARDMETADATA, *PSHAREDCLIPBOARDMETADATA;
394
395int SharedClipboardMetaDataInit(PSHAREDCLIPBOARDMETADATA pMeta);
396void SharedClipboardMetaDataDestroy(PSHAREDCLIPBOARDMETADATA pMeta);
397int SharedClipboardMetaDataAdd(PSHAREDCLIPBOARDMETADATA pMeta, const void *pvDataAdd, uint32_t cbDataAdd);
398int SharedClipboardMetaDataResize(PSHAREDCLIPBOARDMETADATA pMeta, size_t cbNewSize);
399size_t SharedClipboardMetaDataGetUsed(PSHAREDCLIPBOARDMETADATA pMeta);
400size_t SharedClipboardMetaDataGetSize(PSHAREDCLIPBOARDMETADATA pMeta);
401void *SharedClipboardMetaDataMutableRaw(PSHAREDCLIPBOARDMETADATA pMeta);
402const void *SharedClipboardMetaDataRaw(PSHAREDCLIPBOARDMETADATA pMeta);
403
404/**
405 * Enumeration to specify the Shared Clipboard provider source type.
406 */
407typedef enum SHAREDCLIPBOARDPROVIDERSOURCE
408{
409 /** Invalid source type. */
410 SHAREDCLIPBOARDPROVIDERSOURCE_INVALID = 0,
411 /** Source is VbglR3. */
412 SHAREDCLIPBOARDPROVIDERSOURCE_VBGLR3,
413 /** Source is the host service. */
414 SHAREDCLIPBOARDPROVIDERSOURCE_HOSTSERVICE
415} SHAREDCLIPBOARDPROVIDERSOURCE;
416
417/**
418 * Structure for the Shared Clipboard provider creation context.
419 */
420typedef struct _SHAREDCLIPBOARDPROVIDERCREATIONCTX
421{
422 SHAREDCLIPBOARDPROVIDERSOURCE enmSource;
423 union
424 {
425 struct
426 {
427 /** HGCM client ID to use. */
428 uint32_t uClientID;
429 } VBGLR3;
430 } u;
431} SHAREDCLIPBOARDPROVIDERCREATIONCTX, *PSHAREDCLIPBOARDPROVIDERCREATIONCTX;
432
433/**
434 * Interface class acting as a lightweight proxy for abstracting reading / writing clipboard data.
435 *
436 * This is needed because various implementations can run on the host *or* on the guest side,
437 * requiring different methods for handling the actual data.
438 */
439class SharedClipboardProvider
440{
441
442public:
443
444 static SharedClipboardProvider *Create(PSHAREDCLIPBOARDPROVIDERCREATIONCTX pCtx);
445
446 virtual ~SharedClipboardProvider(void);
447
448public:
449
450 uint32_t AddRef(void);
451 uint32_t Release(void);
452
453public: /* Interface to be implemented. */
454
455 virtual int ReadMetaData(uint32_t fFlags = 0);
456 virtual int WriteMetaData(const void *pvBuf, size_t cbBuf, size_t *pcbWritten, uint32_t fFlags = 0);
457
458 virtual int ReadDirectory(PVBOXCLIPBOARDDIRDATA pDirData);
459 virtual int ReadDirectoryObj(SharedClipboardURIObject &Obj);
460
461 virtual int WriteDirectory(const PVBOXCLIPBOARDDIRDATA pDirData);
462 virtual int WriteDirectoryObj(const SharedClipboardURIObject &Obj);
463
464 virtual int ReadFileHdr(PVBOXCLIPBOARDFILEHDR pFileHdr);
465 virtual int ReadFileHdrObj(SharedClipboardURIObject &Obj);
466
467 virtual int WriteFileHdr(const PVBOXCLIPBOARDFILEHDR pFileHdr);
468 virtual int WriteFileHdrObj(const SharedClipboardURIObject &Obj);
469
470 virtual int ReadFileData(PVBOXCLIPBOARDFILEDATA pFileData, uint32_t *pcbRead);
471 virtual int ReadFileDataObj(SharedClipboardURIObject &Obj, uint32_t *pcbRead);
472
473 virtual int WriteFileData(const PVBOXCLIPBOARDFILEDATA pFileData, uint32_t *pcbWritten);
474 virtual int WriteFileDataObj(const SharedClipboardURIObject &Obj, uint32_t *pcbWritten);
475
476 virtual void Reset(void);
477
478public:
479
480 SharedClipboardURIList &GetURIList(void) { return m_URIList; }
481 const SharedClipboardURIObject *GetURIObjectCurrent(void) { return m_URIList.First(); }
482
483protected:
484
485 SharedClipboardProvider(void);
486
487protected:
488
489 /** Number of references to this instance. */
490 volatile uint32_t m_cRefs;
491 /** Current URI list. */
492 SharedClipboardURIList m_URIList;
493};
494
495/**
496 * Shared Clipboard provider implementation for VbglR3 (guest side).
497 */
498class SharedClipboardProviderVbglR3 : protected SharedClipboardProvider
499{
500 friend class SharedClipboardProvider;
501
502public:
503
504 virtual ~SharedClipboardProviderVbglR3(void);
505
506public:
507
508 int ReadMetaData(uint32_t fFlags = 0);
509 int WriteMetaData(const void *pvBuf, size_t cbBuf, size_t *pcbWritten, uint32_t fFlags = 0);
510
511 int ReadDirectory(PVBOXCLIPBOARDDIRDATA pDirData);
512 int WriteDirectory(const PVBOXCLIPBOARDDIRDATA pDirData);
513
514 int ReadFileHdr(PVBOXCLIPBOARDFILEHDR pFileHdr);
515 int WriteFileHdr(const PVBOXCLIPBOARDFILEHDR pFileHdr);
516 int ReadFileData(PVBOXCLIPBOARDFILEDATA pFileData, uint32_t *pcbRead);
517 int WriteFileData(const PVBOXCLIPBOARDFILEDATA pFileData, uint32_t *pcbWritten);
518
519 void Reset(void);
520
521protected:
522
523 SharedClipboardProviderVbglR3(uint32_t uClientID);
524
525 /** HGCM client ID to use. */
526 uint32_t m_uClientID;
527};
528
529/**
530 * Shared Clipboard provider implementation for host service (host side).
531 */
532class SharedClipboardProviderHostService : protected SharedClipboardProvider
533{
534 friend class SharedClipboardProvider;
535
536public:
537
538 virtual ~SharedClipboardProviderHostService(void);
539
540protected:
541
542 SharedClipboardProviderHostService(void);
543};
544
545typedef DECLCALLBACK(int) FNSHAREDCLIPBOARDURITRANSFERSTARTED(void *pvUser);
546/** Pointer to a FNSHAREDCLIPBOARDURITRANSFERSTARTED function. */
547typedef FNSHAREDCLIPBOARDURITRANSFERSTARTED *PFNSHAREDCLIPBOARDURITRANSFERSTARTED;
548
549typedef DECLCALLBACK(int) FNSHAREDCLIPBOARDURITRANSFERCANCELED(void *pvUser);
550/** Pointer to a FNSHAREDCLIPBOARDURITRANSFERCANCELED function. */
551typedef FNSHAREDCLIPBOARDURITRANSFERCANCELED *PFNSHAREDCLIPBOARDURITRANSFERCANCELED;
552
553typedef DECLCALLBACK(int) FNSHAREDCLIPBOARDURITRANSFERCOMPLETE(void *pvUser, int rc);
554/** Pointer to a FNSHAREDCLIPBOARDURITRANSFERCOMPLETE function. */
555typedef FNSHAREDCLIPBOARDURITRANSFERCOMPLETE *PFNSHAREDCLIPBOARDURITRANSFERCOMPLETE;
556
557typedef DECLCALLBACK(int) FNSHAREDCLIPBOARDURITRANSFERERROR(void *pvUser, int rc);
558/** Pointer to a FNSHAREDCLIPBOARDURITRANSFERERROR function. */
559typedef FNSHAREDCLIPBOARDURITRANSFERERROR *PFNSHAREDCLIPBOARDURITRANSFERERROR;
560
561/**
562 * Structure acting as a function callback table for URI transfers.
563 * All callbacks are optional and therefore can be NULL.
564 */
565typedef struct _SHAREDCLIPBOARDURITRANSFERCALLBACKS
566{
567 /** Function pointer, called when the transfer has been started. */
568 PFNSHAREDCLIPBOARDURITRANSFERSTARTED pfnTransferStarted;
569 /** Function pointer, called when the transfer is complete. */
570 PFNSHAREDCLIPBOARDURITRANSFERCOMPLETE pfnTransferComplete;
571 /** Function pointer, called when the transfer has been canceled. */
572 PFNSHAREDCLIPBOARDURITRANSFERCANCELED pfnTransferCanceled;
573 /** Function pointer, called when transfer resulted in an unrecoverable error. */
574 PFNSHAREDCLIPBOARDURITRANSFERERROR pfnTransferError;
575} SHAREDCLIPBOARDURITRANSFERCALLBACKS, *PSHAREDCLIPBOARDURITRANSFERCALLBACKS;
576
577/**
578 * Structure for thread-related members for a single URI transfer.
579 */
580typedef struct _SHAREDCLIPBOARDURITRANSFERTHREAD
581{
582 /** Thread handle for the reading / writing thread.
583 * Can be NIL_RTTHREAD if not being used. */
584 RTTHREAD hThread;
585 /** Thread started indicator. */
586 volatile bool fStarted;
587 /** Thread cancelled flag / indicator. */
588 volatile bool fCancelled;
589} SHAREDCLIPBOARDURITRANSFERTHREAD, *PSHAREDCLIPBOARDURITRANSFERTHREAD;
590
591/**
592 * Structure for maintaining a single URI transfer.
593 */
594typedef struct _SHAREDCLIPBOARDURITRANSFER
595{
596 /** The node member for using this struct in a RTList. */
597 RTLISTNODE Node;
598 /** The Shared Clipboard provider in charge for this transfer. */
599 SharedClipboardProvider *pProvider;
600 /** Opaque pointer to implementation-specific parameters. */
601 void *pvUser;
602 /** Size (in bytes) of implementation-specific parameters. */
603 size_t cbUser;
604 /** Contains thread-related attributes. */
605 SHAREDCLIPBOARDURITRANSFERTHREAD Thread;
606} SHAREDCLIPBOARDURITRANSFER, *PSHAREDCLIPBOARDURITRANSFER;
607
608/**
609 * Structure for keeping URI clipboard information around.
610 */
611typedef struct _SHAREDCLIPBOARDURICTX
612{
613 /** Critical section for serializing access. */
614 RTCRITSECT CritSect;
615 /** List of active transfers.
616 * Use a list or something lateron. */
617 RTLISTANCHOR List;
618 /** Number of concurrent transfers.
619 * At the moment we only support only one transfer at a time. */
620 uint32_t cTransfers;
621} SHAREDCLIPBOARDURICTX, *PSHAREDCLIPBOARDURICTX;
622
623int SharedClipboardURITransferCreate(PSHAREDCLIPBOARDPROVIDERCREATIONCTX pCtx,
624 PSHAREDCLIPBOARDURITRANSFER *ppTransfer);
625void SharedClipboardURITransferDestroy(PSHAREDCLIPBOARDURITRANSFER pTransfer);
626void SharedClipboardURITransferReset(PSHAREDCLIPBOARDURITRANSFER pTransfer);
627int SharedClipboardURITransferWrite(PSHAREDCLIPBOARDURITRANSFER pTransfer);
628int SharedClipboardURITransferWriteThread(RTTHREAD hThread, void *pvUser);
629
630int SharedClipboardURICtxInit(PSHAREDCLIPBOARDURICTX pURI, PSHAREDCLIPBOARDURITRANSFER pTransfer);
631void SharedClipboardURICtxDestroy(PSHAREDCLIPBOARDURICTX pURI);
632void SharedClipboardURICtxReset(PSHAREDCLIPBOARDURICTX pURI);
633PSHAREDCLIPBOARDURITRANSFER SharedClipboardURICtxGetTransfer(PSHAREDCLIPBOARDURICTX pURI, uint32_t uIdx);
634uint32_t SharedClipboardURICtxGetActiveTransfers(PSHAREDCLIPBOARDURICTX pURI);
635int SharedClipboardURICtxTransferAdd(PSHAREDCLIPBOARDURICTX pURI, PSHAREDCLIPBOARDURITRANSFER pTransfer);
636
637bool SharedClipboardMIMEHasFileURLs(const char *pcszFormat, size_t cchFormatMax);
638bool SharedClipboardMIMENeedsCache(const char *pcszFormat, size_t cchFormatMax);
639
640#endif /* !VBOX_INCLUDED_GuestHost_SharedClipboard_uri_h */
641
Note: See TracBrowser for help on using the repository browser.

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