VirtualBox

source: vbox/trunk/include/VBox/GuestHost/SharedClipboard-transfers.h@ 100526

Last change on this file since 100526 was 100526, checked in by vboxsync, 19 months ago

Shared Clipboard: Typo. bugref:9437

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 47.7 KB
Line 
1/* $Id: SharedClipboard-transfers.h 100526 2023-07-11 18:03:56Z vboxsync $ */
2/** @file
3 * Shared Clipboard - Shared transfer functions between host and guest.
4 */
5
6/*
7 * Copyright (C) 2019-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37#ifndef VBOX_INCLUDED_GuestHost_SharedClipboard_transfers_h
38#define VBOX_INCLUDED_GuestHost_SharedClipboard_transfers_h
39#ifndef RT_WITHOUT_PRAGMA_ONCE
40# pragma once
41#endif
42
43#include <iprt/assert.h>
44#include <iprt/critsect.h>
45#include <iprt/fs.h>
46#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS_HTTP
47# include <iprt/http-server.h>
48#endif
49#include <iprt/list.h>
50
51#include <iprt/cpp/list.h>
52#include <iprt/cpp/ministring.h>
53
54#include <VBox/GuestHost/SharedClipboard.h>
55#include <VBox/HostServices/VBoxClipboardSvc.h>
56
57
58struct SHCLTRANSFER;
59/** Pointer to a single shared clipboard transfer. */
60typedef struct SHCLTRANSFER *PSHCLTRANSFER;
61
62
63/** @name Shared Clipboard transfer definitions.
64 * @{
65 */
66
67/** No Shared Clipboard list feature flags defined. */
68#define SHCL_TRANSFER_LIST_FEATURE_F_NONE UINT32_C(0)
69/** Is a root list. */
70#define SHCL_TRANSFER_LIST_FEATURE_F_ROOT RT_BIT(0)
71/** Shared Clipboard feature flags valid mask. */
72#define SHCL_TRANSFER_LIST_FEATURE_F_VALID_MASK 0x1
73
74/** Defines the maximum length (in chars) a Shared Clipboard transfer path can have. */
75#define SHCL_TRANSFER_PATH_MAX RTPATH_MAX
76/** Defines the default maximum transfer chunk size (in bytes) of a Shared Clipboard transfer. */
77#define SHCL_TRANSFER_DEFAULT_MAX_CHUNK_SIZE _64K
78/** Defines the default maximum list handles a Shared Clipboard transfer can have. */
79#define SHCL_TRANSFER_DEFAULT_MAX_LIST_HANDLES _4K
80/** Defines the default maximum object handles a Shared Clipboard transfer can have. */
81#define SHCL_TRANSFER_DEFAULT_MAX_OBJ_HANDLES _4K
82/** Defines the separator for the entries of an URI list (as a string). */
83#define SHCL_TRANSFER_URI_LIST_SEP_STR "\r\n"
84
85/**
86 * Defines the transfer status codes.
87 */
88typedef enum
89{
90 /** No status set. */
91 SHCLTRANSFERSTATUS_NONE = 0,
92 /** Requests a transfer to be initialized by the host. Only used for H->G transfers.
93 * Needed as only the host creates new transfer IDs. */
94 SHCLTRANSFERSTATUS_REQUESTED = 8,
95 /** The transfer has been initialized and is ready to go, but is not running yet.
96 * At this stage the other party can start reading the root list and other stuff. */
97 SHCLTRANSFERSTATUS_INITIALIZED = 1,
98 /** The transfer has been uninitialized and is not usable anymore. */
99 SHCLTRANSFERSTATUS_UNINITIALIZED = 2,
100 /** The transfer is active and running. */
101 SHCLTRANSFERSTATUS_STARTED = 3,
102 /** The transfer has been stopped. */
103 SHCLTRANSFERSTATUS_STOPPED = 4,
104 /** The transfer has been canceled. */
105 SHCLTRANSFERSTATUS_CANCELED = 5,
106 /** The transfer has been killed. */
107 SHCLTRANSFERSTATUS_KILLED = 6,
108 /** The transfer ran into an unrecoverable error.
109 * This results in completely aborting the operation. */
110 SHCLTRANSFERSTATUS_ERROR = 7,
111 /** The usual 32-bit hack. */
112 SHCLTRANSFERSTATUS_32BIT_SIZE_HACK = 0x7fffffff
113} SHCLTRANSFERSTATUSENUM;
114
115/** Defines a transfer status. */
116typedef uint32_t SHCLTRANSFERSTATUS;
117
118/** @} */
119
120/** @name Shared Clipboard handles.
121 * @{
122 */
123
124/** A Shared Clipboard list handle. */
125typedef uint64_t SHCLLISTHANDLE;
126/** Pointer to a Shared Clipboard list handle. */
127typedef SHCLLISTHANDLE *PSHCLLISTHANDLE;
128/** Specifies an invalid Shared Clipboard list handle. */
129#define NIL_SHCLLISTHANDLE ((SHCLLISTHANDLE)UINT64_MAX)
130
131/** A Shared Clipboard object handle. */
132typedef uint64_t SHCLOBJHANDLE;
133/** Pointer to a Shared Clipboard object handle. */
134typedef SHCLOBJHANDLE *PSHCLOBJHANDLE;
135/** Specifies an invalid Shared Clipboard object handle. */
136#define NIL_SHCLOBJHANDLE ((SHCLOBJHANDLE)UINT64_MAX)
137
138/** @} */
139
140/** @name Shared Clipboard open/create flags.
141 * @{
142 */
143/** No flags. Initialization value. */
144#define SHCL_OBJ_CF_NONE UINT32_C(0x00000000)
145
146#if 0 /* These probably won't be needed either */
147/** Lookup only the object, do not return a handle. All other flags are ignored. */
148#define SHCL_OBJ_CF_LOOKUP UINT32_C(0x00000001)
149/** Create/open a directory. */
150#define SHCL_OBJ_CF_DIRECTORY UINT32_C(0x00000004)
151#endif
152
153/** Read/write requested access for the object. */
154#define SHCL_OBJ_CF_ACCESS_MASK_RW UINT32_C(0x00001000)
155/** No access requested. */
156#define SHCL_OBJ_CF_ACCESS_NONE UINT32_C(0x00000000)
157/** Read access requested. */
158#define SHCL_OBJ_CF_ACCESS_READ UINT32_C(0x00001000)
159
160/** Requested share access for the object. */
161#define SHCL_OBJ_CF_ACCESS_MASK_DENY UINT32_C(0x00008000)
162/** Allow any access. */
163#define SHCL_OBJ_CF_ACCESS_DENYNONE UINT32_C(0x00000000)
164/** Do not allow write. */
165#define SHCL_OBJ_CF_ACCESS_DENYWRITE UINT32_C(0x00008000)
166
167/** Requested access to attributes of the object. */
168#define SHCL_OBJ_CF_ACCESS_MASK_ATTR UINT32_C(0x00010000)
169/** No access requested. */
170#define SHCL_OBJ_CF_ACCESS_ATTR_NONE UINT32_C(0x00000000)
171/** Read access requested. */
172#define SHCL_OBJ_CF_ACCESS_ATTR_READ UINT32_C(0x00010000)
173
174/** Valid bits. */
175#define SHCL_OBJ_CF_VALID_MASK UINT32_C(0x00019000)
176/** @} */
177
178/**
179 * The available additional information in a SHCLFSOBJATTR object.
180 * @sa RTFSOBJATTRADD
181 */
182typedef enum _SHCLFSOBJATTRADD
183{
184 /** No additional information is available / requested. */
185 SHCLFSOBJATTRADD_NOTHING = 1,
186 /** The additional unix attributes (SHCLFSOBJATTR::u::Unix) are
187 * available / requested. */
188 SHCLFSOBJATTRADD_UNIX,
189 /** The additional extended attribute size (SHCLFSOBJATTR::u::EASize) is
190 * available / requested. */
191 SHCLFSOBJATTRADD_EASIZE,
192 /** The last valid item (inclusive).
193 * The valid range is SHCLFSOBJATTRADD_NOTHING thru
194 * SHCLFSOBJATTRADD_LAST. */
195 SHCLFSOBJATTRADD_LAST = SHCLFSOBJATTRADD_EASIZE,
196 /** The usual 32-bit hack. */
197 SHCLFSOBJATTRADD_32BIT_SIZE_HACK = 0x7fffffff
198} SHCLFSOBJATTRADD;
199
200
201/* Assert sizes of the IRPT types we're using below. */
202AssertCompileSize(RTFMODE, 4);
203AssertCompileSize(RTFOFF, 8);
204AssertCompileSize(RTINODE, 8);
205AssertCompileSize(RTTIMESPEC, 8);
206AssertCompileSize(RTDEV, 4);
207AssertCompileSize(RTUID, 4);
208
209/**
210 * Shared Clipboard filesystem object attributes.
211 *
212 * @sa RTFSOBJATTR
213 */
214typedef struct _SHCLFSOBJATTR
215{
216 /** Mode flags (st_mode). RTFS_UNIX_*, RTFS_TYPE_*, and RTFS_DOS_*.
217 * @remarks We depend on a number of RTFS_ defines to remain unchanged.
218 * Fortuntately, these are depending on windows, dos and unix
219 * standard values, so this shouldn't be much of a pain. */
220 RTFMODE fMode;
221
222 /** The additional attributes available. */
223 SHCLFSOBJATTRADD enmAdditional;
224
225 /**
226 * Additional attributes.
227 *
228 * Unless explicitly specified to an API, the API can provide additional
229 * data as it is provided by the underlying OS.
230 */
231 union SHCLFSOBJATTRUNION
232 {
233 /** Additional Unix Attributes
234 * These are available when SHCLFSOBJATTRADD is set in fUnix.
235 */
236 struct SHCLFSOBJATTRUNIX
237 {
238 /** The user owning the filesystem object (st_uid).
239 * This field is ~0U if not supported. */
240 RTUID uid;
241
242 /** The group the filesystem object is assigned (st_gid).
243 * This field is ~0U if not supported. */
244 RTGID gid;
245
246 /** Number of hard links to this filesystem object (st_nlink).
247 * This field is 1 if the filesystem doesn't support hardlinking or
248 * the information isn't available.
249 */
250 uint32_t cHardlinks;
251
252 /** The device number of the device which this filesystem object resides on (st_dev).
253 * This field is 0 if this information is not available. */
254 RTDEV INodeIdDevice;
255
256 /** The unique identifier (within the filesystem) of this filesystem object (st_ino).
257 * Together with INodeIdDevice, this field can be used as a OS wide unique id
258 * when both their values are not 0.
259 * This field is 0 if the information is not available. */
260 RTINODE INodeId;
261
262 /** User flags (st_flags).
263 * This field is 0 if this information is not available. */
264 uint32_t fFlags;
265
266 /** The current generation number (st_gen).
267 * This field is 0 if this information is not available. */
268 uint32_t GenerationId;
269
270 /** The device number of a character or block device type object (st_rdev).
271 * This field is 0 if the file isn't of a character or block device type and
272 * when the OS doesn't subscribe to the major+minor device idenfication scheme. */
273 RTDEV Device;
274 } Unix;
275
276 /**
277 * Extended attribute size.
278 */
279 struct SHCLFSOBJATTREASIZE
280 {
281 /** Size of EAs. */
282 RTFOFF cb;
283 } EASize;
284
285 /** Padding the structure to a multiple of 8 bytes. */
286 uint64_t au64Padding[5];
287 } u;
288} SHCLFSOBJATTR;
289AssertCompileSize(SHCLFSOBJATTR, 48);
290/** Pointer to a Shared Clipboard filesystem object attributes structure. */
291typedef SHCLFSOBJATTR *PSHCLFSOBJATTR;
292/** Pointer to a const Shared Clipboard filesystem object attributes structure. */
293typedef const SHCLFSOBJATTR *PCSHCLFSOBJATTR;
294
295/**
296 * Shared Clipboard file system object information structure.
297 *
298 * @sa RTFSOBJINFO
299 */
300typedef struct _SHCLFSOBJINFO
301{
302 /** Logical size (st_size).
303 * For normal files this is the size of the file.
304 * For symbolic links, this is the length of the path name contained
305 * in the symbolic link.
306 * For other objects this fields needs to be specified.
307 */
308 RTFOFF cbObject;
309
310 /** Disk allocation size (st_blocks * DEV_BSIZE). */
311 RTFOFF cbAllocated;
312
313 /** Time of last access (st_atime).
314 * @remarks Here (and other places) we depend on the IPRT timespec to
315 * remain unchanged. */
316 RTTIMESPEC AccessTime;
317
318 /** Time of last data modification (st_mtime). */
319 RTTIMESPEC ModificationTime;
320
321 /** Time of last status change (st_ctime).
322 * If not available this is set to ModificationTime.
323 */
324 RTTIMESPEC ChangeTime;
325
326 /** Time of file birth (st_birthtime).
327 * If not available this is set to ChangeTime.
328 */
329 RTTIMESPEC BirthTime;
330
331 /** Attributes. */
332 SHCLFSOBJATTR Attr;
333
334} SHCLFSOBJINFO;
335AssertCompileSize(SHCLFSOBJINFO, 96);
336/** Pointer to a Shared Clipboard filesystem object information structure. */
337typedef SHCLFSOBJINFO *PSHCLFSOBJINFO;
338/** Pointer to a const Shared Clipboard filesystem object information
339 * structure. */
340typedef const SHCLFSOBJINFO *PCSHCLFSOBJINFO;
341
342/**
343 * Structure for keeping object open/create parameters.
344 */
345typedef struct _SHCLOBJOPENCREATEPARMS
346{
347 /** Path to object to open / create. */
348 char *pszPath;
349 /** Size (in bytes) of path to to object. */
350 uint32_t cbPath;
351 /** SHCL_OBJ_CF_* */
352 uint32_t fCreate;
353 /**
354 * Attributes of object to open/create and
355 * returned actual attributes of opened/created object.
356 */
357 SHCLFSOBJINFO ObjInfo;
358} SHCLOBJOPENCREATEPARMS;
359/** Pointer to Shared Clipboard object open/create parameters. */
360typedef SHCLOBJOPENCREATEPARMS *PSHCLOBJOPENCREATEPARMS;
361
362/**
363 * Structure for keeping a reply message.
364 */
365typedef struct _SHCLREPLY
366{
367 /** Message type (of type VBOX_SHCL_TX_REPLYMSGTYPE_TRANSFER_XXX). */
368 uint32_t uType;
369 /** IPRT result of overall operation. Note: int vs. uint32! */
370 uint32_t rc;
371 union
372 {
373 /** For VBOX_SHCL_TX_REPLYMSGTYPE_TRANSFER_STATUS. */
374 struct
375 {
376 SHCLTRANSFERSTATUS uStatus;
377 } TransferStatus;
378 /** For VBOX_SHCL_TX_REPLYMSGTYPE_LIST_OPEN. */
379 struct
380 {
381 SHCLLISTHANDLE uHandle;
382 } ListOpen;
383 /** For VBOX_SHCL_TX_REPLYMSGTYPE_LIST_CLOSE. */
384 struct
385 {
386 SHCLLISTHANDLE uHandle;
387 } ListClose;
388 /** For VBOX_SHCL_TX_REPLYMSGTYPE_OBJ_OPEN. */
389 struct
390 {
391 SHCLOBJHANDLE uHandle;
392 } ObjOpen;
393 /** For VBOX_SHCL_TX_REPLYMSGTYPE_OBJ_CLOSE. */
394 struct
395 {
396 SHCLOBJHANDLE uHandle;
397 } ObjClose;
398 } u;
399 /** Pointer to optional payload. */
400 void *pvPayload;
401 /** Payload size (in bytes). */
402 uint32_t cbPayload;
403} SHCLREPLY;
404/** Pointer to a Shared Clipboard reply. */
405typedef SHCLREPLY *PSHCLREPLY;
406
407struct _SHCLLISTENTRY;
408typedef _SHCLLISTENTRY SHCLLISTENTRY;
409
410/**
411 * Structure for maintaining Shared Clipboard list open parameters.
412 */
413typedef struct _SHCLLISTOPENPARMS
414{
415 /** Listing flags (see VBOX_SHCL_LIST_FLAG_XXX). */
416 uint32_t fList;
417 /** Size (in bytes) of the filter string. */
418 uint32_t cbFilter;
419 /** Filter string. DOS wilcard-style. */
420 char *pszFilter;
421 /** Size (in bytes) of the listing path. */
422 uint32_t cbPath;
423 /** Listing path (absolute). If empty or NULL the listing's root path will be opened. */
424 char *pszPath;
425} SHCLLISTOPENPARMS;
426/** Pointer to Shared Clipboard list open parameters. */
427typedef SHCLLISTOPENPARMS *PSHCLLISTOPENPARMS;
428
429/**
430 * Structure for keeping a Shared Clipboard list header.
431 */
432typedef struct _SHCLLISTHDR
433{
434 /** Feature flag(s) of type SHCL_TRANSFER_LIST_FEATURE_F_XXX. */
435 uint32_t fFeatures;
436 /** Total entries of the list. */
437 uint64_t cEntries;
438 /** Total size (in bytes) returned. */
439 uint64_t cbTotalSize;
440} SHCLLISTHDR;
441/** Pointer to a Shared Clipboard list header. */
442typedef SHCLLISTHDR *PSHCLLISTHDR;
443
444/**
445 * Structure for a generic Shared Clipboard list entry.
446 */
447typedef struct _SHCLLISTENTRY
448{
449 /** List node. */
450 RTLISTNODE Node;
451 /** Entry name. */
452 char *pszName;
453 /** Size (in bytes) of entry name.
454 * Includes terminator. */
455 uint32_t cbName;
456 /** Information flag(s). Of type VBOX_SHCL_INFO_F_XXX. */
457 uint32_t fInfo;
458 /** Size (in bytes) of the actual list entry. */
459 uint32_t cbInfo;
460 /** Data of the actual list entry. */
461 void *pvInfo;
462} SHCLLISTENTRY;
463/** Pointer to a Shared Clipboard list entry. */
464typedef SHCLLISTENTRY *PSHCLLISTENTRY;
465/** Pointer to a const Shared Clipboard list entry. */
466typedef SHCLLISTENTRY *PCSHCLLISTENTRY;
467
468/** Maximum length (in UTF-8 characters) of a list entry name. Includes terminator. */
469#define SHCLLISTENTRY_MAX_NAME 1024
470
471/**
472 * Structure for a generic Shared Clipboard list.
473 */
474typedef struct _SHCLLIST
475{
476 /** List header. */
477 SHCLLISTHDR Hdr;
478 /** List entries of type PSHCLLISTENTRY. */
479 RTLISTANCHOR lstEntries;
480} SHCLLIST;
481/** Pointer to a generic Shared Clipboard transfer transfer list. */
482typedef SHCLLIST *PSHCLLIST;
483
484/**
485 * Structure for keeping a Shared Clipboard object data chunk.
486 */
487typedef struct _SHCLOBJDATACHUNK
488{
489 /** Handle of object this data chunk is related to. */
490 uint64_t uHandle;
491 /** Pointer to actual data chunk. */
492 void *pvData;
493 /** Size (in bytes) of data chunk. */
494 uint32_t cbData;
495} SHCLOBJDATACHUNK;
496/** Pointer to a Shared Clipboard transfer object data chunk. */
497typedef SHCLOBJDATACHUNK *PSHCLOBJDATACHUNK;
498
499/**
500 * Structure for handling a single transfer object context.
501 */
502typedef struct _SHCLCLIENTTRANSFEROBJCTX
503{
504 /** Pointer to the actual transfer object of this context. */
505 SHCLTRANSFER *pTransfer;
506 /** Object handle of this transfer context. */
507 SHCLOBJHANDLE uHandle;
508} SHCLCLIENTTRANSFEROBJCTX;
509/** Pointer to a Shared Clipboard transfer object context. */
510typedef SHCLCLIENTTRANSFEROBJCTX *PSHCLCLIENTTRANSFEROBJCTX;
511
512typedef struct _SHCLTRANSFEROBJSTATE
513{
514 /** How many bytes were processed (read / write) so far. */
515 uint64_t cbProcessed;
516} SHCLTRANSFEROBJSTATE;
517/** Pointer to a Shared Clipboard transfer object state. */
518typedef SHCLTRANSFEROBJSTATE *PSHCLTRANSFEROBJSTATE;
519
520/**
521 * Enumeration for specifying a Shared Clipboard object type.
522 */
523typedef enum _SHCLOBJTYPE
524{
525 /** Invalid object type. */
526 SHCLOBJTYPE_INVALID = 0,
527 /** Object is a directory. */
528 SHCLOBJTYPE_DIRECTORY,
529 /** Object is a file. */
530 SHCLOBJTYPE_FILE,
531 /** Object is a symbolic link. */
532 SHCLOBJTYPE_SYMLINK,
533 /** The usual 32-bit hack. */
534 SHCLOBJTYPE_32BIT_SIZE_HACK = 0x7fffffff
535} SHCLOBJTYPE;
536
537/**
538 * Structure for a single Shared Clipboard transfer object.
539 */
540typedef struct _SHCLTRANSFEROBJ
541{
542 /** The list node. */
543 RTLISTNODE Node;
544 /** Handle of the object. */
545 SHCLOBJHANDLE hObj;
546 /** Absolute (local) path of the object. Source-style path. */
547 char *pszPathLocalAbs;
548 /** Object file system information. */
549 SHCLFSOBJINFO objInfo;
550 /** Source the object originates from. */
551 SHCLSOURCE enmSource;
552 /** Current state. */
553 SHCLTRANSFEROBJSTATE State;
554 /** Type of object handle. */
555 SHCLOBJTYPE enmType;
556 /** Data union, based on \a enmType. */
557 union
558 {
559 /** Local data. */
560 struct
561 {
562 union
563 {
564 RTDIR hDir;
565 RTFILE hFile;
566 };
567 } Local;
568 } u;
569} SHCLTRANSFEROBJ;
570/** Pointer to a Shared Clipboard transfer object. */
571typedef SHCLTRANSFEROBJ *PSHCLTRANSFEROBJ;
572
573/**
574 * Structure for keeping transfer list handle information.
575 *
576 * This is using to map own (local) handles to the underlying file system.
577 */
578typedef struct _SHCLLISTHANDLEINFO
579{
580 /** The list node. */
581 RTLISTNODE Node;
582 /** The list's handle. */
583 SHCLLISTHANDLE hList;
584 /** Type of list handle. */
585 SHCLOBJTYPE enmType;
586 /** Absolute local path of the list object. */
587 char *pszPathLocalAbs;
588 union
589 {
590 /** Local data, based on enmType. */
591 struct
592 {
593 union
594 {
595 RTDIR hDir;
596 RTFILE hFile;
597 };
598 } Local;
599 } u;
600} SHCLLISTHANDLEINFO;
601/** Pointer to a Shared Clipboard transfer list handle info. */
602typedef SHCLLISTHANDLEINFO *PSHCLLISTHANDLEINFO;
603
604/**
605 * Structure for maintaining an Shared Clipboard transfer state.
606 * Everything in here will be part of a saved state (later).
607 */
608typedef struct _SHCLTRANSFERSTATE
609{
610 /** The transfer's (local) ID. */
611 SHCLTRANSFERID uID;
612 /** The transfer's current status. */
613 SHCLTRANSFERSTATUS enmStatus;
614 /** The transfer's direction, seen from the perspective who created the transfer. */
615 SHCLTRANSFERDIR enmDir;
616 /** The transfer's source, seen from the perspective who created the transfer. */
617 SHCLSOURCE enmSource;
618} SHCLTRANSFERSTATE;
619/** Pointer to a Shared Clipboard transfer state. */
620typedef SHCLTRANSFERSTATE *PSHCLTRANSFERSTATE;
621
622/**
623 * Structure maintaining clipboard transfer provider context data.
624 *
625 * This is handed-in to the provider interface implementations.
626 */
627typedef struct _SHCLTXPROVIDERCTX
628{
629 /** Pointer to the related Shared Clipboard transfer. */
630 PSHCLTRANSFER pTransfer;
631 /** User-defined data pointer. Can be NULL if not needed. */
632 void *pvUser;
633 /** Size (in bytes) of data at user pointer. */
634 size_t cbUser;
635} SHCLTXPROVIDERCTX;
636/** Pointer to Shared Clipboard transfer provider context data. */
637typedef SHCLTXPROVIDERCTX *PSHCLTXPROVIDERCTX;
638
639struct _SHCLTRANSFERCTX;
640typedef struct _SHCLTRANSFERCTX *PSHCLTRANSFERCTX;
641
642/**
643 * Shared Clipboard transfer provider interface table.
644 *
645 * A transfer provider inteface implementation realizes all low level functions
646 * needed for making a Shared Clipboard transfer happen.
647 */
648typedef struct _SHCLTXPROVIDERIFACE
649{
650 /**
651 * Reads the clipboard transfer root list.
652 *
653 * Depending on the provider, this queries information for the root entries.
654 *
655 * @returns VBox status code.
656 * @param pCtx Provider context to use.
657 */
658 DECLCALLBACKMEMBER(int, pfnRootListRead,(PSHCLTXPROVIDERCTX pCtx));
659 /**
660 * Opens a transfer list.
661 *
662 * @returns VBox status code.
663 * @param pCtx Provider context to use.
664 * @param pOpenParms List open parameters to use for opening.
665 * @param phList Where to store the List handle of opened list on success.
666 */
667 DECLCALLBACKMEMBER(int, pfnListOpen,(PSHCLTXPROVIDERCTX pCtx, PSHCLLISTOPENPARMS pOpenParms, PSHCLLISTHANDLE phList));
668 /**
669 * Closes a transfer list.
670 *
671 * @returns VBox status code.
672 * @param pCtx Provider context to use.
673 * @param hList Handle of list to close.
674 */
675 DECLCALLBACKMEMBER(int, pfnListClose,(PSHCLTXPROVIDERCTX pCtx, SHCLLISTHANDLE hList));
676 /**
677 * Reads the list header.
678 *
679 * @returns VBox status code.
680 * @param pCtx Provider context to use.
681 * @param hList List handle of list to read header for.
682 * @param pListHdr Where to store the list header read.
683 */
684 DECLCALLBACKMEMBER(int, pfnListHdrRead,(PSHCLTXPROVIDERCTX pCtx, SHCLLISTHANDLE hList, PSHCLLISTHDR pListHdr));
685 /**
686 * Writes the list header.
687 *
688 * @returns VBox status code.
689 * @param pCtx Provider context to use.
690 * @param hList List handle of list to write header for.
691 * @param pListHdr List header to write.
692 */
693 DECLCALLBACKMEMBER(int, pfnListHdrWrite,(PSHCLTXPROVIDERCTX pCtx, SHCLLISTHANDLE hList, PSHCLLISTHDR pListHdr));
694 /**
695 * Reads a single transfer list entry.
696 *
697 * @returns VBox status code or VERR_NO_MORE_FILES if the end of the list has been reached.
698 * @param pCtx Provider context to use.
699 * @param hList List handle of list to read from.
700 * @param pListEntry Where to store the read information.
701 */
702 DECLCALLBACKMEMBER(int, pfnListEntryRead,(PSHCLTXPROVIDERCTX pCtx, SHCLLISTHANDLE hList, PSHCLLISTENTRY pListEntry));
703 /**
704 * Writes a single transfer list entry.
705 *
706 * @returns VBox status code.
707 * @param pCtx Provider context to use.
708 * @param hList List handle of list to write to.
709 * @param pListEntry Entry information to write.
710 */
711 DECLCALLBACKMEMBER(int, pfnListEntryWrite,(PSHCLTXPROVIDERCTX pCtx, SHCLLISTHANDLE hList, PSHCLLISTENTRY pListEntry));
712 /**
713 * Opens a transfer object.
714 *
715 * @returns VBox status code.
716 * @param pCtx Provider context to use.
717 * @param pCreateParms Open / create parameters of transfer object to open / create.
718 * @param phObj Where to store the handle of transfer object opened on success.
719 */
720 DECLCALLBACKMEMBER(int, pfnObjOpen,(PSHCLTXPROVIDERCTX pCtx, PSHCLOBJOPENCREATEPARMS pCreateParms, PSHCLOBJHANDLE phObj));
721 /**
722 * Closes a transfer object.
723 *
724 * @returns VBox status code.
725 * @param pCtx Provider context to use.
726 * @param hObj Handle of transfer object to close.
727 */
728 DECLCALLBACKMEMBER(int, pfnObjClose,(PSHCLTXPROVIDERCTX pCtx, SHCLOBJHANDLE hObj));
729 /**
730 * Reads from a transfer object.
731 *
732 * @returns VBox status code.
733 * @param pCtx Provider context to use.
734 * @param hObj Handle of transfer object to read from.
735 * @param pvData Buffer for where to store the read data.
736 * @param cbData Size (in bytes) of buffer.
737 * @param fFlags Read flags. Optional.
738 * @param pcbRead Where to return how much bytes were read on success. Optional.
739 */
740 DECLCALLBACKMEMBER(int, pfnObjRead,(PSHCLTXPROVIDERCTX pCtx, SHCLOBJHANDLE hObj, void *pvData, uint32_t cbData,
741 uint32_t fFlags, uint32_t *pcbRead));
742 /**
743 * Writes to a transfer object.
744 *
745 * @returns VBox status code.
746 * @param pCtx Provider context to use.
747 * @param hObj Handle of transfer object to write to.
748 * @param pvData Buffer of data to write.
749 * @param cbData Size (in bytes) of buffer to write.
750 * @param fFlags Write flags. Optional.
751 * @param pcbWritten How much bytes were writtenon success. Optional.
752 */
753 DECLCALLBACKMEMBER(int, pfnObjWrite,(PSHCLTXPROVIDERCTX pCtx, SHCLOBJHANDLE hObj, void *pvData, uint32_t cbData,
754 uint32_t fFlags, uint32_t *pcbWritten));
755} SHCLTXPROVIDERIFACE;
756/** Pointer to a Shared Clipboard transfer provider interface table. */
757typedef SHCLTXPROVIDERIFACE *PSHCLTXPROVIDERIFACE;
758
759/** Queries (assigns) a Shared Clipboard provider interface. */
760#define SHCLTXPROVIDERIFACE_QUERY(a_Iface, a_Name) \
761 a_Iface->pfnRootListRead = a_Name ## RootListRead; \
762 a_Iface->pfnListOpen = a_Name ## ListOpen; \
763 a_Iface->pfnListClose = a_Name ## ListClose; \
764 a_Iface->pfnListHdrRead = a_Name ## ListHdrRead; \
765 a_Iface->pfnListHdrWrite = a_Name ## ListHdrWrite; \
766 a_Iface->pfnListEntryRead = a_Name ## ListEntryRead; \
767 a_Iface->pfnListEntryWrite = a_Name ## ListEntryWrite; \
768 a_Iface->pfnObjOpen = a_Name ## ObjOpen; \
769 a_Iface->pfnObjClose = a_Name ## ObjClose; \
770 a_Iface->pfnObjRead = a_Name ## ObjRead; \
771 a_Iface->pfnObjWrite = a_Name ## ObjWrite;
772
773/** Queries (assigns) a Shared Clipboard provider interface + returns the interface pointer. */
774#define SHCLTXPROVIDERIFACE_QUERY_RET(a_Iface, a_Name) \
775 SHCLTXPROVIDERIFACE_QUERY(a_Iface, a_Name); return a_Iface;
776
777/**
778 * Structure for Shared Clipboard transfer provider.
779 */
780typedef struct _SHCLTXPROVIDER
781{
782 /** Specifies what the source of the provider is. */
783 SHCLSOURCE enmSource;
784 /** The provider interface table to use. */
785 SHCLTXPROVIDERIFACE Interface;
786 /** User-provided callback data. */
787 void *pvUser;
788 /** Size (in bytes) of data at user pointer. */
789 size_t cbUser;
790} SHCLTXPROVIDER;
791/** Pointer to Shared Clipboard transfer provider. */
792typedef SHCLTXPROVIDER *PSHCLTXPROVIDER;
793
794/**
795 * Structure maintaining clipboard transfer callback context data.
796 */
797typedef struct _SHCLTRANSFERCALLBACKCTX
798{
799 /** Pointer to the related Shared Clipboard transfer. */
800 PSHCLTRANSFER pTransfer;
801 /** User-defined data pointer. Can be NULL if not needed. */
802 void *pvUser;
803 /** Size (in bytes) of data at user pointer. */
804 size_t cbUser;
805} SHCLTRANSFERCALLBACKCTX;
806/** Pointer to a Shared Clipboard transfer callback context. */
807typedef SHCLTRANSFERCALLBACKCTX *PSHCLTRANSFERCALLBACKCTX;
808
809/**
810 * Shared Clipboard transfer callback table.
811 *
812 * All callbacks are optional (hence all returning void).
813 */
814typedef struct _SHCLTRANSFERCALLBACKS
815{
816 /**
817 * Called after the transfer got created.
818 *
819 * @param pCbCtx Pointer to callback context to use.
820 */
821 DECLCALLBACKMEMBER(void, pfnOnCreated,(PSHCLTRANSFERCALLBACKCTX pCbCtx));
822 /**
823 * Called after the transfer got initialized.
824 *
825 * @param pCbCtx Pointer to callback context to use.
826 */
827 DECLCALLBACKMEMBER(void, pfnOnInitialized,(PSHCLTRANSFERCALLBACKCTX pCbCtx));
828 /**
829 * Called before the transfer gets destroyed.
830 *
831 * @param pCbCtx Pointer to callback context to use.
832 */
833 DECLCALLBACKMEMBER(void, pfnOnDestroy,(PSHCLTRANSFERCALLBACKCTX pCbCtx));
834 /**
835 * Called after the transfer entered the started state.
836 *
837 * @param pCbCtx Pointer to callback context to use.
838 */
839 DECLCALLBACKMEMBER(void, pfnOnStarted,(PSHCLTRANSFERCALLBACKCTX pCbCtx));
840 /**
841 * Called when the transfer has been completed.
842 *
843 * @param pCbCtx Pointer to callback context to use.
844 * @param rcCompletion Completion result.
845 * VERR_CANCELED if transfer has been canceled.
846 */
847 DECLCALLBACKMEMBER(void, pfnOnCompleted,(PSHCLTRANSFERCALLBACKCTX pCbCtx, int rcCompletion));
848 /**
849 * Called when transfer resulted in an unrecoverable error.
850 *
851 * @param pCbCtx Pointer to callback context to use.
852 * @param rcError Error reason, IPRT-style.
853 */
854 DECLCALLBACKMEMBER(void, pfnOnError,(PSHCLTRANSFERCALLBACKCTX pCbCtx, int rcError));
855 /**
856 * Called after a transfer got registered to a transfer context.
857 *
858 * @param pCbCtx Pointer to callback context to use.
859 * @param pTransferCtx Transfer context transfer was registered to.
860 */
861 DECLCALLBACKMEMBER(void, pfnOnRegistered,(PSHCLTRANSFERCALLBACKCTX pCbCtx, PSHCLTRANSFERCTX pTransferCtx));
862 /**
863 * Called after a transfer got unregistered from a transfer context.
864 *
865 * @param pCbCtx Pointer to callback context to use.
866 * @param pTransferCtx Transfer context transfer was unregistered from.
867 */
868 DECLCALLBACKMEMBER(void, pfnOnUnregistered,(PSHCLTRANSFERCALLBACKCTX pCbCtx, PSHCLTRANSFERCTX pTransferCtx));
869
870 /** User-provided callback data. Can be NULL if not used. */
871 void *pvUser;
872 /** Size (in bytes) of data pointer at \a pvUser. */
873 size_t cbUser;
874} SHCLTRANSFERCALLBACKS;
875/** Pointer to a Shared Clipboard transfer callback table. */
876typedef SHCLTRANSFERCALLBACKS *PSHCLTRANSFERCALLBACKS;
877
878/**
879 * Structure for thread-related members for a single Shared Clipboard transfer.
880 */
881typedef struct _SHCLTRANSFERTHREAD
882{
883 /** Thread handle for the reading / writing thread.
884 * Can be NIL_RTTHREAD if not being used. */
885 RTTHREAD hThread;
886 /** Thread started indicator. */
887 volatile bool fStarted;
888 /** Thread stop flag. */
889 volatile bool fStop;
890 /** Thread cancelled flag / indicator. */
891 volatile bool fCancelled;
892} SHCLTRANSFERTHREAD;
893/** Pointer to a Shared Clipboard transfer thread. */
894typedef SHCLTRANSFERTHREAD *PSHCLTRANSFERTHREAD;
895
896/**
897 * A single Shared Clipboard transfer.
898 *
899 ** @todo Not yet thread safe.
900 */
901typedef struct SHCLTRANSFER
902{
903 /** The node member for using this struct in a RTList. */
904 RTLISTNODE Node;
905 /** Critical section for serializing access. */
906 RTCRITSECT CritSect;
907 /** Number of references to this transfer. */
908 uint32_t cRefs;
909 /** The transfer's state (for SSM, later). */
910 SHCLTRANSFERSTATE State;
911 /** Absolute path to root entries. */
912 char *pszPathRootAbs;
913 /** Timeout (in ms) for waiting of events. */
914 RTMSINTERVAL uTimeoutMs;
915 /** Maximum data chunk size (in bytes) to transfer. Default is 64K. */
916 uint32_t cbMaxChunkSize;
917 /** Status change event. */
918 RTSEMEVENT StatusChangeEvent;
919 /** The transfer's own event source. */
920 SHCLEVENTSOURCE Events;
921 /** Current number of concurrent list handles in \a lstHandles. */
922 uint32_t cListHandles;
923 /** Maximum number of concurrent list handles allowed. */
924 uint32_t cMaxListHandles;
925 /** Next upcoming list handle. For book keeping. */
926 SHCLLISTHANDLE uListHandleNext;
927 /** List of all list handles related to this transfer. */
928 RTLISTANCHOR lstHandles;
929 /** List of root entries of this transfer. */
930 SHCLLIST lstRoots;
931 /** Current number of concurrent object handles. in \a lstObj. */
932 uint32_t cObjHandles;
933 /** Maximum number of concurrent object handles. */
934 uint32_t cMaxObjHandles;
935 /** Next upcoming object handle. For book keeping. */
936 SHCLOBJHANDLE uObjHandleNext;
937 /** Map of all objects handles related to this transfer. */
938 RTLISTANCHOR lstObj;
939 /** The transfer's own provider context. */
940 SHCLTXPROVIDERCTX ProviderCtx;
941 /** The transfer's provider interface. */
942 SHCLTXPROVIDERIFACE ProviderIface;
943 /** The transfer's callback context. */
944 SHCLTRANSFERCALLBACKCTX CallbackCtx;
945 /** The transfer's callback table. */
946 SHCLTRANSFERCALLBACKS Callbacks;
947 /** Opaque pointer to implementation-specific parameters. */
948 void *pvUser;
949 /** Size (in bytes) of implementation-specific parameters. */
950 size_t cbUser;
951 /** Contains thread-related attributes. */
952 SHCLTRANSFERTHREAD Thread;
953} SHCLTRANSFER;
954/** Pointer to a Shared Clipboard transfer. */
955typedef SHCLTRANSFER *PSHCLTRANSFER;
956
957/**
958 * Structure for keeping an Shared Clipboard transfer status report.
959 */
960typedef struct _SHCLTRANSFERREPORT
961{
962 /** Actual status to report. */
963 SHCLTRANSFERSTATUS uStatus;
964 /** Result code (rc) to report; might be unused / invalid, based on enmStatus. */
965 int rc;
966 /** Reporting flags. Currently unused and must be 0. */
967 uint32_t fFlags;
968} SHCLTRANSFERREPORT;
969/** Pointer to Shared Clipboard transfer status. */
970typedef SHCLTRANSFERREPORT *PSHCLTRANSFERREPORT;
971
972#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS_HTTP
973/**
974 * Enumeration for HTTP server status changes.
975 *
976 * Keep those as flags, so that we can wait for multiple statuses, if ever needed.
977 */
978typedef enum _SHCLHTTPSERVERSTATUS
979{
980 /** No status set yet. */
981 SHCLHTTPSERVERSTATUS_NONE = 0x0,
982 /** A new transfer got registered. */
983 SHCLHTTPSERVERSTATUS_STARTED = 0x1,
984 /** A new transfer got registered. */
985 SHCLHTTPSERVERSTATUS_STOPPED = 0x2,
986 /** A new transfer got registered. */
987 SHCLHTTPSERVERSTATUS_TRANSFER_REGISTERED = 0x4,
988 /** A transfer got unregistered. */
989 SHCLHTTPSERVERSTATUS_TRANSFER_UNREGISTERED = 0x8
990} SHCLHTTPSERVERSTATUS;
991
992/**
993 * Structure for keeping a Shared Clipboard HTTP server instance.
994 */
995typedef struct _SHCLHTTPSERVER
996{
997 /** Critical section for serializing access. */
998 RTCRITSECT CritSect;
999 /** Status event for callers to wait for.
1000 * Updates \a enmStatus. */
1001 RTSEMEVENT StatusEvent;
1002 /** Initialized indicator. */
1003 bool fInitialized;
1004 /** Running indicator. */
1005 bool fRunning;
1006 /** Current status. */
1007 SHCLHTTPSERVERSTATUS enmStatus;
1008 /** Handle of the HTTP server instance. */
1009 RTHTTPSERVER hHTTPServer;
1010 /** Port number the HTTP server is running on. 0 if not running. */
1011 uint16_t uPort;
1012 /** List of registered HTTP transfers. */
1013 RTLISTANCHOR lstTransfers;
1014 /** Number of registered HTTP transfers. */
1015 uint32_t cTransfers;
1016 /** Number of files served (via GET) so far.
1017 * Only complete downloads count (i.e. no aborted). */
1018 uint32_t cDownloaded;
1019 /** Cached response data. */
1020 RTHTTPSERVERRESP Resp;
1021} SHCLHTTPSERVER;
1022/** Pointer to Shared Clipboard HTTP server. */
1023typedef SHCLHTTPSERVER *PSHCLHTTPSERVER;
1024
1025/**
1026 * Structure for keeping a Shared Clipboard HTTP context around.
1027 *
1028 * This contains the HTTP server instance, among other things.
1029 */
1030typedef struct _SHCLHTTPCONTEXT
1031{
1032 /** HTTP server instance data. */
1033 SHCLHTTPSERVER HttpServer;
1034} SHCLHTTPCONTEXT;
1035/** Pointer to Shared Clipboard HTTP transfer context. */
1036typedef SHCLHTTPCONTEXT *PSHCLHTTPCONTEXT;
1037
1038#endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS_HTTP */
1039
1040/**
1041 * Structure for keeping a single transfer context event.
1042 */
1043typedef struct _SHCLTRANSFERCTXEVENT
1044{
1045 /** Transfer bound to this event.
1046 * Can be NULL if not being used. */
1047 PSHCLTRANSFER pTransfer;
1048 /** Whether a transfer was registered or not. */
1049 bool fRegistered;
1050} SHCLTRANSFERCTXEVENT;
1051/** Pointer to Shared Clipboard transfer context event. */
1052typedef SHCLTRANSFERCTXEVENT *PSHCLTRANSFERCTXEVENT;
1053
1054/**
1055 * Structure for keeping Shared Clipboard transfer context around.
1056 *
1057 * A transfer context contains a list of (grouped) transfers for book keeping.
1058 */
1059typedef struct _SHCLTRANSFERCTX
1060{
1061 /** Critical section for serializing access. */
1062 RTCRITSECT CritSect;
1063 /** Event used for waiting. for transfer context changes. */
1064 RTSEMEVENT ChangedEvent;
1065 /** Event data for \a ChangedEvent. */
1066 SHCLTRANSFERCTXEVENT ChangedEventData;
1067 /** List of transfers. */
1068 RTLISTANCHOR List;
1069 /** Transfer ID allocation bitmap; clear bits are free, set bits are busy. */
1070 uint64_t bmTransferIds[VBOX_SHCL_MAX_TRANSFERS / sizeof(uint64_t) / 8];
1071 /** Number of running (concurrent) transfers. */
1072 uint16_t cRunning;
1073 /** Maximum Number of running (concurrent) transfers. */
1074 uint16_t cMaxRunning;
1075 /** Number of total transfers (in list). */
1076 uint16_t cTransfers;
1077} SHCLTRANSFERCTX;
1078/** Pointer to Shared Clipboard transfer context. */
1079typedef SHCLTRANSFERCTX *PSHCLTRANSFERCTX;
1080
1081/** @name Shared Clipboard transfer interface providers.
1082 * @{
1083 */
1084PSHCLTXPROVIDERIFACE ShClTransferProviderLocalQueryInterface(PSHCLTXPROVIDER pProvider);
1085/** @} */
1086
1087/** @name Shared Clipboard transfer object API.
1088 * @{
1089 */
1090int ShClTransferObjCtxInit(PSHCLCLIENTTRANSFEROBJCTX pObjCtx);
1091void ShClTransferObjCtxDestroy(PSHCLCLIENTTRANSFEROBJCTX pObjCtx);
1092bool ShClTransferObjCtxIsValid(PSHCLCLIENTTRANSFEROBJCTX pObjCtx);
1093
1094int ShClTransferObjInit(PSHCLTRANSFEROBJ pObj);
1095void ShClTransferObjDestroy(PSHCLTRANSFEROBJ pObj);
1096
1097int ShClTransferObjOpenParmsInit(PSHCLOBJOPENCREATEPARMS pParms);
1098int ShClTransferObjOpenParmsCopy(PSHCLOBJOPENCREATEPARMS pParmsDst, PSHCLOBJOPENCREATEPARMS pParmsSrc);
1099void ShClTransferObjOpenParmsDestroy(PSHCLOBJOPENCREATEPARMS pParms);
1100
1101int ShClTransferObjOpen(PSHCLTRANSFER pTransfer, PSHCLOBJOPENCREATEPARMS pOpenCreateParms, PSHCLOBJHANDLE phObj);
1102int ShClTransferObjClose(PSHCLTRANSFER pTransfer, SHCLOBJHANDLE hObj);
1103bool ShClTransferObjIsComplete(PSHCLTRANSFER pTransfer, SHCLOBJHANDLE hObj);
1104int ShClTransferObjRead(PSHCLTRANSFER pTransfer, SHCLOBJHANDLE hObj, void *pvBuf, uint32_t cbBuf, uint32_t fFlags, uint32_t *pcbRead);
1105int ShClTransferObjWrite(PSHCLTRANSFER pTransfer, SHCLOBJHANDLE hObj, void *pvBuf, uint32_t cbBuf, uint32_t fFlags, uint32_t *pcbWritten);
1106PSHCLTRANSFEROBJ ShClTransferObjGet(PSHCLTRANSFER pTransfer, SHCLOBJHANDLE hObj);
1107
1108PSHCLOBJDATACHUNK ShClTransferObjDataChunkDup(PSHCLOBJDATACHUNK pDataChunk);
1109void ShClTransferObjDataChunkDestroy(PSHCLOBJDATACHUNK pDataChunk);
1110void ShClTransferObjDataChunkFree(PSHCLOBJDATACHUNK pDataChunk);
1111/** @} */
1112
1113/** @name Shared Clipboard transfer API.
1114 * @{
1115 */
1116int ShClTransferCreateEx(SHCLTRANSFERDIR enmDir, SHCLSOURCE enmSource, uint32_t cbMaxChunkSize, uint32_t cMaxListHandles, uint32_t cMaxObjHandles, PSHCLTRANSFER *ppTransfer);
1117int ShClTransferCreate(SHCLTRANSFERDIR enmDir, SHCLSOURCE enmSource, PSHCLTRANSFERCALLBACKS pCallbacks, PSHCLTRANSFER *ppTransfer);
1118int ShClTransferInit(PSHCLTRANSFER pTransfer);
1119int ShClTransferDestroy(PSHCLTRANSFER pTransfer);
1120void ShClTransferReset(PSHCLTRANSFER pTransfer);
1121
1122int ShClTransferRun(PSHCLTRANSFER pTransfer, PFNRTTHREAD pfnThreadFunc, void *pvUser);
1123int ShClTransferStart(PSHCLTRANSFER pTransfer);
1124
1125uint32_t ShClTransferAcquire(PSHCLTRANSFER pTransfer);
1126uint32_t ShClTransferRelease(PSHCLTRANSFER pTransfer);
1127
1128SHCLTRANSFERID ShClTransferGetID(PSHCLTRANSFER pTransfer);
1129SHCLTRANSFERDIR ShClTransferGetDir(PSHCLTRANSFER pTransfer);
1130int ShClTransferGetRootPathAbs(PSHCLTRANSFER pTransfer, char *pszPath, size_t cbPath);
1131SHCLSOURCE ShClTransferGetSource(PSHCLTRANSFER pTransfer);
1132SHCLTRANSFERSTATUS ShClTransferGetStatus(PSHCLTRANSFER pTransfer);
1133int ShClTransferWaitForStatus(PSHCLTRANSFER pTransfer, RTMSINTERVAL msTimeout, SHCLTRANSFERSTATUS enmStatus);
1134int ShClTransferWaitForStatusChange(PSHCLTRANSFER pTransfer, RTMSINTERVAL msTimeout, SHCLTRANSFERSTATUS *penmStatus);
1135
1136int ShClTransferListOpen(PSHCLTRANSFER pTransfer, PSHCLLISTOPENPARMS pOpenParms, PSHCLLISTHANDLE phList);
1137int ShClTransferListClose(PSHCLTRANSFER pTransfer, SHCLLISTHANDLE hList);
1138int ShClTransferListGetHeader(PSHCLTRANSFER pTransfer, SHCLLISTHANDLE hList, PSHCLLISTHDR pHdr);
1139PSHCLLISTHANDLEINFO ShClTransferListGetByHandle(PSHCLTRANSFER pTransfer, SHCLLISTHANDLE hList);
1140PSHCLTRANSFEROBJ ShClTransferListGetObj(PSHCLTRANSFER pTransfer, SHCLLISTHANDLE hList, uint64_t uIdx);
1141int ShClTransferListRead(PSHCLTRANSFER pTransfer, SHCLLISTHANDLE hList, PSHCLLISTENTRY pEntry);
1142int ShClTransferListWrite(PSHCLTRANSFER pTransfer, SHCLLISTHANDLE hList, PSHCLLISTENTRY pEntry);
1143bool ShClTransferListHandleIsValid(PSHCLTRANSFER pTransfer, SHCLLISTHANDLE hList);
1144
1145PSHCLLIST ShClTransferListAlloc(void);
1146void ShClTransferListFree(PSHCLLIST pList);
1147void ShClTransferListInit(PSHCLLIST pList);
1148void ShClTransferListDestroy(PSHCLLIST pList);
1149int ShClTransferListAddEntry(PSHCLLIST pList, PSHCLLISTENTRY pEntry, bool fAppend);
1150
1151int ShClTransferListHandleInfoInit(PSHCLLISTHANDLEINFO pInfo);
1152void ShClTransferListHandleInfoDestroy(PSHCLLISTHANDLEINFO pInfo);
1153
1154int ShClTransferListHdrAlloc(PSHCLLISTHDR *ppListHdr);
1155void ShClTransferListHdrFree(PSHCLLISTHDR pListHdr);
1156PSHCLLISTHDR ShClTransferListHdrDup(PSHCLLISTHDR pListHdr);
1157int ShClTransferListHdrInit(PSHCLLISTHDR pListHdr);
1158void ShClTransferListHdrDestroy(PSHCLLISTHDR pListHdr);
1159void ShClTransferListHdrReset(PSHCLLISTHDR pListHdr);
1160bool ShClTransferListHdrIsValid(PSHCLLISTHDR pListHdr);
1161
1162int ShClTransferListOpenParmsCopy(PSHCLLISTOPENPARMS pDst, PSHCLLISTOPENPARMS pSrc);
1163PSHCLLISTOPENPARMS ShClTransferListOpenParmsDup(PSHCLLISTOPENPARMS pParms);
1164int ShClTransferListOpenParmsInit(PSHCLLISTOPENPARMS pParms);
1165void ShClTransferListOpenParmsDestroy(PSHCLLISTOPENPARMS pParms);
1166
1167int ShClTransferListEntryAlloc(PSHCLLISTENTRY *ppListEntry);
1168void ShClTransferListEntryFree(PSHCLLISTENTRY pListEntry);
1169int ShClTransferListEntryInitEx(PSHCLLISTENTRY pListEntry, uint32_t fInfo, const char *pszName, void *pvInfo, uint32_t cbInfo);
1170int ShClTransferListEntryInit(PSHCLLISTENTRY pListEntry);
1171void ShClTransferListEntryDestroy(PSHCLLISTENTRY pListEntry);
1172bool ShClTransferListEntryIsValid(PSHCLLISTENTRY pListEntry);
1173int ShClTransferListEntryCopy(PSHCLLISTENTRY pDst, PSHCLLISTENTRY pSrc);
1174PSHCLLISTENTRY ShClTransferListEntryDup(PSHCLLISTENTRY pListEntry);
1175
1176int ShClTransferSetProvider(PSHCLTRANSFER pTransfer, PSHCLTXPROVIDER pProvider);
1177
1178int ShClTransferRootsInitFromStringList(PSHCLTRANSFER pTransfer, const char *pszRoots, size_t cbRoots);
1179int ShClTransferRootsInitFromStringListUnicode(PSHCLTRANSFER pTransfer, PRTUTF16 pwszRoots, size_t cbRoots);
1180int ShClTransferRootsInitFromFile(PSHCLTRANSFER pTransfer, const char *pszFile);
1181uint64_t ShClTransferRootsCount(PSHCLTRANSFER pTransfer);
1182PCSHCLLISTENTRY ShClTransferRootsEntryGet(PSHCLTRANSFER pTransfer, uint64_t uIndex);
1183int ShClTransferRootListRead(PSHCLTRANSFER pTransfer);
1184/** @} */
1185
1186/** @name Shared Clipboard transfer context API.
1187 * @{
1188 */
1189int ShClTransferCtxInit(PSHCLTRANSFERCTX pTransferCtx);
1190void ShClTransferCtxDestroy(PSHCLTRANSFERCTX pTransferCtx);
1191void ShClTransferCtxReset(PSHCLTRANSFERCTX pTransferCtx);
1192PSHCLTRANSFER ShClTransferCtxGetTransferById(PSHCLTRANSFERCTX pTransferCtx, uint32_t uID);
1193PSHCLTRANSFER ShClTransferCtxGetTransferByIndex(PSHCLTRANSFERCTX pTransferCtx, uint32_t uIdx);
1194PSHCLTRANSFER ShClTransferCtxGetTransferLast(PSHCLTRANSFERCTX pTransferCtx);
1195uint32_t ShClTransferCtxGetRunningTransfers(PSHCLTRANSFERCTX pTransferCtx);
1196uint32_t ShClTransferCtxGetTotalTransfers(PSHCLTRANSFERCTX pTransferCtx);
1197void ShClTransferCtxCleanup(PSHCLTRANSFERCTX pTransferCtx);
1198bool ShClTransferCtxIsMaximumReached(PSHCLTRANSFERCTX pTransferCtx);
1199int ShClTransferCtxCreateId(PSHCLTRANSFERCTX pTransferCtx, PSHCLTRANSFERID pidTransfer);
1200int ShClTransferCtxRegister(PSHCLTRANSFERCTX pTransferCtx, PSHCLTRANSFER pTransfer, PSHCLTRANSFERID pidTransfer);
1201int ShClTransferCtxRegisterById(PSHCLTRANSFERCTX pTransferCtx, PSHCLTRANSFER pTransfer, SHCLTRANSFERID idTransfer);
1202int ShClTransferCtxUnregisterById(PSHCLTRANSFERCTX pTransferCtx, SHCLTRANSFERID idTransfer);
1203int ShClTransferCtxWait(PSHCLTRANSFERCTX pTransferCtx, RTMSINTERVAL msTimeout, bool fRegister, SHCLTRANSFERID idTransfer, PSHCLTRANSFER *ppTransfer);
1204/** @} */
1205
1206#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS_HTTP
1207/** Namespace used as a prefix for HTTP(S) transfer URLs. */
1208#define SHCL_HTTPT_URL_NAMESPACE "vbcl"
1209
1210/** @name Shared Clipboard HTTP context API.
1211 * @{
1212 */
1213int ShClTransferHttpServerMaybeStart(PSHCLHTTPCONTEXT pCtx);
1214int ShClTransferHttpServerMaybeStop(PSHCLHTTPCONTEXT pCtx);
1215/** @} */
1216
1217/** @name Shared Clipboard HTTP server API.
1218 * @{
1219 */
1220int ShClTransferHttpServerInit(PSHCLHTTPSERVER pSrv);
1221int ShClTransferHttpServerDestroy(PSHCLHTTPSERVER pSrv);
1222int ShClTransferHttpServerStart(PSHCLHTTPSERVER pSrv, unsigned cMaxAttempts, uint16_t *puPort);
1223int ShClTransferHttpServerStartEx(PSHCLHTTPSERVER pSrv, uint16_t uPort);
1224int ShClTransferHttpServerStop(PSHCLHTTPSERVER pSrv);
1225int ShClTransferHttpServerRegisterTransfer(PSHCLHTTPSERVER pSrv, PSHCLTRANSFER pTransfer);
1226int ShClTransferHttpServerUnregisterTransfer(PSHCLHTTPSERVER pSrv, PSHCLTRANSFER pTransfer);
1227PSHCLTRANSFER ShClTransferHttpServerGetTransferFirst(PSHCLHTTPSERVER pSrv);
1228PSHCLTRANSFER ShClTransferHttpServerGetTransferLast(PSHCLHTTPSERVER pSrv);
1229bool ShClTransferHttpServerGetTransfer(PSHCLHTTPSERVER pSrv, SHCLTRANSFERID idTransfer);
1230uint16_t ShClTransferHttpServerGetPort(PSHCLHTTPSERVER pSrv);
1231uint32_t ShClTransferHttpServerGetTransferCount(PSHCLHTTPSERVER pSrv);
1232char *ShClTransferHttpServerGetAddressA(PSHCLHTTPSERVER pSrv);
1233char *ShClTransferHttpServerGetUrlA(PSHCLHTTPSERVER pSrv, SHCLTRANSFERID idTransfer);
1234bool ShClTransferHttpServerIsInitialized(PSHCLHTTPSERVER pSrv);
1235bool ShClTransferHttpServerIsRunning(PSHCLHTTPSERVER pSrv);
1236int ShClTransferHttpServerWaitForStatusChange(PSHCLHTTPSERVER pSrv, SHCLHTTPSERVERSTATUS fStatus, RTMSINTERVAL msTimeout);
1237/** @} */
1238#endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS_HTTP */
1239
1240/** @name Shared Clipboard transfers utility functions.
1241 * @{
1242 */
1243int ShClPathSanitizeFilename(char *pszPath, size_t cbPath);
1244int ShClPathSanitize(char *pszPath, size_t cbPath);
1245const char *ShClTransferStatusToStr(SHCLTRANSFERSTATUS enmStatus);
1246int ShClTransferValidatePath(const char *pcszPath, bool fMustExist);
1247int ShClTransferResolvePathAbs(PSHCLTRANSFER pTransfer, const char *pszPath, uint32_t fFlags, char **ppszResolved);
1248int ShClTransferConvertFileCreateFlags(uint32_t fShClFlags, uint64_t *pfOpen);
1249int ShClFsObjInfoQueryLocal(const char *pszPath, PSHCLFSOBJINFO pObjInfo);
1250int ShClFsObjInfoFromIPRT(PSHCLFSOBJINFO pDst, PCRTFSOBJINFO pSrc);
1251/** @} */
1252
1253/** @name Shared Clipboard MIME functions.
1254 * @{
1255 */
1256bool ShClMIMEHasFileURLs(const char *pcszFormat, size_t cchFormatMax);
1257bool ShClMIMENeedsCache(const char *pcszFormat, size_t cchFormatMax);
1258/** @} */
1259
1260#endif /* !VBOX_INCLUDED_GuestHost_SharedClipboard_transfers_h */
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