1 | /* $Id: mime-type-converter.h 106766 2024-10-29 09:40:57Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Mime-type converter for Shared Clipboard and Drag-and-Drop code.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2024 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.alldomusa.eu.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_mime_type_converter_h
|
---|
38 | #define VBOX_INCLUDED_GuestHost_mime_type_converter_h
|
---|
39 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
40 | # pragma once
|
---|
41 | #endif
|
---|
42 |
|
---|
43 | #include <iprt/cdefs.h>
|
---|
44 | #include <VBox/GuestHost/clipboard-helper.h>
|
---|
45 |
|
---|
46 | /**
|
---|
47 | * Mime-type enumeration callback function.
|
---|
48 | *
|
---|
49 | * Primarily used by VBoxMimeConvEnumerateMimeById when it
|
---|
50 | * goes through the list of supported mime-types and passes
|
---|
51 | * each of them one by one to this callback.
|
---|
52 | *
|
---|
53 | * @param pcszMimeType String representation of a mime-type.
|
---|
54 | * @param pvData User data.
|
---|
55 | */
|
---|
56 | typedef DECLCALLBACKTYPE(void, FNVBFMTCONVMIMEBYID, (const char *pcszMimeType, void *pvData));
|
---|
57 | /** Pointer to a FNVBFMTCONVMIMEBYID. */
|
---|
58 | typedef FNVBFMTCONVMIMEBYID *PFNVBFMTCONVMIMEBYID;
|
---|
59 |
|
---|
60 | /**
|
---|
61 | * Enumerate list of mime-types by ID mask.
|
---|
62 | *
|
---|
63 | * This function goes through the list of supported mime-types and
|
---|
64 | * triggers given callback function for each of them.
|
---|
65 | *
|
---|
66 | * @param uFmtVBox Formats bitmask in VBox representation.
|
---|
67 | * @param pfnCb A callback to trigger.
|
---|
68 | * @param pvData User data.
|
---|
69 | */
|
---|
70 | extern RTDECL(void) VBoxMimeConvEnumerateMimeById(const SHCLFORMAT uFmtVBox, PFNVBFMTCONVMIMEBYID pfnCb,
|
---|
71 | void *pvData);
|
---|
72 |
|
---|
73 | /**
|
---|
74 | * Find first matching mime-type by given VBox formats ID.
|
---|
75 | *
|
---|
76 | * @returns Mime-type as a string or NULL if not found.
|
---|
77 | * @param uFmtVBox Formats bitmask in VBox representation.
|
---|
78 | */
|
---|
79 | extern RTDECL(const char *) VBoxMimeConvGetMimeById(const SHCLFORMAT uFmtVBox);
|
---|
80 |
|
---|
81 | /**
|
---|
82 | * Find VBox format ID by given mime-type.
|
---|
83 | *
|
---|
84 | * @returns Format ID in VBox representation.
|
---|
85 | * @param pcszMimeType Mime-type in string representation.
|
---|
86 | */
|
---|
87 | extern RTDECL(SHCLFORMAT) VBoxMimeConvGetIdByMime(const char *pcszMimeType);
|
---|
88 |
|
---|
89 | /**
|
---|
90 | * Converts data from VBox internal representation into native format.
|
---|
91 | *
|
---|
92 | * @returns IPRT status code.
|
---|
93 | * @param pcszMimeType Mime-type in string representation.
|
---|
94 | * @param pvBufIn Input buffer which contains data in VBox format.
|
---|
95 | * @param cbBufIn Size of input buffer in bytes.
|
---|
96 | * @param ppvBufOut Newly allocated output buffer which will contain data
|
---|
97 | * in specified mime-type format (must be freed by caller).
|
---|
98 | * @param pcbBufOut Size of output buffer.
|
---|
99 | */
|
---|
100 | extern RTDECL(int) VBoxMimeConvVBoxToNative(const char *pcszMimeType, void *pvBufIn, int cbBufIn,
|
---|
101 | void **ppvBufOut, size_t *pcbBufOut);
|
---|
102 |
|
---|
103 | /**
|
---|
104 | * Converts data from native format into VBox internal representation.
|
---|
105 | *
|
---|
106 | * @returns IPRT status code.
|
---|
107 | * @param pcszMimeType Mime-type in string representation.
|
---|
108 | * @param pvBufIn Input buffer which contains data in specified mime-type format.
|
---|
109 | * @param cbBufIn Size of input buffer in bytes.
|
---|
110 | * @param ppvBufOut Newly allocated output buffer which will contain image data
|
---|
111 | * in VBox internal representation format (must be freed by caller).
|
---|
112 | * @param pcbBufOut Size of output buffer.
|
---|
113 | */
|
---|
114 | extern RTDECL(int) VBoxMimeConvNativeToVBox(const char *pcszMimeType, void *pvBufIn, int cbBufIn,
|
---|
115 | void **ppvBufOut, size_t *pcbBufOut);
|
---|
116 |
|
---|
117 | #endif /* !VBOX_INCLUDED_GuestHost_mime_type_converter_h */
|
---|
118 |
|
---|