VirtualBox

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

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

Shared Clipboard/URI: Update.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 37.1 KB
Line 
1/* $Id: SharedClipboard-uri.h 79267 2019-06-21 10:11:59Z vboxsync $ */
2/** @file
3 * Shared Clipboard - Shared URI functions between host and guest.
4 */
5
6/*
7 * Copyright (C) 2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef VBOX_INCLUDED_GuestHost_SharedClipboard_uri_h
28#define VBOX_INCLUDED_GuestHost_SharedClipboard_uri_h
29#ifndef RT_WITHOUT_PRAGMA_ONCE
30# pragma once
31#endif
32
33#include <map>
34
35#include <iprt/assert.h>
36#include <iprt/critsect.h>
37#include <iprt/fs.h>
38#include <iprt/list.h>
39
40#include <iprt/cpp/list.h>
41#include <iprt/cpp/ministring.h>
42
43#include <VBox/HostServices/VBoxClipboardSvc.h>
44
45/** Clipboard area ID. A valid area is >= 1.
46 * If 0 is specified, the last (most recent) area is meant.
47 * Set to UINT32_MAX if not initialized. */
48typedef uint32_t SHAREDCLIPBOARDAREAID;
49
50/** Defines a non-initialized (nil) clipboard area. */
51#define NIL_SHAREDCLIPBOARDAREAID UINT32_MAX
52
53/** SharedClipboardArea open flags. */
54typedef uint32_t SHAREDCLIPBOARDAREAOPENFLAGS;
55
56/** No clipboard area open flags specified. */
57#define SHAREDCLIPBOARDAREA_OPEN_FLAGS_NONE 0
58/** The clipboard area must not exist yet. */
59#define SHAREDCLIPBOARDAREA_OPEN_FLAGS_MUST_NOT_EXIST RT_BIT(0)
60/** Mask of all valid clipboard area open flags. */
61#define SHAREDCLIPBOARDAREA_OPEN_FLAGS_VALID_MASK 0x1
62
63/**
64 * Class for maintaining a Shared Clipboard area
65 * on the host or guest. This will contain all received files & directories
66 * for a single Shared Clipboard operation.
67 *
68 * In case of a failed Shared Clipboard operation this class can also
69 * perform a gentle rollback if required.
70 */
71class SharedClipboardArea
72{
73public:
74
75 SharedClipboardArea(void);
76 SharedClipboardArea(const char *pszPath, SHAREDCLIPBOARDAREAID uID = NIL_SHAREDCLIPBOARDAREAID,
77 SHAREDCLIPBOARDAREAOPENFLAGS fFlags = SHAREDCLIPBOARDAREA_OPEN_FLAGS_NONE);
78 virtual ~SharedClipboardArea(void);
79
80public:
81
82 uint32_t AddRef(void);
83 uint32_t Release(void);
84
85 int Lock(void);
86 int Unlock(void);
87
88 int AddFile(const char *pszFile);
89 int AddDir(const char *pszDir);
90 int Close(void);
91 bool IsOpen(void) const;
92 int OpenEx(const char *pszPath, SHAREDCLIPBOARDAREAID uID = NIL_SHAREDCLIPBOARDAREAID,
93 SHAREDCLIPBOARDAREAOPENFLAGS fFlags = SHAREDCLIPBOARDAREA_OPEN_FLAGS_NONE);
94 int OpenTemp(SHAREDCLIPBOARDAREAID uID = NIL_SHAREDCLIPBOARDAREAID,
95 SHAREDCLIPBOARDAREAOPENFLAGS fFlags = SHAREDCLIPBOARDAREA_OPEN_FLAGS_NONE);
96 SHAREDCLIPBOARDAREAID GetID(void) const;
97 const char *GetDirAbs(void) const;
98 uint32_t GetRefCount(void);
99 int Reopen(void);
100 int Reset(bool fDeleteContent);
101 int Rollback(void);
102
103public:
104
105 static int PathConstruct(const char *pszBase, SHAREDCLIPBOARDAREAID uID, char *pszPath, size_t cbPath);
106
107protected:
108
109 int initInternal(void);
110 int destroyInternal(void);
111 int closeInternal(void);
112
113protected:
114
115 /** Creation timestamp (in ms). */
116 uint64_t m_tsCreatedMs;
117 /** Number of references to this instance. */
118 volatile uint32_t m_cRefs;
119 /** Critical section for serializing access. */
120 RTCRITSECT m_CritSect;
121 /** Open flags. */
122 uint32_t m_fOpen;
123 /** Directory handle for drop directory. */
124 RTDIR m_hDir;
125 /** Absolute path to drop directory. */
126 RTCString m_strPathAbs;
127 /** List for holding created directories in the case of a rollback. */
128 RTCList<RTCString> m_lstDirs;
129 /** List for holding created files in the case of a rollback. */
130 RTCList<RTCString> m_lstFiles;
131 /** Associated clipboard area ID. */
132 SHAREDCLIPBOARDAREAID m_uID;
133};
134
135int SharedClipboardPathSanitizeFilename(char *pszPath, size_t cbPath);
136int SharedClipboardPathSanitize(char *pszPath, size_t cbPath);
137
138/** SharedClipboardURIObject flags. */
139typedef uint32_t SHAREDCLIPBOARDURIOBJECTFLAGS;
140
141/** No flags specified. */
142#define SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE 0
143
144/** Mask of all valid Shared Clipboard URI object flags. */
145#define SHAREDCLIPBOARDURIOBJECT_FLAGS_VALID_MASK UINT32_C(0x0)
146
147/**
148 * Class for handling Shared Clipboard URI objects.
149 * This class abstracts the access and handling objects when performing Shared Clipboard actions.
150 */
151class SharedClipboardURIObject
152{
153public:
154
155 /**
156 * Enumeration for specifying an URI object type.
157 */
158 enum Type
159 {
160 /** Unknown type, do not use. */
161 Type_Unknown = 0,
162 /** Object is a file. */
163 Type_File,
164 /** Object is a directory. */
165 Type_Directory,
166 /** The usual 32-bit hack. */
167 Type_32Bit_Hack = 0x7fffffff
168 };
169
170 /**
171 * Enumeration for specifying an URI object view
172 * for representing its data accordingly.
173 */
174 enum View
175 {
176 /** Unknown view, do not use. */
177 View_Unknown = 0,
178 /** Handle data from the source point of view. */
179 View_Source,
180 /** Handle data from the destination point of view. */
181 View_Target,
182 /** The usual 32-bit hack. */
183 View_Dest_32Bit_Hack = 0x7fffffff
184 };
185
186 SharedClipboardURIObject(void);
187 SharedClipboardURIObject(Type type, const RTCString &strSrcPathAbs = "", const RTCString &strDstPathAbs = "");
188 virtual ~SharedClipboardURIObject(void);
189
190public:
191
192 /**
193 * Returns the given absolute source path of the object.
194 *
195 * @return Absolute source path of the object.
196 */
197 const RTCString &GetSourcePathAbs(void) const { return m_strSrcPathAbs; }
198
199 /**
200 * Returns the given, absolute destination path of the object.
201 *
202 * @return Absolute destination path of the object.
203 */
204 const RTCString &GetDestPathAbs(void) const { return m_strTgtPathAbs; }
205
206 RTFMODE GetMode(void) const;
207
208 uint64_t GetProcessed(void) const;
209
210 uint64_t GetSize(void) const;
211
212 /**
213 * Returns the object's type.
214 *
215 * @return The object's type.
216 */
217 Type GetType(void) const { return m_enmType; }
218
219 /**
220 * Returns the object's view.
221 *
222 * @return The object's view.
223 */
224 View GetView(void) const { return m_enmView; }
225
226public:
227
228 int SetSize(uint64_t cbSize);
229
230public:
231
232 void Close(void);
233 bool IsComplete(void) const;
234 bool IsOpen(void) const;
235 int OpenDirectory(View enmView, uint32_t fCreate = 0, RTFMODE fMode = 0);
236 int OpenDirectoryEx(const RTCString &strPathAbs, View enmView,
237 uint32_t fCreate = 0, RTFMODE fMode = 0,
238 SHAREDCLIPBOARDURIOBJECTFLAGS fFlags = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE);
239 int OpenFile(View enmView, uint64_t fOpen = 0, RTFMODE fMode = 0);
240 int OpenFileEx(const RTCString &strPathAbs, View enmView,
241 uint64_t fOpen = 0, RTFMODE fMode = 0,
242 SHAREDCLIPBOARDURIOBJECTFLAGS fFlags = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE);
243 int QueryInfo(View enmView);
244 int Read(void *pvBuf, size_t cbBuf, uint32_t *pcbRead);
245 void Reset(void);
246 int SetDirectoryData(const RTCString &strPathAbs, View enmView, uint32_t fOpen = 0, RTFMODE fMode = 0,
247 SHAREDCLIPBOARDURIOBJECTFLAGS fFlags = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE);
248 int SetFileData(const RTCString &strPathAbs, View enmView, uint64_t fOpen = 0, RTFMODE fMode = 0,
249 SHAREDCLIPBOARDURIOBJECTFLAGS fFlags = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE);
250 int Write(const void *pvBuf, size_t cbBuf, uint32_t *pcbWritten);
251
252public:
253
254 static int RebaseURIPath(RTCString &strPath, const RTCString &strBaseOld = "", const RTCString &strBaseNew = "");
255
256protected:
257
258 void closeInternal(void);
259 int setDirectoryDataInternal(const RTCString &strPathAbs, View enmView, uint32_t fCreate = 0, RTFMODE fMode = 0,
260 SHAREDCLIPBOARDURIOBJECTFLAGS fFlags = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE);
261 int setFileDataInternal(const RTCString &strPathAbs, View enmView, uint64_t fOpen = 0, RTFMODE fMode = 0,
262 SHAREDCLIPBOARDURIOBJECTFLAGS fFlags = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE);
263 int queryInfoInternal(View enmView);
264
265protected:
266
267 /** The object's type. */
268 Type m_enmType;
269 /** The object's view. */
270 View m_enmView;
271 /** Absolute path (base) for the source. */
272 RTCString m_strSrcPathAbs;
273 /** Absolute path (base) for the target. */
274 RTCString m_strTgtPathAbs;
275 /** Saved SHAREDCLIPBOARDURIOBJECT_FLAGS. */
276 uint32_t m_fFlags;
277 /** Requested file mode.
278 * Note: The actual file mode of an opened file will be in objInfo. */
279 RTFMODE m_fModeRequested;
280
281 /** Union containing data depending on the object's type. */
282 union
283 {
284 /** Structure containing members for objects that
285 * are files. */
286 struct
287 {
288 /** File handle. */
289 RTFILE hFile;
290 /** File system object information of this file. */
291 RTFSOBJINFO objInfo;
292 /** Requested file open flags. */
293 uint32_t fOpenRequested;
294 /** Bytes to proces for reading/writing. */
295 uint64_t cbToProcess;
296 /** Bytes processed reading/writing. */
297 uint64_t cbProcessed;
298 } File;
299 struct
300 {
301 /** Directory handle. */
302 RTDIR hDir;
303 /** File system object information of this directory. */
304 RTFSOBJINFO objInfo;
305 /** Requested directory creation flags. */
306 uint32_t fCreateRequested;
307 } Dir;
308 } u;
309};
310
311/** SharedClipboardURIList flags. */
312typedef uint32_t SHAREDCLIPBOARDURILISTFLAGS;
313
314/** No flags specified. */
315#define SHAREDCLIPBOARDURILIST_FLAGS_NONE 0
316/** Keep the original paths, don't convert paths to relative ones. */
317#define SHAREDCLIPBOARDURILIST_FLAGS_ABSOLUTE_PATHS RT_BIT(0)
318/** Resolve all symlinks. */
319#define SHAREDCLIPBOARDURILIST_FLAGS_RESOLVE_SYMLINKS RT_BIT(1)
320/** Keep the files + directory entries open while
321 * being in this list. */
322#define SHAREDCLIPBOARDURILIST_FLAGS_KEEP_OPEN RT_BIT(2)
323/** Lazy loading: Only enumerate sub directories when needed.
324 ** @todo Implement lazy loading. */
325#define SHAREDCLIPBOARDURILIST_FLAGS_LAZY RT_BIT(3)
326
327/** Mask of all valid Shared Clipboard URI list flags. */
328#define SHAREDCLIPBOARDURILIST_FLAGS_VALID_MASK UINT32_C(0xF)
329
330class SharedClipboardURIList
331{
332public:
333
334 SharedClipboardURIList(void);
335 virtual ~SharedClipboardURIList(void);
336
337public:
338
339 int AppendNativePath(const char *pszPath, SHAREDCLIPBOARDURILISTFLAGS fFlags);
340 int AppendNativePathsFromList(const char *pszNativePaths, size_t cbNativePaths, SHAREDCLIPBOARDURILISTFLAGS fFlags);
341 int AppendNativePathsFromList(const RTCList<RTCString> &lstNativePaths, SHAREDCLIPBOARDURILISTFLAGS fFlags);
342 int AppendURIObject(SharedClipboardURIObject *pObject);
343 int AppendURIPath(const char *pszURI, SHAREDCLIPBOARDURILISTFLAGS fFlags);
344 int AppendURIPathsFromList(const char *pszURIPaths, size_t cbURIPaths, SHAREDCLIPBOARDURILISTFLAGS fFlags);
345 int AppendURIPathsFromList(const RTCList<RTCString> &lstURI, SHAREDCLIPBOARDURILISTFLAGS fFlags);
346
347 void Clear(void);
348 SharedClipboardURIObject *At(size_t i) const { return m_lstTree.at(i); }
349 SharedClipboardURIObject *First(void) const { return m_lstTree.first(); }
350 bool IsEmpty(void) const { return m_lstTree.isEmpty(); }
351 void RemoveFirst(void);
352 int SetFromURIData(const void *pvData, size_t cbData, SHAREDCLIPBOARDURILISTFLAGS fFlags);
353
354 RTCString GetRootEntries(const RTCString &strPathBase = "", const RTCString &strSeparator = "\r\n") const;
355 uint64_t GetRootCount(void) const { return m_lstRoot.size(); }
356 uint64_t GetTotalCount(void) const { return m_cTotal; }
357 uint64_t GetTotalBytes(void) const { return m_cbTotal; }
358
359protected:
360
361 int appendEntry(const char *pcszSource, const char *pcszTarget, SHAREDCLIPBOARDURILISTFLAGS fFlags);
362 int appendObject(SharedClipboardURIObject *pObject);
363 int appendPathRecursive(const char *pcszSrcPath, const char *pcszDstPath, const char *pcszDstBase, size_t cchDstBase, SHAREDCLIPBOARDURILISTFLAGS fFlags);
364
365protected:
366
367 /** List of all top-level file/directory entries.
368 * Note: All paths are kept internally as UNIX paths for
369 * easier conversion/handling! */
370 RTCList<RTCString> m_lstRoot;
371 /** List of all URI objects added. The list's content
372 * might vary depending on how the objects are being
373 * added (lazy or not). */
374 RTCList<SharedClipboardURIObject *> m_lstTree;
375 /** Total number of all URI objects. */
376 uint64_t m_cTotal;
377 /** Total size of all URI objects, that is, the file
378 * size of all objects (in bytes).
379 * Note: Do *not* size_t here, as we also want to support large files
380 * on 32-bit guests. */
381 uint64_t m_cbTotal;
382};
383
384int SharedClipboardURIDataHdrAlloc(PVBOXCLIPBOARDDATAHDR *ppDataHdr);
385void SharedClipboardURIDataHdrFree(PVBOXCLIPBOARDDATAHDR pDataHdr);
386PVBOXCLIPBOARDDATAHDR SharedClipboardURIDataHdrDup(PVBOXCLIPBOARDDATAHDR pDataHdr);
387uint32_t SharedClipboardURIDataHdrGetMetaDataSize(PVBOXCLIPBOARDDATAHDR pDataHdr);
388int SharedClipboardURIDataHdrInit(PVBOXCLIPBOARDDATAHDR pDataHdr);
389void SharedClipboardURIDataHdrDestroy(PVBOXCLIPBOARDDATAHDR pDataHdr);
390void SharedClipboardURIDataHdrFree(PVBOXCLIPBOARDDATAHDR pDataHdr);
391void SharedClipboardURIDataHdrReset(PVBOXCLIPBOARDDATAHDR pDataHdr);
392bool SharedClipboardURIDataHdrIsValid(PVBOXCLIPBOARDDATAHDR pDataHdr);
393
394int SharedClipboardURIDataChunkAlloc(PVBOXCLIPBOARDDATACHUNK *ppDataChunk);
395void SharedClipboardURIDataChunkFree(PVBOXCLIPBOARDDATACHUNK pDataChunk);
396PVBOXCLIPBOARDDATACHUNK SharedClipboardURIDataChunkDup(PVBOXCLIPBOARDDATACHUNK pDataChunk);
397int SharedClipboardURIDataChunkInit(PVBOXCLIPBOARDDATACHUNK pDataChunk);
398void SharedClipboardURIDataChunkDestroy(PVBOXCLIPBOARDDATACHUNK pDataChunk);
399bool SharedClipboardURIDataChunkIsValid(PVBOXCLIPBOARDDATACHUNK pDataChunk);
400
401int SharedClipboardURIDirDataAlloc(PVBOXCLIPBOARDDIRDATA *ppDirData);
402void SharedClipboardURIDirDataFree(PVBOXCLIPBOARDDIRDATA pDirData);
403int SharedClipboardURIDirDataInit(PVBOXCLIPBOARDDIRDATA pDirData);
404void SharedClipboardURIDirDataDestroy(PVBOXCLIPBOARDDIRDATA pDirData);
405PVBOXCLIPBOARDDIRDATA SharedClipboardURIDirDataDup(PVBOXCLIPBOARDDIRDATA pDirData);
406bool SharedClipboardURIDirDataIsValid(PVBOXCLIPBOARDDIRDATA pDirData);
407
408int SharedClipboardURIFileHdrInit(PVBOXCLIPBOARDFILEHDR pFileHdr);
409void SharedClipboardURIFileHdrDestroy(PVBOXCLIPBOARDFILEHDR pFileHdr);
410PVBOXCLIPBOARDFILEHDR SharedClipboardURIFileHdrDup(PVBOXCLIPBOARDFILEHDR pFileHdr);
411bool SharedClipboardURIFileHdrIsValid(PVBOXCLIPBOARDFILEHDR pFileHdr, PVBOXCLIPBOARDDATAHDR pDataHdr);
412
413void SharedClipboardURIFileDataDestroy(PVBOXCLIPBOARDFILEDATA pFileData);
414PVBOXCLIPBOARDFILEDATA SharedClipboardURIFileDataDup(PVBOXCLIPBOARDFILEDATA pFileData);
415bool SharedClipboardURIFileDataIsValid(PVBOXCLIPBOARDFILEDATA pFileData, PVBOXCLIPBOARDDATAHDR pDataHdr);
416
417/** Specifies a meta data format. */
418typedef uint32_t SHAREDCLIPBOARDMETADATAFMT;
419
420/**
421 * Enumeration of meta data formats.
422 */
423typedef enum _SHAREDCLIPBOARDMETADATAFMTENUM
424{
425 /** Unknown meta data format; do not use. */
426 SHAREDCLIPBOARDMETADATAFMT_UNKNOWN = 0,
427 /** Meta data is an URI list.
428 * UTF-8 format with Unix path separators. Each URI entry is separated by "\r\n". */
429 SHAREDCLIPBOARDMETADATAFMT_URI_LIST = 1
430} SHAREDCLIPBOARDMETADATAFMTENUM;
431
432/**
433 * Structure for maintaining meta data format data.
434 */
435typedef struct _SHAREDCLIPBOARDMETADATAFMTDATA
436{
437 /** Meta data format version. */
438 uint32_t uVer;
439 /** Actual meta data format data. */
440 void *pvFmt;
441 /** Size of meta data format data (in bytes). */
442 uint32_t cbFmt;
443} SHAREDCLIPBOARDMETADATAFMTDATA, *PSHAREDCLIPBOARDMETADATAFMTDATA;
444
445/**
446 * Structure for keeping Shared Clipboard meta data.
447 * The actual format of the meta data depends on the format set in enmFmt.
448 */
449typedef struct _SHAREDCLIPBOARDMETADATA
450{
451 /** Format of the data. */
452 SHAREDCLIPBOARDMETADATAFMT enmFmt;
453 /** Actual meta data block. */
454 void *pvMeta;
455 /** Total size (in bytes) of the allocated meta data block .*/
456 uint32_t cbMeta;
457 /** How many bytes are being used in the meta data block. */
458 uint32_t cbUsed;
459} SHAREDCLIPBOARDMETADATA, *PSHAREDCLIPBOARDMETADATA;
460
461int SharedClipboardMetaDataInit(PSHAREDCLIPBOARDMETADATA pMeta, SHAREDCLIPBOARDMETADATAFMT enmFmt);
462void SharedClipboardMetaDataDestroy(PSHAREDCLIPBOARDMETADATA pMeta);
463int SharedClipboardMetaDataAdd(PSHAREDCLIPBOARDMETADATA pMeta, const void *pvDataAdd, uint32_t cbDataAdd);
464int SharedClipboardMetaDataConvertToFormat(const void *pvData, size_t cbData, SHAREDCLIPBOARDMETADATAFMT enmFmt,
465 void **ppvData, uint32_t *pcbData);
466int SharedClipboardMetaDataResize(PSHAREDCLIPBOARDMETADATA pMeta, uint32_t cbNewSize);
467size_t SharedClipboardMetaDataGetFree(PSHAREDCLIPBOARDMETADATA pMeta);
468size_t SharedClipboardMetaDataGetUsed(PSHAREDCLIPBOARDMETADATA pMeta);
469size_t SharedClipboardMetaDataGetSize(PSHAREDCLIPBOARDMETADATA pMeta);
470void *SharedClipboardMetaDataMutableRaw(PSHAREDCLIPBOARDMETADATA pMeta);
471const void *SharedClipboardMetaDataRaw(PSHAREDCLIPBOARDMETADATA pMeta);
472
473/**
474 * Enumeration specifying an URI transfer direction.
475 */
476typedef enum _SHAREDCLIPBOARDURITRANSFERDIR
477{
478 /** Unknown transfer directory. */
479 SHAREDCLIPBOARDURITRANSFERDIR_UNKNOWN = 0,
480 /** Read transfer (from source). */
481 SHAREDCLIPBOARDURITRANSFERDIR_READ,
482 /** Write transfer (to target). */
483 SHAREDCLIPBOARDURITRANSFERDIR_WRITE,
484 /** The usual 32-bit hack. */
485 SHAREDCLIPBOARDURITRANSFERDIR__32BIT_HACK = 0x7fffffff
486} SHAREDCLIPBOARDURITRANSFERDIR;
487
488/**
489 * Structure for maintaining an URI transfer state.
490 * Everything in here will be part of a saved state (later).
491 */
492typedef struct _SHAREDCLIPBOARDURITRANSFERSTATE
493{
494 /** The transfer's direction. */
495 SHAREDCLIPBOARDURITRANSFERDIR enmDir;
496 /** The transfer's cached data header.
497 * Can be NULL if no header has been received yet. */
498 PVBOXCLIPBOARDDATAHDR pHeader;
499 /** The transfer's cached meta data.
500 * Can be NULL if no meta data has been received yet. */
501 PSHAREDCLIPBOARDMETADATA pMeta;
502} SHAREDCLIPBOARDURITRANSFERSTATE, *PSHAREDCLIPBOARDURITRANSFERSTATE;
503
504/**
505 * Enumeration to specify the Shared Clipboard provider source type.
506 */
507typedef enum SHAREDCLIPBOARDPROVIDERSOURCE
508{
509 /** Invalid source type. */
510 SHAREDCLIPBOARDPROVIDERSOURCE_INVALID = 0,
511 /** Source is VbglR3. */
512 SHAREDCLIPBOARDPROVIDERSOURCE_VBGLR3,
513 /** Source is the host service. */
514 SHAREDCLIPBOARDPROVIDERSOURCE_HOSTSERVICE
515} SHAREDCLIPBOARDPROVIDERSOURCE;
516
517class SharedClipboardProvider;
518
519/**
520 * Structure for storing clipboard provider callback data.
521 */
522typedef struct _SHAREDCLIPBOARDPROVIDERCALLBACKDATA
523{
524 /** Pointer to related clipboard provider ("this"). */
525 SharedClipboardProvider *pProvider;
526 /** Saved user pointer. */
527 void *pvUser;
528} SHAREDCLIPBOARDPROVIDERCALLBACKDATA, *PSHAREDCLIPBOARDPROVIDERCALLBACKDATA;
529
530/** Callback functopn for the Shared Clipboard provider. */
531typedef DECLCALLBACK(int) FNSSHAREDCLIPBOARDPROVIDERCALLBACK(PSHAREDCLIPBOARDPROVIDERCALLBACKDATA pData);
532/** Pointer to a FNSSHAREDCLIPBOARDPROVIDERCALLBACK function. */
533typedef FNSSHAREDCLIPBOARDPROVIDERCALLBACK *PFNSSHAREDCLIPBOARDPROVIDERCALLBACK;
534
535/**
536 * Structure acting as a function callback table for clipboard providers.
537 * All callbacks are optional and therefore can be NULL.
538 */
539typedef struct _SHAREDCLIPBOARDPROVIDERCALLBACKS
540{
541 /** Saved user pointer. Will be passed to the callback (if needed). */
542 void *pvUser;
543 /** Function pointer, called when reading the (meta) data header. */
544 PFNSSHAREDCLIPBOARDPROVIDERCALLBACK pfnReadDataHdr;
545 /** Function pointer, called when reading a (meta) data chunk. */
546 PFNSSHAREDCLIPBOARDPROVIDERCALLBACK pfnReadDataChunk;
547} SHAREDCLIPBOARDPROVIDERCALLBACKS, *PSHAREDCLIPBOARDPROVIDERCALLBACKS;
548
549/**
550 * Structure for the Shared Clipboard provider creation context.
551 */
552typedef struct _SHAREDCLIPBOARDPROVIDERCREATIONCTX
553{
554 /** Specifies what the source of the provider is. */
555 SHAREDCLIPBOARDPROVIDERSOURCE enmSource;
556 /** Optional callback table; can be NULL if not needed. */
557 PSHAREDCLIPBOARDPROVIDERCALLBACKS pCallbacks;
558 union
559 {
560 struct
561 {
562 /** HGCM client ID to use. */
563 uint32_t uClientID;
564 } VbglR3;
565 struct
566 {
567 SharedClipboardArea *pArea;
568 } HostService;
569 } u;
570} SHAREDCLIPBOARDPROVIDERCREATIONCTX, *PSHAREDCLIPBOARDPROVIDERCREATIONCTX;
571
572/**
573 * Structure for read parameters.
574 */
575typedef struct _SHAREDCLIPBOARDPROVIDERREADPARMS
576{
577 union
578 {
579 struct
580 {
581 } HostService;
582 } u;
583} SHAREDCLIPBOARDPROVIDERREADPARMS, *PSHAREDCLIPBOARDPROVIDERREADPARMS;
584
585/**
586 * Structure for write parameters.
587 */
588typedef struct _SHAREDCLIPBOARDPROVIDERWRITEPARMS
589{
590 union
591 {
592 struct
593 {
594 uint32_t uMsg;
595 uint32_t cParms;
596 VBOXHGCMSVCPARM *paParms;
597 } HostService;
598 } u;
599} SHAREDCLIPBOARDPROVIDERWRITEPARMS, *PSHAREDCLIPBOARDPROVIDERWRITEPARMS;
600
601/**
602 * Interface class acting as a lightweight proxy for abstracting reading / writing clipboard data.
603 *
604 * This is needed because various implementations can run on the host *or* on the guest side,
605 * requiring different methods for handling the actual data.
606 */
607class SharedClipboardProvider
608{
609
610public:
611
612 static SharedClipboardProvider *Create(PSHAREDCLIPBOARDPROVIDERCREATIONCTX pCtx);
613
614 virtual ~SharedClipboardProvider(void);
615
616public:
617
618 uint32_t AddRef(void);
619 uint32_t Release(void);
620
621public:
622
623 void SetCallbacks(PSHAREDCLIPBOARDPROVIDERCALLBACKS pCallbacks);
624
625public: /* Interface to be implemented. */
626
627 virtual int ReadDataHdr(PVBOXCLIPBOARDDATAHDR *ppDataHdr);
628 virtual int WriteDataHdr(const PVBOXCLIPBOARDDATAHDR pDataHdr);
629
630 virtual int ReadDataChunk(const PVBOXCLIPBOARDDATAHDR pDataHdr, void *pvChunk, uint32_t cbChunk, uint32_t fFlags = 0,
631 uint32_t *pcbRead = NULL);
632 virtual int WriteDataChunk(const PVBOXCLIPBOARDDATAHDR pDataHdr, const void *pvChunk, uint32_t cbChunk, uint32_t fFlags = 0,
633 uint32_t *pcbWritten = NULL);
634
635 virtual int ReadDirectory(PVBOXCLIPBOARDDIRDATA *ppDirData);
636 virtual int WriteDirectory(const PVBOXCLIPBOARDDIRDATA pDirData);
637
638 virtual int ReadFileHdr(PVBOXCLIPBOARDFILEHDR *ppFileHdr);
639 virtual int WriteFileHdr(const PVBOXCLIPBOARDFILEHDR pFileHdr);
640
641 virtual int ReadFileData(void *pvData, uint32_t cbData, uint32_t fFlags = 0, uint32_t *pcbRead = NULL);
642 virtual int WriteFileData(void *pvData, uint32_t cbData, uint32_t fFlags = 0, uint32_t *pcbWritten = NULL);
643
644 virtual void Reset(void);
645
646public: /* Optional callback handling. */
647
648 /*virtual int SetCallbacks();*/
649
650 virtual int OnRead(PSHAREDCLIPBOARDPROVIDERREADPARMS pParms);
651 virtual int OnWrite(PSHAREDCLIPBOARDPROVIDERWRITEPARMS pParms);
652
653protected:
654
655 SharedClipboardProvider(void);
656
657protected:
658
659 /**
660 * Structure for maintaining an internal event.
661 */
662 struct Event
663 {
664 Event(uint32_t uMsg);
665 virtual ~Event();
666
667 void *DataAdopt(void);
668 uint32_t DataSize(void);
669 void *DataRaw(void);
670 void Reset(void);
671 int SetData(const void *pvData, uint32_t cbData);
672 int Wait(RTMSINTERVAL uTimeoutMs);
673
674 /** The event's associated message ID (guest function number). */
675 uint32_t mMsg;
676 /** The event's own event semaphore. */
677 RTSEMEVENT mEvent;
678 /** User-provided data buffer associated to this event. Optional. */
679 void *mpvData;
680 /** Size (in bytes) of user-provided data buffer associated to this event. */
681 uint32_t mcbData;
682 };
683
684 /** Map of events; the key is the guest function number (VBOX_SHARED_CLIPBOARD_GUEST_FN_XXX). */
685 typedef std::map<uint32_t, Event *> EventMap;
686
687 int eventRegister(uint32_t uMsg);
688 int eventUnregister(uint32_t uMsg);
689 int eventUnregisterAll(void);
690 int eventSignal(uint32_t uMsg);
691 int eventWait(uint32_t uMsg, PFNSSHAREDCLIPBOARDPROVIDERCALLBACK pfnCallback, RTMSINTERVAL uTimeoutMs,
692 void **ppvData, uint32_t *pcbData = NULL);
693 SharedClipboardProvider::Event *eventGet(uint32_t uMsg);
694
695protected:
696
697 /** Number of references to this instance. */
698 volatile uint32_t m_cRefs;
699 /** The provider's callback table. */
700 SHAREDCLIPBOARDPROVIDERCALLBACKS m_Callbacks;
701 /** Default timeout (in ms) for waiting for events. */
702 RTMSINTERVAL m_uTimeoutMs;
703 /** Map of (internal) events to provide asynchronous reads / writes. */
704 EventMap m_mapEvents;
705};
706
707/**
708 * Shared Clipboard provider implementation for VbglR3 (guest side).
709 */
710class SharedClipboardProviderVbglR3 : protected SharedClipboardProvider
711{
712 friend class SharedClipboardProvider;
713
714public:
715
716 virtual ~SharedClipboardProviderVbglR3(void);
717
718public:
719
720 int ReadDataHdr(PVBOXCLIPBOARDDATAHDR *ppDataHdr);
721 int WriteDataHdr(const PVBOXCLIPBOARDDATAHDR pDataHdr);
722
723 int ReadDataChunk(const PVBOXCLIPBOARDDATAHDR pDataHdr, void *pvChunk, uint32_t cbChunk, uint32_t fFlags = 0,
724 uint32_t *pcbRead = NULL);
725 int WriteDataChunk(const PVBOXCLIPBOARDDATAHDR pDataHdr, const void *pvChunk, uint32_t cbChunk, uint32_t fFlags = 0,
726 uint32_t *pcbWritten = NULL);
727
728 int ReadDirectory(PVBOXCLIPBOARDDIRDATA *ppDirData);
729 int WriteDirectory(const PVBOXCLIPBOARDDIRDATA pDirData);
730
731 int ReadFileHdr(PVBOXCLIPBOARDFILEHDR *ppFileHdr);
732 int WriteFileHdr(const PVBOXCLIPBOARDFILEHDR pFileHdr);
733
734 int ReadFileData(void *pvData, uint32_t cbData, uint32_t fFlags = 0, uint32_t *pcbRead = NULL);
735 int WriteFileData(void *pvData, uint32_t cbData, uint32_t fFlags = 0, uint32_t *pcbWritten = NULL);
736
737 void Reset(void);
738
739protected:
740
741 SharedClipboardProviderVbglR3(uint32_t uClientID);
742
743 /** HGCM client ID to use. */
744 uint32_t m_uClientID;
745};
746
747#ifdef VBOX_WITH_SHARED_CLIPBOARD_HOST
748/**
749 * Shared Clipboard provider implementation for host service (host side).
750 */
751class SharedClipboardProviderHostService : protected SharedClipboardProvider
752{
753 friend class SharedClipboardProvider;
754
755public:
756
757 virtual ~SharedClipboardProviderHostService();
758
759public:
760
761 int ReadDataHdr(PVBOXCLIPBOARDDATAHDR *ppDataHdr);
762 int WriteDataHdr(const PVBOXCLIPBOARDDATAHDR pDataHdr);
763
764 int ReadDataChunk(const PVBOXCLIPBOARDDATAHDR pDataHdr, void *pvChunk, uint32_t cbChunk, uint32_t fFlags = 0,
765 uint32_t *pcbRead = NULL);
766 int WriteDataChunk(const PVBOXCLIPBOARDDATAHDR pDataHdr, const void *pvChunk, uint32_t cbChunk, uint32_t fFlags = 0,
767 uint32_t *pcbWritten = NULL);
768
769 int ReadDirectory(PVBOXCLIPBOARDDIRDATA *ppDirData);
770 int WriteDirectory(const PVBOXCLIPBOARDDIRDATA pDirData);
771
772 int ReadFileHdr(PVBOXCLIPBOARDFILEHDR *ppFileHdr);
773 int WriteFileHdr(const PVBOXCLIPBOARDFILEHDR pFileHdr);
774
775 int ReadFileData(void *pvData, uint32_t cbData, uint32_t fFlags = 0, uint32_t *pcbRead = NULL);
776 int WriteFileData(void *pvData, uint32_t cbData, uint32_t fFlags = 0, uint32_t *pcbWritten = NULL);
777
778 void Reset(void);
779
780public:
781
782 int OnWrite(PSHAREDCLIPBOARDPROVIDERWRITEPARMS pParms);
783
784protected:
785
786 SharedClipboardProviderHostService(SharedClipboardArea *pArea);
787
788protected:
789
790 /** Pointer to associated clipboard area. */
791 SharedClipboardArea *m_pArea;
792};
793#endif /* VBOX_WITH_SHARED_CLIPBOARD_HOST */
794
795struct _SHAREDCLIPBOARDURITRANSFER;
796typedef _SHAREDCLIPBOARDURITRANSFER *PSHAREDCLIPBOARDURITRANSFER;
797
798/**
799 * Structure for storing URI transfer callback data.
800 */
801typedef struct _SHAREDCLIPBOARDURITRANSFERCALLBACKDATA
802{
803 /** Pointer to related URI transfer. */
804 PSHAREDCLIPBOARDURITRANSFER pTransfer;
805 /** Saved user pointer. */
806 void *pvUser;
807} SHAREDCLIPBOARDURITRANSFERCALLBACKDATA, *PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA;
808
809typedef DECLCALLBACK(void) FNSHAREDCLIPBOARDURITRANSFERSTARTED(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData);
810/** Pointer to a FNSHAREDCLIPBOARDURITRANSFERSTARTED function. */
811typedef FNSHAREDCLIPBOARDURITRANSFERSTARTED *PFNSHAREDCLIPBOARDURITRANSFERSTARTED;
812
813typedef DECLCALLBACK(void) FNSHAREDCLIPBOARDURITRANSFERCANCELED(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData);
814/** Pointer to a FNSHAREDCLIPBOARDURITRANSFERCANCELED function. */
815typedef FNSHAREDCLIPBOARDURITRANSFERCANCELED *PFNSHAREDCLIPBOARDURITRANSFERCANCELED;
816
817typedef DECLCALLBACK(void) FNSHAREDCLIPBOARDURITRANSFERCOMPLETE(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData, int rc);
818/** Pointer to a FNSHAREDCLIPBOARDURITRANSFERCOMPLETE function. */
819typedef FNSHAREDCLIPBOARDURITRANSFERCOMPLETE *PFNSHAREDCLIPBOARDURITRANSFERCOMPLETE;
820
821typedef DECLCALLBACK(void) FNSHAREDCLIPBOARDURITRANSFERERROR(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData, int rc);
822/** Pointer to a FNSHAREDCLIPBOARDURITRANSFERERROR function. */
823typedef FNSHAREDCLIPBOARDURITRANSFERERROR *PFNSHAREDCLIPBOARDURITRANSFERERROR;
824
825/**
826 * Structure acting as a function callback table for URI transfers.
827 * All callbacks are optional and therefore can be NULL.
828 */
829typedef struct _SHAREDCLIPBOARDURITRANSFERCALLBACKS
830{
831 /** Saved user pointer. */
832 void *pvUser;
833 /** Function pointer, called when the transfer has been started. */
834 PFNSHAREDCLIPBOARDURITRANSFERSTARTED pfnTransferStarted;
835 /** Function pointer, called when the transfer is complete. */
836 PFNSHAREDCLIPBOARDURITRANSFERCOMPLETE pfnTransferComplete;
837 /** Function pointer, called when the transfer has been canceled. */
838 PFNSHAREDCLIPBOARDURITRANSFERCANCELED pfnTransferCanceled;
839 /** Function pointer, called when transfer resulted in an unrecoverable error. */
840 PFNSHAREDCLIPBOARDURITRANSFERERROR pfnTransferError;
841} SHAREDCLIPBOARDURITRANSFERCALLBACKS, *PSHAREDCLIPBOARDURITRANSFERCALLBACKS;
842
843/**
844 * Structure for thread-related members for a single URI transfer.
845 */
846typedef struct _SHAREDCLIPBOARDURITRANSFERTHREAD
847{
848 /** Thread handle for the reading / writing thread.
849 * Can be NIL_RTTHREAD if not being used. */
850 RTTHREAD hThread;
851 /** Thread started indicator. */
852 volatile bool fStarted;
853 /** Thread cancelled flag / indicator. */
854 volatile bool fCancelled;
855} SHAREDCLIPBOARDURITRANSFERTHREAD, *PSHAREDCLIPBOARDURITRANSFERTHREAD;
856
857/**
858 * Structure for handling a single URI object context.
859 */
860typedef struct _SHAREDCLIPBOARDCLIENTURIOBJCTX
861{
862 /** Pointer to current object being processed. */
863 SharedClipboardURIObject *pObj;
864} SHAREDCLIPBOARDCLIENTURIOBJCTX, *PSHAREDCLIPBOARDCLIENTURIOBJCTX;
865
866/**
867 * Structure for maintaining a single URI transfer.
868 *
869 ** @todo Not yet thread safe.
870 */
871typedef struct _SHAREDCLIPBOARDURITRANSFER
872{
873 /** The node member for using this struct in a RTList. */
874 RTLISTNODE Node;
875 /** Critical section for serializing access. */
876 RTCRITSECT CritSect;
877 /** The transfer's state (for SSM, later). */
878 SHAREDCLIPBOARDURITRANSFERSTATE State;
879 /** The transfer's own (local) area, if any (can be NULL if not needed).
880 * The area itself has a clipboard area ID assigned.
881 * On the host this area ID gets shared (maintained / locked) across all VMs via VBoxSVC. */
882 SharedClipboardArea *pArea;
883 /** The URI list for this transfer. */
884 SharedClipboardURIList *pURIList;
885 /** Context of current object being handled. */
886 SHAREDCLIPBOARDCLIENTURIOBJCTX ObjCtx;
887 /** The Shared Clipboard provider in charge for this transfer. */
888 SharedClipboardProvider *pProvider;
889 /** Opaque pointer to implementation-specific parameters. */
890 void *pvUser;
891 /** Size (in bytes) of implementation-specific parameters. */
892 size_t cbUser;
893 /** Contains thread-related attributes. */
894 SHAREDCLIPBOARDURITRANSFERTHREAD Thread;
895 /** (Optional) callbacks related to this transfer. */
896 SHAREDCLIPBOARDURITRANSFERCALLBACKS Callbacks;
897} SHAREDCLIPBOARDURITRANSFER, *PSHAREDCLIPBOARDURITRANSFER;
898
899/**
900 * Structure for keeping URI clipboard information around.
901 */
902typedef struct _SHAREDCLIPBOARDURICTX
903{
904 /** Critical section for serializing access. */
905 RTCRITSECT CritSect;
906 /** List of active transfers.
907 * Use a list or something lateron. */
908 RTLISTANCHOR List;
909 /** Number of concurrent transfers.
910 * At the moment we only support only one transfer per client at a time. */
911 uint32_t cTransfers;
912 /** Maximum Number of concurrent transfers.
913 * At the moment we only support only one transfer per client at a time. */
914 uint32_t cMaxTransfers;
915} SHAREDCLIPBOARDURICTX, *PSHAREDCLIPBOARDURICTX;
916
917int SharedClipboardURIObjCtxInit(PSHAREDCLIPBOARDCLIENTURIOBJCTX pObjCtx);
918void SharedClipboardURIObjCtxDestroy(PSHAREDCLIPBOARDCLIENTURIOBJCTX pObjCtx);
919SharedClipboardURIObject *SharedClipboardURIObjCtxGetObj(PSHAREDCLIPBOARDCLIENTURIOBJCTX pObjCtx);
920bool SharedClipboardURIObjCtxIsValid(PSHAREDCLIPBOARDCLIENTURIOBJCTX pObjCtx);
921
922int SharedClipboardURITransferCreate(SHAREDCLIPBOARDURITRANSFERDIR enmDir, PSHAREDCLIPBOARDURITRANSFER *ppTransfer);
923int SharedClipboardURITransferDestroy(PSHAREDCLIPBOARDURITRANSFER pTransfer);
924int SharedClipboardURITransferPrepare(PSHAREDCLIPBOARDURITRANSFER pTransfer);
925int SharedClipboardURITransferProviderCreate(PSHAREDCLIPBOARDURITRANSFER pTransfer,
926 PSHAREDCLIPBOARDPROVIDERCREATIONCTX pProviderCtx);
927void SharedClipboardURITransferReset(PSHAREDCLIPBOARDURITRANSFER pTransfer);
928SharedClipboardArea *SharedClipboardURITransferGetArea(PSHAREDCLIPBOARDURITRANSFER pTransfer);
929PSHAREDCLIPBOARDCLIENTURIOBJCTX SharedClipboardURITransferGetCurrentObjCtx(PSHAREDCLIPBOARDURITRANSFER pTransfer);
930const SharedClipboardURIObject *SharedClipboardURITransferGetCurrentObject(PSHAREDCLIPBOARDURITRANSFER pTransfer);
931SharedClipboardProvider *SharedClipboardURITransferGetProvider(PSHAREDCLIPBOARDURITRANSFER pTransfer);
932SharedClipboardURIList *SharedClipboardURITransferGetList(PSHAREDCLIPBOARDURITRANSFER pTransfer);
933SharedClipboardURIObject *SharedClipboardURITransferGetObject(PSHAREDCLIPBOARDURITRANSFER pTransfer, uint64_t uIdx);
934int SharedClipboardURITransferRun(PSHAREDCLIPBOARDURITRANSFER pTransfer, bool fAsync);
935void SharedClipboardURITransferSetCallbacks(PSHAREDCLIPBOARDURITRANSFER pTransfer, PSHAREDCLIPBOARDURITRANSFERCALLBACKS pCallbacks);
936
937int SharedClipboardURITransferMetaDataAdd(PSHAREDCLIPBOARDURITRANSFER pTransfer, const void *pvMeta, uint32_t cbMeta);
938bool SharedClipboardURITransferMetaDataIsComplete(PSHAREDCLIPBOARDURITRANSFER pTransfer);
939int SharedClipboardURITransferMetaGet(PSHAREDCLIPBOARDURITRANSFER pTransfer, const void *pvMeta, uint32_t cbMeta);
940int SharedClipboardURITransferMetaDataRead(PSHAREDCLIPBOARDURITRANSFER pTransfer, uint32_t *pcbRead);
941int SharedClipboardURITransferMetaDataWrite(PSHAREDCLIPBOARDURITRANSFER pTransfer, uint32_t *pcbWritten);
942
943int SharedClipboardURITransferRead(PSHAREDCLIPBOARDURITRANSFER pTransfer);
944int SharedClipboardURITransferReadObjects(PSHAREDCLIPBOARDURITRANSFER pTransfer);
945
946int SharedClipboardURITransferWrite(PSHAREDCLIPBOARDURITRANSFER pTransfer);
947int SharedClipboardURITransferWriteObjects(PSHAREDCLIPBOARDURITRANSFER pTransfer);
948
949int SharedClipboardURICtxInit(PSHAREDCLIPBOARDURICTX pURI);
950void SharedClipboardURICtxDestroy(PSHAREDCLIPBOARDURICTX pURI);
951void SharedClipboardURICtxReset(PSHAREDCLIPBOARDURICTX pURI);
952PSHAREDCLIPBOARDURITRANSFER SharedClipboardURICtxGetTransfer(PSHAREDCLIPBOARDURICTX pURI, uint32_t uIdx);
953uint32_t SharedClipboardURICtxGetActiveTransfers(PSHAREDCLIPBOARDURICTX pURI);
954bool SharedClipboardURICtxMaximumTransfersReached(PSHAREDCLIPBOARDURICTX pURI);
955int SharedClipboardURICtxTransferAdd(PSHAREDCLIPBOARDURICTX pURI, PSHAREDCLIPBOARDURITRANSFER pTransfer);
956int SharedClipboardURICtxTransferRemove(PSHAREDCLIPBOARDURICTX pURI, PSHAREDCLIPBOARDURITRANSFER pTransfer);
957
958bool SharedClipboardMIMEHasFileURLs(const char *pcszFormat, size_t cchFormatMax);
959bool SharedClipboardMIMENeedsCache(const char *pcszFormat, size_t cchFormatMax);
960
961#endif /* !VBOX_INCLUDED_GuestHost_SharedClipboard_uri_h */
962
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