- Timestamp:
- Aug 13, 2020 7:08:34 AM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 139887
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/GuestDnDPrivate.h
r85583 r85739 837 837 /** @} */ 838 838 839 p rotected:839 public: 840 840 841 841 /** Pointer to context this class is tied to. */ 842 842 void *m_pvCtx; 843 /** The DnD protocol version to use, depending on the 844 * installed Guest Additions. See DragAndDropSvc.h for 845 * a protocol changelog. */ 846 uint32_t m_uProtocolVersion; 847 /** The guest feature flags reported to the host (VBOX_DND_GF_XXX). */ 848 uint64_t m_fGuestFeatures0; 843 849 /** Event for waiting for response. */ 844 850 RTSEMEVENT m_EventSem; … … 1003 1009 HRESULT i_addFormats(const GuestDnDMIMEList &aFormats); 1004 1010 HRESULT i_removeFormats(const GuestDnDMIMEList &aFormats); 1005 1006 HRESULT i_getProtocolVersion(ULONG *puVersion);1007 1011 /** @} */ 1008 1012 1009 1013 protected: 1010 1011 int getProtocolVersion(uint32_t *puVersion);1012 1014 1013 1015 /** @name Functions for handling a simple host HGCM message queue. … … 1035 1037 /** Whether the object still is in pending state. */ 1036 1038 bool m_fIsPending; 1039 /** Pointer to response bound to this object. */ 1040 GuestDnDResponse *m_pResp; 1037 1041 /** @} */ 1038 1042 … … 1042 1046 struct 1043 1047 { 1044 /** The DnD protocol version to use, depending on the1045 * installed Guest Additions. See DragAndDropSvc.h for1046 * a protocol changelog. */1047 uint32_t uProtocolVersion;1048 1048 /** Outgoing message queue (FIFO). */ 1049 1049 GuestDnDMsgList lstMsgOut; -
trunk/src/VBox/Main/src-client/GuestDnDPrivate.cpp
r85681 r85739 291 291 292 292 GuestDnDResponse::GuestDnDResponse(const ComObjPtr<Guest>& pGuest) 293 : m_EventSem(NIL_RTSEMEVENT) 293 : m_uProtocolVersion(0) 294 , m_fGuestFeatures0(VBOX_DND_GF_NONE) 295 , m_EventSem(NIL_RTSEMEVENT) 294 296 , m_dndActionDefault(0) 295 297 , m_dndLstActionsAllowed(0) … … 519 521 520 522 int rc = VERR_WRONG_ORDER; /* Play safe. */ 523 524 /* Whether or not to try calling host-installed callbacks after successfully processing the message. */ 521 525 bool fTryCallbacks = false; 522 526 … … 525 529 case DragAndDropSvc::GUEST_DND_CONNECT: 526 530 { 527 LogThisFunc(("Client connected\n")); 528 529 /* Nothing to do here (yet). */ 531 DragAndDropSvc::PVBOXDNDCBCONNECTDATA pCBData = reinterpret_cast<DragAndDropSvc::PVBOXDNDCBCONNECTDATA>(pvParms); 532 AssertPtr(pCBData); 533 AssertReturn(sizeof(DragAndDropSvc::VBOXDNDCBCONNECTDATA) == cbParms, VERR_INVALID_PARAMETER); 534 AssertReturn(DragAndDropSvc::CB_MAGIC_DND_CONNECT == pCBData->hdr.uMagic, VERR_INVALID_PARAMETER); 535 536 m_uProtocolVersion = pCBData->uProtocolVersion; 537 /** @todo Handle flags. */ 538 539 LogThisFunc(("Client connected, using protocol v%RU32\n", m_uProtocolVersion)); 540 541 rc = VINF_SUCCESS; 542 break; 543 } 544 545 case DragAndDropSvc::GUEST_DND_REPORT_FEATURES: 546 { 547 DragAndDropSvc::PVBOXDNDCBREPORTFEATURESDATA pCBData = reinterpret_cast<DragAndDropSvc::PVBOXDNDCBREPORTFEATURESDATA>(pvParms); 548 AssertPtr(pCBData); 549 AssertReturn(sizeof(DragAndDropSvc::VBOXDNDCBREPORTFEATURESDATA) == cbParms, VERR_INVALID_PARAMETER); 550 AssertReturn(DragAndDropSvc::CB_MAGIC_DND_REPORT_FEATURES == pCBData->hdr.uMagic, VERR_INVALID_PARAMETER); 551 552 m_fGuestFeatures0 = pCBData->fGuestFeatures0; 553 554 LogThisFunc(("Client reported features: %#RX64\n", m_fGuestFeatures0)); 555 530 556 rc = VINF_SUCCESS; 531 557 break; … … 1151 1177 /* Initialize public attributes. */ 1152 1178 m_lstFmtSupported = GuestDnDInst()->defaultFormats(); 1153 1154 /* Initialzie private stuff. */1155 m_DataBase.uProtocolVersion = 0;1156 1179 } 1157 1180 … … 1218 1241 } 1219 1242 1220 /* Deprecated. */1221 HRESULT GuestDnDBase::i_getProtocolVersion(ULONG *puVersion)1222 {1223 int rc = getProtocolVersion((uint32_t *)puVersion);1224 return RT_SUCCESS(rc) ? S_OK : E_FAIL;1225 }1226 1227 /**1228 * Tries to guess the DnD protocol version to use on the guest, based on the1229 * installed Guest Additions version + revision.1230 *1231 * Deprecated.1232 *1233 * If unable to retrieve the protocol version, VERR_NOT_FOUND is returned along1234 * with protocol version 1.1235 *1236 * @return IPRT status code.1237 * @param puProto Where to store the protocol version.1238 */1239 int GuestDnDBase::getProtocolVersion(uint32_t *puProto)1240 {1241 AssertPtrReturn(puProto, VERR_INVALID_POINTER);1242 1243 int rc;1244 1245 uint32_t uProto = 0;1246 uint32_t uVerAdditions;1247 uint32_t uRevAdditions;1248 if ( m_pGuest1249 && (uVerAdditions = m_pGuest->i_getAdditionsVersion()) > 01250 && (uRevAdditions = m_pGuest->i_getAdditionsRevision()) > 0)1251 {1252 #if 0 && defined(DEBUG)1253 /* Hardcode the to-used protocol version; nice for testing side effects. */1254 if (true)1255 uProto = 3;1256 else1257 #endif1258 if (uVerAdditions >= VBOX_FULL_VERSION_MAKE(5, 0, 0))1259 {1260 /** @todo1261 * r=bird: This is just too bad for anyone using an OSE additions build...1262 */1263 if (uRevAdditions >= 103344) /* Since r103344: Protocol v3. */1264 uProto = 3;1265 else1266 uProto = 2; /* VBox 5.0.0 - 5.0.8: Protocol v2. */1267 }1268 /* else: uProto: 0 */1269 1270 LogFlowFunc(("uVerAdditions=%RU32 (%RU32.%RU32.%RU32), r%RU32\n",1271 uVerAdditions, VBOX_FULL_VERSION_GET_MAJOR(uVerAdditions), VBOX_FULL_VERSION_GET_MINOR(uVerAdditions),1272 VBOX_FULL_VERSION_GET_BUILD(uVerAdditions), uRevAdditions));1273 rc = VINF_SUCCESS;1274 }1275 else1276 {1277 uProto = 1; /* Fallback. */1278 rc = VERR_NOT_FOUND;1279 }1280 1281 LogRel2(("DnD: Guest is using protocol v%RU32, rc=%Rrc\n", uProto, rc));1282 1283 *puProto = uProto;1284 return rc;1285 }1286 1287 1243 /** 1288 1244 * Adds a new guest DnD message to the internal message queue. … … 1352 1308 GuestDnDMsg Msg; 1353 1309 Msg.setType(HOST_DND_CANCEL); 1354 if (m_ DataBase.uProtocolVersion >= 3)1310 if (m_pResp->m_uProtocolVersion >= 3) 1355 1311 Msg.appendUInt32(0); /** @todo ContextID not used yet. */ 1356 1312 -
trunk/src/VBox/Main/src-client/GuestDnDSourceImpl.cpp
r85681 r85739 156 156 unconst(m_pGuest) = pGuest; 157 157 158 /* Set the response we're going to use for this object. 159 * 160 * At the moment we only have one response total, as we 161 * don't allow 162 * 1) parallel transfers (multiple G->H at the same time) 163 * nor 2) mixed transfers (G->H + H->G at the same time). 164 */ 165 m_pResp = GuestDnDInst()->response(); 166 AssertPtrReturn(m_pResp, VERR_INVALID_POINTER); 167 158 168 /* Confirm a successful initialization when it's the case. */ 159 169 autoInitSpan.setSucceeded(); … … 254 264 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 255 265 256 return GuestDnDBase::i_getProtocolVersion(aProtocolVersion); 266 *aProtocolVersion = m_pResp->m_uProtocolVersion; 267 268 return S_OK; 257 269 #endif /* VBOX_WITH_DRAG_AND_DROP */ 258 270 } … … 273 285 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 274 286 275 /* Determine guest DnD protocol to use. */276 GuestDnDBase::getProtocolVersion(&m_DataBase.uProtocolVersion);277 278 287 /* Default is ignoring the action. */ 279 288 if (aDefaultAction) … … 284 293 GuestDnDMsg Msg; 285 294 Msg.setType(HOST_DND_GH_REQ_PENDING); 286 if (m_ DataBase.uProtocolVersion >= 3)295 if (m_pResp->m_uProtocolVersion >= 3) 287 296 Msg.appendUInt32(0); /** @todo ContextID not used yet. */ 288 297 Msg.appendUInt32(uScreenId); … … 673 682 size_t cbMetaAnnounced; 674 683 675 if (m_ DataBase.uProtocolVersion < 3)684 if (m_pResp->m_uProtocolVersion < 3) 676 685 { 677 686 cbData = pSndData->u.v1.cbData; … … 890 899 891 900 /* Note: Protocol v1 does not send any file sizes, so always 0. */ 892 if (m_ DataBase.uProtocolVersion >= 2)901 if (m_pResp->m_uProtocolVersion >= 2) 893 902 rc = DnDTransferObjectSetSize(pObj, cbSize); 894 903 … … 1138 1147 REGISTER_CALLBACK(GUEST_DND_DISCONNECT); 1139 1148 REGISTER_CALLBACK(GUEST_DND_GH_EVT_ERROR); 1140 if (m_ DataBase.uProtocolVersion >= 3)1149 if (m_pResp->m_uProtocolVersion >= 3) 1141 1150 REGISTER_CALLBACK(GUEST_DND_GH_SND_DATA_HDR); 1142 1151 REGISTER_CALLBACK(GUEST_DND_GH_SND_DATA); … … 1149 1158 GuestDnDMsg Msg; 1150 1159 Msg.setType(HOST_DND_GH_EVT_DROPPED); 1151 if (m_ DataBase.uProtocolVersion >= 3)1160 if (m_pResp->m_uProtocolVersion >= 3) 1152 1161 Msg.appendUInt32(0); /** @todo ContextID not used yet. */ 1153 1162 Msg.appendPointer((void*)pCtx->strFmtRecv.c_str(), (uint32_t)pCtx->strFmtRecv.length() + 1); … … 1173 1182 UNREGISTER_CALLBACK(GUEST_DND_DISCONNECT); 1174 1183 UNREGISTER_CALLBACK(GUEST_DND_GH_EVT_ERROR); 1175 if (m_ DataBase.uProtocolVersion >= 3)1184 if (m_pResp->m_uProtocolVersion >= 3) 1176 1185 UNREGISTER_CALLBACK(GUEST_DND_GH_SND_DATA_HDR); 1177 1186 UNREGISTER_CALLBACK(GUEST_DND_GH_SND_DATA); … … 1251 1260 REGISTER_CALLBACK(GUEST_DND_DISCONNECT); 1252 1261 REGISTER_CALLBACK(GUEST_DND_GH_EVT_ERROR); 1253 if (m_ DataBase.uProtocolVersion >= 3)1262 if (m_pResp->m_uProtocolVersion >= 3) 1254 1263 REGISTER_CALLBACK(GUEST_DND_GH_SND_DATA_HDR); 1255 1264 REGISTER_CALLBACK(GUEST_DND_GH_SND_DATA); 1256 1265 REGISTER_CALLBACK(GUEST_DND_GH_SND_DIR); 1257 if (m_ DataBase.uProtocolVersion >= 2)1266 if (m_pResp->m_uProtocolVersion >= 2) 1258 1267 REGISTER_CALLBACK(GUEST_DND_GH_SND_FILE_HDR); 1259 1268 REGISTER_CALLBACK(GUEST_DND_GH_SND_FILE_DATA); … … 1276 1285 GuestDnDMsg Msg; 1277 1286 Msg.setType(HOST_DND_GH_EVT_DROPPED); 1278 if (m_ DataBase.uProtocolVersion >= 3)1287 if (m_pResp->m_uProtocolVersion >= 3) 1279 1288 Msg.appendUInt32(0); /** @todo ContextID not used yet. */ 1280 1289 Msg.appendPointer((void*)pCtx->strFmtRecv.c_str(), (uint32_t)pCtx->strFmtRecv.length() + 1); … … 1572 1581 AssertReturn(CB_MAGIC_DND_GH_SND_FILE_DATA == pCBData->hdr.uMagic, VERR_INVALID_PARAMETER); 1573 1582 1574 if (pThis->m_ DataBase.uProtocolVersion <= 1)1583 if (pThis->m_pResp->m_uProtocolVersion <= 1) 1575 1584 { 1576 1585 /** -
trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp
r85681 r85739 154 154 unconst(m_pGuest) = pGuest; 155 155 156 /* Set the response we're going to use for this object. 157 * 158 * At the moment we only have one response total, as we 159 * don't allow 160 * 1) parallel transfers (multiple G->H at the same time) 161 * nor 2) mixed transfers (G->H + H->G at the same time). 162 */ 163 m_pResp = GuestDnDInst()->response(); 164 AssertPtrReturn(m_pResp, VERR_INVALID_POINTER); 165 156 166 /* Confirm a successful initialization when it's the case. */ 157 167 autoInitSpan.setSucceeded(); … … 252 262 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 253 263 254 return GuestDnDBase::i_getProtocolVersion(aProtocolVersion); 264 *aProtocolVersion = m_pResp->m_uProtocolVersion; 265 266 return S_OK; 255 267 #endif /* VBOX_WITH_DRAG_AND_DROP */ 256 268 } … … 279 291 AutoCaller autoCaller(this); 280 292 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 281 282 /* Determine guest DnD protocol to use. */283 GuestDnDBase::getProtocolVersion(&m_DataBase.uProtocolVersion);284 293 285 294 /* Default action is ignoring. */ … … 324 333 GuestDnDMsg Msg; 325 334 Msg.setType(HOST_DND_HG_EVT_ENTER); 326 if (m_ DataBase.uProtocolVersion >= 3)335 if (m_pResp->m_uProtocolVersion >= 3) 327 336 Msg.appendUInt32(0); /** @todo ContextID not used yet. */ 328 337 Msg.appendUInt32(aScreenId); … … 337 346 if (RT_SUCCESS(rc)) 338 347 { 339 GuestDnDResponse *pResp = GuestDnDInst()->response(); 340 if (pResp && RT_SUCCESS(pResp->waitForGuestResponse())) 341 resAction = GuestDnD::toMainAction(pResp->getActionDefault()); 348 if (RT_SUCCESS(m_pResp->waitForGuestResponse())) 349 resAction = GuestDnD::toMainAction(m_pResp->getActionDefault()); 342 350 } 343 351 } … … 402 410 GuestDnDMsg Msg; 403 411 Msg.setType(HOST_DND_HG_EVT_MOVE); 404 if (m_ DataBase.uProtocolVersion >= 3)412 if (m_pResp->m_uProtocolVersion >= 3) 405 413 Msg.appendUInt32(0); /** @todo ContextID not used yet. */ 406 414 Msg.appendUInt32(aScreenId); … … 449 457 GuestDnDMsg Msg; 450 458 Msg.setType(HOST_DND_HG_EVT_LEAVE); 451 if (m_ DataBase.uProtocolVersion >= 3)459 if (m_pResp->m_uProtocolVersion >= 3) 452 460 Msg.appendUInt32(0); /** @todo ContextID not used yet. */ 453 461 … … 525 533 GuestDnDMsg Msg; 526 534 Msg.setType(HOST_DND_HG_EVT_DROPPED); 527 if (m_ DataBase.uProtocolVersion >= 3)535 if (m_pResp->m_uProtocolVersion >= 3) 528 536 Msg.appendUInt32(0); /** @todo ContextID not used yet. */ 529 537 Msg.appendUInt32(aScreenId); … … 844 852 const char *pcszFmt = pCtx->Meta.strFmt.c_str(); 845 853 846 LogFlowFunc(("uProto =%u, szFmt=%s, cbFmt=%RU32, cbData=%zu\n", m_DataBase.uProtocolVersion, pcszFmt, cbFmt, cbData));854 LogFlowFunc(("uProtoVer=%RU32, szFmt=%s, cbFmt=%RU32, cbData=%zu\n", m_pResp->m_uProtocolVersion, pcszFmt, cbFmt, cbData)); 847 855 848 856 LogRel2(("DnD: Sending meta data to guest as '%s' (%zu bytes)\n", pcszFmt, cbData)); … … 862 870 Msg.setType(HOST_DND_HG_SND_DATA); 863 871 864 if (m_ DataBase.uProtocolVersion < 3)872 if (m_pResp->m_uProtocolVersion < 3) 865 873 { 866 874 Msg.appendUInt32(pCtx->uScreenID); /* uScreenId */ … … 910 918 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 911 919 912 if (m_ DataBase.uProtocolVersion < 3) /* Protocol < v3 did not support this, skip. */920 if (m_pResp->m_uProtocolVersion < 3) /* Protocol < v3 did not support this, skip. */ 913 921 return VINF_SUCCESS; 914 922 … … 959 967 960 968 pMsg->setType(HOST_DND_HG_SND_DIR); 961 if (m_ DataBase.uProtocolVersion >= 3)969 if (m_pResp->m_uProtocolVersion >= 3) 962 970 pMsg->appendUInt32(0); /** @todo ContextID not used yet. */ 963 971 pMsg->appendString(pcszDstPath); /* path */ … … 1006 1014 if (RT_SUCCESS(rc)) 1007 1015 { 1008 if (m_ DataBase.uProtocolVersion >= 2)1016 if (m_pResp->m_uProtocolVersion >= 2) 1009 1017 { 1010 1018 if (!(pCtx->Transfer.fObjState & DND_OBJ_STATE_HAS_HDR)) … … 1088 1096 /* Protocol version 1 sends the file path *every* time with a new file chunk. 1089 1097 * In protocol version 2 we only do this once with HOST_DND_HG_SND_FILE_HDR. */ 1090 if (m_ DataBase.uProtocolVersion <= 1)1098 if (m_pResp->m_uProtocolVersion <= 1) 1091 1099 { 1092 1100 const size_t cchDstPath = RTStrNLen(pcszDstPath, RTPATH_MAX); … … 1095 1103 pMsg->appendUInt32((uint32_t)cchDstPath + 1); /* cbName */ 1096 1104 } 1097 else if (m_ DataBase.uProtocolVersion >= 2)1105 else if (m_pResp->m_uProtocolVersion >= 2) 1098 1106 { 1099 1107 pMsg->appendUInt32(0); /** @todo ContextID not used yet. */ … … 1112 1120 LogFlowFunc(("cbBufe=%zu, cbRead=%RU32\n", cbBuf, cbRead)); 1113 1121 1114 if (m_ DataBase.uProtocolVersion <= 1)1122 if (m_pResp->m_uProtocolVersion <= 1) 1115 1123 { 1116 1124 pMsg->appendPointer(pvBuf, cbRead); /* pvData */ … … 1123 1131 pMsg->appendUInt32(cbRead); /* cbData */ 1124 1132 1125 if (m_ DataBase.uProtocolVersion >= 3)1133 if (m_pResp->m_uProtocolVersion >= 3) 1126 1134 { 1127 1135 /** @todo Calculate checksum. */ … … 1415 1423 /* Host callbacks. */ 1416 1424 REGISTER_CALLBACK(HOST_DND_HG_SND_DIR); 1417 if (m_ DataBase.uProtocolVersion >= 2)1425 if (m_pResp->m_uProtocolVersion >= 2) 1418 1426 REGISTER_CALLBACK(HOST_DND_HG_SND_FILE_HDR); 1419 1427 REGISTER_CALLBACK(HOST_DND_HG_SND_FILE_DATA); … … 1482 1490 * Send the data header first. 1483 1491 */ 1484 if (m_ DataBase.uProtocolVersion >= 3)1492 if (m_pResp->m_uProtocolVersion >= 3) 1485 1493 rc = i_sendMetaDataHeader(pCtx); 1486 1494 … … 1510 1518 /* Host callbacks. */ 1511 1519 UNREGISTER_CALLBACK(HOST_DND_HG_SND_DIR); 1512 if (m_ DataBase.uProtocolVersion >= 2)1520 if (m_pResp->m_uProtocolVersion >= 2) 1513 1521 UNREGISTER_CALLBACK(HOST_DND_HG_SND_FILE_HDR); 1514 1522 UNREGISTER_CALLBACK(HOST_DND_HG_SND_FILE_DATA);
Note:
See TracChangeset
for help on using the changeset viewer.