Changeset 85694 in vbox for trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnDDataObject.cpp
- Timestamp:
- Aug 11, 2020 4:30:25 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnDDataObject.cpp
r85681 r85694 42 42 43 43 VBoxDnDDataObject::VBoxDnDDataObject(LPFORMATETC pFormatEtc, LPSTGMEDIUM pStgMed, ULONG cFormats) 44 : m Status(Uninitialized),45 m RefCount(1),46 m cFormats(0),47 m pvData(NULL),48 m cbData(0)44 : m_enmStatus(Status_Uninitialized), 45 m_cRefs(1), 46 m_cFormats(0), 47 m_pvData(NULL), 48 m_cbData(0) 49 49 { 50 50 HRESULT hr; … … 55 55 try 56 56 { 57 m pFormatEtc = new FORMATETC[cAllFormats];58 RT_BZERO(m pFormatEtc, sizeof(FORMATETC) * cAllFormats);59 m pStgMedium = new STGMEDIUM[cAllFormats];60 RT_BZERO(m pStgMedium, sizeof(STGMEDIUM) * cAllFormats);57 m_paFormatEtc = new FORMATETC[cAllFormats]; 58 RT_BZERO(m_paFormatEtc, sizeof(FORMATETC) * cAllFormats); 59 m_paStgMedium = new STGMEDIUM[cAllFormats]; 60 RT_BZERO(m_paStgMedium, sizeof(STGMEDIUM) * cAllFormats); 61 61 62 62 /* … … 73 73 LogFlowFunc(("Format %RU32: cfFormat=%RI16, tyMed=%RU32, dwAspect=%RU32\n", 74 74 i, pFormatEtc[i].cfFormat, pFormatEtc[i].tymed, pFormatEtc[i].dwAspect)); 75 m pFormatEtc[i] = pFormatEtc[i];76 m pStgMedium[i] = pStgMed[i];75 m_paFormatEtc[i] = pFormatEtc[i]; 76 m_paStgMedium[i] = pStgMed[i]; 77 77 } 78 78 } … … 87 87 if (SUCCEEDED(hr)) 88 88 { 89 int rc2 = RTSemEventCreate(&m EventDropped);89 int rc2 = RTSemEventCreate(&m_EvtDropped); 90 90 AssertRC(rc2); 91 91 … … 115 115 RegisterClipboardFormat(CFSTR_SHELLIDLISTOFFSET)); 116 116 #endif 117 m cFormats = cFormats;118 m Status =Initialized;117 m_cFormats = cFormats; 118 m_enmStatus = Status_Initialized; 119 119 } 120 120 … … 124 124 VBoxDnDDataObject::~VBoxDnDDataObject(void) 125 125 { 126 if (m pFormatEtc)127 delete[] m pFormatEtc;128 129 if (m pStgMedium)130 delete[] m pStgMedium;131 132 if (m pvData)133 RTMemFree(m pvData);134 135 LogFlowFunc(("mRefCount=%RI32\n", m RefCount));126 if (m_paFormatEtc) 127 delete[] m_paFormatEtc; 128 129 if (m_paStgMedium) 130 delete[] m_paStgMedium; 131 132 if (m_pvData) 133 RTMemFree(m_pvData); 134 135 LogFlowFunc(("mRefCount=%RI32\n", m_cRefs)); 136 136 } 137 137 … … 142 142 STDMETHODIMP_(ULONG) VBoxDnDDataObject::AddRef(void) 143 143 { 144 return InterlockedIncrement(&m RefCount);144 return InterlockedIncrement(&m_cRefs); 145 145 } 146 146 147 147 STDMETHODIMP_(ULONG) VBoxDnDDataObject::Release(void) 148 148 { 149 LONG lCount = InterlockedDecrement(&m RefCount);149 LONG lCount = InterlockedDecrement(&m_cRefs); 150 150 if (lCount == 0) 151 151 { … … 181 181 if (!LookupFormatEtc(pFormatEtc, &lIndex)) /* Format supported? */ 182 182 return DV_E_FORMATETC; 183 if (lIndex >= m cFormats) /* Paranoia. */183 if (lIndex >= m_cFormats) /* Paranoia. */ 184 184 return DV_E_FORMATETC; 185 185 186 LPFORMATETC pThisFormat = &m pFormatEtc[lIndex];186 LPFORMATETC pThisFormat = &m_paFormatEtc[lIndex]; 187 187 AssertPtr(pThisFormat); 188 188 189 LPSTGMEDIUM pThisMedium = &m pStgMedium[lIndex];189 LPSTGMEDIUM pThisMedium = &m_paStgMedium[lIndex]; 190 190 AssertPtr(pThisMedium); 191 191 … … 194 194 HRESULT hr = DV_E_FORMATETC; /* Play safe. */ 195 195 196 LogFlowFunc(("mStatus=%ld\n", m Status));197 if (m Status ==Dropping)196 LogFlowFunc(("mStatus=%ld\n", m_enmStatus)); 197 if (m_enmStatus == Status_Dropping) 198 198 { 199 199 LogRel2(("DnD: Waiting for drop event ...\n")); 200 int rc2 = RTSemEventWait(m EventDropped, RT_INDEFINITE_WAIT);201 LogFlowFunc(("rc2=%Rrc, mStatus=%ld\n", rc2, m Status)); RT_NOREF(rc2);202 } 203 204 if (m Status ==Dropped)200 int rc2 = RTSemEventWait(m_EvtDropped, RT_INDEFINITE_WAIT); 201 LogFlowFunc(("rc2=%Rrc, mStatus=%ld\n", rc2, m_enmStatus)); RT_NOREF(rc2); 202 } 203 204 if (m_enmStatus == Status_Dropped) 205 205 { 206 206 LogRel2(("DnD: Drop event received\n")); … … 209 209 pThisFormat->tymed, pThisFormat->dwAspect)); 210 210 LogRel3(("DnD: Got strFormat=%s, pvData=%p, cbData=%RU32\n", 211 m strFormat.c_str(), mpvData, mcbData));211 m_strFormat.c_str(), m_pvData, m_cbData)); 212 212 213 213 /* … … 220 220 * URI list handling. 221 221 */ 222 if (DnDMIMEHasFileURLs(m strFormat.c_str(), RTSTR_MAX))222 if (DnDMIMEHasFileURLs(m_strFormat.c_str(), RTSTR_MAX)) 223 223 { 224 224 char **papszFiles; 225 225 size_t cFiles; 226 int rc = RTStrSplit((const char *)m pvData, mcbData, DND_PATH_SEPARATOR, &papszFiles, &cFiles);226 int rc = RTStrSplit((const char *)m_pvData, m_cbData, DND_PATH_SEPARATOR, &papszFiles, &cFiles); 227 227 if ( RT_SUCCESS(rc) 228 228 && cFiles) … … 263 263 && (pFormatEtc->cfFormat == CF_TEXT)) 264 264 { 265 pMedium->hGlobal = GlobalAlloc(GHND, m cbData + 1);265 pMedium->hGlobal = GlobalAlloc(GHND, m_cbData + 1); 266 266 if (pMedium->hGlobal) 267 267 { 268 268 char *pcDst = (char *)GlobalLock(pMedium->hGlobal); 269 memcpy(pcDst, m pvData, mcbData);270 pcDst[m cbData] = '\0';269 memcpy(pcDst, m_pvData, m_cbData); 270 pcDst[m_cbData] = '\0'; 271 271 GlobalUnlock(pMedium->hGlobal); 272 272 … … 356 356 * Plain text handling. 357 357 */ 358 else if ( m strFormat.equalsIgnoreCase("text/plain")359 || m strFormat.equalsIgnoreCase("text/html")360 || m strFormat.equalsIgnoreCase("text/plain;charset=utf-8")361 || m strFormat.equalsIgnoreCase("text/plain;charset=utf-16")362 || m strFormat.equalsIgnoreCase("text/richtext")363 || m strFormat.equalsIgnoreCase("UTF8_STRING")364 || m strFormat.equalsIgnoreCase("TEXT")365 || m strFormat.equalsIgnoreCase("STRING"))358 else if ( m_strFormat.equalsIgnoreCase("text/plain") 359 || m_strFormat.equalsIgnoreCase("text/html") 360 || m_strFormat.equalsIgnoreCase("text/plain;charset=utf-8") 361 || m_strFormat.equalsIgnoreCase("text/plain;charset=utf-16") 362 || m_strFormat.equalsIgnoreCase("text/richtext") 363 || m_strFormat.equalsIgnoreCase("UTF8_STRING") 364 || m_strFormat.equalsIgnoreCase("TEXT") 365 || m_strFormat.equalsIgnoreCase("STRING")) 366 366 { 367 pMedium->hGlobal = GlobalAlloc(GHND, m cbData + 1);367 pMedium->hGlobal = GlobalAlloc(GHND, m_cbData + 1); 368 368 if (pMedium->hGlobal) 369 369 { 370 370 char *pcDst = (char *)GlobalLock(pMedium->hGlobal); 371 memcpy(pcDst, m pvData, mcbData);372 pcDst[m cbData] = '\0';371 memcpy(pcDst, m_pvData, m_cbData); 372 pcDst[m_cbData] = '\0'; 373 373 GlobalUnlock(pMedium->hGlobal); 374 374 … … 377 377 } 378 378 else 379 LogRel(("DnD: Error: Format '%s' not implemented\n", m strFormat.c_str()));379 LogRel(("DnD: Error: Format '%s' not implemented\n", m_strFormat.c_str())); 380 380 } 381 381 … … 401 401 402 402 if (hr == DV_E_FORMATETC) 403 LogRel(("DnD: Error handling format '%s' (%RU32 bytes)\n", m strFormat.c_str(), mcbData));403 LogRel(("DnD: Error handling format '%s' (%RU32 bytes)\n", m_strFormat.c_str(), m_cbData)); 404 404 405 405 LogFlowFunc(("hr=%Rhrc\n", hr)); … … 438 438 STDMETHODIMP VBoxDnDDataObject::EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC **ppEnumFormatEtc) 439 439 { 440 LogFlowFunc(("dwDirection=%RI32, mcFormats=%RI32, mpFormatEtc=%p\n", dwDirection, m cFormats, mpFormatEtc));440 LogFlowFunc(("dwDirection=%RI32, mcFormats=%RI32, mpFormatEtc=%p\n", dwDirection, m_cFormats, m_paFormatEtc)); 441 441 442 442 HRESULT hr; 443 443 if (dwDirection == DATADIR_GET) 444 hr = VBoxDnDEnumFormatEtc::CreateEnumFormatEtc(m cFormats, mpFormatEtc, ppEnumFormatEtc);444 hr = VBoxDnDEnumFormatEtc::CreateEnumFormatEtc(m_cFormats, m_paFormatEtc, ppEnumFormatEtc); 445 445 else 446 446 hr = E_NOTIMPL; … … 480 480 { 481 481 LogFlowFunc(("Aborting ...\n")); 482 m Status =Aborted;483 return RTSemEventSignal(m EventDropped);482 m_enmStatus = Status_Aborted; 483 return RTSemEventSignal(m_EvtDropped); 484 484 } 485 485 … … 585 585 /* puIndex is optional. */ 586 586 587 for (ULONG i = 0; i < m cFormats; i++)588 { 589 if( (pFormatEtc->tymed & m pFormatEtc[i].tymed)590 && pFormatEtc->cfFormat == m pFormatEtc[i].cfFormat591 && pFormatEtc->dwAspect == m pFormatEtc[i].dwAspect)587 for (ULONG i = 0; i < m_cFormats; i++) 588 { 589 if( (pFormatEtc->tymed & m_paFormatEtc[i].tymed) 590 && pFormatEtc->cfFormat == m_paFormatEtc[i].cfFormat 591 && pFormatEtc->dwAspect == m_paFormatEtc[i].dwAspect) 592 592 { 593 593 LogRel3(("DnD: Format found: tyMed=%RI32, cfFormat=%RI16, sFormats=%s, dwAspect=%RI32, ulIndex=%RU32\n", 594 pFormatEtc->tymed, pFormatEtc->cfFormat, VBoxDnDDataObject::ClipboardFormatToString(m pFormatEtc[i].cfFormat),594 pFormatEtc->tymed, pFormatEtc->cfFormat, VBoxDnDDataObject::ClipboardFormatToString(m_paFormatEtc[i].cfFormat), 595 595 pFormatEtc->dwAspect, i)); 596 596 if (puIndex) … … 605 605 606 606 return false; 607 }608 609 /* static */610 HGLOBAL VBoxDnDDataObject::MemDup(HGLOBAL hMemSource)611 {612 DWORD dwLen = GlobalSize(hMemSource);613 AssertReturn(dwLen, NULL);614 PVOID pvSource = GlobalLock(hMemSource);615 if (pvSource)616 {617 PVOID pvDest = GlobalAlloc(GMEM_FIXED, dwLen);618 if (pvDest)619 memcpy(pvDest, pvSource, dwLen);620 621 GlobalUnlock(hMemSource);622 return pvDest;623 }624 625 return NULL;626 607 } 627 608 … … 660 641 { 661 642 LogFlowFunc(("Setting status to %ld\n", status)); 662 m Status = status;643 m_enmStatus = status; 663 644 } 664 645 … … 678 659 if (cbData) 679 660 { 680 m pvData = RTMemAlloc(cbData);681 if (m pvData)661 m_pvData = RTMemAlloc(cbData); 662 if (m_pvData) 682 663 { 683 memcpy(m pvData, pvData, cbData);684 m cbData = cbData;664 memcpy(m_pvData, pvData, cbData); 665 m_cbData = cbData; 685 666 rc = VINF_SUCCESS; 686 667 } … … 693 674 if (RT_SUCCESS(rc)) 694 675 { 695 m Status =Dropped;696 m strFormat = strFormat;676 m_enmStatus = Status_Dropped; 677 m_strFormat = strFormat; 697 678 } 698 679 else 699 680 { 700 m Status =Aborted;681 m_enmStatus = Status_Aborted; 701 682 } 702 683 … … 704 685 LogRel2(("DnD: Signalling drop event\n")); 705 686 706 int rc2 = RTSemEventSignal(m EventDropped);687 int rc2 = RTSemEventSignal(m_EvtDropped); 707 688 if (RT_SUCCESS(rc)) 708 689 rc = rc2; 709 690 710 LogFunc(("mStatus=%RU32, rc=%Rrc\n", m Status, rc));691 LogFunc(("mStatus=%RU32, rc=%Rrc\n", m_enmStatus, rc)); 711 692 return rc; 712 693 }
Note:
See TracChangeset
for help on using the changeset viewer.