VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnDDataObject.cpp@ 56661

Last change on this file since 56661 was 56661, checked in by vboxsync, 10 years ago

DnD/VBoxTray: Also support retrieving plain text, added better (release) diagnostics, some renaming.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 20.1 KB
Line 
1/* $Id: VBoxDnDDataObject.cpp 56661 2015-06-26 14:46:12Z vboxsync $ */
2/** @file
3 * VBoxDnDDataObject.cpp - IDataObject implementation.
4 */
5
6/*
7 * Copyright (C) 2013-2015 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17#include <windows.h>
18#include <new> /* For bad_alloc. */
19#include <shlobj.h>
20
21#include <iprt/path.h>
22#include <iprt/semaphore.h>
23#include <iprt/uri.h>
24
25#ifdef LOG_GROUP
26# undef LOG_GROUP
27#endif
28#define LOG_GROUP LOG_GROUP_GUEST_DND
29#include <VBox/log.h>
30
31#include "VBoxTray.h"
32#include "VBoxHelpers.h"
33#include "VBoxDnD.h"
34
35#ifdef DEBUG
36 /* Enable the following line to get much more debug output about
37 * (un)known clipboard formats. */
38//# define VBOX_DND_DEBUG_FORMATS
39#endif
40
41/** @todo Implement IDataObjectAsyncCapability interface? */
42
43VBoxDnDDataObject::VBoxDnDDataObject(LPFORMATETC pFormatEtc, LPSTGMEDIUM pStgMed, ULONG cFormats)
44 : mStatus(Uninitialized),
45 mRefCount(1),
46 mcFormats(0),
47 mpvData(NULL),
48 mcbData(0)
49{
50 HRESULT hr;
51
52 ULONG cFixedFormats = 1;
53 ULONG cAllFormats = cFormats + cFixedFormats;
54
55 try
56 {
57 mpFormatEtc = new FORMATETC[cAllFormats];
58 RT_BZERO(mpFormatEtc, sizeof(FORMATETC) * cAllFormats);
59 mpStgMedium = new STGMEDIUM[cAllFormats];
60 RT_BZERO(mpStgMedium, sizeof(STGMEDIUM) * cAllFormats);
61
62 /*
63 * Registration of dynamic formats needed?
64 */
65 LogFlowFunc(("%RU32 dynamic formats\n", cFormats));
66 if (cFormats)
67 {
68 AssertPtr(pFormatEtc);
69 AssertPtr(pStgMed);
70
71 for (ULONG i = 0; i < cFormats; i++)
72 {
73 LogFlowFunc(("Format %RU32: cfFormat=%RI16, tyMed=%RU32, dwAspect=%RU32\n",
74 i, pFormatEtc[i].cfFormat, pFormatEtc[i].tymed, pFormatEtc[i].dwAspect));
75 mpFormatEtc[i] = pFormatEtc[i];
76 mpStgMedium[i] = pStgMed[i];
77 }
78 }
79
80 hr = S_OK;
81 }
82 catch (std::bad_alloc &)
83 {
84 hr = E_OUTOFMEMORY;
85 }
86
87 if (SUCCEEDED(hr))
88 {
89 int rc2 = RTSemEventCreate(&mSemEvent);
90 AssertRC(rc2);
91
92 /*
93 * Register fixed formats.
94 */
95#if 0
96 /* CF_HDROP. */
97 RegisterFormat(&mpFormatEtc[cFormats], CF_HDROP);
98 mpStgMedium[cFormats++].tymed = TYMED_HGLOBAL;
99
100 /* IStream. */
101 RegisterFormat(&mpFormatEtc[cFormats++],
102 RegisterClipboardFormat(CFSTR_FILEDESCRIPTOR));
103 RegisterFormat(&mpFormatEtc[cFormats++],
104 RegisterClipboardFormat(CFSTR_FILECONTENTS),
105 TYMED_ISTREAM, 0 /* lIndex */);
106
107 /* Required for e.g. Windows Media Player. */
108 RegisterFormat(&mpFormatEtc[cFormats++],
109 RegisterClipboardFormat(CFSTR_FILENAME));
110 RegisterFormat(&mpFormatEtc[cFormats++],
111 RegisterClipboardFormat(CFSTR_FILENAMEW));
112 RegisterFormat(&mpFormatEtc[cFormats++],
113 RegisterClipboardFormat(CFSTR_SHELLIDLIST));
114 RegisterFormat(&mpFormatEtc[cFormats++],
115 RegisterClipboardFormat(CFSTR_SHELLIDLISTOFFSET));
116#endif
117 mcFormats = cFormats;
118 mStatus = Initialized;
119 }
120
121 LogFlowFunc(("cFormats=%RU32, hr=%Rhrc\n", cFormats, hr));
122}
123
124VBoxDnDDataObject::~VBoxDnDDataObject(void)
125{
126 if (mpFormatEtc)
127 delete[] mpFormatEtc;
128
129 if (mpStgMedium)
130 delete[] mpStgMedium;
131
132 if (mpvData)
133 RTMemFree(mpvData);
134
135 LogFlowFunc(("mRefCount=%RI32\n", mRefCount));
136}
137
138/*
139 * IUnknown methods.
140 */
141
142STDMETHODIMP_(ULONG) VBoxDnDDataObject::AddRef(void)
143{
144 return InterlockedIncrement(&mRefCount);
145}
146
147STDMETHODIMP_(ULONG) VBoxDnDDataObject::Release(void)
148{
149 LONG lCount = InterlockedDecrement(&mRefCount);
150 if (lCount == 0)
151 {
152 delete this;
153 return 0;
154 }
155
156 return lCount;
157}
158
159STDMETHODIMP VBoxDnDDataObject::QueryInterface(REFIID iid, void **ppvObject)
160{
161 AssertPtrReturn(ppvObject, E_INVALIDARG);
162
163 if ( iid == IID_IDataObject
164 || iid == IID_IUnknown)
165 {
166 AddRef();
167 *ppvObject = this;
168 return S_OK;
169 }
170
171 *ppvObject = 0;
172 return E_NOINTERFACE;
173}
174
175/**
176 * Retrieves the data stored in this object and store the result in
177 * pMedium.
178 *
179 * @return IPRT status code.
180 * @return HRESULT
181 * @param pFormatEtc
182 * @param pMedium
183 */
184STDMETHODIMP VBoxDnDDataObject::GetData(LPFORMATETC pFormatEtc, LPSTGMEDIUM pMedium)
185{
186 AssertPtrReturn(pFormatEtc, DV_E_FORMATETC);
187 AssertPtrReturn(pMedium, DV_E_FORMATETC);
188
189 ULONG lIndex;
190 if (!LookupFormatEtc(pFormatEtc, &lIndex)) /* Format supported? */
191 return DV_E_FORMATETC;
192 if (lIndex >= mcFormats) /* Paranoia. */
193 return DV_E_FORMATETC;
194
195 LPFORMATETC pThisFormat = &mpFormatEtc[lIndex];
196 AssertPtr(pThisFormat);
197
198 LPSTGMEDIUM pThisMedium = &mpStgMedium[lIndex];
199 AssertPtr(pThisMedium);
200
201 LogFlowFunc(("Using pThisFormat=%p, pThisMedium=%p\n", pThisFormat, pThisMedium));
202
203 HRESULT hr = DV_E_FORMATETC; /* Play safe. */
204
205 LogFlowFunc(("mStatus=%ld\n", mStatus));
206 if (mStatus == Dropping)
207 {
208 LogFlowFunc(("Waiting for event ...\n"));
209 int rc2 = RTSemEventWait(mSemEvent, RT_INDEFINITE_WAIT);
210 LogFlowFunc(("rc=%Rrc, mStatus=%ld\n", rc2, mStatus));
211 }
212
213 if (mStatus == Dropped)
214 {
215 LogRel3(("DnD: cfFormat=%RI16, sFormat=%s, tyMed=%RU32, dwAspect=%RU32\n",
216 pThisFormat->cfFormat, VBoxDnDDataObject::ClipboardFormatToString(pFormatEtc->cfFormat),
217 pThisFormat->tymed, pThisFormat->dwAspect));
218 LogRel3(("DnD: Got strFormat=%s, pvData=%p, cbData=%RU32\n",
219 mstrFormat.c_str(), mpvData, mcbData));
220
221 /*
222 * Initialize default values.
223 */
224 pMedium->tymed = pThisFormat->tymed;
225 pMedium->pUnkForRelease = NULL;
226
227 /*
228 * URI list handling.
229 */
230 if (mstrFormat.equalsIgnoreCase("text/uri-list"))
231 {
232 RTCList<RTCString> lstFilesURI = RTCString((char*)mpvData, mcbData).split("\r\n");
233 RTCList<RTCString> lstFiles;
234 for (size_t i = 0; i < lstFilesURI.size(); i++)
235 {
236 /* Extract path from URI. */
237 char *pszPath = RTUriPath(lstFilesURI.at(i).c_str());
238 if ( pszPath
239 && strlen(pszPath) > 1)
240 {
241 pszPath++; /** @todo Skip first '/' (part of URI). Correct? */
242 pszPath = RTPathChangeToDosSlashes(pszPath, false /* fForce */);
243 lstFiles.append(pszPath);
244 }
245 }
246#ifdef DEBUG
247 LogFlowFunc(("Files (%zu)\n", lstFiles.size()));
248 for (size_t i = 0; i < lstFiles.size(); i++)
249 LogFlowFunc(("\tFile: %s\n", lstFiles.at(i).c_str()));
250#endif
251
252#if 0
253 if ( (pFormatEtc->tymed & TYMED_ISTREAM)
254 && (pFormatEtc->dwAspect == DVASPECT_CONTENT)
255 && (pFormatEtc->cfFormat == CF_FILECONTENTS))
256 {
257
258 }
259 else if ( (pFormatEtc->tymed & TYMED_HGLOBAL)
260 && (pFormatEtc->dwAspect == DVASPECT_CONTENT)
261 && (pFormatEtc->cfFormat == CF_FILEDESCRIPTOR))
262 {
263
264 }
265 else if ( (pFormatEtc->tymed & TYMED_HGLOBAL)
266 && (pFormatEtc->cfFormat == CF_PREFERREDDROPEFFECT))
267 {
268 HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE | GMEM_ZEROINIT, sizeof(DWORD));
269 DWORD *pdwEffect = (DWORD *)GlobalLock(hData);
270 AssertPtr(pdwEffect);
271 *pdwEffect = DROPEFFECT_COPY;
272 GlobalUnlock(hData);
273
274 pMedium->hGlobal = hData;
275 pMedium->tymed = TYMED_HGLOBAL;
276 }
277 else
278#endif
279 if ( (pFormatEtc->tymed & TYMED_HGLOBAL)
280 && (pFormatEtc->dwAspect == DVASPECT_CONTENT)
281 && (pFormatEtc->cfFormat == CF_TEXT))
282 {
283 pMedium->hGlobal = GlobalAlloc(GHND, mcbData + 1);
284 if (pMedium->hGlobal)
285 {
286 char *pcDst = (char *)GlobalLock(pMedium->hGlobal);
287 memcpy(pcDst, mpvData, mcbData);
288 pcDst[mcbData] = '\0';
289 GlobalUnlock(pMedium->hGlobal);
290
291 hr = S_OK;
292 }
293 }
294 else if ( (pFormatEtc->tymed & TYMED_HGLOBAL)
295 && (pFormatEtc->dwAspect == DVASPECT_CONTENT)
296 && (pFormatEtc->cfFormat == CF_HDROP))
297 {
298 int rc = VINF_SUCCESS;
299
300 size_t cchFiles = 0; /* Number of ASCII characters. */
301 for (size_t i = 0; i < lstFiles.size(); i++)
302 {
303 cchFiles += strlen(lstFiles.at(i).c_str());
304 cchFiles += 1; /* Terminating '\0'. */
305 }
306
307 size_t cbBuf = sizeof(DROPFILES) + ((cchFiles + 1) * sizeof(RTUTF16));
308 DROPFILES *pBuf = (DROPFILES *)RTMemAllocZ(cbBuf);
309 if (pBuf)
310 {
311 pBuf->pFiles = sizeof(DROPFILES);
312 pBuf->fWide = 1; /* We use unicode. Always. */
313
314 uint8_t *pCurFile = (uint8_t *)pBuf + pBuf->pFiles;
315 AssertPtr(pCurFile);
316
317 for (size_t i = 0; i < lstFiles.size() && RT_SUCCESS(rc); i++)
318 {
319 size_t cchCurFile;
320 PRTUTF16 pwszFile;
321 rc = RTStrToUtf16(lstFiles.at(i).c_str(), &pwszFile);
322 if (RT_SUCCESS(rc))
323 {
324 cchCurFile = RTUtf16Len(pwszFile);
325 Assert(cchCurFile);
326 memcpy(pCurFile, pwszFile, cchCurFile * sizeof(RTUTF16));
327 RTUtf16Free(pwszFile);
328 }
329 else
330 break;
331
332 pCurFile += cchCurFile * sizeof(RTUTF16);
333
334 /* Terminate current file name. */
335 *pCurFile = L'\0';
336 pCurFile += sizeof(RTUTF16);
337 }
338
339 if (RT_SUCCESS(rc))
340 {
341 *pCurFile = L'\0'; /* Final list terminator. */
342
343 pMedium->tymed = TYMED_HGLOBAL;
344 pMedium->pUnkForRelease = NULL;
345 pMedium->hGlobal = GlobalAlloc( GMEM_ZEROINIT
346 | GMEM_MOVEABLE
347 | GMEM_DDESHARE, cbBuf);
348 if (pMedium->hGlobal)
349 {
350 LPVOID pMem = GlobalLock(pMedium->hGlobal);
351 if (pMem)
352 {
353 memcpy(pMem, pBuf, cbBuf);
354 GlobalUnlock(pMedium->hGlobal);
355
356 hr = S_OK;
357 }
358 }
359 }
360
361 RTMemFree(pBuf);
362 }
363 else
364 rc = VERR_NO_MEMORY;
365
366 if (RT_FAILURE(rc))
367 hr = DV_E_FORMATETC;
368 }
369 }
370 /*
371 * Plain text handling.
372 */
373 else if ( mstrFormat.equalsIgnoreCase("text/plain")
374 || mstrFormat.equalsIgnoreCase("text/html")
375 || mstrFormat.equalsIgnoreCase("text/plain;charset=utf-8")
376 || mstrFormat.equalsIgnoreCase("text/plain;charset=utf-16")
377 || mstrFormat.equalsIgnoreCase("text/plain")
378 || mstrFormat.equalsIgnoreCase("text/richtext")
379 || mstrFormat.equalsIgnoreCase("UTF8_STRING")
380 || mstrFormat.equalsIgnoreCase("TEXT")
381 || mstrFormat.equalsIgnoreCase("STRING"))
382 {
383 pMedium->hGlobal = GlobalAlloc(GHND, mcbData + 1);
384 if (pMedium->hGlobal)
385 {
386 char *pcDst = (char *)GlobalLock(pMedium->hGlobal);
387 memcpy(pcDst, mpvData, mcbData);
388 pcDst[mcbData] = '\0';
389 GlobalUnlock(pMedium->hGlobal);
390
391 hr = S_OK;
392 }
393 }
394 else
395 LogRel(("DnD: Error: Format '%s' not implemented\n", mstrFormat.c_str()));
396 }
397
398 /* Error handling; at least return some basic data. */
399 if (FAILED(hr))
400 {
401 LogFlowFunc(("Copying medium ...\n"));
402 switch (pThisMedium->tymed)
403 {
404
405 case TYMED_HGLOBAL:
406 pMedium->hGlobal = (HGLOBAL)OleDuplicateData(pThisMedium->hGlobal,
407 pThisFormat->cfFormat, NULL);
408 break;
409
410 default:
411 break;
412 }
413
414 pMedium->tymed = pThisFormat->tymed;
415 pMedium->pUnkForRelease = NULL;
416 }
417
418 if (hr == DV_E_FORMATETC)
419 LogRel(("DnD: Error handling format '%s' (%RU32 bytes)\n", mstrFormat.c_str(), mcbData));
420
421 LogFlowFunc(("hr=%Rhrc\n", hr));
422 return hr;
423}
424
425/**
426 * Only required for IStream / IStorage interfaces.
427 *
428 * @return IPRT status code.
429 * @return HRESULT
430 * @param pFormatEtc
431 * @param pMedium
432 */
433STDMETHODIMP VBoxDnDDataObject::GetDataHere(LPFORMATETC pFormatEtc, LPSTGMEDIUM pMedium)
434{
435 LogFlowFunc(("\n"));
436 return DATA_E_FORMATETC;
437}
438
439/**
440 * Query if this objects supports a specific format.
441 *
442 * @return IPRT status code.
443 * @return HRESULT
444 * @param pFormatEtc
445 */
446STDMETHODIMP VBoxDnDDataObject::QueryGetData(LPFORMATETC pFormatEtc)
447{
448 LogFlowFunc(("\n"));
449 return (LookupFormatEtc(pFormatEtc, NULL /* puIndex */)) ? S_OK : DV_E_FORMATETC;
450}
451
452STDMETHODIMP VBoxDnDDataObject::GetCanonicalFormatEtc(LPFORMATETC pFormatEct, LPFORMATETC pFormatEtcOut)
453{
454 LogFlowFunc(("\n"));
455
456 /* Set this to NULL in any case. */
457 pFormatEtcOut->ptd = NULL;
458 return E_NOTIMPL;
459}
460
461STDMETHODIMP VBoxDnDDataObject::SetData(LPFORMATETC pFormatEtc, LPSTGMEDIUM pMedium, BOOL fRelease)
462{
463 return E_NOTIMPL;
464}
465
466STDMETHODIMP VBoxDnDDataObject::EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC **ppEnumFormatEtc)
467{
468 LogFlowFunc(("dwDirection=%RI32, mcFormats=%RI32, mpFormatEtc=%p\n",
469 dwDirection, mcFormats, mpFormatEtc));
470
471 HRESULT hr;
472 if (dwDirection == DATADIR_GET)
473 {
474 hr = VBoxDnDEnumFormatEtc::CreateEnumFormatEtc(mcFormats, mpFormatEtc, ppEnumFormatEtc);
475 }
476 else
477 hr = E_NOTIMPL;
478
479 LogFlowFunc(("hr=%Rhrc\n", hr));
480 return hr;
481}
482
483STDMETHODIMP VBoxDnDDataObject::DAdvise(LPFORMATETC pFormatEtc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection)
484{
485 return OLE_E_ADVISENOTSUPPORTED;
486}
487
488STDMETHODIMP VBoxDnDDataObject::DUnadvise(DWORD dwConnection)
489{
490 return OLE_E_ADVISENOTSUPPORTED;
491}
492
493STDMETHODIMP VBoxDnDDataObject::EnumDAdvise(IEnumSTATDATA **ppEnumAdvise)
494{
495 return OLE_E_ADVISENOTSUPPORTED;
496}
497
498/*
499 * Own stuff.
500 */
501
502int VBoxDnDDataObject::Abort(void)
503{
504 LogFlowFunc(("Aborting ...\n"));
505 mStatus = Aborted;
506 return RTSemEventSignal(mSemEvent);
507}
508
509/* static */
510const char* VBoxDnDDataObject::ClipboardFormatToString(CLIPFORMAT fmt)
511{
512#if 0
513 char szFormat[128];
514 if (GetClipboardFormatName(fmt, szFormat, sizeof(szFormat)))
515 LogFlowFunc(("wFormat=%RI16, szName=%s\n", fmt, szFormat));
516#endif
517
518 switch (fmt)
519 {
520
521 case 1:
522 return "CF_TEXT";
523 case 2:
524 return "CF_BITMAP";
525 case 3:
526 return "CF_METAFILEPICT";
527 case 4:
528 return "CF_SYLK";
529 case 5:
530 return "CF_DIF";
531 case 6:
532 return "CF_TIFF";
533 case 7:
534 return "CF_OEMTEXT";
535 case 8:
536 return "CF_DIB";
537 case 9:
538 return "CF_PALETTE";
539 case 10:
540 return "CF_PENDATA";
541 case 11:
542 return "CF_RIFF";
543 case 12:
544 return "CF_WAVE";
545 case 13:
546 return "CF_UNICODETEXT";
547 case 14:
548 return "CF_ENHMETAFILE";
549 case 15:
550 return "CF_HDROP";
551 case 16:
552 return "CF_LOCALE";
553 case 17:
554 return "CF_DIBV5";
555 case 18:
556 return "CF_MAX";
557 case 49158:
558 return "FileName";
559 case 49159:
560 return "FileNameW";
561 case 49161:
562 return "DATAOBJECT";
563 case 49171:
564 return "Ole Private Data";
565 case 49314:
566 return "Shell Object Offsets";
567 case 49316:
568 return "File Contents";
569 case 49317:
570 return "File Group Descriptor";
571 case 49323:
572 return "Preferred Drop Effect";
573 case 49380:
574 return "Shell Object Offsets";
575 case 49382:
576 return "FileContents";
577 case 49383:
578 return "FileGroupDescriptor";
579 case 49389:
580 return "Preferred DropEffect";
581 case 49268:
582 return "Shell IDList Array";
583 case 49619:
584 return "RenPrivateFileAttachments";
585 default:
586 break;
587 }
588
589 return "unknown";
590}
591
592bool VBoxDnDDataObject::LookupFormatEtc(LPFORMATETC pFormatEtc, ULONG *puIndex)
593{
594 AssertReturn(pFormatEtc, false);
595 /* puIndex is optional. */
596
597 for (ULONG i = 0; i < mcFormats; i++)
598 {
599 if( (pFormatEtc->tymed & mpFormatEtc[i].tymed)
600 && pFormatEtc->cfFormat == mpFormatEtc[i].cfFormat
601 && pFormatEtc->dwAspect == mpFormatEtc[i].dwAspect)
602 {
603 LogRel3(("DnD: Format found: tyMed=%RI32, cfFormat=%RI16, sFormats=%s, dwAspect=%RI32, ulIndex=%RU32\n",
604 pFormatEtc->tymed, pFormatEtc->cfFormat, VBoxDnDDataObject::ClipboardFormatToString(mpFormatEtc[i].cfFormat),
605 pFormatEtc->dwAspect, i));
606 if (puIndex)
607 *puIndex = i;
608 return true;
609 }
610 }
611
612 LogRel3(("DnD: Format NOT found: tyMed=%RI32, cfFormat=%RI16, sFormats=%s, dwAspect=%RI32\n",
613 pFormatEtc->tymed, pFormatEtc->cfFormat, VBoxDnDDataObject::ClipboardFormatToString(pFormatEtc->cfFormat),
614 pFormatEtc->dwAspect));
615
616 return false;
617}
618
619/* static */
620HGLOBAL VBoxDnDDataObject::MemDup(HGLOBAL hMemSource)
621{
622 DWORD dwLen = GlobalSize(hMemSource);
623 AssertReturn(dwLen, NULL);
624 PVOID pvSource = GlobalLock(hMemSource);
625 if (pvSource)
626 {
627 PVOID pvDest = GlobalAlloc(GMEM_FIXED, dwLen);
628 if (pvDest)
629 memcpy(pvDest, pvSource, dwLen);
630
631 GlobalUnlock(hMemSource);
632 return pvDest;
633 }
634
635 return NULL;
636}
637
638void VBoxDnDDataObject::RegisterFormat(LPFORMATETC pFormatEtc, CLIPFORMAT clipFormat,
639 TYMED tyMed, LONG lIndex, DWORD dwAspect,
640 DVTARGETDEVICE *pTargetDevice)
641{
642 AssertPtr(pFormatEtc);
643
644 pFormatEtc->cfFormat = clipFormat;
645 pFormatEtc->tymed = tyMed;
646 pFormatEtc->lindex = lIndex;
647 pFormatEtc->dwAspect = dwAspect;
648 pFormatEtc->ptd = pTargetDevice;
649
650 LogFlowFunc(("Registered format=%ld, sFormat=%s\n",
651 pFormatEtc->cfFormat, VBoxDnDDataObject::ClipboardFormatToString(pFormatEtc->cfFormat)));
652}
653
654void VBoxDnDDataObject::SetStatus(Status status)
655{
656 LogFlowFunc(("Setting status to %ld\n", status));
657 mStatus = status;
658}
659
660int VBoxDnDDataObject::Signal(const RTCString &strFormat,
661 const void *pvData, uint32_t cbData)
662{
663 LogFlowFunc(("Signalling ...\n"));
664
665 int rc;
666
667 mStatus = Dropped;
668 mstrFormat = strFormat;
669 if (cbData)
670 {
671 mpvData = RTMemAlloc(cbData);
672 if (mpvData)
673 {
674 memcpy(mpvData, pvData, cbData);
675 mcbData = cbData;
676 rc = VINF_SUCCESS;
677 }
678 else
679 rc = VERR_NO_MEMORY;
680 }
681 else
682 rc = VINF_SUCCESS;
683
684 if (RT_FAILURE(rc))
685 mStatus = Aborted;
686
687 /* Signal in any case. */
688 int rc2 = RTSemEventSignal(mSemEvent);
689 if (RT_SUCCESS(rc))
690 rc = rc2;
691
692 return rc;
693}
694
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette