VirtualBox

Changeset 100881 in vbox for trunk/src/VBox/HostServices


Ignore:
Timestamp:
Aug 15, 2023 2:33:57 PM (16 months ago)
Author:
vboxsync
Message:

Shared Clipboard: Docs. bugref:9437

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp

    r100655 r100881  
    3535 *
    3636 * The service is split into a platform-independent core and platform-specific
    37  * backends.  The service defines two communication protocols - one to
    38  * communicate with the clipboard service running on the guest, and one to
    39  * communicate with the backend.  These will be described in a very skeletal
    40  * fashion here.
    41  *
    42  * r=bird: The "two communication protocols" does not seems to be factual, there
    43  * is only one protocol, the first one mentioned.  It cannot be backend
    44  * specific, because the guest/host protocol is platform and backend agnostic in
    45  * nature.  You may call it versions, but I take a great dislike to "protocol
    46  * versions" here, as you've just extended the existing protocol with a feature
    47  * that allows to transfer files and directories too.  See @bugref{9437#c39}.
    48  *
     37 * backends. The backends also make use of the aforementioned shared guest/host
     38 * clipboard code, to avoid code duplication.
    4939 *
    5040 * @section sec_hostclip_guest_proto  The guest communication protocol
     
    10696 * @section sec_uri_intro               Transferring files
    10797 *
    108  * Since VBox x.x.x transferring files via Shared Clipboard is supported.
     98 * Since VBox 7.1 transferring files via Shared Clipboard is supported.
    10999 * See the VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS define for supported / enabled
    110100 * platforms. This is called "Shared Clipboard transfers".
    111101 *
    112  * Copying files / directories from guest A to guest B requires the host
    113  * service to act as a proxy and cache, as we don't allow direct VM-to-VM
    114  * communication. Copying from / to the host also is taken into account.
    115  *
    116102 * At the moment a transfer is a all-or-nothing operation, e.g. it either
    117  * completes or fails completely. There might be callbacks in the future
    118  * to e.g. skip failing entries.
     103 * completes or fails completely.
    119104 *
    120105 * Known limitations:
    121106 *
     107 * - On Linux hosts / guests only single files per transfer is supported, as we
     108 *   use a HTTP server to provide the files to the desktop file managers (Nemo,
     109 *   Nautilus, Dolphin, ++).
    122110 * - Support for VRDE (VRDP) is not implemented yet (see #9498).
    123111 * - Unicode support on Windows hosts / guests is not enabled (yet).
     
    133121 * duplication where applicable.
    134122 *
     123 * The terms "source" and "destination" in the source code depend on the current
     124 * context the code is being run, e.g. host -> guest (H->G) or guest -> host (G->H)
     125 * directions.
     126 *
    135127 * Per HGCM client there is a so-called "transfer context", which in turn can
    136  * have one or mulitple so-called "Shared Clipboard transfer" objects. At the
    137  * moment we only support on concurrent Shared Clipboard transfer per transfer
    138  * context. It's being used for reading from a source or writing to destination,
    139  * depening on its direction. An Shared Clipboard transfer can have optional
    140  * callbacks which might be needed by various implementations. Also, transfers
    141  * optionally can run in an asynchronous thread to prevent blocking the UI while
    142  * running.
    143  *
    144  * @section sec_transfer_providers        Transfer providers
    145  *
    146  * For certain implementations (for example on Windows guests / hosts, using
    147  * IDataObject and IStream objects) a more flexible approach reqarding reading /
    148  * writing is needed. For this so-called transfer providers abstract the way of how
    149  * data is being read / written in the current context (host / guest), while
    150  * the rest of the code stays the same.
     128 * have one or mulitple transfer objects. This is being used for reading from
     129 * a source or writing to destination, depending on its direction.
     130 *
     131 * A transfer consists of the following mechanisms:
     132 * - a general callback table for hooking into creation, initialization and so on.
     133 * - a provider interface which performs the actual transfer operations.
     134 *
     135 * Involved components:
     136 * - VBoxSharedClipboardSvc as host service
     137 * - VBoxTray for Windows guests
     138 * - VBoxClient for Linux guests
     139 * - VbglR3 for common guest code used by VBoxTray / VBoxClient
     140 * - Common code in GuestHost/SharedClipboard
     141 * - Main for implementing event plumbing to API clients + controlling clipboard modes
     142 *
     143 * Also, transfers optionally can run in a separate thread to prevent blocking
     144 * the UI while running.
    151145 *
    152146 * @section sec_transfer_protocol         Transfer protocol
     
    156150 * directories and open/close/read/write file system objects.
    157151 *
    158  * Note that this is different from the DnD approach, as Shared Clipboard transfers
    159  * need to be deeper integrated within the host / guest OS (i.e. for progress UI),
    160  * and this might require non-monolithic / random access APIs to achieve.
    161  *
    162  * As there can be multiple file system objects (fs objects) selected for transfer,
     152 * A transfer is identified (on a per-VM basis) through its transfer ID.
     153 * This transfer ID is part of a so-called "context ID" (CID), which must be part of (almost) every transfer-related HGCM message.
     154 * Transfer IDs always are created and communicated by the host.
     155 *
     156 * As there can be multiple file system objects (fs objects) selected to transfer,
    163157 * a transfer can be queried for its root entries, which then contains the top-level
    164158 * elements. Based on these elements, (a) (recursive) listing(s) can be performed
     
    167161 * might need this mechanism.
    168162 *
     163 * The following describes the protocol flow, where the source and destination depends on the transfer direction:
     164 *
     165 * - For host -> guest (H->G) transfers:
     166 *      Source is the host, whereas the guest is the destination.
     167 * - For guest -> host (G->H) transfers:
     168 *      Source is the guest, whereas the host is the destination.
     169 *
    169170 * An Shared Clipboard transfer has three stages:
    170  *  - 1. Announcement: An Shared Clipboard transfer-compatible format (currently only one format available)
    171  *          has been announced, the destination side creates a transfer object, which then,
    172  *          depending on the actual implementation, can be used to tell the OS that
    173  *          there is transfer (file) data available.
    174  *          At this point this just acts as a (kind-of) promise to the OS that we
    175  *          can provide (file) data at some later point in time.
    176  *
    177  *  - 2. Initialization: As soon as the OS requests the (file) data, mostly triggered
    178  *          by the user starting a paste operation (CTRL + V), the transfer get initialized
    179  *          on the destination side, which in turn lets the source know that a transfer
    180  *          is going to happen.
    181  *
    182  *  - 3. Transfer: At this stage the actual transfer from source to the destination takes
    183  *          place. How the actual transfer is structurized (e.g. which files / directories
    184  *          are transferred in which order) depends on the destination implementation. This
    185  *          is necessary in order to fulfill requirements on the destination side with
    186  *          regards to ETA calculation or other dependencies.
    187  *          Both sides can abort or cancel the transfer at any time.
     171 *
     172 * - Stage 1: Announcement (by the source)
     173 * - Stage 2: Initialization (by the source + by the destination)
     174 * - Stage 3: Start
     175 *
     176 * Transfer statuses are handled by the VBOX_SHCL_HOST_MSG_TRANSFER_STATUS /
     177 * VBOX_SHCL_GUEST_FN_REPLY + VBOX_SHCL_TX_REPLYMSGTYPE_TRANSFER_STATUS HGCM messages.
     178 *
     179 * Both sides can abort or cancel the transfer at any time via an ERROR transfer status.
     180 *
     181 * For host -> guest transfers:
     182 *
     183 * - Stage 1:
     184 *   - A (possible) transfer gets announced by the host by announcing the format VBOX_SHCL_FMT_URI_LIST to the guest.
     185 * - Stage 2:
     186 *   - As soon as the guest wants to make use of the transfer ("pasting into file manager"),
     187 *     it requests a transfer ID from the host via sending the transfer status REQUESTED to the host.
     188 *   - The host received the REQUESTED status from the guest, creating a transfer locally and acknowledges the transfer ID
     189 *     via the REQUESTED status to the guest. Reports ERROR status to the guest otherwise.
     190 *   - The guest received the REQUESTED status from the host, then creating the transfer on its
     191 *     side with the transfer ID received from the host.
     192 *   - The guest sends back the INITIALIZED status to the host on success, or ERROR on error.
     193 *   - The host sends the INITIALIZED status, telling the guest that the host is ready to operate on the transfer.
     194 *
     195 * For guest -> host transfers:
     196 *
     197 * - Stage 1:
     198 *   - A (possible) transfer gets announced by the guest by announcing the format VBOX_SHCL_FMT_URI_LIST to the host.
     199 * - Stage 2:
     200 *   - As soon as the host wants to make use of the transfer ("pasting into file manager"),
     201 *     it creates and initialized a transfer (with a transfer ID) locally and reports it to the guest with an INITIALIZED status.
     202 *   - The guest receives the INITIALIZED status from the host and creates + initializes a transfer on its
     203 *     side with the transfer ID received from the host.
    188204 */
    189205
     
    14731489 * Reports clipboard formats to the guest.
    14741490 *
     1491 * @note    Host backend callers must check if it's active (use
     1492 *          ShClSvcIsBackendActive) before calling to prevent mixing up the
     1493 *          VRDE clipboard.
     1494 *
    14751495 * @returns VBox status code.
    14761496 * @param   pClient             Client to report clipboard formats to.
    1477  * @param   fFormats            The formats to report (VBOX_SHCL_FMT_XXX).
    1478  *                              VBOX_SHCL_FMT_NONE will empty (clear) the clipboard.
     1497 * @param   fFormats            The formats to report (VBOX_SHCL_FMT_XXX), zero
     1498 *                              is okay (empty the clipboard).
     1499 *
    14791500 * @thread  Backend thread.
    14801501 */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette