VirtualBox

Changeset 85681 in vbox for trunk/src/VBox/Main/src-client


Ignore:
Timestamp:
Aug 11, 2020 9:36:37 AM (4 years ago)
Author:
vboxsync
Message:

DnD: Lots of documentation.

Location:
trunk/src/VBox/Main/src-client
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/GuestDnDPrivate.cpp

    r85561 r85681  
    5555 *
    5656 * 1. GUI: Uses the Qt classes for Drag and Drop and mainly forward the content
    57  *    of it to the Main IGuest interface (see UIDnDHandler.cpp).
     57 *    of it to the Main IGuest / IGuestDnDSource / IGuestDnDTarget interfaces.
    5858 * 2. Main: Public interface for doing Drag and Drop. Also manage the IProgress
    5959 *    interfaces for blocking the caller by showing a progress dialog (see
     
    6262 *    encapsulate the internal communication details (see dndmanager.cpp and
    6363 *    friends).
    64  * 4. Guest additions: Split into the platform neutral part (see
     64 * 4. Guest Additions: Split into the platform neutral part (see
    6565 *    VBoxGuestR3LibDragAndDrop.cpp) and the guest OS specific parts.
    6666 *    Receive/send message from/to the HGCM service and does all guest specific
    67  *    operations. Currently only X11 is supported (see draganddrop.cpp within
    68  *    VBoxClient).
     67 *    operations. For Windows guests VBoxTray is in charge, whereas on UNIX-y guests
     68 *    VBoxClient will be used.
     69 *
     70 * Terminology:
     71 *
     72 * All transfers contain a MIME format and according meta data. This meta data then can
     73 * be interpreted either as raw meta data or something else. When raw meta data is
     74 * being handled, this gets passed through to the destination (guest / host) without
     75 * modification. Other meta data (like URI lists) can and will be modified by the
     76 * receiving side before passing to OS. How and when modifications will be applied
     77 * depends on the MIME format.
    6978 *
    7079 * Host -> Guest:
    7180 * 1. There are DnD Enter, Move, Leave events which are send exactly like this
    72  *    to the guest. The info includes the pos, mimetypes and allowed actions.
     81 *    to the guest. The info includes the position, MIME types and allowed actions.
    7382 *    The guest has to respond with an action it would accept, so the GUI could
    74  *    change the cursor.
     83 *    change the cursor accordingly.
    7584 * 2. On drop, first a drop event is sent. If this is accepted a drop data
    7685 *    event follows. This blocks the GUI and shows some progress indicator.
     
    8594 *    shows some progress indicator.
    8695 *
    87  * Some hints:
     96 * Implementation hints:
    8897 * m_strSupportedFormats here in this file defines the allowed mime-types.
    8998 * This is necessary because we need special handling for some of the
     
    104113 * same has to be done in the G->H direction when it is implemented.
    105114 *
    106  * Of course only regularly files are supported. Symlinks are resolved and
    107  * transfered as regularly files. First we don't know if the other side support
    108  * symlinks at all and second they could point to somewhere in a directory tree
    109  * which not exists on the other side.
    110  *
    111  * The code tries to preserve the file modes of the transfered dirs/files. This
    112  * is useful (and maybe necessary) for two things:
     115 * Only regular files are supported; symlinks are not allowed.
     116 *
     117 * Transfers currently are an all-succeed or all-fail operation (see todos).
     118 *
     119 * On MacOS hosts we had to implement own DnD "promises" support for file transfers,
     120 * as Qt does not support this out-of-the-box.
     121 *
     122 * The code tries to preserve the file modes of the transfered directories / files.
     123 * This is useful (and maybe necessary) for two things:
    113124 * 1. If a file is executable, it should be also after the transfer, so the
    114125 *    user can just execute it, without manually tweaking the modes first.
     
    118129 * ourself, in e.g. for a cleanup case after cancel).
    119130 *
    120  * Cancel is supported in both directions and cleans up all previous steps
    121  * (thats is: deleting already transfered dirs/files).
    122  *
    123  * In general I propose the following changes in the VBox HGCM infrastructure
    124  * for the future:
    125  * - Currently it isn't really possible to send messages to the guest from the
    126  *   host. The host informs the guest just that there is something, the guest
    127  *   than has to ask which message and depending on that send the appropriate
    128  *   message to the host, which is filled with the right data.
    129  * - There is no generic interface for sending bigger memory blocks to/from the
    130  *   guest. This is now done here, but I guess was also necessary for e.g.
    131  *   guest execution. So something generic which brake this up into smaller
    132  *   blocks and send it would be nice (with all the error handling and such
    133  *   ofc).
    134  * - I developed a "protocol" for the DnD communication here. So the host and
    135  *   the guest have always to match in the revision. This is ofc bad, because
    136  *   the additions could be outdated easily. So some generic protocol number
    137  *   support in HGCM for asking the host and the guest of the support version,
    138  *   would be nice. Ofc at least the host should be able to talk to the guest,
    139  *   even when the version is below the host one.
    140  * All this stuff would be useful for the current services, but also for future
    141  * onces.
     131 * ACEs / ACLs currently are not supported.
     132 *
     133 * Cancelling ongoing transfers is supported in both directions by the guest
     134 * and/or host side and cleans up all previous steps. This also involves
     135 * removing partially transferred directories / files in the temporary directory.
    142136 *
    143137 ** @todo
    144138 * - ESC doesn't really work (on Windows guests it's already implemented)
    145  *   ... in any case it seems a little bit difficult to handle from the Qt
    146  *   side. Maybe also a host specific implementation becomes necessary ...
    147  *   this would be really worst ofc.
    148  * - Add support for more mime-types (especially images, csv)
     139 *   ... in any case it seems a little bit difficult to handle from the Qt side.
     140 * - Transfers currently do not have any interactive (UI) callbacks / hooks which
     141 *   e.g. would allow to skip / replace / rename and entry, or abort the operation on failure.
     142 * - Add support for more MIME types (especially images, csv)
    149143 * - Test unusual behavior:
    150144 *   - DnD service crash in the guest during a DnD op (e.g. crash of VBoxClient or X11)
     
    152146 * - Security considerations: We transfer a lot of memory between the guest and
    153147 *   the host and even allow the creation of dirs/files. Maybe there should be
    154  *   limits introduced to preventing DOS attacks or filling up all the memory
     148 *   limits introduced to preventing DoS attacks or filling up all the memory
    155149 *   (both in the host and the guest).
    156150 */
  • trunk/src/VBox/Main/src-client/GuestDnDSourceImpl.cpp

    r85564 r85681  
    5757    virtual ~GuestDnDSourceTask(void) { }
    5858
     59    /** Returns the overall result of the task. */
    5960    int getRC(void) const { return mRC; }
     61    /** Returns if the overall result of the task is ok (succeeded) or not. */
    6062    bool isOk(void) const { return RT_SUCCESS(mRC); }
    6163
    6264protected:
    6365
     66    /** COM object pointer to the parent (source). */
    6467    const ComObjPtr<GuestDnDSource>     mSource;
     68    /** Overall result of the task. */
    6569    int                                 mRC;
    6670};
     
    507511/////////////////////////////////////////////////////////////////////////////
    508512
     513/**
     514 * Returns an error string from a guest DnD error.
     515 *
     516 * @returns Error string.
     517 * @param   guestRc             Guest error to return error string for.
     518 */
    509519/* static */
    510520Utf8Str GuestDnDSource::i_guestErrorToString(int guestRc)
     
    545555}
    546556
     557/**
     558 * Returns an error string from a host DnD error.
     559 *
     560 * @returns Error string.
     561 * @param   hostRc              Host error to return error string for.
     562 */
    547563/* static */
    548564Utf8Str GuestDnDSource::i_hostErrorToString(int hostRc)
     
    583599}
    584600
     601/**
     602 * Resets all internal data and state.
     603 */
    585604void GuestDnDSource::i_reset(void)
    586605{
     
    632651
    633652/**
    634  * Handles receiving a send data block from the guest.
     653 * Main function for receiving data from the guest.
    635654 *
    636655 * @returns VBox status code.
     
    762781    return rc;
    763782}
     783
    764784
    765785int GuestDnDSource::i_onReceiveDir(GuestDnDRecvCtx *pCtx, const char *pszPath, uint32_t cbPath, uint32_t fMode)
     
    904924}
    905925
     926/**
     927 * Receives file data from the guest.
     928 *
     929 * @returns VBox status code.
     930 * @param   pCtx                Receive context to use.
     931 * @param   pvData              Pointer to file data received from the guest.
     932 * @param   pCtx                Size (in bytes) of file data received from the guest.
     933 */
    906934int GuestDnDSource::i_onReceiveFileData(GuestDnDRecvCtx *pCtx, const void *pvData, uint32_t cbData)
    907935{
     
    971999
    9721000/**
    973  * @returns VBox status code that the caller ignores. Not sure if that's
    974  *          intentional or not.
     1001 * Main function to receive DnD data from the guest.
     1002 *
     1003 * @returns VBox status code.
     1004 * @param   pCtx                Receive context to use.
     1005 * @param   msTimeout           Timeout (in ms) to wait for receiving data.
    9751006 */
    9761007int GuestDnDSource::i_receiveData(GuestDnDRecvCtx *pCtx, RTMSINTERVAL msTimeout)
     
    10661097}
    10671098
     1099/**
     1100 * Receives raw (meta) data from the guest.
     1101 *
     1102 * @returns VBox status code.
     1103 * @param   pCtx                Receive context to use.
     1104 * @param   msTimeout           Timeout (in ms) to wait for receiving data.
     1105 */
    10681106int GuestDnDSource::i_receiveRawData(GuestDnDRecvCtx *pCtx, RTMSINTERVAL msTimeout)
    10691107{
     
    11711209}
    11721210
     1211/**
     1212 * Receives transfer data (files / directories / ...) from the guest.
     1213 *
     1214 * @returns VBox status code.
     1215 * @param   pCtx                Receive context to use.
     1216 * @param   msTimeout           Timeout (in ms) to wait for receiving data.
     1217 */
    11731218int GuestDnDSource::i_receiveTransferData(GuestDnDRecvCtx *pCtx, RTMSINTERVAL msTimeout)
    11741219{
     
    13051350}
    13061351
     1352/**
     1353 * Static HGCM service callback which handles receiving raw data.
     1354 *
     1355 * @returns VBox status code. Will get sent back to the host service.
     1356 * @param   uMsg                HGCM message ID (function number).
     1357 * @param   pvParms             Pointer to additional message data. Optional and can be NULL.
     1358 * @param   cbParms             Size (in bytes) additional message data. Optional and can be 0.
     1359 * @param   pvUser              User-supplied pointer on callback registration.
     1360 */
    13071361/* static */
    13081362DECLCALLBACK(int) GuestDnDSource::i_receiveRawDataCallback(uint32_t uMsg, void *pvParms, size_t cbParms, void *pvUser)
     
    14341488}
    14351489
     1490/**
     1491 * Static HGCM service callback which handles receiving transfer data from the guest.
     1492 *
     1493 * @returns VBox status code. Will get sent back to the host service.
     1494 * @param   uMsg                HGCM message ID (function number).
     1495 * @param   pvParms             Pointer to additional message data. Optional and can be NULL.
     1496 * @param   cbParms             Size (in bytes) additional message data. Optional and can be 0.
     1497 * @param   pvUser              User-supplied pointer on callback registration.
     1498 */
    14361499/* static */
    14371500DECLCALLBACK(int) GuestDnDSource::i_receiveTransferDataCallback(uint32_t uMsg, void *pvParms, size_t cbParms, void *pvUser)
  • trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp

    r85564 r85681  
    6060    virtual ~GuestDnDTargetTask(void) { }
    6161
     62    /** Returns the overall result of the task. */
    6263    int getRC(void) const { return mRC; }
     64    /** Returns if the overall result of the task is ok (succeeded) or not. */
    6365    bool isOk(void) const { return RT_SUCCESS(mRC); }
    6466
    6567protected:
    6668
     69    /** COM object pointer to the parent (source). */
    6770    const ComObjPtr<GuestDnDTarget>     mTarget;
     71    /** Overall result of the task. */
    6872    int                                 mRC;
    6973};
     
    670674}
    671675
     676/**
     677 * Returns an error string from a guest DnD error.
     678 *
     679 * @returns Error string.
     680 * @param   guestRc             Guest error to return error string for.
     681 */
    672682/* static */
    673683Utf8Str GuestDnDTarget::i_guestErrorToString(int guestRc)
     
    708718}
    709719
     720/**
     721 * Returns an error string from a host DnD error.
     722 *
     723 * @returns Error string.
     724 * @param   hostRc              Host error to return error string for.
     725 */
    710726/* static */
    711727Utf8Str GuestDnDTarget::i_hostErrorToString(int hostRc)
     
    742758}
    743759
     760/**
     761 * Resets all internal data and state.
     762 */
    744763void GuestDnDTarget::i_reset(void)
    745764{
     
    919938}
    920939
     940/**
     941 * Sends a directory entry to the guest.
     942 *
     943 * @returns VBox status code.
     944 * @param   pCtx                Send context to use.
     945 * @param   pObj                Transfer object to send. Must be a directory.
     946 * @param   pMsg                Where to store the message to send.
     947 */
    921948int GuestDnDTarget::i_sendDirectory(GuestDnDSendCtx *pCtx, PDNDTRANSFEROBJECT pObj, GuestDnDMsg *pMsg)
    922949{
     
    942969
    943970/**
    944  * Sends a transfer file to the guest.
     971 * Sends a file to the guest.
    945972 *
    946973 * @returns VBox status code.
    947  * @param   pCtx
    948  * @param   pObj
    949  * @param   pMsg
     974 * @param   pCtx                Send context to use.
     975 * @param   pObj                Transfer object to send. Must be a file.
     976 * @param   pMsg                Where to store the message to send.
    950977 */
    951978int GuestDnDTarget::i_sendFile(GuestDnDSendCtx *pCtx,
     
    10341061}
    10351062
     1063/**
     1064 * Helper function to send actual file data to the guest.
     1065 *
     1066 * @returns VBox status code.
     1067 * @param   pCtx                Send context to use.
     1068 * @param   pObj                Transfer object to send. Must be a file.
     1069 * @param   pMsg                Where to store the message to send.
     1070 */
    10361071int GuestDnDTarget::i_sendFileData(GuestDnDSendCtx *pCtx,
    10371072                                   PDNDTRANSFEROBJECT pObj, GuestDnDMsg *pMsg)
     
    11131148}
    11141149
     1150/**
     1151 * Static HGCM service callback which handles sending transfer data to the guest.
     1152 *
     1153 * @returns VBox status code. Will get sent back to the host service.
     1154 * @param   uMsg                HGCM message ID (function number).
     1155 * @param   pvParms             Pointer to additional message data. Optional and can be NULL.
     1156 * @param   cbParms             Size (in bytes) additional message data. Optional and can be 0.
     1157 * @param   pvUser              User-supplied pointer on callback registration.
     1158 */
    11151159/* static */
    11161160DECLCALLBACK(int) GuestDnDTarget::i_sendTransferDataCallback(uint32_t uMsg, void *pvParms, size_t cbParms, void *pvUser)
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