Changeset 57221 in vbox for trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp
- Timestamp:
- Aug 6, 2015 7:19:19 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp
r56909 r57221 177 177 } 178 178 179 HRESULT GuestDnDTarget::getFormats( std::vector<com::Utf8Str>&aFormats)179 HRESULT GuestDnDTarget::getFormats(GuestDnDMIMEList &aFormats) 180 180 { 181 181 #if !defined(VBOX_WITH_DRAG_AND_DROP) … … 192 192 } 193 193 194 HRESULT GuestDnDTarget::addFormats(const std::vector<com::Utf8Str>&aFormats)194 HRESULT GuestDnDTarget::addFormats(const GuestDnDMIMEList &aFormats) 195 195 { 196 196 #if !defined(VBOX_WITH_DRAG_AND_DROP) … … 207 207 } 208 208 209 HRESULT GuestDnDTarget::removeFormats(const std::vector<com::Utf8Str>&aFormats)209 HRESULT GuestDnDTarget::removeFormats(const GuestDnDMIMEList &aFormats) 210 210 { 211 211 #if !defined(VBOX_WITH_DRAG_AND_DROP) … … 243 243 DnDAction_T aDefaultAction, 244 244 const std::vector<DnDAction_T> &aAllowedActions, 245 const std::vector<com::Utf8Str>&aFormats,245 const GuestDnDMIMEList &aFormats, 246 246 DnDAction_T *aResultAction) 247 247 { … … 276 276 return S_OK; 277 277 278 /* Make a flat data string out of the supported format list. */ 279 Utf8Str strFormats = GuestDnD::toFormatString(m_vecFmtSup, aFormats); 280 281 /* If there is no valid supported format, ignore this request. */ 278 /* 279 * Make a flat data string out of the supported format list. 280 * In the GuestDnDTarget case the source formats are from the host, 281 * as GuestDnDTarget acts as a source for the guest. 282 */ 283 Utf8Str strFormats = GuestDnD::toFormatString(GuestDnD::toFilteredFormatList(m_lstFmtSupported, aFormats)); 282 284 if (strFormats.isEmpty()) 283 return setError(E_INVALIDARG, tr(" Specified format(s) not supported"));285 return setError(E_INVALIDARG, tr("No or not supported format(s) specified")); 284 286 285 287 LogRel2(("DnD: Offered formats to guest:\n")); … … 290 292 /* Save the formats offered to the guest. This is needed to later 291 293 * decide what to do with the data when sending stuff to the guest. */ 292 m_ vecFmtOff= aFormats;293 Assert(m_ vecFmtOff.size());294 m_lstFmtOffered = aFormats; 295 Assert(m_lstFmtOffered.size()); 294 296 295 297 HRESULT hr = S_OK; … … 335 337 DnDAction_T aDefaultAction, 336 338 const std::vector<DnDAction_T> &aAllowedActions, 337 const std::vector<com::Utf8Str>&aFormats,339 const GuestDnDMIMEList &aFormats, 338 340 DnDAction_T *aResultAction) 339 341 { … … 359 361 return S_OK; 360 362 361 /* Make a flat data string out of the supported format list. */ 362 RTCString strFormats = GuestDnD::toFormatString(m_vecFmtSup, aFormats); 363 /* If there is no valid supported format, ignore this request. */ 363 /* 364 * Make a flat data string out of the supported format list. 365 * In the GuestDnDTarget case the source formats are from the host, 366 * as GuestDnDTarget acts as a source for the guest. 367 */ 368 Utf8Str strFormats = GuestDnD::toFormatString(GuestDnD::toFilteredFormatList(m_lstFmtSupported, aFormats)); 364 369 if (strFormats.isEmpty()) 365 return setError(E_INVALIDARG, tr(" Specified format(s) not supported"));370 return setError(E_INVALIDARG, tr("No or not supported format(s) specified")); 366 371 367 372 HRESULT hr = S_OK; … … 433 438 DnDAction_T aDefaultAction, 434 439 const std::vector<DnDAction_T> &aAllowedActions, 435 const std::vector<com::Utf8Str>&aFormats,440 const GuestDnDMIMEList &aFormats, 436 441 com::Utf8Str &aFormat, 437 442 DnDAction_T *aResultAction) … … 441 446 #else /* VBOX_WITH_DRAG_AND_DROP */ 442 447 443 /* Input validation. */ 444 445 /* Everything else is optional. */ 448 if (aDefaultAction == DnDAction_Ignore) 449 return setError(E_INVALIDARG, tr("Invalid default action specified")); 450 if (!aAllowedActions.size()) 451 return setError(E_INVALIDARG, tr("Invalid allowed actions specified")); 452 if (!aFormats.size()) 453 return setError(E_INVALIDARG, tr("No drop format(s) specified")); 454 /* aResultAction is optional. */ 446 455 447 456 AutoCaller autoCaller(this); … … 449 458 450 459 /* Default action is ignoring. */ 451 DnDAction_T resAction = DnDAction_Ignore;452 453 /* Check & convert the drag & drop actions . */454 uint32_t uDefAction = 0;460 DnDAction_T resAction = DnDAction_Ignore; 461 462 /* Check & convert the drag & drop actions to HGCM codes. */ 463 uint32_t uDefAction = DND_IGNORE_ACTION; 455 464 uint32_t uAllowedActions = 0; 456 GuestDnD::toHGCMActions(aDefaultAction, &uDefAction,465 GuestDnD::toHGCMActions(aDefaultAction, &uDefAction, 457 466 aAllowedActions, &uAllowedActions); 458 467 /* If there is no usable action, ignore this request. */ … … 465 474 } 466 475 467 /* Make a flat data string out of the supported format list. */ 468 Utf8Str strFormats = GuestDnD::toFormatString(m_vecFmtSup, aFormats); 469 /* If there is no valid supported format, ignore this request. */ 476 /* 477 * Make a flat data string out of the supported format list. 478 * In the GuestDnDTarget case the source formats are from the host, 479 * as GuestDnDTarget acts as a source for the guest. 480 */ 481 Utf8Str strFormats = GuestDnD::toFormatString(GuestDnD::toFilteredFormatList(m_lstFmtSupported, aFormats)); 470 482 if (strFormats.isEmpty()) 471 return setError(E_INVALIDARG, tr("Specified format(s) not supported")); 472 473 HRESULT hr = S_OK; 483 return setError(E_INVALIDARG, tr("No or not supported format(s) specified")); 474 484 475 485 /* Adjust the coordinates in a multi-monitor setup. */ 476 int rc= GuestDnDInst()->adjustScreenCoordinates(aScreenId, &aX, &aY);477 if ( RT_SUCCESS(rc))486 HRESULT hr = GuestDnDInst()->adjustScreenCoordinates(aScreenId, &aX, &aY); 487 if (SUCCEEDED(hr)) 478 488 { 479 489 GuestDnDMsg Msg; … … 487 497 Msg.setNextUInt32(strFormats.length() + 1); 488 498 489 rc = GuestDnDInst()->hostCall(Msg.getType(), Msg.getCount(), Msg.getParms());499 int rc = GuestDnDInst()->hostCall(Msg.getType(), Msg.getCount(), Msg.getParms()); 490 500 if (RT_SUCCESS(rc)) 491 501 { 492 502 GuestDnDResponse *pResp = GuestDnDInst()->response(); 493 if (pResp && RT_SUCCESS(pResp->waitForGuestResponse())) 503 AssertPtr(pResp); 504 505 rc = pResp->waitForGuestResponse(); 506 if (RT_SUCCESS(rc)) 494 507 { 495 508 resAction = GuestDnD::toMainAction(pResp->defAction()); 496 aFormat = pResp->fmtReq(); 497 498 LogFlowFunc(("resFormat=%s, resAction=%RU32\n", 499 pResp->fmtReq().c_str(), pResp->defAction())); 509 510 GuestDnDMIMEList lstFormats = pResp->formats(); 511 if (lstFormats.size() == 1) /* Exactly one format to use specified? */ 512 { 513 aFormat = lstFormats.at(0); 514 LogFlowFunc(("resFormat=%s, resAction=%RU32\n", aFormat.c_str(), pResp->defAction())); 515 } 516 else 517 hr = setError(VBOX_E_IPRT_ERROR, tr("Guest returned invalid drop formats (%zu formats)"), lstFormats.size()); 500 518 } 501 } 502 } 503 504 if (RT_FAILURE(rc)) 505 hr = VBOX_E_IPRT_ERROR; 519 else 520 hr = setError(VBOX_E_IPRT_ERROR, tr("Waiting for response of dropped event failed (%Rrc)"), rc); 521 } 522 else 523 hr = setError(VBOX_E_IPRT_ERROR, tr("Sending dropped event to guest failed (%Rrc)"), rc); 524 } 525 else 526 hr = setError(hr, tr("Retrieving drop coordinates failed")); 506 527 507 528 if (SUCCEEDED(hr)) … … 737 758 * 738 759 ** @todo Support more than one format; add a format<->function handler concept. Later. */ 739 bool fHasURIList = std::find(m_ vecFmtOff.begin(),740 m_ vecFmtOff.end(), "text/uri-list") != m_vecFmtOff.end();760 bool fHasURIList = std::find(m_lstFmtOffered.begin(), 761 m_lstFmtOffered.end(), "text/uri-list") != m_lstFmtOffered.end(); 741 762 if (fHasURIList) 742 763 {
Note:
See TracChangeset
for help on using the changeset viewer.