1 | /* $Id: SharedClipboard-transfers.h 85121 2020-07-08 19:33:26Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Shared Clipboard - Shared transfer functions between host and guest.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2019-2020 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_transfers_h
|
---|
28 | #define VBOX_INCLUDED_GuestHost_SharedClipboard_transfers_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 | #include <VBox/HostServices/VBoxClipboardSvc.h>
|
---|
45 |
|
---|
46 |
|
---|
47 | struct SHCLTRANSFER;
|
---|
48 | /** Pointer to a single shared clipboard transfer */
|
---|
49 | typedef struct SHCLTRANSFER *PSHCLTRANSFER;
|
---|
50 |
|
---|
51 |
|
---|
52 | /** @name Shared Clipboard transfer definitions.
|
---|
53 | * @{
|
---|
54 | */
|
---|
55 |
|
---|
56 | /**
|
---|
57 | * Defines the transfer status codes.
|
---|
58 | */
|
---|
59 | typedef enum
|
---|
60 | {
|
---|
61 | /** No status set. */
|
---|
62 | SHCLTRANSFERSTATUS_NONE = 0,
|
---|
63 | /** The transfer has been initialized but is not running yet. */
|
---|
64 | SHCLTRANSFERSTATUS_INITIALIZED,
|
---|
65 | /** The transfer is active and running. */
|
---|
66 | SHCLTRANSFERSTATUS_STARTED,
|
---|
67 | /** The transfer has been stopped. */
|
---|
68 | SHCLTRANSFERSTATUS_STOPPED,
|
---|
69 | /** The transfer has been canceled. */
|
---|
70 | SHCLTRANSFERSTATUS_CANCELED,
|
---|
71 | /** The transfer has been killed. */
|
---|
72 | SHCLTRANSFERSTATUS_KILLED,
|
---|
73 | /** The transfer ran into an unrecoverable error. */
|
---|
74 | SHCLTRANSFERSTATUS_ERROR,
|
---|
75 | /** The usual 32-bit hack. */
|
---|
76 | SHCLTRANSFERSTATUS_32BIT_SIZE_HACK = 0x7fffffff
|
---|
77 | } SHCLTRANSFERSTATUSENUM;
|
---|
78 |
|
---|
79 | /** Defines a transfer status. */
|
---|
80 | typedef uint32_t SHCLTRANSFERSTATUS;
|
---|
81 |
|
---|
82 | /** @} */
|
---|
83 |
|
---|
84 | /** @name Shared Clipboard handles.
|
---|
85 | * @{
|
---|
86 | */
|
---|
87 |
|
---|
88 | /** A Shared Clipboard list handle. */
|
---|
89 | typedef uint64_t SHCLLISTHANDLE;
|
---|
90 | /** Pointer to a Shared Clipboard list handle. */
|
---|
91 | typedef SHCLLISTHANDLE *PSHCLLISTHANDLE;
|
---|
92 | /** Specifies an invalid Shared Clipboard list handle.
|
---|
93 | * @todo r=bird: The convention is NIL_SHCLLISTHANDLE. */
|
---|
94 | #define SHCLLISTHANDLE_INVALID ((SHCLLISTHANDLE)UINT64_MAX)
|
---|
95 |
|
---|
96 | /** A Shared Clipboard object handle. */
|
---|
97 | typedef uint64_t SHCLOBJHANDLE;
|
---|
98 | /** Pointer to a Shared Clipboard object handle. */
|
---|
99 | typedef SHCLOBJHANDLE *PSHCLOBJHANDLE;
|
---|
100 | /** Specifies an invalid Shared Clipboard object handle.
|
---|
101 | * @todo r=bird: The convention is NIL_SHCLOBJHANDLE. */
|
---|
102 | #define SHCLOBJHANDLE_INVALID ((SHCLOBJHANDLE)UINT64_MAX)
|
---|
103 |
|
---|
104 | /** @} */
|
---|
105 |
|
---|
106 | /** @name Shared Clipboard open/create flags.
|
---|
107 | * @{
|
---|
108 | */
|
---|
109 | /** No flags. Initialization value. */
|
---|
110 | #define SHCL_OBJ_CF_NONE UINT32_C(0x00000000)
|
---|
111 |
|
---|
112 | #if 0 /* These probably won't be needed either */
|
---|
113 | /** Lookup only the object, do not return a handle. All other flags are ignored. */
|
---|
114 | #define SHCL_OBJ_CF_LOOKUP UINT32_C(0x00000001)
|
---|
115 | /** Create/open a directory. */
|
---|
116 | #define SHCL_OBJ_CF_DIRECTORY UINT32_C(0x00000004)
|
---|
117 | #endif
|
---|
118 |
|
---|
119 | /** Read/write requested access for the object. */
|
---|
120 | #define SHCL_OBJ_CF_ACCESS_MASK_RW UINT32_C(0x00001000)
|
---|
121 | /** No access requested. */
|
---|
122 | #define SHCL_OBJ_CF_ACCESS_NONE UINT32_C(0x00000000)
|
---|
123 | /** Read access requested. */
|
---|
124 | #define SHCL_OBJ_CF_ACCESS_READ UINT32_C(0x00001000)
|
---|
125 |
|
---|
126 | /** Requested share access for the object. */
|
---|
127 | #define SHCL_OBJ_CF_ACCESS_MASK_DENY UINT32_C(0x00008000)
|
---|
128 | /** Allow any access. */
|
---|
129 | #define SHCL_OBJ_CF_ACCESS_DENYNONE UINT32_C(0x00000000)
|
---|
130 | /** Do not allow write. */
|
---|
131 | #define SHCL_OBJ_CF_ACCESS_DENYWRITE UINT32_C(0x00008000)
|
---|
132 |
|
---|
133 | /** Requested access to attributes of the object. */
|
---|
134 | #define SHCL_OBJ_CF_ACCESS_MASK_ATTR UINT32_C(0x00010000)
|
---|
135 | /** No access requested. */
|
---|
136 | #define SHCL_OBJ_CF_ACCESS_ATTR_NONE UINT32_C(0x00000000)
|
---|
137 | /** Read access requested. */
|
---|
138 | #define SHCL_OBJ_CF_ACCESS_ATTR_READ UINT32_C(0x00010000)
|
---|
139 |
|
---|
140 | /** Valid bits. */
|
---|
141 | #define SHCL_OBJ_CF_VALID_MASK UINT32_C(0x00018000)
|
---|
142 | /** @} */
|
---|
143 |
|
---|
144 | /**
|
---|
145 | * The available additional information in a SHCLFSOBJATTR object.
|
---|
146 | * @sa RTFSOBJATTRADD
|
---|
147 | */
|
---|
148 | typedef enum _SHCLFSOBJATTRADD
|
---|
149 | {
|
---|
150 | /** No additional information is available / requested. */
|
---|
151 | SHCLFSOBJATTRADD_NOTHING = 1,
|
---|
152 | /** The additional unix attributes (SHCLFSOBJATTR::u::Unix) are
|
---|
153 | * available / requested. */
|
---|
154 | SHCLFSOBJATTRADD_UNIX,
|
---|
155 | /** The additional extended attribute size (SHCLFSOBJATTR::u::EASize) is
|
---|
156 | * available / requested. */
|
---|
157 | SHCLFSOBJATTRADD_EASIZE,
|
---|
158 | /** The last valid item (inclusive).
|
---|
159 | * The valid range is SHCLFSOBJATTRADD_NOTHING thru
|
---|
160 | * SHCLFSOBJATTRADD_LAST. */
|
---|
161 | SHCLFSOBJATTRADD_LAST = SHCLFSOBJATTRADD_EASIZE,
|
---|
162 | /** The usual 32-bit hack. */
|
---|
163 | SHCLFSOBJATTRADD_32BIT_SIZE_HACK = 0x7fffffff
|
---|
164 | } SHCLFSOBJATTRADD;
|
---|
165 |
|
---|
166 |
|
---|
167 | /* Assert sizes of the IRPT types we're using below. */
|
---|
168 | AssertCompileSize(RTFMODE, 4);
|
---|
169 | AssertCompileSize(RTFOFF, 8);
|
---|
170 | AssertCompileSize(RTINODE, 8);
|
---|
171 | AssertCompileSize(RTTIMESPEC, 8);
|
---|
172 | AssertCompileSize(RTDEV, 4);
|
---|
173 | AssertCompileSize(RTUID, 4);
|
---|
174 |
|
---|
175 | /**
|
---|
176 | * Shared Clipboard filesystem object attributes.
|
---|
177 | *
|
---|
178 | * @sa RTFSOBJATTR
|
---|
179 | */
|
---|
180 | typedef struct _SHCLFSOBJATTR
|
---|
181 | {
|
---|
182 | /** Mode flags (st_mode). RTFS_UNIX_*, RTFS_TYPE_*, and RTFS_DOS_*.
|
---|
183 | * @remarks We depend on a number of RTFS_ defines to remain unchanged.
|
---|
184 | * Fortuntately, these are depending on windows, dos and unix
|
---|
185 | * standard values, so this shouldn't be much of a pain. */
|
---|
186 | RTFMODE fMode;
|
---|
187 |
|
---|
188 | /** The additional attributes available. */
|
---|
189 | SHCLFSOBJATTRADD enmAdditional;
|
---|
190 |
|
---|
191 | /**
|
---|
192 | * Additional attributes.
|
---|
193 | *
|
---|
194 | * Unless explicitly specified to an API, the API can provide additional
|
---|
195 | * data as it is provided by the underlying OS.
|
---|
196 | */
|
---|
197 | union SHCLFSOBJATTRUNION
|
---|
198 | {
|
---|
199 | /** Additional Unix Attributes
|
---|
200 | * These are available when SHCLFSOBJATTRADD is set in fUnix.
|
---|
201 | */
|
---|
202 | struct SHCLFSOBJATTRUNIX
|
---|
203 | {
|
---|
204 | /** The user owning the filesystem object (st_uid).
|
---|
205 | * This field is ~0U if not supported. */
|
---|
206 | RTUID uid;
|
---|
207 |
|
---|
208 | /** The group the filesystem object is assigned (st_gid).
|
---|
209 | * This field is ~0U if not supported. */
|
---|
210 | RTGID gid;
|
---|
211 |
|
---|
212 | /** Number of hard links to this filesystem object (st_nlink).
|
---|
213 | * This field is 1 if the filesystem doesn't support hardlinking or
|
---|
214 | * the information isn't available.
|
---|
215 | */
|
---|
216 | uint32_t cHardlinks;
|
---|
217 |
|
---|
218 | /** The device number of the device which this filesystem object resides on (st_dev).
|
---|
219 | * This field is 0 if this information is not available. */
|
---|
220 | RTDEV INodeIdDevice;
|
---|
221 |
|
---|
222 | /** The unique identifier (within the filesystem) of this filesystem object (st_ino).
|
---|
223 | * Together with INodeIdDevice, this field can be used as a OS wide unique id
|
---|
224 | * when both their values are not 0.
|
---|
225 | * This field is 0 if the information is not available. */
|
---|
226 | RTINODE INodeId;
|
---|
227 |
|
---|
228 | /** User flags (st_flags).
|
---|
229 | * This field is 0 if this information is not available. */
|
---|
230 | uint32_t fFlags;
|
---|
231 |
|
---|
232 | /** The current generation number (st_gen).
|
---|
233 | * This field is 0 if this information is not available. */
|
---|
234 | uint32_t GenerationId;
|
---|
235 |
|
---|
236 | /** The device number of a character or block device type object (st_rdev).
|
---|
237 | * This field is 0 if the file isn't of a character or block device type and
|
---|
238 | * when the OS doesn't subscribe to the major+minor device idenfication scheme. */
|
---|
239 | RTDEV Device;
|
---|
240 | } Unix;
|
---|
241 |
|
---|
242 | /**
|
---|
243 | * Extended attribute size.
|
---|
244 | */
|
---|
245 | struct SHCLFSOBJATTREASIZE
|
---|
246 | {
|
---|
247 | /** Size of EAs. */
|
---|
248 | RTFOFF cb;
|
---|
249 | } EASize;
|
---|
250 |
|
---|
251 | /** Padding the structure to a multiple of 8 bytes. */
|
---|
252 | uint64_t au64Padding[5];
|
---|
253 | } u;
|
---|
254 | } SHCLFSOBJATTR;
|
---|
255 | AssertCompileSize(SHCLFSOBJATTR, 48);
|
---|
256 | /** Pointer to a Shared Clipboard filesystem object attributes structure. */
|
---|
257 | typedef SHCLFSOBJATTR *PSHCLFSOBJATTR;
|
---|
258 | /** Pointer to a const Shared Clipboard filesystem object attributes structure. */
|
---|
259 | typedef const SHCLFSOBJATTR *PCSHCLFSOBJATTR;
|
---|
260 |
|
---|
261 | /**
|
---|
262 | * Shared Clipboard file system object information structure.
|
---|
263 | *
|
---|
264 | * @sa RTFSOBJINFO
|
---|
265 | */
|
---|
266 | typedef struct _SHCLFSOBJINFO
|
---|
267 | {
|
---|
268 | /** Logical size (st_size).
|
---|
269 | * For normal files this is the size of the file.
|
---|
270 | * For symbolic links, this is the length of the path name contained
|
---|
271 | * in the symbolic link.
|
---|
272 | * For other objects this fields needs to be specified.
|
---|
273 | */
|
---|
274 | RTFOFF cbObject;
|
---|
275 |
|
---|
276 | /** Disk allocation size (st_blocks * DEV_BSIZE). */
|
---|
277 | RTFOFF cbAllocated;
|
---|
278 |
|
---|
279 | /** Time of last access (st_atime).
|
---|
280 | * @remarks Here (and other places) we depend on the IPRT timespec to
|
---|
281 | * remain unchanged. */
|
---|
282 | RTTIMESPEC AccessTime;
|
---|
283 |
|
---|
284 | /** Time of last data modification (st_mtime). */
|
---|
285 | RTTIMESPEC ModificationTime;
|
---|
286 |
|
---|
287 | /** Time of last status change (st_ctime).
|
---|
288 | * If not available this is set to ModificationTime.
|
---|
289 | */
|
---|
290 | RTTIMESPEC ChangeTime;
|
---|
291 |
|
---|
292 | /** Time of file birth (st_birthtime).
|
---|
293 | * If not available this is set to ChangeTime.
|
---|
294 | */
|
---|
295 | RTTIMESPEC BirthTime;
|
---|
296 |
|
---|
297 | /** Attributes. */
|
---|
298 | SHCLFSOBJATTR Attr;
|
---|
299 |
|
---|
300 | } SHCLFSOBJINFO;
|
---|
301 | AssertCompileSize(SHCLFSOBJINFO, 96);
|
---|
302 | /** Pointer to a Shared Clipboard filesystem object information structure. */
|
---|
303 | typedef SHCLFSOBJINFO *PSHCLFSOBJINFO;
|
---|
304 | /** Pointer to a const Shared Clipboard filesystem object information
|
---|
305 | * structure. */
|
---|
306 | typedef const SHCLFSOBJINFO *PCSHCLFSOBJINFO;
|
---|
307 |
|
---|
308 | /**
|
---|
309 | * Structure for keeping object open/create parameters.
|
---|
310 | */
|
---|
311 | typedef struct _SHCLOBJOPENCREATEPARMS
|
---|
312 | {
|
---|
313 | /** Path to object to open / create. */
|
---|
314 | char *pszPath;
|
---|
315 | /** Size (in bytes) of path to to object. */
|
---|
316 | uint32_t cbPath;
|
---|
317 | /** SHCL_OBJ_CF_* */
|
---|
318 | uint32_t fCreate;
|
---|
319 | /**
|
---|
320 | * Attributes of object to open/create and
|
---|
321 | * returned actual attributes of opened/created object.
|
---|
322 | */
|
---|
323 | SHCLFSOBJINFO ObjInfo;
|
---|
324 | } SHCLOBJOPENCREATEPARMS, *PSHCLOBJOPENCREATEPARMS;
|
---|
325 |
|
---|
326 | /**
|
---|
327 | * Structure for keeping a reply message.
|
---|
328 | */
|
---|
329 | typedef struct _SHCLREPLY
|
---|
330 | {
|
---|
331 | /** Message type of type VBOX_SHCL_REPLYMSGTYPE_XXX. */
|
---|
332 | uint32_t uType;
|
---|
333 | /** IPRT result of overall operation. Note: int vs. uint32! */
|
---|
334 | uint32_t rc;
|
---|
335 | union
|
---|
336 | {
|
---|
337 | struct
|
---|
338 | {
|
---|
339 | SHCLTRANSFERSTATUS uStatus;
|
---|
340 | } TransferStatus;
|
---|
341 | struct
|
---|
342 | {
|
---|
343 | SHCLLISTHANDLE uHandle;
|
---|
344 | } ListOpen;
|
---|
345 | struct
|
---|
346 | {
|
---|
347 | SHCLLISTHANDLE uHandle;
|
---|
348 | } ListClose;
|
---|
349 | struct
|
---|
350 | {
|
---|
351 | SHCLOBJHANDLE uHandle;
|
---|
352 | } ObjOpen;
|
---|
353 | struct
|
---|
354 | {
|
---|
355 | SHCLOBJHANDLE uHandle;
|
---|
356 | } ObjClose;
|
---|
357 | } u;
|
---|
358 | /** Pointer to optional payload. */
|
---|
359 | void *pvPayload;
|
---|
360 | /** Payload size (in bytes). */
|
---|
361 | uint32_t cbPayload;
|
---|
362 | } SHCLREPLY, *PSHCLREPLY;
|
---|
363 |
|
---|
364 | struct _SHCLLISTENTRY;
|
---|
365 | typedef _SHCLLISTENTRY SHCLLISTENTRY;
|
---|
366 |
|
---|
367 | /** Defines a single root list entry. Currently the same as a regular list entry. */
|
---|
368 | typedef SHCLLISTENTRY SHCLROOTLISTENTRY;
|
---|
369 | /** Defines a pointer to a single root list entry. Currently the same as a regular list entry pointer. */
|
---|
370 | typedef SHCLROOTLISTENTRY *PSHCLROOTLISTENTRY;
|
---|
371 |
|
---|
372 | /**
|
---|
373 | * Structure for keeping Shared Clipboard root list headers.
|
---|
374 | */
|
---|
375 | typedef struct _SHCLROOTLISTHDR
|
---|
376 | {
|
---|
377 | /** Roots listing flags; unused at the moment. */
|
---|
378 | uint32_t fRoots;
|
---|
379 | /** Number of root list entries. */
|
---|
380 | uint32_t cRoots;
|
---|
381 | } SHCLROOTLISTHDR, *PSHCLROOTLISTHDR;
|
---|
382 |
|
---|
383 | /**
|
---|
384 | * Structure for maintaining a Shared Clipboard root list.
|
---|
385 | */
|
---|
386 | typedef struct _SHCLROOTLIST
|
---|
387 | {
|
---|
388 | /** Root list header. */
|
---|
389 | SHCLROOTLISTHDR Hdr;
|
---|
390 | /** Root list entries. */
|
---|
391 | SHCLROOTLISTENTRY *paEntries;
|
---|
392 | } SHCLROOTLIST, *PSHCLROOTLIST;
|
---|
393 |
|
---|
394 | /**
|
---|
395 | * Structure for maintaining Shared Clipboard list open paramters.
|
---|
396 | */
|
---|
397 | typedef struct _SHCLLISTOPENPARMS
|
---|
398 | {
|
---|
399 | /** Listing flags (see VBOX_SHCL_LIST_FLAG_XXX). */
|
---|
400 | uint32_t fList;
|
---|
401 | /** Size (in bytes) of the filter string. */
|
---|
402 | uint32_t cbFilter;
|
---|
403 | /** Filter string. DOS wilcard-style. */
|
---|
404 | char *pszFilter;
|
---|
405 | /** Size (in bytes) of the listing path. */
|
---|
406 | uint32_t cbPath;
|
---|
407 | /** Listing path (absolute). If empty or NULL the listing's root path will be opened. */
|
---|
408 | char *pszPath;
|
---|
409 | } SHCLLISTOPENPARMS, *PSHCLLISTOPENPARMS;
|
---|
410 |
|
---|
411 | /**
|
---|
412 | * Structure for keeping a Shared Clipboard list header.
|
---|
413 | */
|
---|
414 | typedef struct _SHCLLISTHDR
|
---|
415 | {
|
---|
416 | /** Feature flag(s). Not being used atm. */
|
---|
417 | uint32_t fFeatures;
|
---|
418 | /** Total objects returned. */
|
---|
419 | uint64_t cTotalObjects;
|
---|
420 | /** Total size (in bytes) returned. */
|
---|
421 | uint64_t cbTotalSize;
|
---|
422 | } SHCLLISTHDR, *PSHCLLISTHDR;
|
---|
423 |
|
---|
424 | /**
|
---|
425 | * Structure for a Shared Clipboard list entry.
|
---|
426 | */
|
---|
427 | typedef struct _SHCLLISTENTRY
|
---|
428 | {
|
---|
429 | /** Entry name. */
|
---|
430 | char *pszName;
|
---|
431 | /** Size (in bytes) of entry name. */
|
---|
432 | uint32_t cbName;
|
---|
433 | /** Information flag(s). */
|
---|
434 | uint32_t fInfo;
|
---|
435 | /** Size (in bytes) of the actual list entry. */
|
---|
436 | uint32_t cbInfo;
|
---|
437 | /** Data of the actual list entry. */
|
---|
438 | void *pvInfo;
|
---|
439 | } SHCLLISTENTRY, *PSHCLLISTENTRY;
|
---|
440 |
|
---|
441 | /** Maximum length (in UTF-8 characters) of a list entry name. */
|
---|
442 | #define SHCLLISTENTRY_MAX_NAME RTPATH_MAX /** @todo Improve this to be more dynamic. */
|
---|
443 |
|
---|
444 | /**
|
---|
445 | * Structure for maintaining a Shared Clipboard list.
|
---|
446 | */
|
---|
447 | typedef struct _SHCLLIST
|
---|
448 | {
|
---|
449 | /** List header. */
|
---|
450 | SHCLLISTHDR Hdr;
|
---|
451 | /** List entries. */
|
---|
452 | SHCLROOTLISTENTRY *paEntries;
|
---|
453 | } SHCLLIST, *PSHCLLIST;
|
---|
454 |
|
---|
455 | /**
|
---|
456 | * Structure for keeping a Shared Clipboard object data chunk.
|
---|
457 | */
|
---|
458 | typedef struct _SHCLOBJDATACHUNK
|
---|
459 | {
|
---|
460 | /** Handle of object this data chunk is related to. */
|
---|
461 | uint64_t uHandle;
|
---|
462 | /** Pointer to actual data chunk. */
|
---|
463 | void *pvData;
|
---|
464 | /** Size (in bytes) of data chunk. */
|
---|
465 | uint32_t cbData;
|
---|
466 | } SHCLOBJDATACHUNK, *PSHCLOBJDATACHUNK;
|
---|
467 |
|
---|
468 | /**
|
---|
469 | * Enumeration for specifying a clipboard area object type.
|
---|
470 | */
|
---|
471 | typedef enum _SHCLAREAOBJTYPE
|
---|
472 | {
|
---|
473 | /** Unknown object type; do not use. */
|
---|
474 | SHCLAREAOBJTYPE_UNKNOWN = 0,
|
---|
475 | /** Object is a directory. */
|
---|
476 | SHCLAREAOBJTYPE_DIR,
|
---|
477 | /** Object is a file. */
|
---|
478 | SHCLAREAOBJTYPE_FILE,
|
---|
479 | /** Object is a symbolic link. */
|
---|
480 | SHCLAREAOBJTYPE_SYMLINK,
|
---|
481 | /** The usual 32-bit hack. */
|
---|
482 | SHCLAREAOBJTYPE_32Bit_Hack = 0x7fffffff
|
---|
483 | } SHCLAREAOBJTYPE;
|
---|
484 |
|
---|
485 | /** Clipboard area ID. A valid area is >= 1.
|
---|
486 | * If 0 is specified, the last (most recent) area is meant.
|
---|
487 | * Set to UINT32_MAX if not initialized. */
|
---|
488 | typedef uint32_t SHCLAREAID;
|
---|
489 |
|
---|
490 | /** Defines a non-initialized (nil) clipboard area. */
|
---|
491 | #define NIL_SHCLAREAID UINT32_MAX
|
---|
492 |
|
---|
493 | /** SharedClipboardArea open flags. */
|
---|
494 | typedef uint32_t SHCLAREAOPENFLAGS;
|
---|
495 |
|
---|
496 | /** No clipboard area open flags specified. */
|
---|
497 | #define SHCLAREA_OPEN_FLAGS_NONE 0
|
---|
498 | /** The clipboard area must not exist yet. */
|
---|
499 | #define SHCLAREA_OPEN_FLAGS_MUST_NOT_EXIST RT_BIT(0)
|
---|
500 | /** Mask of all valid clipboard area open flags. */
|
---|
501 | #define SHCLAREA_OPEN_FLAGS_VALID_MASK 0x1
|
---|
502 |
|
---|
503 | /** Defines a clipboard area object state. */
|
---|
504 | typedef uint32_t SHCLAREAOBJSTATE;
|
---|
505 |
|
---|
506 | /** No object state set. */
|
---|
507 | #define SHCLAREAOBJSTATE_NONE 0
|
---|
508 | /** The object is considered as being complete (e.g. serialized). */
|
---|
509 | #define SHCLAREAOBJSTATE_COMPLETE RT_BIT(0)
|
---|
510 |
|
---|
511 | /**
|
---|
512 | * Lightweight structure to keep a clipboard area object's state.
|
---|
513 | *
|
---|
514 | * Note: We don't want to use the ClipboardURIObject class here, as this
|
---|
515 | * is too heavy for this purpose.
|
---|
516 | */
|
---|
517 | typedef struct _SHCLAREAOBJ
|
---|
518 | {
|
---|
519 | SHCLAREAOBJTYPE enmType;
|
---|
520 | SHCLAREAOBJSTATE fState;
|
---|
521 | } SHCLAREAOBJ, *PSHCLAREAOBJ;
|
---|
522 |
|
---|
523 | /**
|
---|
524 | * Class for maintaining a Shared Clipboard area on the host or guest.
|
---|
525 | *
|
---|
526 | * This will contain all received files & directories for a single Shared
|
---|
527 | * Clipboard operation.
|
---|
528 | *
|
---|
529 | * In case of a failed Shared Clipboard operation this class can also
|
---|
530 | * perform a gentle rollback if required.
|
---|
531 | */
|
---|
532 | class SharedClipboardArea
|
---|
533 | {
|
---|
534 | public:
|
---|
535 |
|
---|
536 | SharedClipboardArea(void);
|
---|
537 | SharedClipboardArea(const char *pszPath, SHCLAREAID uID = NIL_SHCLAREAID,
|
---|
538 | SHCLAREAOPENFLAGS fFlags = SHCLAREA_OPEN_FLAGS_NONE);
|
---|
539 | virtual ~SharedClipboardArea(void);
|
---|
540 |
|
---|
541 | public:
|
---|
542 |
|
---|
543 | uint32_t AddRef(void);
|
---|
544 | uint32_t Release(void);
|
---|
545 |
|
---|
546 | int Lock(void);
|
---|
547 | int Unlock(void);
|
---|
548 |
|
---|
549 | int AddObject(const char *pszPath, const SHCLAREAOBJ &Obj);
|
---|
550 | int GetObject(const char *pszPath, PSHCLAREAOBJ pObj);
|
---|
551 |
|
---|
552 | int Close(void);
|
---|
553 | bool IsOpen(void) const;
|
---|
554 | int OpenEx(const char *pszPath, SHCLAREAID uID = NIL_SHCLAREAID,
|
---|
555 | SHCLAREAOPENFLAGS fFlags = SHCLAREA_OPEN_FLAGS_NONE);
|
---|
556 | int OpenTemp(SHCLAREAID uID = NIL_SHCLAREAID,
|
---|
557 | SHCLAREAOPENFLAGS fFlags = SHCLAREA_OPEN_FLAGS_NONE);
|
---|
558 | SHCLAREAID GetID(void) const;
|
---|
559 | const char *GetDirAbs(void) const;
|
---|
560 | uint32_t GetRefCount(void);
|
---|
561 | int Reopen(void);
|
---|
562 | int Reset(bool fDeleteContent);
|
---|
563 | int Rollback(void);
|
---|
564 |
|
---|
565 | public:
|
---|
566 |
|
---|
567 | static int PathConstruct(const char *pszBase, SHCLAREAID uID, char *pszPath, size_t cbPath);
|
---|
568 |
|
---|
569 | protected:
|
---|
570 |
|
---|
571 | int initInternal(void);
|
---|
572 | int destroyInternal(void);
|
---|
573 | int closeInternal(void);
|
---|
574 |
|
---|
575 | protected:
|
---|
576 |
|
---|
577 | typedef std::map<RTCString, SHCLAREAOBJ> SharedClipboardAreaFsObjMap;
|
---|
578 |
|
---|
579 | /** Creation timestamp (in ms). */
|
---|
580 | uint64_t m_tsCreatedMs;
|
---|
581 | /** Number of references to this instance. */
|
---|
582 | volatile uint32_t m_cRefs;
|
---|
583 | /** Critical section for serializing access. */
|
---|
584 | RTCRITSECT m_CritSect;
|
---|
585 | /** Open flags. */
|
---|
586 | uint32_t m_fOpen;
|
---|
587 | /** Directory handle for root clipboard directory. */
|
---|
588 | RTDIR m_hDir;
|
---|
589 | /** Absolute path to root clipboard directory. */
|
---|
590 | RTCString m_strPathAbs;
|
---|
591 | /** List for holding created directories in the case of a rollback. */
|
---|
592 | SharedClipboardAreaFsObjMap m_mapObj;
|
---|
593 | /** Associated clipboard area ID. */
|
---|
594 | SHCLAREAID m_uID;
|
---|
595 | };
|
---|
596 |
|
---|
597 | /**
|
---|
598 | * Structure for handling a single transfer object context.
|
---|
599 | */
|
---|
600 | typedef struct _SHCLCLIENTTRANSFEROBJCTX
|
---|
601 | {
|
---|
602 | SHCLTRANSFER *pTransfer;
|
---|
603 | SHCLOBJHANDLE uHandle;
|
---|
604 | } SHCLCLIENTTRANSFEROBJCTX, *PSHCLCLIENTTRANSFEROBJCTX;
|
---|
605 |
|
---|
606 | typedef struct _SHCLTRANSFEROBJSTATE
|
---|
607 | {
|
---|
608 | /** How many bytes were processed (read / write) so far. */
|
---|
609 | uint64_t cbProcessed;
|
---|
610 | } SHCLTRANSFEROBJSTATE, *PSHCLTRANSFEROBJSTATE;
|
---|
611 |
|
---|
612 | typedef struct _SHCLTRANSFEROBJ
|
---|
613 | {
|
---|
614 | SHCLOBJHANDLE uHandle;
|
---|
615 | char *pszPathAbs;
|
---|
616 | SHCLFSOBJINFO objInfo;
|
---|
617 | SHCLSOURCE enmSource;
|
---|
618 | SHCLTRANSFEROBJSTATE State;
|
---|
619 | } SHCLTRANSFEROBJ, *PSHCLTRANSFEROBJ;
|
---|
620 |
|
---|
621 | /**
|
---|
622 | * Enumeration for specifying a Shared Clipboard object type.
|
---|
623 | */
|
---|
624 | typedef enum _SHCLOBJTYPE
|
---|
625 | {
|
---|
626 | /** Invalid object type. */
|
---|
627 | SHCLOBJTYPE_INVALID = 0,
|
---|
628 | /** Object is a directory. */
|
---|
629 | SHCLOBJTYPE_DIRECTORY,
|
---|
630 | /** Object is a file. */
|
---|
631 | SHCLOBJTYPE_FILE,
|
---|
632 | /** Object is a symbolic link. */
|
---|
633 | SHCLOBJTYPE_SYMLINK,
|
---|
634 | /** The usual 32-bit hack. */
|
---|
635 | SHCLOBJTYPE_32BIT_SIZE_HACK = 0x7fffffff
|
---|
636 | } SHCLOBJTYPE;
|
---|
637 |
|
---|
638 | /**
|
---|
639 | * Structure for keeping transfer list handle information.
|
---|
640 | * This is using to map own (local) handles to the underlying file system.
|
---|
641 | */
|
---|
642 | typedef struct _SHCLLISTHANDLEINFO
|
---|
643 | {
|
---|
644 | /** The list node. */
|
---|
645 | RTLISTNODE Node;
|
---|
646 | /** The list's handle. */
|
---|
647 | SHCLLISTHANDLE hList;
|
---|
648 | /** Type of list handle. */
|
---|
649 | SHCLOBJTYPE enmType;
|
---|
650 | /** Absolute local path of the list object. */
|
---|
651 | char *pszPathLocalAbs;
|
---|
652 | union
|
---|
653 | {
|
---|
654 | /** Local data, based on enmType. */
|
---|
655 | struct
|
---|
656 | {
|
---|
657 | union
|
---|
658 | {
|
---|
659 | RTDIR hDir;
|
---|
660 | RTFILE hFile;
|
---|
661 | };
|
---|
662 | } Local;
|
---|
663 | } u;
|
---|
664 | } SHCLLISTHANDLEINFO, *PSHCLLISTHANDLEINFO;
|
---|
665 |
|
---|
666 | /**
|
---|
667 | * Structure for keeping transfer object handle information.
|
---|
668 | * This is using to map own (local) handles to the underlying file system.
|
---|
669 | */
|
---|
670 | typedef struct _SHCLOBJHANDLEINFO
|
---|
671 | {
|
---|
672 | /** The list node. */
|
---|
673 | RTLISTNODE Node;
|
---|
674 | /** The object's handle. */
|
---|
675 | SHCLOBJHANDLE hObj;
|
---|
676 | /** Type of object handle. */
|
---|
677 | SHCLOBJTYPE enmType;
|
---|
678 | /** Absolute local path of the object. */
|
---|
679 | char *pszPathLocalAbs;
|
---|
680 | union
|
---|
681 | {
|
---|
682 | /** Local data, based on enmType. */
|
---|
683 | struct
|
---|
684 | {
|
---|
685 | union
|
---|
686 | {
|
---|
687 | RTDIR hDir;
|
---|
688 | RTFILE hFile;
|
---|
689 | };
|
---|
690 | } Local;
|
---|
691 | } u;
|
---|
692 | } SHCLOBJHANDLEINFO, *PSHCLOBJHANDLEINFO;
|
---|
693 |
|
---|
694 | /**
|
---|
695 | * Structure for keeping a single root list entry.
|
---|
696 | */
|
---|
697 | typedef struct _SHCLLISTROOT
|
---|
698 | {
|
---|
699 | /** The list node. */
|
---|
700 | RTLISTNODE Node;
|
---|
701 | /** Absolute path of entry. */
|
---|
702 | char *pszPathAbs;
|
---|
703 | } SHCLLISTROOT, *PSHCLLISTROOT;
|
---|
704 |
|
---|
705 | /**
|
---|
706 | * Structure for maintaining an Shared Clipboard transfer state.
|
---|
707 | * Everything in here will be part of a saved state (later).
|
---|
708 | */
|
---|
709 | typedef struct _SHCLTRANSFERSTATE
|
---|
710 | {
|
---|
711 | /** The transfer's (local) ID. */
|
---|
712 | SHCLTRANSFERID uID;
|
---|
713 | /** The transfer's current status. */
|
---|
714 | SHCLTRANSFERSTATUS enmStatus;
|
---|
715 | /** The transfer's direction, seen from the perspective who created the transfer. */
|
---|
716 | SHCLTRANSFERDIR enmDir;
|
---|
717 | /** The transfer's source, seen from the perspective who created the transfer. */
|
---|
718 | SHCLSOURCE enmSource;
|
---|
719 | } SHCLTRANSFERSTATE, *PSHCLTRANSFERSTATE;
|
---|
720 |
|
---|
721 | /**
|
---|
722 | * Structure maintaining clipboard transfer provider context data.
|
---|
723 | * This is handed in to the provider implementation callbacks.
|
---|
724 | */
|
---|
725 | typedef struct SHCLPROVIDERCTX
|
---|
726 | {
|
---|
727 | /** Pointer to the related Shared Clipboard transfer. */
|
---|
728 | PSHCLTRANSFER pTransfer;
|
---|
729 | /** User-defined data pointer. Can be NULL if not needed. */
|
---|
730 | void *pvUser;
|
---|
731 | } SHCLPROVIDERCTX, *PSHCLPROVIDERCTX;
|
---|
732 |
|
---|
733 | /**
|
---|
734 | * Shared Clipboard transfer provider interface table.
|
---|
735 | */
|
---|
736 | typedef struct SHCLPROVIDERINTERFACE
|
---|
737 | {
|
---|
738 | DECLCALLBACKMEMBER(int, pfnTransferOpen,(PSHCLPROVIDERCTX pCtx));
|
---|
739 | DECLCALLBACKMEMBER(int, pfnTransferClose,(PSHCLPROVIDERCTX pCtx));
|
---|
740 | DECLCALLBACKMEMBER(int, pfnRootsGet,(PSHCLPROVIDERCTX pCtx, PSHCLROOTLIST *ppRootList));
|
---|
741 | DECLCALLBACKMEMBER(int, pfnListOpen,(PSHCLPROVIDERCTX pCtx, PSHCLLISTOPENPARMS pOpenParms, PSHCLLISTHANDLE phList));
|
---|
742 | DECLCALLBACKMEMBER(int, pfnListClose,(PSHCLPROVIDERCTX pCtx, SHCLLISTHANDLE hList));
|
---|
743 | DECLCALLBACKMEMBER(int, pfnListHdrRead,(PSHCLPROVIDERCTX pCtx, SHCLLISTHANDLE hList, PSHCLLISTHDR pListHdr));
|
---|
744 | DECLCALLBACKMEMBER(int, pfnListHdrWrite,(PSHCLPROVIDERCTX pCtx, SHCLLISTHANDLE hList, PSHCLLISTHDR pListHdr));
|
---|
745 | DECLCALLBACKMEMBER(int, pfnListEntryRead,(PSHCLPROVIDERCTX pCtx, SHCLLISTHANDLE hList, PSHCLLISTENTRY pEntry));
|
---|
746 | DECLCALLBACKMEMBER(int, pfnListEntryWrite,(PSHCLPROVIDERCTX pCtx, SHCLLISTHANDLE hList, PSHCLLISTENTRY pEntry));
|
---|
747 | DECLCALLBACKMEMBER(int, pfnObjOpen,(PSHCLPROVIDERCTX pCtx, PSHCLOBJOPENCREATEPARMS pCreateParms, PSHCLOBJHANDLE phObj));
|
---|
748 | DECLCALLBACKMEMBER(int, pfnObjClose,(PSHCLPROVIDERCTX pCtx, SHCLOBJHANDLE hObj));
|
---|
749 | DECLCALLBACKMEMBER(int, pfnObjRead,(PSHCLPROVIDERCTX pCtx, SHCLOBJHANDLE hObj, void *pvData, uint32_t cbData,
|
---|
750 | uint32_t fFlags, uint32_t *pcbRead));
|
---|
751 | DECLCALLBACKMEMBER(int, pfnObjWrite,(PSHCLPROVIDERCTX pCtx, SHCLOBJHANDLE hObj, void *pvData, uint32_t cbData,
|
---|
752 | uint32_t fFlags, uint32_t *pcbWritten));
|
---|
753 | } SHCLPROVIDERINTERFACE, *PSHCLPROVIDERINTERFACE;
|
---|
754 |
|
---|
755 | /**
|
---|
756 | * Structure for the Shared Clipboard provider creation context.
|
---|
757 | */
|
---|
758 | typedef struct _SHCLPROVIDERCREATIONCTX
|
---|
759 | {
|
---|
760 | /** Specifies what the source of the provider is. */
|
---|
761 | SHCLSOURCE enmSource;
|
---|
762 | /** The provider interface table. */
|
---|
763 | SHCLPROVIDERINTERFACE Interface;
|
---|
764 | /** Provider callback data. */
|
---|
765 | void *pvUser;
|
---|
766 | } SHCLPROVIDERCREATIONCTX, *PSHCLPROVIDERCREATIONCTX;
|
---|
767 |
|
---|
768 |
|
---|
769 | /**
|
---|
770 | * Structure for storing Shared Clipboard transfer callback data.
|
---|
771 | */
|
---|
772 | typedef struct _SHCLTRANSFERCALLBACKDATA
|
---|
773 | {
|
---|
774 | /** Pointer to related Shared Clipboard transfer. */
|
---|
775 | PSHCLTRANSFER pTransfer;
|
---|
776 | /** Saved user pointer. */
|
---|
777 | void *pvUser;
|
---|
778 | /** Size (in bytes) of data at user pointer. */
|
---|
779 | size_t cbUser;
|
---|
780 | } SHCLTRANSFERCALLBACKDATA, *PSHCLTRANSFERCALLBACKDATA;
|
---|
781 |
|
---|
782 | /**
|
---|
783 | * Function callback table for Shared Clipboard transfers.
|
---|
784 | *
|
---|
785 | * All callbacks are optional and therefore can be NULL.
|
---|
786 | */
|
---|
787 | typedef struct SHCLTRANSFERCALLBACKS
|
---|
788 | {
|
---|
789 | /** User pointer to data. Optional and can be NULL. */
|
---|
790 | void *pvUser;
|
---|
791 | /** Size (in bytes) of user data pointing at. Optional and can be 0. */
|
---|
792 | size_t cbUser;
|
---|
793 | /** Called after the transfer has been initialized. */
|
---|
794 | DECLCALLBACKMEMBER(int, pfnTransferInitialize,(PSHCLTRANSFERCALLBACKDATA pData));
|
---|
795 | /** Called before the transfer will be started. */
|
---|
796 | DECLCALLBACKMEMBER(int, pfnTransferStart,(PSHCLTRANSFERCALLBACKDATA pData));
|
---|
797 | /** Called when reading / writing the list header is complete. */
|
---|
798 | DECLCALLBACKMEMBER(void, pfnListHeaderComplete,(PSHCLTRANSFERCALLBACKDATA pData));
|
---|
799 | /** Called when reading / writing a list entry is complete. */
|
---|
800 | DECLCALLBACKMEMBER(void, pfnListEntryComplete,(PSHCLTRANSFERCALLBACKDATA pData));
|
---|
801 | /** Called when the transfer is complete. */
|
---|
802 | DECLCALLBACKMEMBER(void, pfnTransferComplete,(PSHCLTRANSFERCALLBACKDATA pData, int rc));
|
---|
803 | /** Called when the transfer has been canceled. */
|
---|
804 | DECLCALLBACKMEMBER(void, pfnTransferCanceled,(PSHCLTRANSFERCALLBACKDATA pData));
|
---|
805 | /** Called when transfer resulted in an unrecoverable error. */
|
---|
806 | DECLCALLBACKMEMBER(void, pfnTransferError,(PSHCLTRANSFERCALLBACKDATA pData, int rc));
|
---|
807 | } SHCLTRANSFERCALLBACKS, *PSHCLTRANSFERCALLBACKS;
|
---|
808 |
|
---|
809 | /**
|
---|
810 | * Structure for thread-related members for a single Shared Clipboard transfer.
|
---|
811 | */
|
---|
812 | typedef struct _SHCLTRANSFERTHREAD
|
---|
813 | {
|
---|
814 | /** Thread handle for the reading / writing thread.
|
---|
815 | * Can be NIL_RTTHREAD if not being used. */
|
---|
816 | RTTHREAD hThread;
|
---|
817 | /** Thread started indicator. */
|
---|
818 | volatile bool fStarted;
|
---|
819 | /** Thread stop flag. */
|
---|
820 | volatile bool fStop;
|
---|
821 | /** Thread cancelled flag / indicator. */
|
---|
822 | volatile bool fCancelled;
|
---|
823 | } SHCLTRANSFERTHREAD, *PSHCLTRANSFERTHREAD;
|
---|
824 |
|
---|
825 | /**
|
---|
826 | * A single Shared Clipboard transfer.
|
---|
827 | *
|
---|
828 | ** @todo Not yet thread safe.
|
---|
829 | */
|
---|
830 | typedef struct SHCLTRANSFER
|
---|
831 | {
|
---|
832 | /** The node member for using this struct in a RTList. */
|
---|
833 | RTLISTNODE Node;
|
---|
834 | /** The transfer's state (for SSM, later). */
|
---|
835 | SHCLTRANSFERSTATE State;
|
---|
836 | /** Absolute path to root entries. */
|
---|
837 | char *pszPathRootAbs;
|
---|
838 | /** Timeout (in ms) for waiting of events. Default is 30s. */
|
---|
839 | RTMSINTERVAL uTimeoutMs;
|
---|
840 | /** Maximum data chunk size (in bytes) to transfer. Default is 64K. */
|
---|
841 | uint32_t cbMaxChunkSize;
|
---|
842 | /** The transfer's own event source. */
|
---|
843 | SHCLEVENTSOURCE Events;
|
---|
844 | /** Current number of concurrent list handles. */
|
---|
845 | uint32_t cListHandles;
|
---|
846 | /** Maximum number of concurrent list handles. */
|
---|
847 | uint32_t cMaxListHandles;
|
---|
848 | /** Next upcoming list handle. */
|
---|
849 | SHCLLISTHANDLE uListHandleNext;
|
---|
850 | /** List of all list handles elated to this transfer. */
|
---|
851 | RTLISTANCHOR lstList;
|
---|
852 | /** Number of root entries in list. */
|
---|
853 | uint64_t cRoots;
|
---|
854 | /** List of root entries of this transfer. */
|
---|
855 | RTLISTANCHOR lstRoots;
|
---|
856 | /** Current number of concurrent object handles. */
|
---|
857 | uint32_t cObjHandles;
|
---|
858 | /** Maximum number of concurrent object handles. */
|
---|
859 | uint32_t cMaxObjHandles;
|
---|
860 | /** Next upcoming object handle. */
|
---|
861 | SHCLOBJHANDLE uObjHandleNext;
|
---|
862 | /** Map of all objects handles related to this transfer. */
|
---|
863 | RTLISTANCHOR lstObj;
|
---|
864 | /** The transfer's own (local) area, if any (can be NULL if not needed).
|
---|
865 | * The area itself has a clipboard area ID assigned.
|
---|
866 | * On the host this area ID gets shared (maintained / locked) across all VMs via VBoxSVC. */
|
---|
867 | SharedClipboardArea *pArea;
|
---|
868 | /** The transfer's own provider context. */
|
---|
869 | SHCLPROVIDERCTX ProviderCtx;
|
---|
870 | /** The transfer's provider interface. */
|
---|
871 | SHCLPROVIDERINTERFACE ProviderIface;
|
---|
872 | /** The transfer's (optional) callback table. */
|
---|
873 | SHCLTRANSFERCALLBACKS Callbacks;
|
---|
874 | /** Opaque pointer to implementation-specific parameters. */
|
---|
875 | void *pvUser;
|
---|
876 | /** Size (in bytes) of implementation-specific parameters. */
|
---|
877 | size_t cbUser;
|
---|
878 | /** Contains thread-related attributes. */
|
---|
879 | SHCLTRANSFERTHREAD Thread;
|
---|
880 | /** Critical section for serializing access. */
|
---|
881 | RTCRITSECT CritSect;
|
---|
882 | } SHCLTRANSFER, *PSHCLTRANSFER;
|
---|
883 |
|
---|
884 | /**
|
---|
885 | * Structure for keeping an Shared Clipboard transfer status report.
|
---|
886 | */
|
---|
887 | typedef struct _SHCLTRANSFERREPORT
|
---|
888 | {
|
---|
889 | /** Actual status to report. */
|
---|
890 | SHCLTRANSFERSTATUS uStatus;
|
---|
891 | /** Result code (rc) to report; might be unused / invalid, based on enmStatus. */
|
---|
892 | int rc;
|
---|
893 | /** Reporting flags. Currently unused and must be 0. */
|
---|
894 | uint32_t fFlags;
|
---|
895 | } SHCLTRANSFERREPORT, *PSHCLTRANSFERREPORT;
|
---|
896 |
|
---|
897 | /**
|
---|
898 | * Structure for keeping Shared Clipboard transfer context around.
|
---|
899 | */
|
---|
900 | typedef struct _SHCLTRANSFERCTX
|
---|
901 | {
|
---|
902 | /** Critical section for serializing access. */
|
---|
903 | RTCRITSECT CritSect;
|
---|
904 | /** List of transfers. */
|
---|
905 | RTLISTANCHOR List;
|
---|
906 | /** Transfer ID allocation bitmap; clear bits are free, set bits are busy. */
|
---|
907 | uint64_t bmTransferIds[VBOX_SHCL_MAX_TRANSFERS / sizeof(uint64_t) / 8];
|
---|
908 | /** Number of running (concurrent) transfers. */
|
---|
909 | uint16_t cRunning;
|
---|
910 | /** Maximum Number of running (concurrent) transfers. */
|
---|
911 | uint16_t cMaxRunning;
|
---|
912 | /** Number of total transfers (in list). */
|
---|
913 | uint16_t cTransfers;
|
---|
914 | } SHCLTRANSFERCTX, *PSHCLTRANSFERCTX;
|
---|
915 |
|
---|
916 | int ShClTransferObjCtxInit(PSHCLCLIENTTRANSFEROBJCTX pObjCtx);
|
---|
917 | void ShClTransferObjCtxDestroy(PSHCLCLIENTTRANSFEROBJCTX pObjCtx);
|
---|
918 | bool ShClTransferObjCtxIsValid(PSHCLCLIENTTRANSFEROBJCTX pObjCtx);
|
---|
919 |
|
---|
920 | int ShClTransferObjHandleInfoInit(PSHCLOBJHANDLEINFO pInfo);
|
---|
921 | void ShClTransferObjHandleInfoDestroy(PSHCLOBJHANDLEINFO pInfo);
|
---|
922 |
|
---|
923 | int ShClTransferObjOpenParmsInit(PSHCLOBJOPENCREATEPARMS pParms);
|
---|
924 | int ShClTransferObjOpenParmsCopy(PSHCLOBJOPENCREATEPARMS pParmsDst, PSHCLOBJOPENCREATEPARMS pParmsSrc);
|
---|
925 | void ShClTransferObjOpenParmsDestroy(PSHCLOBJOPENCREATEPARMS pParms);
|
---|
926 |
|
---|
927 | int ShClTransferObjOpen(PSHCLTRANSFER pTransfer, PSHCLOBJOPENCREATEPARMS pOpenCreateParms, PSHCLOBJHANDLE phObj);
|
---|
928 | int ShClTransferObjClose(PSHCLTRANSFER pTransfer, SHCLOBJHANDLE hObj);
|
---|
929 | int ShClTransferObjRead(PSHCLTRANSFER pTransfer, SHCLOBJHANDLE hObj, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead, uint32_t fFlags);
|
---|
930 | int ShClTransferObjWrite(PSHCLTRANSFER pTransfer, SHCLOBJHANDLE hObj, void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten, uint32_t fFlags);
|
---|
931 |
|
---|
932 | PSHCLOBJDATACHUNK ShClTransferObjDataChunkDup(PSHCLOBJDATACHUNK pDataChunk);
|
---|
933 | void ShClTransferObjDataChunkDestroy(PSHCLOBJDATACHUNK pDataChunk);
|
---|
934 | void ShClTransferObjDataChunkFree(PSHCLOBJDATACHUNK pDataChunk);
|
---|
935 |
|
---|
936 | int ShClTransferCreate(PSHCLTRANSFER *ppTransfer);
|
---|
937 | int ShClTransferDestroy(PSHCLTRANSFER pTransfer);
|
---|
938 |
|
---|
939 | int ShClTransferInit(PSHCLTRANSFER pTransfer, uint32_t uID, SHCLTRANSFERDIR enmDir, SHCLSOURCE enmSource);
|
---|
940 | int ShClTransferOpen(PSHCLTRANSFER pTransfer);
|
---|
941 | int ShClTransferClose(PSHCLTRANSFER pTransfer);
|
---|
942 |
|
---|
943 | int ShClTransferListOpen(PSHCLTRANSFER pTransfer, PSHCLLISTOPENPARMS pOpenParms, PSHCLLISTHANDLE phList);
|
---|
944 | int ShClTransferListClose(PSHCLTRANSFER pTransfer, SHCLLISTHANDLE hList);
|
---|
945 | int ShClTransferListGetHeader(PSHCLTRANSFER pTransfer, SHCLLISTHANDLE hList, PSHCLLISTHDR pHdr);
|
---|
946 | PSHCLTRANSFEROBJ ShClTransferListGetObj(PSHCLTRANSFER pTransfer, SHCLLISTHANDLE hList, uint64_t uIdx);
|
---|
947 | int ShClTransferListRead(PSHCLTRANSFER pTransfer, SHCLLISTHANDLE hList, PSHCLLISTENTRY pEntry);
|
---|
948 | int ShClTransferListWrite(PSHCLTRANSFER pTransfer, SHCLLISTHANDLE hList, PSHCLLISTENTRY pEntry);
|
---|
949 | bool ShClTransferListHandleIsValid(PSHCLTRANSFER pTransfer, SHCLLISTHANDLE hList);
|
---|
950 |
|
---|
951 | int ShClPathSanitizeFilename(char *pszPath, size_t cbPath);
|
---|
952 | int ShClPathSanitize(char *pszPath, size_t cbPath);
|
---|
953 |
|
---|
954 | PSHCLROOTLIST ShClTransferRootListAlloc(void);
|
---|
955 | void ShClTransferRootListFree(PSHCLROOTLIST pRootList);
|
---|
956 |
|
---|
957 | PSHCLROOTLISTHDR ShClTransferRootListHdrDup(PSHCLROOTLISTHDR pRoots);
|
---|
958 | int ShClTransferRootListHdrInit(PSHCLROOTLISTHDR pRoots);
|
---|
959 | void ShClTransferRootListHdrDestroy(PSHCLROOTLISTHDR pRoots);
|
---|
960 |
|
---|
961 | int ShClTransferRootListEntryCopy(PSHCLROOTLISTENTRY pDst, PSHCLROOTLISTENTRY pSrc);
|
---|
962 | int ShClTransferRootListEntryInit(PSHCLROOTLISTENTRY pRootListEntry);
|
---|
963 | void ShClTransferRootListEntryDestroy(PSHCLROOTLISTENTRY pRootListEntry);
|
---|
964 | PSHCLROOTLISTENTRY ShClTransferRootListEntryDup(PSHCLROOTLISTENTRY pRootListEntry);
|
---|
965 |
|
---|
966 | int ShClTransferListHandleInfoInit(PSHCLLISTHANDLEINFO pInfo);
|
---|
967 | void ShClTransferListHandleInfoDestroy(PSHCLLISTHANDLEINFO pInfo);
|
---|
968 |
|
---|
969 | int ShClTransferListHdrAlloc(PSHCLLISTHDR *ppListHdr);
|
---|
970 | void ShClTransferListHdrFree(PSHCLLISTHDR pListHdr);
|
---|
971 | PSHCLLISTHDR ShClTransferListHdrDup(PSHCLLISTHDR pListHdr);
|
---|
972 | int ShClTransferListHdrInit(PSHCLLISTHDR pListHdr);
|
---|
973 | void ShClTransferListHdrDestroy(PSHCLLISTHDR pListHdr);
|
---|
974 | void ShClTransferListHdrReset(PSHCLLISTHDR pListHdr);
|
---|
975 | bool ShClTransferListHdrIsValid(PSHCLLISTHDR pListHdr);
|
---|
976 |
|
---|
977 | int ShClTransferListOpenParmsCopy(PSHCLLISTOPENPARMS pDst, PSHCLLISTOPENPARMS pSrc);
|
---|
978 | PSHCLLISTOPENPARMS ShClTransferListOpenParmsDup(PSHCLLISTOPENPARMS pParms);
|
---|
979 | int ShClTransferListOpenParmsInit(PSHCLLISTOPENPARMS pParms);
|
---|
980 | void ShClTransferListOpenParmsDestroy(PSHCLLISTOPENPARMS pParms);
|
---|
981 |
|
---|
982 | int ShClTransferListEntryAlloc(PSHCLLISTENTRY *ppListEntry);
|
---|
983 | void ShClTransferListEntryFree(PSHCLLISTENTRY pListEntry);
|
---|
984 | int ShClTransferListEntryCopy(PSHCLLISTENTRY pDst, PSHCLLISTENTRY pSrc);
|
---|
985 | PSHCLLISTENTRY ShClTransferListEntryDup(PSHCLLISTENTRY pListEntry);
|
---|
986 | int ShClTransferListEntryInit(PSHCLLISTENTRY pListEntry);
|
---|
987 | void ShClTransferListEntryDestroy(PSHCLLISTENTRY pListEntry);
|
---|
988 | bool ShClTransferListEntryIsValid(PSHCLLISTENTRY pListEntry);
|
---|
989 |
|
---|
990 | int ShClTransferSetInterface(PSHCLTRANSFER pTransfer, PSHCLPROVIDERCREATIONCTX pCreationCtx);
|
---|
991 | int ShClTransferRootsSet(PSHCLTRANSFER pTransfer, const char *pszRoots, size_t cbRoots);
|
---|
992 | void ShClTransferReset(PSHCLTRANSFER pTransfer);
|
---|
993 | SharedClipboardArea *ShClTransferGetArea(PSHCLTRANSFER pTransfer);
|
---|
994 |
|
---|
995 | uint32_t ShClTransferRootsCount(PSHCLTRANSFER pTransfer);
|
---|
996 | int ShClTransferRootsEntry(PSHCLTRANSFER pTransfer, uint64_t uIndex, PSHCLROOTLISTENTRY pEntry);
|
---|
997 | int ShClTransferRootsGet(PSHCLTRANSFER pTransfer, PSHCLROOTLIST *ppRootList);
|
---|
998 |
|
---|
999 | SHCLTRANSFERID ShClTransferGetID(PSHCLTRANSFER pTransfer);
|
---|
1000 | SHCLTRANSFERDIR ShClTransferGetDir(PSHCLTRANSFER pTransfer);
|
---|
1001 | SHCLSOURCE ShClTransferGetSource(PSHCLTRANSFER pTransfer);
|
---|
1002 | SHCLTRANSFERSTATUS ShClTransferGetStatus(PSHCLTRANSFER pTransfer);
|
---|
1003 | int ShClTransferRun(PSHCLTRANSFER pTransfer, PFNRTTHREAD pfnThreadFunc, void *pvUser);
|
---|
1004 | int ShClTransferStart(PSHCLTRANSFER pTransfer);
|
---|
1005 | void ShClTransferSetCallbacks(PSHCLTRANSFER pTransfer, PSHCLTRANSFERCALLBACKS pCallbacks);
|
---|
1006 |
|
---|
1007 | int ShClTransferCtxInit(PSHCLTRANSFERCTX pTransferCtx);
|
---|
1008 | void ShClTransferCtxDestroy(PSHCLTRANSFERCTX pTransferCtx);
|
---|
1009 | void ShClTransferCtxReset(PSHCLTRANSFERCTX pTransferCtx);
|
---|
1010 | PSHCLTRANSFER ShClTransferCtxGetTransfer(PSHCLTRANSFERCTX pTransferCtx, uint32_t uIdx);
|
---|
1011 | uint32_t ShClTransferCtxGetRunningTransfers(PSHCLTRANSFERCTX pTransferCtx);
|
---|
1012 | uint32_t ShClTransferCtxGetTotalTransfers(PSHCLTRANSFERCTX pTransferCtx);
|
---|
1013 | void ShClTransferCtxCleanup(PSHCLTRANSFERCTX pTransferCtx);
|
---|
1014 | bool ShClTransferCtxTransfersMaximumReached(PSHCLTRANSFERCTX pTransferCtx);
|
---|
1015 | int ShClTransferCtxTransferRegister(PSHCLTRANSFERCTX pTransferCtx, PSHCLTRANSFER pTransfer, uint32_t *pidTransfer);
|
---|
1016 | int ShClTransferCtxTransferRegisterByIndex(PSHCLTRANSFERCTX pTransferCtx, PSHCLTRANSFER pTransfer, uint32_t idTransfer);
|
---|
1017 | int ShClTransferCtxTransferUnregister(PSHCLTRANSFERCTX pTransferCtx, uint32_t idTransfer);
|
---|
1018 |
|
---|
1019 | void ShClFsObjFromIPRT(PSHCLFSOBJINFO pDst, PCRTFSOBJINFO pSrc);
|
---|
1020 |
|
---|
1021 | bool ShClMIMEHasFileURLs(const char *pcszFormat, size_t cchFormatMax);
|
---|
1022 | bool ShClMIMENeedsCache(const char *pcszFormat, size_t cchFormatMax);
|
---|
1023 |
|
---|
1024 | const char *ShClTransferStatusToStr(SHCLTRANSFERSTATUS enmStatus);
|
---|
1025 |
|
---|
1026 | #endif /* !VBOX_INCLUDED_GuestHost_SharedClipboard_transfers_h */
|
---|
1027 |
|
---|