Changeset 58212 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Oct 13, 2015 11:49:33 AM (9 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDataObject_win.cpp
r58069 r58212 42 42 UIDnDDataObject::UIDnDDataObject(UIDnDHandler *pDnDHandler, const QStringList &lstFormats) 43 43 : m_pDnDHandler(pDnDHandler) 44 , mStatus(Uninitialized) 45 , mRefCount(1) 46 , mcFormats(0) 47 , mpFormatEtc(NULL) 48 , mpStgMedium(NULL) 49 , mSemEvent(NIL_RTSEMEVENT) 50 , mpvData(NULL) 51 , mcbData(0) 44 , m_enmStatus(DnDDataObjectStatus_Uninitialized) 45 , m_cRefs(1) 46 , m_cFormats(0) 47 , m_pFormatEtc(NULL) 48 , m_pStgMedium(NULL) 49 , m_SemEvent(NIL_RTSEMEVENT) 50 , m_fDataRetrieved(false) 51 , m_pvData(NULL) 52 , m_cbData(0) 52 53 { 53 54 HRESULT hr; … … 58 59 try 59 60 { 60 m pFormatEtc = new FORMATETC[cMaxFormats];61 RT_BZERO(m pFormatEtc, sizeof(FORMATETC) * cMaxFormats);62 m pStgMedium = new STGMEDIUM[cMaxFormats];63 RT_BZERO(m pStgMedium, sizeof(STGMEDIUM) * cMaxFormats);61 m_pFormatEtc = new FORMATETC[cMaxFormats]; 62 RT_BZERO(m_pFormatEtc, sizeof(FORMATETC) * cMaxFormats); 63 m_pStgMedium = new STGMEDIUM[cMaxFormats]; 64 RT_BZERO(m_pStgMedium, sizeof(STGMEDIUM) * cMaxFormats); 64 65 65 66 for (int i = 0; … … 68 69 { 69 70 const QString &strFormat = lstFormats.at(i); 70 if (m lstFormats.contains(strFormat))71 if (m_lstFormats.contains(strFormat)) 71 72 continue; 72 73 … … 74 75 if (strFormat.contains("text/uri-list", Qt::CaseInsensitive)) 75 76 { 76 RegisterFormat(&m pFormatEtc[cRegisteredFormats], CF_TEXT);77 m pStgMedium[cRegisteredFormats++].tymed = TYMED_HGLOBAL;78 RegisterFormat(&m pFormatEtc[cRegisteredFormats], CF_UNICODETEXT);79 m pStgMedium[cRegisteredFormats++].tymed = TYMED_HGLOBAL;80 RegisterFormat(&m pFormatEtc[cRegisteredFormats], CF_HDROP);81 m pStgMedium[cRegisteredFormats++].tymed = TYMED_HGLOBAL;82 83 m lstFormats << strFormat;77 RegisterFormat(&m_pFormatEtc[cRegisteredFormats], CF_TEXT); 78 m_pStgMedium[cRegisteredFormats++].tymed = TYMED_HGLOBAL; 79 RegisterFormat(&m_pFormatEtc[cRegisteredFormats], CF_UNICODETEXT); 80 m_pStgMedium[cRegisteredFormats++].tymed = TYMED_HGLOBAL; 81 RegisterFormat(&m_pFormatEtc[cRegisteredFormats], CF_HDROP); 82 m_pStgMedium[cRegisteredFormats++].tymed = TYMED_HGLOBAL; 83 84 m_lstFormats << strFormat; 84 85 } 85 86 /* Plain text ("text/plain"). */ 86 87 if (strFormat.contains("text/plain", Qt::CaseInsensitive)) 87 88 { 88 RegisterFormat(&m pFormatEtc[cRegisteredFormats], CF_TEXT);89 m pStgMedium[cRegisteredFormats++].tymed = TYMED_HGLOBAL;90 RegisterFormat(&m pFormatEtc[cRegisteredFormats], CF_UNICODETEXT);91 m pStgMedium[cRegisteredFormats++].tymed = TYMED_HGLOBAL;92 93 m lstFormats << strFormat;89 RegisterFormat(&m_pFormatEtc[cRegisteredFormats], CF_TEXT); 90 m_pStgMedium[cRegisteredFormats++].tymed = TYMED_HGLOBAL; 91 RegisterFormat(&m_pFormatEtc[cRegisteredFormats], CF_UNICODETEXT); 92 m_pStgMedium[cRegisteredFormats++].tymed = TYMED_HGLOBAL; 93 94 m_lstFormats << strFormat; 94 95 } 95 96 } … … 106 107 if (SUCCEEDED(hr)) 107 108 { 108 int rc2 = RTSemEventCreate(&m SemEvent);109 int rc2 = RTSemEventCreate(&m_SemEvent); 109 110 AssertRC(rc2); 110 111 … … 130 131 RegisterClipboardFormat(CFSTR_SHELLIDLISTOFFSET)); 131 132 #endif 132 m cFormats= cRegisteredFormats;133 m Status = Dropped;133 m_cFormats = cRegisteredFormats; 134 m_enmStatus = DnDDataObjectStatus_Dropping; 134 135 } 135 136 … … 139 140 UIDnDDataObject::~UIDnDDataObject(void) 140 141 { 141 if (m pFormatEtc)142 delete[] m pFormatEtc;143 144 if (m pStgMedium)145 delete[] m pStgMedium;146 147 if (m pvData)148 RTMemFree(m pvData);149 150 if (m SemEvent != NIL_RTSEMEVENT)151 RTSemEventDestroy(m SemEvent);152 153 LogFlowFunc(("mRefCount=%RI32\n", m RefCount));142 if (m_pFormatEtc) 143 delete[] m_pFormatEtc; 144 145 if (m_pStgMedium) 146 delete[] m_pStgMedium; 147 148 if (m_pvData) 149 RTMemFree(m_pvData); 150 151 if (m_SemEvent != NIL_RTSEMEVENT) 152 RTSemEventDestroy(m_SemEvent); 153 154 LogFlowFunc(("mRefCount=%RI32\n", m_cRefs)); 154 155 } 155 156 … … 160 161 STDMETHODIMP_(ULONG) UIDnDDataObject::AddRef(void) 161 162 { 162 return InterlockedIncrement(&m RefCount);163 return InterlockedIncrement(&m_cRefs); 163 164 } 164 165 165 166 STDMETHODIMP_(ULONG) UIDnDDataObject::Release(void) 166 167 { 167 LONG lCount = InterlockedDecrement(&m RefCount);168 LONG lCount = InterlockedDecrement(&m_cRefs); 168 169 if (lCount == 0) 169 170 { … … 210 211 LPSTGMEDIUM pThisMedium = NULL; 211 212 213 LogFlowThisFunc(("\n")); 214 212 215 /* Format supported? */ 213 216 ULONG lIndex; 214 217 if ( LookupFormatEtc(pFormatEtc, &lIndex) 215 && lIndex < m cFormats) /* Paranoia. */216 { 217 pThisMedium = &m pStgMedium[lIndex];218 && lIndex < m_cFormats) /* Paranoia. */ 219 { 220 pThisMedium = &m_pStgMedium[lIndex]; 218 221 AssertPtr(pThisMedium); 219 pThisFormat = &m pFormatEtc[lIndex];222 pThisFormat = &m_pFormatEtc[lIndex]; 220 223 AssertPtr(pThisFormat); 221 224 222 LogFlow Func(("pThisMedium=%p, pThisFormat=%p\n", pThisMedium, pThisFormat));223 LogFlow Func(("mStatus=%ld\n",mStatus));224 switch (m Status)225 LogFlowThisFunc(("pThisMedium=%p, pThisFormat=%p\n", pThisMedium, pThisFormat)); 226 LogFlowThisFunc(("mStatus=%RU32\n", m_enmStatus)); 227 switch (m_enmStatus) 225 228 { 226 case D ropping:229 case DnDDataObjectStatus_Dropping: 227 230 { 228 LogRel3(("DnD: Dropping\n")); 229 LogFlowFunc(("Waiting for event ...\n")); 230 int rc2 = RTSemEventWait(mSemEvent, RT_INDEFINITE_WAIT); 231 LogFlowFunc(("rc=%Rrc, mStatus=%ld\n", rc2, mStatus)); 231 #if 0 232 LogRel3(("DnD: Dropping\n")); 233 LogFlowFunc(("Waiting for event ...\n")); 234 int rc2 = RTSemEventWait(m_SemEvent, RT_INDEFINITE_WAIT); 235 LogFlowFunc(("rc=%Rrc, mStatus=%RU32\n", rc2, m_enmStatus)); 236 #endif 237 break; 232 238 } 233 239 234 case D ropped:240 case DnDDataObjectStatus_Dropped: 235 241 { 236 242 LogRel3(("DnD: Dropped\n")); … … 239 245 pThisFormat->tymed, pThisFormat->dwAspect)); 240 246 LogRel3(("DnD: Got strFormat=%s, pvData=%p, cbData=%RU32\n", 241 m strFormat.toAscii().constData(), mpvData, mcbData));247 m_strFormat.toAscii().constData(), m_pvData, m_cbData)); 242 248 243 249 QVariant::Type vaType; … … 288 294 289 295 int rc; 290 if (!mVaData.isValid()) 296 297 if (!m_fDataRetrieved) 291 298 { 292 /* Note: We're usig Qt::MoveAction because this speeds up the whole operation 293 * significantly: Instead of copying the data from the temporary location to 294 * the final destination we just move it. 295 * 296 * Note2: The Qt::MoveAction *only* affects the behavior on the host! The desired 297 * action for the guest (e.g. moving a file from guest to host) is not affected 298 * by this setting. */ 299 rc = m_pDnDHandler->retrieveData(Qt::MoveAction, 300 strMIMEType, vaType, mVaData); 299 if (m_pDnDHandler) 300 { 301 rc = m_pDnDHandler->retrieveData(Qt::CopyAction, 302 strMIMEType, vaType, m_vaData); 303 } 304 else 305 rc = VERR_NOT_FOUND; 306 307 m_fDataRetrieved = true; 308 LogFlowFunc(("Retrieving data ended with %Rrc\n", rc)); 301 309 } 302 else 303 rc = VINF_SUCCESS; /* Data already retrieved. */ 304 305 if (RT_SUCCESS(rc)) 310 else /* Data already been retrieved. */ 311 rc = VINF_SUCCESS; 312 313 if ( RT_SUCCESS(rc) 314 && m_vaData.isValid()) 306 315 { 307 316 if ( strMIMEType.startsWith("text/uri-list") 308 317 /* One item. */ 309 && ( m VaData.canConvert(QVariant::String)318 && ( m_vaData.canConvert(QVariant::String) 310 319 /* Multiple items. */ 311 || m VaData.canConvert(QVariant::StringList))320 || m_vaData.canConvert(QVariant::StringList)) 312 321 ) 313 322 { 314 QStringList lstFilesURI = m VaData.toStringList();323 QStringList lstFilesURI = m_vaData.toStringList(); 315 324 QStringList lstFiles; 316 325 for (size_t i = 0; i < lstFilesURI.size(); i++) … … 331 340 332 341 size_t cFiles = lstFiles.size(); 342 LogFlowThisFunc(("Files (%zu)\n", cFiles)); 333 343 if ( RT_SUCCESS(rc) 334 344 && cFiles) 335 345 { 336 #ifdef DEBUG 337 LogFlowFunc(("Files (%zu)\n", cFiles)); 338 for (size_t i = 0; i < cFiles; i++) 339 LogFlowFunc(("\tFile: %s\n", lstFiles.at(i).toAscii().constData())); 340 #endif 341 size_t cchFiles = 0; /* Number of ASCII characters. */ 346 size_t cchFiles = 0; /* Number of characters. */ 342 347 for (size_t i = 0; i < cFiles; i++) 343 348 { 344 cchFiles += strlen(lstFiles.at(i).toAscii().constData()); 349 const char *pszFile = lstFiles.at(i).toAscii().constData(); 350 cchFiles += strlen(pszFile); 345 351 cchFiles += 1; /* Terminating '\0'. */ 352 LogFlowThisFunc(("\tFile: %s (cchFiles=%zu)\n", pszFile, cchFiles)); 346 353 } 347 354 348 size_t cbBuf = sizeof(DROPFILES) + ((cchFiles + 1) * sizeof(RTUTF16)); 355 /* List termination with '\0'. */ 356 cchFiles++; 357 358 size_t cbBuf = sizeof(DROPFILES) + (cchFiles * sizeof(RTUTF16)); 349 359 DROPFILES *pDropFiles = (DROPFILES *)RTMemAllocZ(cbBuf); 350 360 if (pDropFiles) 351 361 { 352 pDropFiles->pFiles = sizeof(DROPFILES); 353 pDropFiles->fWide = 1; /* We use unicode. Always. */ 362 /* Put the files list right after our DROPFILES structure. */ 363 pDropFiles->pFiles = sizeof(DROPFILES); /* Offset to file list. */ 364 pDropFiles->fWide = 1; /* We use Unicode. Always. */ 354 365 355 366 uint8_t *pCurFile = (uint8_t *)pDropFiles + pDropFiles->pFiles; 356 367 AssertPtr(pCurFile); 357 368 369 LogFlowThisFunc(("Encoded:\n")); 358 370 for (size_t i = 0; i < cFiles; i++) 359 371 { 372 const char *pszFile = lstFiles.at(i).toUtf8().constData(); 373 Assert(strlen(pszFile)); 374 360 375 size_t cchCurFile; 361 376 PRTUTF16 pwszFile; 362 rc = RTStrToUtf16( lstFiles.at(i).toAscii().constData(), &pwszFile);377 rc = RTStrToUtf16(pszFile, &pwszFile); 363 378 if (RT_SUCCESS(rc)) 364 379 { … … 376 391 *pCurFile = L'\0'; 377 392 pCurFile += sizeof(RTUTF16); 393 394 LogFlowThisFunc(("\t#%zu: cchCurFile=%zu\n", i, cchCurFile)); 378 395 } 379 396 … … 382 399 *pCurFile = L'\0'; /* Final list terminator. */ 383 400 384 pMedium->tymed = TYMED_HGLOBAL; 401 /* 402 * Fill out the medium structure we're going to report back. 403 */ 404 pMedium->tymed = TYMED_HGLOBAL; 385 405 pMedium->pUnkForRelease = NULL; 386 pMedium->hGlobal = GlobalAlloc( GMEM_ZEROINIT387 | GMEM_MOVEABLE388 | GMEM_DDESHARE, cbBuf);406 pMedium->hGlobal = GlobalAlloc( GMEM_ZEROINIT 407 | GMEM_MOVEABLE 408 | GMEM_DDESHARE, cbBuf); 389 409 if (pMedium->hGlobal) 390 410 { … … 402 422 else 403 423 rc = VERR_NO_MEMORY; 424 425 LogFlowThisFunc(("Copying to TYMED_HGLOBAL (%zu bytes): %Rrc\n", cbBuf, rc)); 404 426 } 405 427 406 428 RTMemFree(pDropFiles); 407 429 } 430 else 431 rc = VERR_NO_MEMORY; 432 433 if (RT_FAILURE(rc)) 434 LogFlowThisFunc(("Failed with %Rrc\n", rc)); 408 435 } 409 436 } 410 437 else if ( strMIMEType.startsWith("text/plain") 411 && m VaData.canConvert(QVariant::String))438 && m_vaData.canConvert(QVariant::String)) 412 439 { 413 bool fUnicode = pFormatEtc->cfFormat == CF_UNICODETEXT;414 int cbCh= fUnicode415 ? sizeof(WCHAR) : sizeof(char);416 417 QString strText = m VaData.toString();440 const bool fUnicode = pFormatEtc->cfFormat == CF_UNICODETEXT; 441 const size_t cbCh = fUnicode 442 ? sizeof(WCHAR) : sizeof(char); 443 444 QString strText = m_vaData.toString(); 418 445 size_t cbSrc = strText.length() * cbCh; 419 446 Assert(cbSrc); … … 423 450 AssertPtr(pvSrc); 424 451 425 LogFlowFunc(("pvSrc=0x%p, cbSrc=%zu, cb ch=%d, fUnicode=%RTbool\n",452 LogFlowFunc(("pvSrc=0x%p, cbSrc=%zu, cbCh=%zu, fUnicode=%RTbool\n", 426 453 pvSrc, cbSrc, cbCh, fUnicode)); 427 454 428 pMedium->tymed = TYMED_HGLOBAL;455 pMedium->tymed = TYMED_HGLOBAL; 429 456 pMedium->pUnkForRelease = NULL; 430 pMedium->hGlobal = GlobalAlloc( GMEM_ZEROINIT 431 | GMEM_MOVEABLE 432 | GMEM_DDESHARE, 433 cbSrc); 457 pMedium->hGlobal = GlobalAlloc(GHND | GMEM_SHARE, cbSrc); 434 458 if (pMedium->hGlobal) 435 459 { … … 449 473 } 450 474 else 451 LogFlowFunc(("MIME type=%s not supported\n", 452 strMIMEType.toAscii().constData())); 453 454 LogFlowFunc(("Handling formats ended with rc=%Rrc\n", rc)); 475 LogRel2(("DnD: MIME type '%s' not supported\n", strMIMEType.toAscii().constData())); 476 477 LogFlowThisFunc(("Handling formats ended with rc=%Rrc\n", rc)); 455 478 } 479 480 break; 456 481 } 457 482 … … 488 513 } 489 514 490 LogFlow Func(("Returning hr=%Rhrc\n", hr));515 LogFlowThisFunc(("Returning hr=%Rhrc\n", hr)); 491 516 return hr; 492 517 } … … 535 560 { 536 561 LogFlowFunc(("dwDirection=%RI32, mcFormats=%RI32, mpFormatEtc=%p\n", 537 dwDirection, m cFormats, mpFormatEtc));562 dwDirection, m_cFormats, m_pFormatEtc)); 538 563 539 564 HRESULT hr; 540 565 if (dwDirection == DATADIR_GET) 541 566 { 542 hr = UIDnDEnumFormatEtc::CreateEnumFormatEtc(m cFormats, mpFormatEtc, ppEnumFormatEtc);567 hr = UIDnDEnumFormatEtc::CreateEnumFormatEtc(m_cFormats, m_pFormatEtc, ppEnumFormatEtc); 543 568 } 544 569 else … … 571 596 { 572 597 LogFlowFunc(("Aborting ...\n")); 573 m Status =Aborted;574 return RTSemEventSignal(m SemEvent);598 m_enmStatus = DnDDataObjectStatus_Aborted; 599 return RTSemEventSignal(m_SemEvent); 575 600 } 576 601 … … 661 686 /* puIndex is optional. */ 662 687 663 for (ULONG i = 0; i < m cFormats; i++)664 { 665 if( (pFormatEtc->tymed & m pFormatEtc[i].tymed)666 && pFormatEtc->cfFormat == m pFormatEtc[i].cfFormat667 && pFormatEtc->dwAspect == m pFormatEtc[i].dwAspect)688 for (ULONG i = 0; i < m_cFormats; i++) 689 { 690 if( (pFormatEtc->tymed & m_pFormatEtc[i].tymed) 691 && pFormatEtc->cfFormat == m_pFormatEtc[i].cfFormat 692 && pFormatEtc->dwAspect == m_pFormatEtc[i].dwAspect) 668 693 { 669 694 LogRel3(("DnD: Format found: tyMed=%RI32, cfFormat=%RI16, sFormats=%s, dwAspect=%RI32, ulIndex=%RU32\n", 670 pFormatEtc->tymed, pFormatEtc->cfFormat, UIDnDDataObject::ClipboardFormatToString(m pFormatEtc[i].cfFormat),695 pFormatEtc->tymed, pFormatEtc->cfFormat, UIDnDDataObject::ClipboardFormatToString(m_pFormatEtc[i].cfFormat), 671 696 pFormatEtc->dwAspect, i)); 672 697 … … 677 702 } 678 703 704 #if 0 679 705 LogRel3(("DnD: Format NOT found: tyMed=%RI32, cfFormat=%RI16, sFormats=%s, dwAspect=%RI32\n", 680 706 pFormatEtc->tymed, pFormatEtc->cfFormat, UIDnDDataObject::ClipboardFormatToString(pFormatEtc->cfFormat), 681 707 pFormatEtc->dwAspect)); 708 #endif 682 709 683 710 return false; 684 }685 686 /* static */687 HGLOBAL UIDnDDataObject::MemDup(HGLOBAL hMemSource)688 {689 DWORD dwLen = GlobalSize(hMemSource);690 AssertReturn(dwLen, NULL);691 PVOID pvSource = GlobalLock(hMemSource);692 if (pvSource)693 {694 PVOID pvDest = GlobalAlloc(GMEM_FIXED, dwLen);695 if (pvDest)696 memcpy(pvDest, pvSource, dwLen);697 698 GlobalUnlock(hMemSource);699 return pvDest;700 }701 702 return NULL;703 711 } 704 712 … … 719 727 } 720 728 721 void UIDnDDataObject::SetStatus(Status status) 722 { 723 LogFlowFunc(("Setting status to %ld\n", status)); 724 mStatus = status; 729 void UIDnDDataObject::SetStatus(DnDDataObjectStatus enmStatus) 730 { 731 LogFlowFunc(("Setting status to %RU32\n", enmStatus)); 732 m_enmStatus = enmStatus; 733 } 734 735 void UIDnDDataObject::Signal(void) 736 { 737 SetStatus(DnDDataObjectStatus_Dropped); 725 738 } 726 739 … … 732 745 int rc; 733 746 734 SetStatus(Dropped);735 736 mstrFormat = strFormat;737 747 if (cbData) 738 748 { 739 m pvData = RTMemAlloc(cbData);740 if (m pvData)749 m_pvData = RTMemAlloc(cbData); 750 if (m_pvData) 741 751 { 742 memcpy(m pvData, pvData, cbData);743 m cbData = cbData;752 memcpy(m_pvData, pvData, cbData); 753 m_cbData = cbData; 744 754 rc = VINF_SUCCESS; 745 755 } … … 750 760 rc = VINF_SUCCESS; 751 761 752 if (RT_FAILURE(rc)) 753 mStatus = Aborted; 762 if (RT_SUCCESS(rc)) 763 { 764 m_strFormat = strFormat; 765 SetStatus(DnDDataObjectStatus_Dropped); 766 } 767 else 768 SetStatus(DnDDataObjectStatus_Aborted); 754 769 755 770 /* Signal in any case. */ 756 int rc2 = RTSemEventSignal(m SemEvent);771 int rc2 = RTSemEventSignal(m_SemEvent); 757 772 if (RT_SUCCESS(rc)) 758 773 rc = rc2; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDataObject_win.h
r56780 r58212 37 37 public: 38 38 39 enum Status39 enum DnDDataObjectStatus 40 40 { 41 Uninitialized = 0, 42 Initialized, 43 Dropping, 44 Dropped, 45 Aborted 41 DnDDataObjectStatus_Uninitialized = 0, 42 DnDDataObjectStatus_Initialized, 43 DnDDataObjectStatus_Dropping, 44 DnDDataObjectStatus_Dropped, 45 DnDDataObjectStatus_Aborted, 46 DnDDataObjectStatus_32Bit_Hack = 0x7fffffff 46 47 }; 47 48 … … 71 72 public: 72 73 73 static const char *ClipboardFormatToString(CLIPFORMAT fmt);74 static const char *ClipboardFormatToString(CLIPFORMAT fmt); 74 75 75 76 int Abort(void); 76 void S etStatus(Status status);77 void Signal(void); 77 78 int Signal(const QString &strFormat, const void *pvData, uint32_t cbData); 78 79 79 80 protected: 80 81 82 void SetStatus(DnDDataObjectStatus enmStatus); 83 81 84 bool LookupFormatEtc(LPFORMATETC pFormatEtc, ULONG *puIndex); 82 static HGLOBAL MemDup(HGLOBAL hMemSource);83 85 void RegisterFormat(LPFORMATETC pFormatEtc, CLIPFORMAT clipFormat, TYMED tyMed = TYMED_HGLOBAL, 84 86 LONG lindex = -1, DWORD dwAspect = DVASPECT_CONTENT, DVTARGETDEVICE *pTargetDevice = NULL); 85 87 86 UIDnDHandler *m_pDnDHandler; 87 88 Status mStatus; 89 LONG mRefCount; 88 /** Pointe rto drag and drop handler. */ 89 UIDnDHandler *m_pDnDHandler; 90 /** Current drag and drop status. */ 91 DnDDataObjectStatus m_enmStatus; 92 /** Internal reference count of this object. */ 93 LONG m_cRefs; 90 94 /** Number of native formats registered. This can be a different number than supplied with mlstFormats. */ 91 ULONG mcFormats;92 FORMATETC *mpFormatEtc;93 STGMEDIUM *mpStgMedium;94 RTSEMEVENT mSemEvent;95 QStringList mlstFormats;96 QString mstrFormat;95 ULONG m_cFormats; 96 FORMATETC *m_pFormatEtc; 97 STGMEDIUM *m_pStgMedium; 98 RTSEMEVENT m_SemEvent; 99 QStringList m_lstFormats; 100 QString m_strFormat; 97 101 /** The retrieved data as a QVariant. Needed for buffering in case a second format needs the same data, 98 102 * e.g. CF_TEXT and CF_UNICODETEXT. */ 99 QVariant mVaData; 103 QVariant m_vaData; 104 /** Whether the data already was retrieved or not. */ 105 bool m_fDataRetrieved; 100 106 /** The retrieved data as a raw buffer. */ 101 void *mpvData;107 void *m_pvData; 102 108 /** Raw buffer size (in bytes). */ 103 uint32_t mcbData;109 uint32_t m_cbData; 104 110 }; 105 111 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDropSource_win.cpp
r56780 r58212 24 24 #include <iprt/thread.h> 25 25 26 /* Qt includes: */ 27 #include <QApplication> 28 29 /* Windows includes: */ 30 #include <QApplication> 26 31 #include <windows.h> 27 32 #include <new> /* For bad_alloc. */ 28 33 29 34 #include "UIDnDDropSource_win.h" 35 #include "UIDnDDataObject_win.h" 30 36 31 32 33 UIDnDDropSource::UIDnDDropSource(QWidget *pParent) 34 : mRefCount(1), 35 mpParent(pParent), 36 mdwCurEffect(0), 37 muCurAction(Qt::IgnoreAction) 37 UIDnDDropSource::UIDnDDropSource(QWidget *pParent, UIDnDDataObject *pDataObject) 38 : m_cRefCount(1) 39 , m_pParent(pParent) 40 , m_pDataObject(pDataObject) 41 , m_dwCurEffect(DROPEFFECT_NONE) 42 , m_uCurAction(Qt::IgnoreAction) 38 43 { 39 LogFlowFunc(("pParent=0x%p\n", m pParent));44 LogFlowFunc(("pParent=0x%p\n", m_pParent)); 40 45 } 41 46 42 47 UIDnDDropSource::~UIDnDDropSource(void) 43 48 { 44 LogFlowFunc(("mRefCount=%R I32\n", mRefCount));49 LogFlowFunc(("mRefCount=%RU32\n", m_cRefCount)); 45 50 } 46 51 … … 51 56 STDMETHODIMP_(ULONG) UIDnDDropSource::AddRef(void) 52 57 { 53 return InterlockedIncrement(&mRefCount); 58 LogFlowFunc(("mRefCount=%RU32\n", m_cRefCount + 1)); 59 return (ULONG)InterlockedIncrement(&m_cRefCount); 54 60 } 55 61 56 62 STDMETHODIMP_(ULONG) UIDnDDropSource::Release(void) 57 63 { 58 LONG lCount = InterlockedDecrement(&mRefCount); 59 if (lCount == 0) 64 Assert(m_cRefCount > 0); 65 LogFlowFunc(("mRefCount=%RU32\n", m_cRefCount - 1)); 66 LONG lCount = InterlockedDecrement(&m_cRefCount); 67 if (lCount <= 0) 60 68 { 61 69 delete this; … … 63 71 } 64 72 65 return lCount;73 return (ULONG)lCount; 66 74 } 67 75 … … 94 102 STDMETHODIMP UIDnDDropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD dwKeyState) 95 103 { 96 #ifndef DEBUG_andy 97 LogFlowFunc(("fEscapePressed=%RTbool, dwKeyState=0x%x, mdwCurEffect=%RI32, muCurAction=%RU32\n", 98 fEscapePressed, dwKeyState, mdwCurEffect, muCurAction)); 99 #endif 104 LogFlowFunc(("fEscapePressed=%RTbool, dwKeyState=0x%x, m_dwCurEffect=%RI32, m_uCurAction=%RU32\n", 105 RT_BOOL(fEscapePressed), dwKeyState, m_dwCurEffect, m_uCurAction)); 100 106 101 107 /* ESC pressed? Bail out. */ 102 108 if (fEscapePressed) 103 109 { 104 m dwCurEffect = 0;105 m uCurAction= Qt::IgnoreAction;110 m_dwCurEffect = DROPEFFECT_NONE; 111 m_uCurAction = Qt::IgnoreAction; 106 112 107 113 LogRel2(("DnD: User cancelled dropping data to the host\n")); … … 118 124 if (fDropContent) 119 125 { 126 if (m_pDataObject) 127 m_pDataObject->Signal(); 128 120 129 LogRel2(("DnD: User dropped data to the host\n")); 121 130 return DRAGDROP_S_DROP; 122 131 } 132 133 QApplication::processEvents(); 123 134 124 135 /* No change, just continue. */ … … 134 145 STDMETHODIMP UIDnDDropSource::GiveFeedback(DWORD dwEffect) 135 146 { 136 147 Qt::DropActions dropActions = Qt::IgnoreAction; 137 148 138 #ifndef DEBUG_andy139 149 LogFlowFunc(("dwEffect=0x%x\n", dwEffect)); 140 #endif141 150 if (dwEffect) 142 151 { … … 147 156 if (dwEffect & DROPEFFECT_LINK) 148 157 dropActions |= Qt::LinkAction; 158 159 m_dwCurEffect = dwEffect; 149 160 } 150 161 151 mdwCurEffect = dwEffect; 152 muCurAction = dropActions; 162 m_uCurAction = dropActions; 153 163 154 164 return DRAGDROP_S_USEDEFAULTCURSORS; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDropSource_win.h
r55821 r58212 22 22 #include "COMEnums.h" 23 23 24 class UIDnDDataObject; 25 26 /** 27 * Implementation of IDropSource for drag and drop on the host. 28 */ 24 29 class UIDnDDropSource : public IDropSource 25 30 { 26 31 public: 27 32 28 UIDnDDropSource(QWidget *pParent );33 UIDnDDropSource(QWidget *pParent, UIDnDDataObject *pDataObject); 29 34 virtual ~UIDnDDropSource(void); 30 35 31 36 public: 32 37 33 uint32_t GetCurrentAction(void) { return muCurAction; }38 uint32_t GetCurrentAction(void) const { return m_uCurAction; } 34 39 35 40 public: /* IUnknown methods. */ … … 46 51 protected: 47 52 48 LONG mRefCount; 49 QWidget *mpParent; 50 DWORD mdwCurEffect; 51 Qt::DropActions muCurAction; 53 /** Pointer to parent widget. */ 54 QWidget *m_pParent; 55 UIDnDDataObject *m_pDataObject; 56 /** The current reference count. */ 57 LONG m_cRefCount; 58 /** Current (last) drop effect issued. */ 59 DWORD m_dwCurEffect; 60 /** Current drop action to perform in case of a successful drop. */ 61 Qt::DropActions m_uCurAction; 52 62 }; 53 63 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDHandler.cpp
r57292 r58212 335 335 336 336 # ifdef RT_OS_WINDOWS 337 338 UIDnDDropSource *pDropSource = new UIDnDDropSource(m_pParent);339 if (!pDropSource)340 return VERR_NO_MEMORY;341 337 UIDnDDataObject *pDataObject = new UIDnDDataObject(this, lstFormats); 342 338 if (!pDataObject) 339 return VERR_NO_MEMORY; 340 UIDnDDropSource *pDropSource = new UIDnDDropSource(m_pParent, pDataObject); 341 if (!pDropSource) 343 342 return VERR_NO_MEMORY; 344 343 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDMIMEData.cpp
r57288 r58212 109 109 110 110 /* Let the user know. */ 111 LogRel(("D rag and drop support for OS X is disabled in this version."));111 LogRel(("DnD: Drag and drop support for OS X is not available in this version\n")); 112 112 # endif /* VBOX_WITH_DRAG_AND_DROP_PROMISES */ 113 113 #else /* !RT_OS_DARWIN */ … … 120 120 { 121 121 LogFlowFunc(("Current drop action is 0x%x, so can't drop yet\n", m_curAction)); 122 rc = VERR_ WRONG_ORDER;122 rc = VERR_NOT_FOUND; 123 123 } 124 124 #endif … … 172 172 173 173 if (RT_FAILURE(rc)) 174 LogRel (("DnD: Retrieving data failed with %Rrc\n", rc));174 LogRel2(("DnD: Retrieving data failed with %Rrc\n", rc)); 175 175 176 176 return QVariant(QVariant::Invalid); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
r58011 r58212 101 101 102 102 103 #ifdef DEBUG_andy 103 #ifdef DEBUG 104 # ifdef DEBUG_andy 104 105 /* Macro for debugging drag and drop actions which usually would 105 106 * go to Main's logging group. */ 106 # define DNDDEBUG(x) LogRel(x) 107 #else 108 # define DNDDEBUG(x) 107 # define DNDDEBUG(x) LogFlowFunc(x) 108 # else 109 # define DNDDEBUG(x) 110 # endif 109 111 #endif 110 112
Note:
See TracChangeset
for help on using the changeset viewer.