VirtualBox

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

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

Shared Clipboard/URI: Doxygen.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 43.1 KB
Line 
1/* $Id: SharedClipboard-uri.h 79703 2019-07-11 19:36:33Z 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 <map>
34
35#include <iprt/assert.h>
36#include <iprt/critsect.h>
37#include <iprt/fs.h>
38#include <iprt/list.h>
39
40#include <iprt/cpp/list.h>
41#include <iprt/cpp/ministring.h>
42
43#include <VBox/GuestHost/SharedClipboard.h>
44
45/** @name Shared Clipboard handles.
46 * @{
47 */
48
49/** A Shared Clipboard list handle. */
50typedef uint64_t SHAREDCLIPBOARDLISTHANDLE;
51/** Pointer to a Shared Clipboard list handle. */
52typedef SHAREDCLIPBOARDLISTHANDLE *PSHAREDCLIPBOARDLISTHANDLE;
53
54/** Specifies an invalid Shared Clipboard list handle. */
55#define SHAREDCLIPBOARDLISTHANDLE_INVALID 0
56
57/** A Shared Clipboard object handle. */
58typedef uint64_t SHAREDCLIPBOARDOBJHANDLE;
59/** Pointer to a Shared Clipboard object handle. */
60typedef SHAREDCLIPBOARDOBJHANDLE *PSHAREDCLIPBOARDOBJHANDLE;
61
62/** Specifies an invalid Shared Clipboard object handle. */
63#define SHAREDCLIPBOARDOBJHANDLE_INVALID 0
64
65/** @} */
66
67/** @name Shared Clipboard open/create flags.
68 * @{
69 */
70
71/** No flags. Initialization value. */
72#define SHAREDCLIPBOARD_CF_NONE (0x00000000)
73
74/** Lookup only the object, do not return a handle. All other flags are ignored. */
75#define SHAREDCLIPBOARD_CF_LOOKUP (0x00000001)
76
77/** Create/open a directory. */
78#define SHAREDCLIPBOARD_CF_DIRECTORY (0x00000004)
79
80/** Open/create action to do if object exists
81 * and if the object does not exists.
82 * REPLACE file means atomically DELETE and CREATE.
83 * OVERWRITE file means truncating the file to 0 and
84 * setting new size.
85 * When opening an existing directory REPLACE and OVERWRITE
86 * actions are considered invalid, and cause returning
87 * FILE_EXISTS with NIL handle.
88 */
89#define SHAREDCLIPBOARD_CF_ACT_MASK_IF_EXISTS (0x000000F0)
90#define SHAREDCLIPBOARD_CF_ACT_MASK_IF_NEW (0x00000F00)
91
92/** What to do if object exists. */
93#define SHAREDCLIPBOARD_CF_ACT_OPEN_IF_EXISTS (0x00000000)
94#define SHAREDCLIPBOARD_CF_ACT_FAIL_IF_EXISTS (0x00000010)
95#define SHAREDCLIPBOARD_CF_ACT_REPLACE_IF_EXISTS (0x00000020)
96#define SHAREDCLIPBOARD_CF_ACT_OVERWRITE_IF_EXISTS (0x00000030)
97
98/** What to do if object does not exist. */
99#define SHAREDCLIPBOARD_CF_ACT_CREATE_IF_NEW (0x00000000)
100#define SHAREDCLIPBOARD_CF_ACT_FAIL_IF_NEW (0x00000100)
101
102/** Read/write requested access for the object. */
103#define SHAREDCLIPBOARD_CF_ACCESS_MASK_RW (0x00003000)
104
105/** No access requested. */
106#define SHAREDCLIPBOARD_CF_ACCESS_NONE (0x00000000)
107/** Read access requested. */
108#define SHAREDCLIPBOARD_CF_ACCESS_READ (0x00001000)
109/** Write access requested. */
110#define SHAREDCLIPBOARD_CF_ACCESS_WRITE (0x00002000)
111/** Read/Write access requested. */
112#define SHAREDCLIPBOARD_CF_ACCESS_READWRITE (SHAREDCLIPBOARD_CF_ACCESS_READ | SHAREDCLIPBOARD_CF_ACCESS_WRITE)
113
114/** Requested share access for the object. */
115#define SHAREDCLIPBOARD_CF_ACCESS_MASK_DENY (0x0000C000)
116
117/** Allow any access. */
118#define SHAREDCLIPBOARD_CF_ACCESS_DENYNONE (0x00000000)
119/** Do not allow read. */
120#define SHAREDCLIPBOARD_CF_ACCESS_DENYREAD (0x00004000)
121/** Do not allow write. */
122#define SHAREDCLIPBOARD_CF_ACCESS_DENYWRITE (0x00008000)
123/** Do not allow access. */
124#define SHAREDCLIPBOARD_CF_ACCESS_DENYALL (SHAREDCLIPBOARD_CF_ACCESS_DENYREAD | SHAREDCLIPBOARD_CF_ACCESS_DENYWRITE)
125
126/** Requested access to attributes of the object. */
127#define SHAREDCLIPBOARD_CF_ACCESS_MASK_ATTR (0x00030000)
128
129/** No access requested. */
130#define SHAREDCLIPBOARD_CF_ACCESS_ATTR_NONE (0x00000000)
131/** Read access requested. */
132#define SHAREDCLIPBOARD_CF_ACCESS_ATTR_READ (0x00010000)
133/** Write access requested. */
134#define SHAREDCLIPBOARD_CF_ACCESS_ATTR_WRITE (0x00020000)
135/** Read/Write access requested. */
136#define SHAREDCLIPBOARD_CF_ACCESS_ATTR_READWRITE (SHAREDCLIPBOARD_CF_ACCESS_ATTR_READ | SHAREDCLIPBOARD_CF_ACCESS_ATTR_WRITE)
137
138/** The file is opened in append mode. Ignored if SHAREDCLIPBOARD_CF_ACCESS_WRITE is not set. */
139#define SHAREDCLIPBOARD_CF_ACCESS_APPEND (0x00040000)
140
141/** @} */
142
143/** Result of an open/create request.
144 * Along with handle value the result code
145 * identifies what has happened while
146 * trying to open the object.
147 */
148typedef enum _SHAREDCLIPBOARDCREATERESULT
149{
150 SHAREDCLIPBOARD_CREATERESULT_NONE,
151 /** Specified path does not exist. */
152 SHAREDCLIPBOARD_CREATERESULT_PATH_NOT_FOUND,
153 /** Path to file exists, but the last component does not. */
154 SHAREDCLIPBOARD_CREATERESULT_FILE_NOT_FOUND,
155 /** File already exists and either has been opened or not. */
156 SHAREDCLIPBOARD_CREATERESULT_FILE_EXISTS,
157 /** New file was created. */
158 SHAREDCLIPBOARD_CREATERESULT_FILE_CREATED,
159 /** Existing file was replaced or overwritten. */
160 SHAREDCLIPBOARD_CREATERESULT_FILE_REPLACED,
161 /** Blow the type up to 32-bit. */
162 SHAREDCLIPBOARD_CREATERESULT_32BIT_HACK = 0x7fffffff
163} SHAREDCLIPBOARDCREATERESULT;
164AssertCompile(SHAREDCLIPBOARD_CREATERESULT_NONE == 0);
165AssertCompileSize(SHAREDCLIPBOARDCREATERESULT, 4);
166
167/**
168 * The available additional information in a SHAREDCLIPBOARDFSOBJATTR object.
169 */
170typedef enum _SHAREDCLIPBOARDFSOBJATTRADD
171{
172 /** No additional information is available / requested. */
173 SHAREDCLIPBOARDFSOBJATTRADD_NOTHING = 1,
174 /** The additional unix attributes (SHAREDCLIPBOARDFSOBJATTR::u::Unix) are
175 * available / requested. */
176 SHAREDCLIPBOARDFSOBJATTRADD_UNIX,
177 /** The additional extended attribute size (SHAREDCLIPBOARDFSOBJATTR::u::EASize) is
178 * available / requested. */
179 SHAREDCLIPBOARDFSOBJATTRADD_EASIZE,
180 /** The last valid item (inclusive).
181 * The valid range is SHAREDCLIPBOARDFSOBJATTRADD_NOTHING thru
182 * SHAREDCLIPBOARDFSOBJATTRADD_LAST. */
183 SHAREDCLIPBOARDFSOBJATTRADD_LAST = SHAREDCLIPBOARDFSOBJATTRADD_EASIZE,
184
185 /** The usual 32-bit hack. */
186 SHAREDCLIPBOARDFSOBJATTRADD_32BIT_SIZE_HACK = 0x7fffffff
187} SHAREDCLIPBOARDFSOBJATTRADD;
188
189
190/* Assert sizes of the IRPT types we're using below. */
191AssertCompileSize(RTFMODE, 4);
192AssertCompileSize(RTFOFF, 8);
193AssertCompileSize(RTINODE, 8);
194AssertCompileSize(RTTIMESPEC, 8);
195AssertCompileSize(RTDEV, 4);
196AssertCompileSize(RTUID, 4);
197
198/**
199 * Shared Clipboard filesystem object attributes.
200 */
201#pragma pack(1)
202typedef struct _SHAREDCLIPBOARDFSOBJATTR
203{
204 /** Mode flags (st_mode). RTFS_UNIX_*, RTFS_TYPE_*, and RTFS_DOS_*.
205 * @remarks We depend on a number of RTFS_ defines to remain unchanged.
206 * Fortuntately, these are depending on windows, dos and unix
207 * standard values, so this shouldn't be much of a pain. */
208 RTFMODE fMode;
209
210 /** The additional attributes available. */
211 SHAREDCLIPBOARDFSOBJATTRADD enmAdditional;
212
213 /**
214 * Additional attributes.
215 *
216 * Unless explicitly specified to an API, the API can provide additional
217 * data as it is provided by the underlying OS.
218 */
219 union SHAREDCLIPBOARDFSOBJATTRUNION
220 {
221 /** Additional Unix Attributes
222 * These are available when SHAREDCLIPBOARDFSOBJATTRADD is set in fUnix.
223 */
224 struct SHAREDCLIPBOARDFSOBJATTRUNIX
225 {
226 /** The user owning the filesystem object (st_uid).
227 * This field is ~0U if not supported. */
228 RTUID uid;
229
230 /** The group the filesystem object is assigned (st_gid).
231 * This field is ~0U if not supported. */
232 RTGID gid;
233
234 /** Number of hard links to this filesystem object (st_nlink).
235 * This field is 1 if the filesystem doesn't support hardlinking or
236 * the information isn't available.
237 */
238 uint32_t cHardlinks;
239
240 /** The device number of the device which this filesystem object resides on (st_dev).
241 * This field is 0 if this information is not available. */
242 RTDEV INodeIdDevice;
243
244 /** The unique identifier (within the filesystem) of this filesystem object (st_ino).
245 * Together with INodeIdDevice, this field can be used as a OS wide unique id
246 * when both their values are not 0.
247 * This field is 0 if the information is not available. */
248 RTINODE INodeId;
249
250 /** User flags (st_flags).
251 * This field is 0 if this information is not available. */
252 uint32_t fFlags;
253
254 /** The current generation number (st_gen).
255 * This field is 0 if this information is not available. */
256 uint32_t GenerationId;
257
258 /** The device number of a character or block device type object (st_rdev).
259 * This field is 0 if the file isn't of a character or block device type and
260 * when the OS doesn't subscribe to the major+minor device idenfication scheme. */
261 RTDEV Device;
262 } Unix;
263
264 /**
265 * Extended attribute size.
266 */
267 struct SHAREDCLIPBOARDFSOBJATTREASIZE
268 {
269 /** Size of EAs. */
270 RTFOFF cb;
271 } EASize;
272 } u;
273} SHAREDCLIPBOARDFSOBJATTR;
274#pragma pack()
275AssertCompileSize(SHAREDCLIPBOARDFSOBJATTR, 44);
276/** Pointer to a shared folder filesystem object attributes structure. */
277typedef SHAREDCLIPBOARDFSOBJATTR *PSHAREDCLIPBOARDFSOBJATTR;
278/** Pointer to a const shared folder filesystem object attributes structure. */
279typedef const SHAREDCLIPBOARDFSOBJATTR *PCSHAREDCLIPBOARDFSOBJATTR;
280
281/**
282 * Shared Clipboard file system object information structure.
283 */
284#pragma pack(1)
285typedef struct _SHAREDCLIPBOARDFSOBJINFO
286{
287 /** Logical size (st_size).
288 * For normal files this is the size of the file.
289 * For symbolic links, this is the length of the path name contained
290 * in the symbolic link.
291 * For other objects this fields needs to be specified.
292 */
293 RTFOFF cbObject;
294
295 /** Disk allocation size (st_blocks * DEV_BSIZE). */
296 RTFOFF cbAllocated;
297
298 /** Time of last access (st_atime).
299 * @remarks Here (and other places) we depend on the IPRT timespec to
300 * remain unchanged. */
301 RTTIMESPEC AccessTime;
302
303 /** Time of last data modification (st_mtime). */
304 RTTIMESPEC ModificationTime;
305
306 /** Time of last status change (st_ctime).
307 * If not available this is set to ModificationTime.
308 */
309 RTTIMESPEC ChangeTime;
310
311 /** Time of file birth (st_birthtime).
312 * If not available this is set to ChangeTime.
313 */
314 RTTIMESPEC BirthTime;
315
316 /** Attributes. */
317 SHAREDCLIPBOARDFSOBJATTR Attr;
318
319} SHAREDCLIPBOARDFSOBJINFO;
320#pragma pack()
321AssertCompileSize(SHAREDCLIPBOARDFSOBJINFO, 92);
322/** Pointer to a shared folder filesystem object information structure. */
323typedef SHAREDCLIPBOARDFSOBJINFO *PSHAREDCLIPBOARDFSOBJINFO;
324/** Pointer to a const shared folder filesystem object information
325 * structure. */
326typedef const SHAREDCLIPBOARDFSOBJINFO *PCSHAREDCLIPBOARDFSOBJINFO;
327
328#pragma pack(1)
329typedef struct _VBOXCLIPBOARDCREATEPARMS
330{
331 /** Returned SHAREDCLIPBOARDOBJHANDLE of opened object. */
332 SHAREDCLIPBOARDOBJHANDLE uHandle;
333 /** Returned result of the operation. */
334 SHAREDCLIPBOARDCREATERESULT enmResult;
335 /** SHAREDCLIPBOARD_CF_* */
336 uint32_t fCreate;
337 /**
338 * Attributes of object to create and
339 * returned actual attributes of opened/created object.
340 */
341 SHAREDCLIPBOARDFSOBJINFO ObjInfo;
342} VBOXCLIPBOARDCREATEPARMS, *PVBOXCLIPBOARDCREATEPARMS;
343#pragma pack()
344
345/**
346 * Structure for keeping a reply message.
347 */
348typedef struct _VBOXCLIPBOARDREPLY
349{
350 /** Message type of type VBOX_SHAREDCLIPBOARD_REPLYMSGTYPE_XXX. */
351 uint32_t uType;
352 /** IPRT result of overall operation. Note: int vs. uint32! */
353 uint32_t rc;
354 union
355 {
356 struct
357 {
358 SHAREDCLIPBOARDLISTHANDLE uHandle;
359 } ListOpen;
360 struct
361 {
362 SHAREDCLIPBOARDOBJHANDLE uHandle;
363 } ObjOpen;
364 } u;
365 /** Pointer to optional payload. */
366 void *pvPayload;
367 /** Payload size (in bytes). */
368 uint32_t cbPayload;
369} VBOXCLIPBOARDREPLY, *PVBOXCLIPBOARDREPLY;
370
371/**
372 * Structure for keeping Shared Clipboard list root entries.
373 */
374typedef struct _VBOXCLIPBOARDROOTS
375{
376 /** Roots listing flags; unused at the moment. */
377 uint32_t fRoots;
378 /** Boolean indicating that more root items are following. */
379 bool fMore;
380 /** Number of root items in this message. */
381 uint32_t cRoots;
382 /** Size (in bytes) of string list. */
383 uint32_t cbRoots;
384 /** String list (separated with CRLF) containing the root items. */
385 char *pszRoots;
386} VBOXCLIPBOARDROOTS, *PVBOXCLIPBOARDROOTS;
387
388/**
389 * Structure for maintaining Shared Clipboard list open paramters.
390 */
391typedef struct _VBOXCLIPBOARDLISTOPENPARMS
392{
393 /** Listing flags (see VBOX_SHAREDCLIPBOARD_LIST_FLAG_XXX). */
394 uint32_t fList;
395 /** Size (in bytes) of the filter string. */
396 uint32_t cbFilter;
397 /** Filter string. DOS wilcard-style. */
398 char *pszFilter;
399 /** Size (in bytes) of the listing path. */
400 uint32_t cbPath;
401 /** Listing path (absolute). If empty or NULL the listing's root path will be opened. */
402 char *pszPath;
403} VBOXCLIPBOARDLISTOPENPARMS, *PVBOXCLIPBOARDLISTOPENPARMS;
404
405/**
406 * Structure for keeping a Shared Clipboard list header.
407 */
408typedef struct _VBOXCLIPBOARDLISTHDR
409{
410 /** Feature flag(s). Not being used atm. */
411 uint32_t fFeatures;
412 /** Total objects returned. */
413 uint64_t cTotalObjects;
414 /** Total size (in bytes) returned. */
415 uint64_t cbTotalSize;
416 /** Compression being method used. Not implemented yet. */
417 uint32_t enmCompression;
418 /** Checksum type being used. Not implemented yet. */
419 uint32_t enmChecksumType;
420} VBOXCLIPBOARDLISTHDR, *PVBOXCLIPBOARDLISTHDR;
421
422/**
423 * Structure for a Shared Clipboard list entry.
424 */
425typedef struct _VBOXCLIPBOARDLISTENTRY
426{
427 /** Entry name. */
428 char *pszName;
429 /** Size (in bytes) of entry name. */
430 uint32_t cbName;
431 /** Information flag(s). */
432 uint32_t fInfo;
433 /** Size (in bytes) of the actual list entry. */
434 uint32_t cbInfo;
435 /** Data of the actual list entry. */
436 void *pvInfo;
437} VBOXCLIPBOARDLISTENTRY, *PVBOXCLIPBOARDLISTENTRY;
438
439#define VBOXCLIPBOARDLISTENTRY_MAX_NAME RTPATH_MAX
440
441/**
442 * Structure for a Shared Clipboard object header.
443 */
444typedef struct _VBOXCLIPBOARDOBJHDR
445{
446 /** Header type. Currently not being used. */
447 uint32_t enmType;
448} VBOXCLIPBOARDOBJHDR, *PVBOXCLIPBOARDOBJHDR;
449
450/**
451 * Enumeration for specifying a clipboard area object type.
452 */
453typedef enum _SHAREDCLIPBOARDAREAOBJTYPE
454{
455 /** Unknown object type; do not use. */
456 SHAREDCLIPBOARDAREAOBJTYPE_UNKNOWN = 0,
457 /** Object is a directory. */
458 SHAREDCLIPBOARDAREAOBJTYPE_DIR,
459 /** Object is a file. */
460 SHAREDCLIPBOARDAREAOBJTYPE_FILE,
461 /** Object is a symbolic link. */
462 SHAREDCLIPBOARDAREAOBJTYPE_SYMLINK,
463 /** The usual 32-bit hack. */
464 SHAREDCLIPBOARDAREAOBJTYPE_32Bit_Hack = 0x7fffffff
465} SHAREDCLIPBOARDAREAOBJTYPE;
466
467/** Clipboard area ID. A valid area is >= 1.
468 * If 0 is specified, the last (most recent) area is meant.
469 * Set to UINT32_MAX if not initialized. */
470typedef uint32_t SHAREDCLIPBOARDAREAID;
471
472/** Defines a non-initialized (nil) clipboard area. */
473#define NIL_SHAREDCLIPBOARDAREAID UINT32_MAX
474
475/** SharedClipboardArea open flags. */
476typedef uint32_t SHAREDCLIPBOARDAREAOPENFLAGS;
477
478/** No clipboard area open flags specified. */
479#define SHAREDCLIPBOARDAREA_OPEN_FLAGS_NONE 0
480/** The clipboard area must not exist yet. */
481#define SHAREDCLIPBOARDAREA_OPEN_FLAGS_MUST_NOT_EXIST RT_BIT(0)
482/** Mask of all valid clipboard area open flags. */
483#define SHAREDCLIPBOARDAREA_OPEN_FLAGS_VALID_MASK 0x1
484
485/** Defines a clipboard area object state. */
486typedef uint32_t SHAREDCLIPBOARDAREAOBJSTATE;
487
488/** No object state set. */
489#define SHAREDCLIPBOARDAREAOBJSTATE_NONE 0
490/** The object is considered as being complete (e.g. serialized). */
491#define SHAREDCLIPBOARDAREAOBJSTATE_COMPLETE RT_BIT(0)
492
493/**
494 * Lightweight structure to keep a clipboard area object's state.
495 *
496 * Note: We don't want to use the ClipboardURIObject class here, as this
497 * is too heavy for this purpose.
498 */
499typedef struct _SHAREDCLIPBOARDAREAOBJ
500{
501 SHAREDCLIPBOARDAREAOBJTYPE enmType;
502 SHAREDCLIPBOARDAREAOBJSTATE fState;
503} SHAREDCLIPBOARDAREAOBJ, *PSHAREDCLIPBOARDAREAOBJ;
504
505/**
506 * Class for maintaining a Shared Clipboard area
507 * on the host or guest. This will contain all received files & directories
508 * for a single Shared Clipboard operation.
509 *
510 * In case of a failed Shared Clipboard operation this class can also
511 * perform a gentle rollback if required.
512 */
513class SharedClipboardArea
514{
515public:
516
517 SharedClipboardArea(void);
518 SharedClipboardArea(const char *pszPath, SHAREDCLIPBOARDAREAID uID = NIL_SHAREDCLIPBOARDAREAID,
519 SHAREDCLIPBOARDAREAOPENFLAGS fFlags = SHAREDCLIPBOARDAREA_OPEN_FLAGS_NONE);
520 virtual ~SharedClipboardArea(void);
521
522public:
523
524 uint32_t AddRef(void);
525 uint32_t Release(void);
526
527 int Lock(void);
528 int Unlock(void);
529
530 int AddObject(const char *pszPath, const SHAREDCLIPBOARDAREAOBJ &Obj);
531 int GetObject(const char *pszPath, PSHAREDCLIPBOARDAREAOBJ pObj);
532
533 int Close(void);
534 bool IsOpen(void) const;
535 int OpenEx(const char *pszPath, SHAREDCLIPBOARDAREAID uID = NIL_SHAREDCLIPBOARDAREAID,
536 SHAREDCLIPBOARDAREAOPENFLAGS fFlags = SHAREDCLIPBOARDAREA_OPEN_FLAGS_NONE);
537 int OpenTemp(SHAREDCLIPBOARDAREAID uID = NIL_SHAREDCLIPBOARDAREAID,
538 SHAREDCLIPBOARDAREAOPENFLAGS fFlags = SHAREDCLIPBOARDAREA_OPEN_FLAGS_NONE);
539 SHAREDCLIPBOARDAREAID GetID(void) const;
540 const char *GetDirAbs(void) const;
541 uint32_t GetRefCount(void);
542 int Reopen(void);
543 int Reset(bool fDeleteContent);
544 int Rollback(void);
545
546public:
547
548 static int PathConstruct(const char *pszBase, SHAREDCLIPBOARDAREAID uID, char *pszPath, size_t cbPath);
549
550protected:
551
552 int initInternal(void);
553 int destroyInternal(void);
554 int closeInternal(void);
555
556protected:
557
558 typedef std::map<RTCString, SHAREDCLIPBOARDAREAOBJ> SharedClipboardAreaFsObjMap;
559
560 /** Creation timestamp (in ms). */
561 uint64_t m_tsCreatedMs;
562 /** Number of references to this instance. */
563 volatile uint32_t m_cRefs;
564 /** Critical section for serializing access. */
565 RTCRITSECT m_CritSect;
566 /** Open flags. */
567 uint32_t m_fOpen;
568 /** Directory handle for root clipboard directory. */
569 RTDIR m_hDir;
570 /** Absolute path to root clipboard directory. */
571 RTCString m_strPathAbs;
572 /** List for holding created directories in the case of a rollback. */
573 SharedClipboardAreaFsObjMap m_mapObj;
574 /** Associated clipboard area ID. */
575 SHAREDCLIPBOARDAREAID m_uID;
576};
577
578int SharedClipboardPathSanitizeFilename(char *pszPath, size_t cbPath);
579int SharedClipboardPathSanitize(char *pszPath, size_t cbPath);
580
581PVBOXCLIPBOARDROOTS SharedClipboardURIRootsDup(PVBOXCLIPBOARDROOTS pRoots);
582int SharedClipboardURIRootsInit(PVBOXCLIPBOARDROOTS pRoots);
583void SharedClipboardURIRootsDestroy(PVBOXCLIPBOARDROOTS pRoots);
584
585int SharedClipboardURIListHdrAlloc(PVBOXCLIPBOARDLISTHDR *ppListHdr);
586void SharedClipboardURIListHdrFree(PVBOXCLIPBOARDLISTHDR pListHdr);
587PVBOXCLIPBOARDLISTHDR SharedClipboardURIListHdrDup(PVBOXCLIPBOARDLISTHDR pListHdr);
588int SharedClipboardURIListHdrInit(PVBOXCLIPBOARDLISTHDR pListHdr);
589void SharedClipboardURIListHdrDestroy(PVBOXCLIPBOARDLISTHDR pListHdr);
590void SharedClipboardURIListHdrFree(PVBOXCLIPBOARDLISTHDR pListHdr);
591void SharedClipboardURIListHdrReset(PVBOXCLIPBOARDLISTHDR pListHdr);
592bool SharedClipboardURIListHdrIsValid(PVBOXCLIPBOARDLISTHDR pListHdr);
593
594int SharedClipboardURIListOpenParmsCopy(PVBOXCLIPBOARDLISTOPENPARMS pDst, PVBOXCLIPBOARDLISTOPENPARMS pSrc);
595PVBOXCLIPBOARDLISTOPENPARMS SharedClipboardURIListOpenParmsDup(PVBOXCLIPBOARDLISTOPENPARMS pParms);
596int SharedClipboardURIListOpenParmsInit(PVBOXCLIPBOARDLISTOPENPARMS pParms);
597void SharedClipboardURIListOpenParmsDestroy(PVBOXCLIPBOARDLISTOPENPARMS pParms);
598
599int SharedClipboardURIListEntryAlloc(PVBOXCLIPBOARDLISTENTRY *ppListEntry);
600void SharedClipboardURIListEntryFree(PVBOXCLIPBOARDLISTENTRY pListEntry);
601int SharedClipboardURIListEntryCopy(PVBOXCLIPBOARDLISTENTRY pDst, PVBOXCLIPBOARDLISTENTRY pSrc);
602PVBOXCLIPBOARDLISTENTRY SharedClipboardURIListEntryDup(PVBOXCLIPBOARDLISTENTRY pListEntry);
603int SharedClipboardURIListEntryInit(PVBOXCLIPBOARDLISTENTRY pListEntry);
604void SharedClipboardURIListEntryDestroy(PVBOXCLIPBOARDLISTENTRY pListEntry);
605bool SharedClipboardURIListEntryIsValid(PVBOXCLIPBOARDLISTENTRY pListEntry);
606
607/**
608 * Enumeration specifying an URI transfer direction.
609 */
610typedef enum _SHAREDCLIPBOARDURITRANSFERDIR
611{
612 /** Unknown transfer directory. */
613 SHAREDCLIPBOARDURITRANSFERDIR_UNKNOWN = 0,
614 /** Read transfer (from source). */
615 SHAREDCLIPBOARDURITRANSFERDIR_READ,
616 /** Write transfer (to target). */
617 SHAREDCLIPBOARDURITRANSFERDIR_WRITE,
618 /** The usual 32-bit hack. */
619 SHAREDCLIPBOARDURITRANSFERDIR_32BIT_HACK = 0x7fffffff
620} SHAREDCLIPBOARDURITRANSFERDIR;
621
622struct _SHAREDCLIPBOARDURITRANSFER;
623typedef struct _SHAREDCLIPBOARDURITRANSFER SHAREDCLIPBOARDURITRANSFER;
624
625/**
626 * Structure for handling a single URI object context.
627 */
628typedef struct _SHAREDCLIPBOARDCLIENTURIOBJCTX
629{
630 SHAREDCLIPBOARDURITRANSFER *pTransfer;
631 SHAREDCLIPBOARDOBJHANDLE uHandle;
632} SHAREDCLIPBOARDCLIENTURIOBJCTX, *PSHAREDCLIPBOARDCLIENTURIOBJCTX;
633
634typedef struct _SHAREDCLIPBOARDURITRANSFEROBJSTATE
635{
636 uint64_t cbProcessed;
637} SHAREDCLIPBOARDURITRANSFEROBJSTATE, *PSHAREDCLIPBOARDURITRANSFEROBJSTATE;
638
639typedef struct _SHAREDCLIPBOARDURITRANSFEROBJ
640{
641 SHAREDCLIPBOARDOBJHANDLE uHandle;
642 char *pszPathAbs;
643 SHAREDCLIPBOARDFSOBJINFO objInfo;
644 SHAREDCLIPBOARDSOURCE enmSource;
645 SHAREDCLIPBOARDURITRANSFEROBJSTATE State;
646} SHAREDCLIPBOARDURITRANSFEROBJ, *PSHAREDCLIPBOARDURITRANSFEROBJ;
647
648/** No status set. */
649#define SHAREDCLIPBOARDURITRANSFERSTATUS_NONE 0
650/** The transfer has been announced but is not running yet. */
651#define SHAREDCLIPBOARDURITRANSFERSTATUS_READY 1
652/** The transfer is active and running. */
653#define SHAREDCLIPBOARDURITRANSFERSTATUS_RUNNING 2
654/** The transfer has been completed. */
655#define SHAREDCLIPBOARDURITRANSFERSTATUS_COMPLETED 3
656/** The transfer has been canceled. */
657#define SHAREDCLIPBOARDURITRANSFERSTATUS_CANCELED 4
658/** The transfer ran into an unrecoverable error. */
659#define SHAREDCLIPBOARDURITRANSFERSTATUS_ERROR 5
660
661/** Defines a transfer status. */
662typedef uint32_t SHAREDCLIPBOARDURITRANSFERSTATUS;
663
664/**
665 * Structure for an (optional) URI transfer event payload.
666 */
667typedef struct _SHAREDCLIPBOARDURITRANSFERPAYLOAD
668{
669 /** Payload ID; currently unused. */
670 uint32_t uID;
671 /** Pointer to actual payload data. */
672 void *pvData;
673 /** Size (in bytes) of actual payload data. */
674 uint32_t cbData;
675} SHAREDCLIPBOARDURITRANSFERPAYLOAD, *PSHAREDCLIPBOARDURITRANSFERPAYLOAD;
676
677/**
678 * Structure for maintaining an URI transfer event.
679 */
680typedef struct _SHAREDCLIPBOARDURITRANSFEREVENT
681{
682 /** Event semaphore for signalling the event. */
683 RTSEMEVENT hEventSem;
684 /** Payload to this event. Optional and can be NULL. */
685 PSHAREDCLIPBOARDURITRANSFERPAYLOAD pPayload;
686} SHAREDCLIPBOARDURITRANSFEREVENT, *PSHAREDCLIPBOARDURITRANSFEREVENT;
687
688/**
689 * Enumeration for an URI transfer event type.
690 */
691typedef enum _SHAREDCLIPBOARDURITRANSFEREVENTTYPE
692{
693 SHAREDCLIPBOARDURITRANSFEREVENTTYPE_UNKNOWN,
694 SHAREDCLIPBOARDURITRANSFEREVENTTYPE_GET_ROOTS,
695 SHAREDCLIPBOARDURITRANSFEREVENTTYPE_LIST_OPEN,
696 SHAREDCLIPBOARDURITRANSFEREVENTTYPE_LIST_CLOSE,
697 SHAREDCLIPBOARDURITRANSFEREVENTTYPE_LIST_HDR_READ,
698 SHAREDCLIPBOARDURITRANSFEREVENTTYPE_LIST_HDR_WRITE,
699 SHAREDCLIPBOARDURITRANSFEREVENTTYPE_LIST_ENTRY_READ,
700 SHAREDCLIPBOARDURITRANSFEREVENTTYPE_LIST_ENTRY_WRITE,
701 SHAREDCLIPBOARDURITRANSFEREVENTTYPE_OBJ_OPEN,
702 SHAREDCLIPBOARDURITRANSFEREVENTTYPE_OBJ_CLOSE,
703 SHAREDCLIPBOARDURITRANSFEREVENTTYPE_OBJ_READ,
704 SHAREDCLIPBOARDURITRANSFEREVENTTYPE_OBJ_WRITE,
705 SHAREDCLIPBOARDURITRANSFEREVENTTYPE_ERROR,
706 /** Marks the end of the event list. */
707 SHAREDCLIPBOARDURITRANSFEREVENTTYPE_LAST,
708 /** The usual 32-bit hack. */
709 SHAREDCLIPBOARDURITRANSFEREVENTTYPE_32BIT_HACK = 0x7fffffff
710} SHAREDCLIPBOARDURITRANSFEREVENTTYPE;
711
712/** Map of URI transfer events.
713 * The key specifies the event type of SHAREDCLIPBOARDURITRANSFEREVENTTYPE. */
714typedef std::map<uint32_t, SHAREDCLIPBOARDURITRANSFEREVENT *> SharedClipboardURITransferEventMap;
715
716typedef struct _SHAREDCLIPBOARDURILISTHANDLEINFO
717{
718 VBOXCLIPBOARDLISTOPENPARMS OpenParms;
719 RTFMODE fMode;
720 union
721 {
722 struct
723 {
724 union
725 {
726 RTDIR hDirRoot;
727 RTFILE hFile;
728 };
729 } Local;
730 } u;
731} SHAREDCLIPBOARDURILISTHANDLEINFO, *PSHAREDCLIPBOARDURILISTHANDLEINFO;
732
733typedef struct _SHAREDCLIPBOARDOBJHANDLEINFO
734{
735 union
736 {
737 struct
738 {
739 RTDIR hDirRoot;
740 } Local;
741 } u;
742} SHAREDCLIPBOARDURIOBJHANDLEINFO, *PSHAREDCLIPBOARDURIOBJHANDLEINFO;
743
744/** Map of URI list handles.
745 * The key specifies the list handle. */
746typedef std::map<SHAREDCLIPBOARDLISTHANDLE, SHAREDCLIPBOARDURILISTHANDLEINFO *> SharedClipboardURIListMap;
747
748/** Map of URI object handles.
749 * The key specifies the object handle. */
750typedef std::map<SHAREDCLIPBOARDOBJHANDLE, SHAREDCLIPBOARDURILISTHANDLEINFO *> SharedClipboardURIObjMap;
751
752/** List of URI list root entries. */
753typedef RTCList<RTCString> SharedClipboardURIListRootEntries;
754
755/**
756 * Structure for maintaining an URI transfer state.
757 * Everything in here will be part of a saved state (later).
758 */
759typedef struct _SHAREDCLIPBOARDURITRANSFERSTATE
760{
761 /** The transfer's current status. */
762 SHAREDCLIPBOARDURITRANSFERSTATUS enmStatus;
763 /** The transfer's direction. */
764 SHAREDCLIPBOARDURITRANSFERDIR enmDir;
765 /** The transfer's source. */
766 SHAREDCLIPBOARDSOURCE enmSource;
767} SHAREDCLIPBOARDURITRANSFERSTATE, *PSHAREDCLIPBOARDURITRANSFERSTATE;
768
769struct _SHAREDCLIPBOARDURITRANSFER;
770typedef struct _SHAREDCLIPBOARDURITRANSFER *PSHAREDCLIPBOARDURITRANSFER;
771
772/**
773 * Structure maintaining URI clipboard provider context data.
774 * This is handed in to the provider implementation callbacks.
775 */
776typedef struct _SHAREDCLIPBOARDPROVIDERCTX
777{
778 /** Pointer to the related URI transfer. */
779 PSHAREDCLIPBOARDURITRANSFER pTransfer;
780 /** User-defined data pointer. Can be NULL if not needed. */
781 void *pvUser;
782} SHAREDCLIPBOARDPROVIDERCTX, *PSHAREDCLIPBOARDPROVIDERCTX;
783
784/** Defines an URI clipboard provider function declaration with additional parameters. */
785#define SHAREDCLIPBOARDPROVIDERFUNCDECL(a_Name, ...) \
786 typedef DECLCALLBACK(int) RT_CONCAT(FNSHAREDCLIPBOARDPROVIDER, a_Name)(PSHAREDCLIPBOARDPROVIDERCTX, __VA_ARGS__); \
787 typedef RT_CONCAT(FNSHAREDCLIPBOARDPROVIDER, a_Name) RT_CONCAT(*PFNSHAREDCLIPBOARDPROVIDER, a_Name);
788
789/** Defines an URI clipboard provider function declaration with additional parameters. */
790#define SHAREDCLIPBOARDPROVIDERFUNCDECLRET(a_Ret, a_Name, ...) \
791 typedef DECLCALLBACK(a_Ret) RT_CONCAT(FNSHAREDCLIPBOARDPROVIDER, a_Name)(PSHAREDCLIPBOARDPROVIDERCTX, __VA_ARGS__); \
792 typedef RT_CONCAT(FNSHAREDCLIPBOARDPROVIDER, a_Name) RT_CONCAT(*PFNSHAREDCLIPBOARDPROVIDER, a_Name);
793
794/** Defines an URI clipboard provider function declaration (no additional parameters). */
795#define SHAREDCLIPBOARDPROVIDERFUNCDECLVOID(a_Name) \
796 typedef DECLCALLBACK(int) RT_CONCAT(FNSHAREDCLIPBOARDPROVIDER, a_Name)(PSHAREDCLIPBOARDPROVIDERCTX); \
797 typedef RT_CONCAT(FNSHAREDCLIPBOARDPROVIDER, a_Name) RT_CONCAT(*PFNSHAREDCLIPBOARDPROVIDER, a_Name);
798
799/** Declares a URI clipboard provider function member. */
800#define SHAREDCLIPBOARDPROVIDERFUNCMEMBER(a_Name, a_Member) \
801 RT_CONCAT(PFNSHAREDCLIPBOARDPROVIDER, a_Name) a_Member;
802
803SHAREDCLIPBOARDPROVIDERFUNCDECLVOID(TRANSFEROPEN)
804SHAREDCLIPBOARDPROVIDERFUNCDECLVOID(TRANSFERCLOSE)
805SHAREDCLIPBOARDPROVIDERFUNCDECL(GETROOTS, char **ppapszRoots, uint32_t *pcRoots)
806SHAREDCLIPBOARDPROVIDERFUNCDECL(LISTOPEN, PVBOXCLIPBOARDLISTOPENPARMS pOpenParms, PSHAREDCLIPBOARDLISTHANDLE phList)
807SHAREDCLIPBOARDPROVIDERFUNCDECL(LISTCLOSE, SHAREDCLIPBOARDLISTHANDLE hList);
808SHAREDCLIPBOARDPROVIDERFUNCDECL(LISTHDRREAD, SHAREDCLIPBOARDLISTHANDLE hList, PVBOXCLIPBOARDLISTHDR pListHdr)
809SHAREDCLIPBOARDPROVIDERFUNCDECL(LISTHDRWRITE, SHAREDCLIPBOARDLISTHANDLE hList, PVBOXCLIPBOARDLISTHDR pListHdr)
810SHAREDCLIPBOARDPROVIDERFUNCDECL(LISTENTRYREAD, SHAREDCLIPBOARDLISTHANDLE hList, PVBOXCLIPBOARDLISTENTRY pEntry)
811SHAREDCLIPBOARDPROVIDERFUNCDECL(LISTENTRYWRITE, SHAREDCLIPBOARDLISTHANDLE hList, PVBOXCLIPBOARDLISTENTRY pEntry)
812SHAREDCLIPBOARDPROVIDERFUNCDECL(OBJOPEN, const char *pszPath, PVBOXCLIPBOARDCREATEPARMS pCreateParms, PSHAREDCLIPBOARDOBJHANDLE phObj)
813SHAREDCLIPBOARDPROVIDERFUNCDECL(OBJCLOSE, SHAREDCLIPBOARDOBJHANDLE hObj)
814SHAREDCLIPBOARDPROVIDERFUNCDECL(OBJREAD, SHAREDCLIPBOARDOBJHANDLE hObj, void *pvData, uint32_t cbData, uint32_t fFlags, uint32_t *pcbRead)
815SHAREDCLIPBOARDPROVIDERFUNCDECL(OBJWRITE, SHAREDCLIPBOARDOBJHANDLE hObj, void *pvData, uint32_t cbData, uint32_t fFlags, uint32_t *pcbWritten)
816
817/**
818 * Shared Clipboard URI provider interface table.
819 */
820typedef struct _SHAREDCLIPBOARDPROVIDERINTERFACE
821{
822 SHAREDCLIPBOARDPROVIDERFUNCMEMBER(TRANSFEROPEN, pfnTransferOpen);
823 SHAREDCLIPBOARDPROVIDERFUNCMEMBER(TRANSFERCLOSE, pfnTransferClose);
824 SHAREDCLIPBOARDPROVIDERFUNCMEMBER(GETROOTS, pfnGetRoots);
825 SHAREDCLIPBOARDPROVIDERFUNCMEMBER(LISTOPEN, pfnListOpen);
826 SHAREDCLIPBOARDPROVIDERFUNCMEMBER(LISTCLOSE, pfnListClose);
827 SHAREDCLIPBOARDPROVIDERFUNCMEMBER(LISTHDRREAD, pfnListHdrRead);
828 SHAREDCLIPBOARDPROVIDERFUNCMEMBER(LISTHDRWRITE, pfnListHdrWrite);
829 SHAREDCLIPBOARDPROVIDERFUNCMEMBER(LISTENTRYREAD, pfnListEntryRead);
830 SHAREDCLIPBOARDPROVIDERFUNCMEMBER(LISTENTRYWRITE, pfnListEntryWrite);
831 SHAREDCLIPBOARDPROVIDERFUNCMEMBER(OBJOPEN, pfnObjOpen);
832 SHAREDCLIPBOARDPROVIDERFUNCMEMBER(OBJCLOSE, pfnObjClose);
833 SHAREDCLIPBOARDPROVIDERFUNCMEMBER(OBJREAD, pfnObjRead);
834 SHAREDCLIPBOARDPROVIDERFUNCMEMBER(OBJWRITE, pfnObjWrite);
835} SHAREDCLIPBOARDPROVIDERINTERFACE, *PSHAREDCLIPBOARDPROVIDERINTERFACE;
836
837/**
838 * Structure for the Shared Clipboard provider creation context.
839 */
840typedef struct _SHAREDCLIPBOARDPROVIDERCREATIONCTX
841{
842 /** Specifies what the source of the provider is. */
843 SHAREDCLIPBOARDSOURCE enmSource;
844 /** The provider interface table. */
845 SHAREDCLIPBOARDPROVIDERINTERFACE Interface;
846 /** Provider callback data. */
847 void *pvUser;
848} SHAREDCLIPBOARDPROVIDERCREATIONCTX, *PSHAREDCLIPBOARDPROVIDERCREATIONCTX;
849
850struct _SHAREDCLIPBOARDURITRANSFER;
851typedef _SHAREDCLIPBOARDURITRANSFER *PSHAREDCLIPBOARDURITRANSFER;
852
853/**
854 * Structure for storing URI transfer callback data.
855 */
856typedef struct _SHAREDCLIPBOARDURITRANSFERCALLBACKDATA
857{
858 /** Pointer to related URI transfer. */
859 PSHAREDCLIPBOARDURITRANSFER pTransfer;
860 /** Saved user pointer. */
861 void *pvUser;
862} SHAREDCLIPBOARDURITRANSFERCALLBACKDATA, *PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA;
863
864#define SHAREDCLIPBOARDTRANSFERCALLBACKDECLVOID(a_Name) \
865 typedef DECLCALLBACK(void) RT_CONCAT(FNSHAREDCLIPBOARDCALLBACK, a_Name)(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData); \
866 typedef RT_CONCAT(FNSHAREDCLIPBOARDCALLBACK, a_Name) RT_CONCAT(*PFNSHAREDCLIPBOARDCALLBACK, a_Name);
867
868#define SHAREDCLIPBOARDTRANSFERCALLBACKDECL(a_Name, ...) \
869 typedef DECLCALLBACK(void) RT_CONCAT(FNSHAREDCLIPBOARDCALLBACK, a_Name)(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData, __VA_ARGS__); \
870 typedef RT_CONCAT(FNSHAREDCLIPBOARDCALLBACK, a_Name) RT_CONCAT(*PFNSHAREDCLIPBOARDCALLBACK, a_Name);
871
872#define SHAREDCLIPBOARDTRANSFERCALLBACKMEMBER(a_Name, a_Member) \
873 RT_CONCAT(PFNSHAREDCLIPBOARDCALLBACK, a_Name) a_Member;
874
875SHAREDCLIPBOARDTRANSFERCALLBACKDECLVOID(TRANSFERPREPARE)
876SHAREDCLIPBOARDTRANSFERCALLBACKDECLVOID(TRANSFERSTARTED)
877SHAREDCLIPBOARDTRANSFERCALLBACKDECLVOID(LISTHEADERCOMPLETE)
878SHAREDCLIPBOARDTRANSFERCALLBACKDECLVOID(LISTENTRYCOMPLETE)
879SHAREDCLIPBOARDTRANSFERCALLBACKDECL (TRANSFERCOMPLETE, int rc)
880SHAREDCLIPBOARDTRANSFERCALLBACKDECLVOID(TRANSFERCANCELED)
881SHAREDCLIPBOARDTRANSFERCALLBACKDECL (TRANSFERERROR, int rc)
882
883/**
884 * Structure acting as a function callback table for URI transfers.
885 * All callbacks are optional and therefore can be NULL.
886 */
887typedef struct _SHAREDCLIPBOARDURITRANSFERCALLBACKS
888{
889 /** Saved user pointer. */
890 void *pvUser;
891 /** Function pointer, called when the transfer is going to be prepared. */
892 SHAREDCLIPBOARDTRANSFERCALLBACKMEMBER(TRANSFERPREPARE, pfnTransferPrepare);
893 /** Function pointer, called when the transfer has been started. */
894 SHAREDCLIPBOARDTRANSFERCALLBACKMEMBER(TRANSFERSTARTED, pfnTransferStarted);
895 /** Function pointer, called when reading / writing the list header is complete. */
896 SHAREDCLIPBOARDTRANSFERCALLBACKMEMBER(LISTHEADERCOMPLETE, pfnListHeaderComplete);
897 /** Function pointer, called when reading / writing a list entry is complete. */
898 SHAREDCLIPBOARDTRANSFERCALLBACKMEMBER(LISTENTRYCOMPLETE, pfnListEntryComplete);
899 /** Function pointer, called when the transfer is complete. */
900 SHAREDCLIPBOARDTRANSFERCALLBACKMEMBER(TRANSFERCOMPLETE, pfnTransferComplete);
901 /** Function pointer, called when the transfer has been canceled. */
902 SHAREDCLIPBOARDTRANSFERCALLBACKMEMBER(TRANSFERCANCELED, pfnTransferCanceled);
903 /** Function pointer, called when transfer resulted in an unrecoverable error. */
904 SHAREDCLIPBOARDTRANSFERCALLBACKMEMBER(TRANSFERERROR, pfnTransferError);
905} SHAREDCLIPBOARDURITRANSFERCALLBACKS, *PSHAREDCLIPBOARDURITRANSFERCALLBACKS;
906
907/**
908 * Structure for thread-related members for a single URI transfer.
909 */
910typedef struct _SHAREDCLIPBOARDURITRANSFERTHREAD
911{
912 /** Thread handle for the reading / writing thread.
913 * Can be NIL_RTTHREAD if not being used. */
914 RTTHREAD hThread;
915 /** Thread started indicator. */
916 volatile bool fStarted;
917 /** Thread stop flag. */
918 volatile bool fStop;
919 /** Thread cancelled flag / indicator. */
920 volatile bool fCancelled;
921} SHAREDCLIPBOARDURITRANSFERTHREAD, *PSHAREDCLIPBOARDURITRANSFERTHREAD;
922
923/**
924 * Structure for maintaining a single URI transfer.
925 *
926 ** @todo Not yet thread safe.
927 */
928typedef struct _SHAREDCLIPBOARDURITRANSFER
929{
930 /** The node member for using this struct in a RTList. */
931 RTLISTNODE Node;
932 /** Critical section for serializing access. */
933 RTCRITSECT CritSect;
934 /** The transfer's state (for SSM, later). */
935 SHAREDCLIPBOARDURITRANSFERSTATE State;
936 /** Events related to this transfer. */
937 SharedClipboardURITransferEventMap *pMapEvents;
938 /** Map of all lists related to this transfer. */
939 SharedClipboardURIListMap *pMapLists;
940 /** List of root entries of this transfer. */
941 SharedClipboardURIListRootEntries lstRootEntries;
942 /** Map of all objects related to this transfer. */
943 SharedClipboardURIObjMap *pMapObj;
944 /** The transfer's own (local) area, if any (can be NULL if not needed).
945 * The area itself has a clipboard area ID assigned.
946 * On the host this area ID gets shared (maintained / locked) across all VMs via VBoxSVC. */
947 SharedClipboardArea *pArea;
948 SHAREDCLIPBOARDPROVIDERCTX ProviderCtx;
949 /** The transfer's provider interface. */
950 SHAREDCLIPBOARDPROVIDERINTERFACE ProviderIface;
951 /** The transfer's (optional) callback table. */
952 SHAREDCLIPBOARDURITRANSFERCALLBACKS Callbacks;
953 /** Opaque pointer to implementation-specific parameters. */
954 void *pvUser;
955 /** Size (in bytes) of implementation-specific parameters. */
956 size_t cbUser;
957 /** Contains thread-related attributes. */
958 SHAREDCLIPBOARDURITRANSFERTHREAD Thread;
959} SHAREDCLIPBOARDURITRANSFER, *PSHAREDCLIPBOARDURITRANSFER;
960
961/**
962 * Structure for keeping URI clipboard information around.
963 */
964typedef struct _SHAREDCLIPBOARDURICTX
965{
966 /** Critical section for serializing access. */
967 RTCRITSECT CritSect;
968 /** List of transfers. */
969 RTLISTANCHOR List;
970 /** Number of running (concurrent) transfers.
971 * At the moment we only support only one transfer per client at a time. */
972 uint32_t cRunning;
973 /** Maximum Number of running (concurrent) transfers.
974 * At the moment we only support only one transfer per client at a time. */
975 uint32_t cMaxRunning;
976 /** Number of total transfers (in list). */
977 uint32_t cTransfers;
978} SHAREDCLIPBOARDURICTX, *PSHAREDCLIPBOARDURICTX;
979
980int SharedClipboardURIObjCtxInit(PSHAREDCLIPBOARDCLIENTURIOBJCTX pObjCtx);
981void SharedClipboardURIObjCtxDestroy(PSHAREDCLIPBOARDCLIENTURIOBJCTX pObjCtx);
982bool SharedClipboardURIObjCtxIsValid(PSHAREDCLIPBOARDCLIENTURIOBJCTX pObjCtx);
983
984int SharedClipboardURITransferCreate(SHAREDCLIPBOARDURITRANSFERDIR enmDir, SHAREDCLIPBOARDSOURCE enmSource,
985 PSHAREDCLIPBOARDURITRANSFER *ppTransfer);
986int SharedClipboardURITransferDestroy(PSHAREDCLIPBOARDURITRANSFER pTransfer);
987
988int SharedClipboardURITransferOpen(PSHAREDCLIPBOARDURITRANSFER pTransfer);
989int SharedClipboardURITransferClose(PSHAREDCLIPBOARDURITRANSFER pTransfer);
990
991int SharedClipboardURITransferListOpen(PSHAREDCLIPBOARDURITRANSFER pTransfer, PVBOXCLIPBOARDLISTOPENPARMS pOpenParms,
992 PSHAREDCLIPBOARDLISTHANDLE phList);
993int SharedClipboardURITransferListClose(PSHAREDCLIPBOARDURITRANSFER pTransfer, SHAREDCLIPBOARDLISTHANDLE hList);
994int SharedClipboardURITransferListGetHeader(PSHAREDCLIPBOARDURITRANSFER pTransfer, SHAREDCLIPBOARDLISTHANDLE hList,
995 PVBOXCLIPBOARDLISTHDR pHdr);
996PSHAREDCLIPBOARDURITRANSFEROBJ SharedClipboardURITransferListGetObj(PSHAREDCLIPBOARDURITRANSFER pTransfer,
997 SHAREDCLIPBOARDLISTHANDLE hList, uint64_t uIdx);
998int SharedClipboardURITransferListRead(PSHAREDCLIPBOARDURITRANSFER pTransfer, SHAREDCLIPBOARDLISTHANDLE hList,
999 PVBOXCLIPBOARDLISTENTRY pEntry);
1000int SharedClipboardURITransferListWrite(PSHAREDCLIPBOARDURITRANSFER pTransfer, SHAREDCLIPBOARDLISTHANDLE hList,
1001 PVBOXCLIPBOARDLISTENTRY pEntry);
1002bool SharedClipboardURITransferListHandleIsValid(PSHAREDCLIPBOARDURITRANSFER pTransfer, SHAREDCLIPBOARDLISTHANDLE hList);
1003
1004int SharedClipboardURITransferPrepare(PSHAREDCLIPBOARDURITRANSFER pTransfer);
1005int SharedClipboardURITransferSetData(PSHAREDCLIPBOARDURITRANSFER pTransfer, SharedClipboardURIListRootEntries *pEntries);
1006int SharedClipboardURITransferSetInterface(PSHAREDCLIPBOARDURITRANSFER pTransfer,
1007 PSHAREDCLIPBOARDPROVIDERCREATIONCTX pCreationCtx);
1008int SharedClipboardURILTransferSetRoots(PSHAREDCLIPBOARDURITRANSFER pTransfer, const char *papszRoots, size_t cbRoots);
1009void SharedClipboardURITransferReset(PSHAREDCLIPBOARDURITRANSFER pTransfer);
1010SharedClipboardArea *SharedClipboardURITransferGetArea(PSHAREDCLIPBOARDURITRANSFER pTransfer);
1011int SharedClipboardURILTransferGetRoots(PSHAREDCLIPBOARDURITRANSFER pTransfer, char **ppapszRoots, uint32_t *pcRoots);
1012SHAREDCLIPBOARDSOURCE SharedClipboardURITransferGetSource(PSHAREDCLIPBOARDURITRANSFER pTransfer);
1013SHAREDCLIPBOARDURITRANSFERSTATUS SharedClipboardURITransferGetStatus(PSHAREDCLIPBOARDURITRANSFER pTransfer);
1014int SharedClipboardURITransferHandleReply(PSHAREDCLIPBOARDURITRANSFER pTransfer, PVBOXCLIPBOARDREPLY pReply);
1015int SharedClipboardURITransferRun(PSHAREDCLIPBOARDURITRANSFER pTransfer, PFNRTTHREAD pfnThreadFunc, void *pvUser);
1016void SharedClipboardURITransferSetCallbacks(PSHAREDCLIPBOARDURITRANSFER pTransfer,
1017 PSHAREDCLIPBOARDURITRANSFERCALLBACKS pCallbacks);
1018
1019int SharedClipboardURITransferPayloadAlloc(uint32_t uID, const void *pvData, uint32_t cbData,
1020 PSHAREDCLIPBOARDURITRANSFERPAYLOAD *ppPayload);
1021void SharedClipboardURITransferPayloadFree(PSHAREDCLIPBOARDURITRANSFERPAYLOAD pPayload);
1022
1023int SharedClipboardURITransferEventRegister(PSHAREDCLIPBOARDURITRANSFER pTransfer, uint32_t uID);
1024int SharedClipboardURITransferEventUnregister(PSHAREDCLIPBOARDURITRANSFER pTransfer, uint32_t uID);
1025int SharedClipboardURITransferEventWait(PSHAREDCLIPBOARDURITRANSFER pTransfer, uint32_t uID, RTMSINTERVAL uTimeoutMs,
1026 PSHAREDCLIPBOARDURITRANSFERPAYLOAD *ppPayload);
1027int SharedClipboardURITransferEventSignal(PSHAREDCLIPBOARDURITRANSFER pTransfer, uint32_t uID, PSHAREDCLIPBOARDURITRANSFERPAYLOAD pPayload);
1028
1029int SharedClipboardURITransferRead(PSHAREDCLIPBOARDURITRANSFER pTransfer);
1030int SharedClipboardURITransferReadObjects(PSHAREDCLIPBOARDURITRANSFER pTransfer);
1031
1032int SharedClipboardURITransferWrite(PSHAREDCLIPBOARDURITRANSFER pTransfer);
1033int SharedClipboardURITransferWriteObjects(PSHAREDCLIPBOARDURITRANSFER pTransfer);
1034
1035int SharedClipboardURICtxInit(PSHAREDCLIPBOARDURICTX pURI);
1036void SharedClipboardURICtxDestroy(PSHAREDCLIPBOARDURICTX pURI);
1037void SharedClipboardURICtxReset(PSHAREDCLIPBOARDURICTX pURI);
1038PSHAREDCLIPBOARDURITRANSFER SharedClipboardURICtxGetTransfer(PSHAREDCLIPBOARDURICTX pURI, uint32_t uIdx);
1039uint32_t SharedClipboardURICtxGetRunningTransfers(PSHAREDCLIPBOARDURICTX pURI);
1040uint32_t SharedClipboardURICtxGetTotalTransfers(PSHAREDCLIPBOARDURICTX pURI);
1041void SharedClipboardURICtxTransfersCleanup(PSHAREDCLIPBOARDURICTX pURI);
1042bool SharedClipboardURICtxTransfersMaximumReached(PSHAREDCLIPBOARDURICTX pURI);
1043int SharedClipboardURICtxTransferAdd(PSHAREDCLIPBOARDURICTX pURI, PSHAREDCLIPBOARDURITRANSFER pTransfer);
1044int SharedClipboardURICtxTransferRemove(PSHAREDCLIPBOARDURICTX pURI, PSHAREDCLIPBOARDURITRANSFER pTransfer);
1045
1046void SharedClipboardFsObjFromIPRT(PSHAREDCLIPBOARDFSOBJINFO pDst, PCRTFSOBJINFO pSrc);
1047
1048bool SharedClipboardMIMEHasFileURLs(const char *pcszFormat, size_t cchFormatMax);
1049bool SharedClipboardMIMENeedsCache(const char *pcszFormat, size_t cchFormatMax);
1050
1051#endif /* !VBOX_INCLUDED_GuestHost_SharedClipboard_uri_h */
1052
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