Changeset 85681 in vbox for trunk/src/VBox/Main/src-client
- Timestamp:
- Aug 11, 2020 9:36:37 AM (4 years ago)
- Location:
- trunk/src/VBox/Main/src-client
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/GuestDnDPrivate.cpp
r85561 r85681 55 55 * 56 56 * 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. 58 58 * 2. Main: Public interface for doing Drag and Drop. Also manage the IProgress 59 59 * interfaces for blocking the caller by showing a progress dialog (see … … 62 62 * encapsulate the internal communication details (see dndmanager.cpp and 63 63 * friends). 64 * 4. Guest additions: Split into the platform neutral part (see64 * 4. Guest Additions: Split into the platform neutral part (see 65 65 * VBoxGuestR3LibDragAndDrop.cpp) and the guest OS specific parts. 66 66 * 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. 69 78 * 70 79 * Host -> Guest: 71 80 * 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. 73 82 * The guest has to respond with an action it would accept, so the GUI could 74 * change the cursor .83 * change the cursor accordingly. 75 84 * 2. On drop, first a drop event is sent. If this is accepted a drop data 76 85 * event follows. This blocks the GUI and shows some progress indicator. … … 85 94 * shows some progress indicator. 86 95 * 87 * Somehints:96 * Implementation hints: 88 97 * m_strSupportedFormats here in this file defines the allowed mime-types. 89 98 * This is necessary because we need special handling for some of the … … 104 113 * same has to be done in the G->H direction when it is implemented. 105 114 * 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: 113 124 * 1. If a file is executable, it should be also after the transfer, so the 114 125 * user can just execute it, without manually tweaking the modes first. … … 118 129 * ourself, in e.g. for a cleanup case after cancel). 119 130 * 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. 142 136 * 143 137 ** @todo 144 138 * - 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) 149 143 * - Test unusual behavior: 150 144 * - DnD service crash in the guest during a DnD op (e.g. crash of VBoxClient or X11) … … 152 146 * - Security considerations: We transfer a lot of memory between the guest and 153 147 * the host and even allow the creation of dirs/files. Maybe there should be 154 * limits introduced to preventing D OS attacks or filling up all the memory148 * limits introduced to preventing DoS attacks or filling up all the memory 155 149 * (both in the host and the guest). 156 150 */ -
trunk/src/VBox/Main/src-client/GuestDnDSourceImpl.cpp
r85564 r85681 57 57 virtual ~GuestDnDSourceTask(void) { } 58 58 59 /** Returns the overall result of the task. */ 59 60 int getRC(void) const { return mRC; } 61 /** Returns if the overall result of the task is ok (succeeded) or not. */ 60 62 bool isOk(void) const { return RT_SUCCESS(mRC); } 61 63 62 64 protected: 63 65 66 /** COM object pointer to the parent (source). */ 64 67 const ComObjPtr<GuestDnDSource> mSource; 68 /** Overall result of the task. */ 65 69 int mRC; 66 70 }; … … 507 511 ///////////////////////////////////////////////////////////////////////////// 508 512 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 */ 509 519 /* static */ 510 520 Utf8Str GuestDnDSource::i_guestErrorToString(int guestRc) … … 545 555 } 546 556 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 */ 547 563 /* static */ 548 564 Utf8Str GuestDnDSource::i_hostErrorToString(int hostRc) … … 583 599 } 584 600 601 /** 602 * Resets all internal data and state. 603 */ 585 604 void GuestDnDSource::i_reset(void) 586 605 { … … 632 651 633 652 /** 634 * Handles receiving a send data blockfrom the guest.653 * Main function for receiving data from the guest. 635 654 * 636 655 * @returns VBox status code. … … 762 781 return rc; 763 782 } 783 764 784 765 785 int GuestDnDSource::i_onReceiveDir(GuestDnDRecvCtx *pCtx, const char *pszPath, uint32_t cbPath, uint32_t fMode) … … 904 924 } 905 925 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 */ 906 934 int GuestDnDSource::i_onReceiveFileData(GuestDnDRecvCtx *pCtx, const void *pvData, uint32_t cbData) 907 935 { … … 971 999 972 1000 /** 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. 975 1006 */ 976 1007 int GuestDnDSource::i_receiveData(GuestDnDRecvCtx *pCtx, RTMSINTERVAL msTimeout) … … 1066 1097 } 1067 1098 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 */ 1068 1106 int GuestDnDSource::i_receiveRawData(GuestDnDRecvCtx *pCtx, RTMSINTERVAL msTimeout) 1069 1107 { … … 1171 1209 } 1172 1210 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 */ 1173 1218 int GuestDnDSource::i_receiveTransferData(GuestDnDRecvCtx *pCtx, RTMSINTERVAL msTimeout) 1174 1219 { … … 1305 1350 } 1306 1351 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 */ 1307 1361 /* static */ 1308 1362 DECLCALLBACK(int) GuestDnDSource::i_receiveRawDataCallback(uint32_t uMsg, void *pvParms, size_t cbParms, void *pvUser) … … 1434 1488 } 1435 1489 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 */ 1436 1499 /* static */ 1437 1500 DECLCALLBACK(int) GuestDnDSource::i_receiveTransferDataCallback(uint32_t uMsg, void *pvParms, size_t cbParms, void *pvUser) -
trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp
r85564 r85681 60 60 virtual ~GuestDnDTargetTask(void) { } 61 61 62 /** Returns the overall result of the task. */ 62 63 int getRC(void) const { return mRC; } 64 /** Returns if the overall result of the task is ok (succeeded) or not. */ 63 65 bool isOk(void) const { return RT_SUCCESS(mRC); } 64 66 65 67 protected: 66 68 69 /** COM object pointer to the parent (source). */ 67 70 const ComObjPtr<GuestDnDTarget> mTarget; 71 /** Overall result of the task. */ 68 72 int mRC; 69 73 }; … … 670 674 } 671 675 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 */ 672 682 /* static */ 673 683 Utf8Str GuestDnDTarget::i_guestErrorToString(int guestRc) … … 708 718 } 709 719 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 */ 710 726 /* static */ 711 727 Utf8Str GuestDnDTarget::i_hostErrorToString(int hostRc) … … 742 758 } 743 759 760 /** 761 * Resets all internal data and state. 762 */ 744 763 void GuestDnDTarget::i_reset(void) 745 764 { … … 919 938 } 920 939 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 */ 921 948 int GuestDnDTarget::i_sendDirectory(GuestDnDSendCtx *pCtx, PDNDTRANSFEROBJECT pObj, GuestDnDMsg *pMsg) 922 949 { … … 942 969 943 970 /** 944 * Sends a transferfile to the guest.971 * Sends a file to the guest. 945 972 * 946 973 * @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. 950 977 */ 951 978 int GuestDnDTarget::i_sendFile(GuestDnDSendCtx *pCtx, … … 1034 1061 } 1035 1062 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 */ 1036 1071 int GuestDnDTarget::i_sendFileData(GuestDnDSendCtx *pCtx, 1037 1072 PDNDTRANSFEROBJECT pObj, GuestDnDMsg *pMsg) … … 1113 1148 } 1114 1149 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 */ 1115 1159 /* static */ 1116 1160 DECLCALLBACK(int) GuestDnDTarget::i_sendTransferDataCallback(uint32_t uMsg, void *pvParms, size_t cbParms, void *pvUser)
Note:
See TracChangeset
for help on using the changeset viewer.