VirtualBox

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

Last change on this file since 58306 was 58069, checked in by vboxsync, 9 years ago

IPRT,*: Simplified RTUriFilePath by removing the uFormat parameter. It now defaults to the host path style just like RTUriFileCreate.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 20.5 KB
Line 
1/* $Id: VBoxDnDDataObject.cpp 58069 2015-10-07 00:05:47Z 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 int rc = VINF_SUCCESS;
233
234 RTCList<RTCString> lstFilesURI = RTCString((char*)mpvData, mcbData).split("\r\n");
235 RTCList<RTCString> lstFiles;
236 for (size_t i = 0; i < lstFilesURI.size(); i++)
237 {
238 char *pszFilePath = RTUriFilePath(lstFilesURI.at(i).c_str());
239 if (pszFilePath)
240 {
241 lstFiles.append(pszFilePath);
242 RTStrFree(pszFilePath);
243 }
244 else /* Unable to parse -- refuse entire request. */
245 {
246 lstFiles.clear();
247 rc = VERR_INVALID_PARAMETER;
248 break;
249 }
250 }
251
252 size_t cFiles = lstFiles.size();
253 if ( RT_SUCCESS(rc)
254 && cFiles)
255 {
256#ifdef DEBUG
257 LogFlowFunc(("Files (%zu)\n", cFiles));
258 for (size_t i = 0; i < cFiles; i++)
259 LogFlowFunc(("\tFile: %s\n", lstFiles.at(i).c_str()));
260#endif
261
262#if 0
263 if ( (pFormatEtc->tymed & TYMED_ISTREAM)
264 && (pFormatEtc->dwAspect == DVASPECT_CONTENT)
265 && (pFormatEtc->cfFormat == CF_FILECONTENTS))
266 {
267
268 }
269 else if ( (pFormatEtc->tymed & TYMED_HGLOBAL)
270 && (pFormatEtc->dwAspect == DVASPECT_CONTENT)
271 && (pFormatEtc->cfFormat == CF_FILEDESCRIPTOR))
272 {
273
274 }
275 else if ( (pFormatEtc->tymed & TYMED_HGLOBAL)
276 && (pFormatEtc->cfFormat == CF_PREFERREDDROPEFFECT))
277 {
278 HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE | GMEM_ZEROINIT, sizeof(DWORD));
279 DWORD *pdwEffect = (DWORD *)GlobalLock(hData);
280 AssertPtr(pdwEffect);
281 *pdwEffect = DROPEFFECT_COPY;
282 GlobalUnlock(hData);
283
284 pMedium->hGlobal = hData;
285 pMedium->tymed = TYMED_HGLOBAL;
286 }
287 else
288#endif
289 if ( (pFormatEtc->tymed & TYMED_HGLOBAL)
290 && (pFormatEtc->dwAspect == DVASPECT_CONTENT)
291 && (pFormatEtc->cfFormat == CF_TEXT))
292 {
293 pMedium->hGlobal = GlobalAlloc(GHND, mcbData + 1);
294 if (pMedium->hGlobal)
295 {
296 char *pcDst = (char *)GlobalLock(pMedium->hGlobal);
297 memcpy(pcDst, mpvData, mcbData);
298 pcDst[mcbData] = '\0';
299 GlobalUnlock(pMedium->hGlobal);
300
301 hr = S_OK;
302 }
303 }
304 else if ( (pFormatEtc->tymed & TYMED_HGLOBAL)
305 && (pFormatEtc->dwAspect == DVASPECT_CONTENT)
306 && (pFormatEtc->cfFormat == CF_HDROP))
307 {
308 size_t cchFiles = 0; /* Number of ASCII characters. */
309 for (size_t i = 0; i < cFiles; i++)
310 {
311 cchFiles += strlen(lstFiles.at(i).c_str());
312 cchFiles += 1; /* Terminating '\0'. */
313 }
314
315 size_t cbBuf = sizeof(DROPFILES) + ((cchFiles + 1) * sizeof(RTUTF16));
316 DROPFILES *pBuf = (DROPFILES *)RTMemAllocZ(cbBuf);
317 if (pBuf)
318 {
319 pBuf->pFiles = sizeof(DROPFILES);
320 pBuf->fWide = 1; /* We use unicode. Always. */
321
322 uint8_t *pCurFile = (uint8_t *)pBuf + pBuf->pFiles;
323 AssertPtr(pCurFile);
324
325 for (size_t i = 0; i < cFiles && RT_SUCCESS(rc); i++)
326 {
327 size_t cchCurFile;
328 PRTUTF16 pwszFile;
329 rc = RTStrToUtf16(lstFiles.at(i).c_str(), &pwszFile);
330 if (RT_SUCCESS(rc))
331 {
332 cchCurFile = RTUtf16Len(pwszFile);
333 Assert(cchCurFile);
334 memcpy(pCurFile, pwszFile, cchCurFile * sizeof(RTUTF16));
335 RTUtf16Free(pwszFile);
336 }
337 else
338 break;
339
340 pCurFile += cchCurFile * sizeof(RTUTF16);
341
342 /* Terminate current file name. */
343 *pCurFile = L'\0';
344 pCurFile += sizeof(RTUTF16);
345 }
346
347 if (RT_SUCCESS(rc))
348 {
349 *pCurFile = L'\0'; /* Final list terminator. */
350
351 pMedium->tymed = TYMED_HGLOBAL;
352 pMedium->pUnkForRelease = NULL;
353 pMedium->hGlobal = GlobalAlloc( GMEM_ZEROINIT
354 | GMEM_MOVEABLE
355 | GMEM_DDESHARE, cbBuf);
356 if (pMedium->hGlobal)
357 {
358 LPVOID pMem = GlobalLock(pMedium->hGlobal);
359 if (pMem)
360 {
361 memcpy(pMem, pBuf, cbBuf);
362 GlobalUnlock(pMedium->hGlobal);
363
364 hr = S_OK;
365 }
366 }
367 }
368
369 RTMemFree(pBuf);
370 }
371 else
372 rc = VERR_NO_MEMORY;
373 }
374 }
375
376 if (RT_FAILURE(rc))
377 hr = DV_E_FORMATETC;
378 }
379 /*
380 * Plain text handling.
381 */
382 else if ( mstrFormat.equalsIgnoreCase("text/plain")
383 || mstrFormat.equalsIgnoreCase("text/html")
384 || mstrFormat.equalsIgnoreCase("text/plain;charset=utf-8")
385 || mstrFormat.equalsIgnoreCase("text/plain;charset=utf-16")
386 || mstrFormat.equalsIgnoreCase("text/plain")
387 || mstrFormat.equalsIgnoreCase("text/richtext")
388 || mstrFormat.equalsIgnoreCase("UTF8_STRING")
389 || mstrFormat.equalsIgnoreCase("TEXT")
390 || mstrFormat.equalsIgnoreCase("STRING"))
391 {
392 pMedium->hGlobal = GlobalAlloc(GHND, mcbData + 1);
393 if (pMedium->hGlobal)
394 {
395 char *pcDst = (char *)GlobalLock(pMedium->hGlobal);
396 memcpy(pcDst, mpvData, mcbData);
397 pcDst[mcbData] = '\0';
398 GlobalUnlock(pMedium->hGlobal);
399
400 hr = S_OK;
401 }
402 }
403 else
404 LogRel(("DnD: Error: Format '%s' not implemented\n", mstrFormat.c_str()));
405 }
406
407 /* Error handling; at least return some basic data. */
408 if (FAILED(hr))
409 {
410 LogFlowFunc(("Copying medium ...\n"));
411 switch (pThisMedium->tymed)
412 {
413
414 case TYMED_HGLOBAL:
415 pMedium->hGlobal = (HGLOBAL)OleDuplicateData(pThisMedium->hGlobal,
416 pThisFormat->cfFormat, NULL);
417 break;
418
419 default:
420 break;
421 }
422
423 pMedium->tymed = pThisFormat->tymed;
424 pMedium->pUnkForRelease = NULL;
425 }
426
427 if (hr == DV_E_FORMATETC)
428 LogRel(("DnD: Error handling format '%s' (%RU32 bytes)\n", mstrFormat.c_str(), mcbData));
429
430 LogFlowFunc(("hr=%Rhrc\n", hr));
431 return hr;
432}
433
434/**
435 * Only required for IStream / IStorage interfaces.
436 *
437 * @return IPRT status code.
438 * @return HRESULT
439 * @param pFormatEtc
440 * @param pMedium
441 */
442STDMETHODIMP VBoxDnDDataObject::GetDataHere(LPFORMATETC pFormatEtc, LPSTGMEDIUM pMedium)
443{
444 LogFlowFunc(("\n"));
445 return DATA_E_FORMATETC;
446}
447
448/**
449 * Query if this objects supports a specific format.
450 *
451 * @return IPRT status code.
452 * @return HRESULT
453 * @param pFormatEtc
454 */
455STDMETHODIMP VBoxDnDDataObject::QueryGetData(LPFORMATETC pFormatEtc)
456{
457 LogFlowFunc(("\n"));
458 return (LookupFormatEtc(pFormatEtc, NULL /* puIndex */)) ? S_OK : DV_E_FORMATETC;
459}
460
461STDMETHODIMP VBoxDnDDataObject::GetCanonicalFormatEtc(LPFORMATETC pFormatEct, LPFORMATETC pFormatEtcOut)
462{
463 LogFlowFunc(("\n"));
464
465 /* Set this to NULL in any case. */
466 pFormatEtcOut->ptd = NULL;
467 return E_NOTIMPL;
468}
469
470STDMETHODIMP VBoxDnDDataObject::SetData(LPFORMATETC pFormatEtc, LPSTGMEDIUM pMedium, BOOL fRelease)
471{
472 return E_NOTIMPL;
473}
474
475STDMETHODIMP VBoxDnDDataObject::EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC **ppEnumFormatEtc)
476{
477 LogFlowFunc(("dwDirection=%RI32, mcFormats=%RI32, mpFormatEtc=%p\n",
478 dwDirection, mcFormats, mpFormatEtc));
479
480 HRESULT hr;
481 if (dwDirection == DATADIR_GET)
482 {
483 hr = VBoxDnDEnumFormatEtc::CreateEnumFormatEtc(mcFormats, mpFormatEtc, ppEnumFormatEtc);
484 }
485 else
486 hr = E_NOTIMPL;
487
488 LogFlowFunc(("hr=%Rhrc\n", hr));
489 return hr;
490}
491
492STDMETHODIMP VBoxDnDDataObject::DAdvise(LPFORMATETC pFormatEtc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection)
493{
494 return OLE_E_ADVISENOTSUPPORTED;
495}
496
497STDMETHODIMP VBoxDnDDataObject::DUnadvise(DWORD dwConnection)
498{
499 return OLE_E_ADVISENOTSUPPORTED;
500}
501
502STDMETHODIMP VBoxDnDDataObject::EnumDAdvise(IEnumSTATDATA **ppEnumAdvise)
503{
504 return OLE_E_ADVISENOTSUPPORTED;
505}
506
507/*
508 * Own stuff.
509 */
510
511int VBoxDnDDataObject::Abort(void)
512{
513 LogFlowFunc(("Aborting ...\n"));
514 mStatus = Aborted;
515 return RTSemEventSignal(mSemEvent);
516}
517
518/* static */
519const char* VBoxDnDDataObject::ClipboardFormatToString(CLIPFORMAT fmt)
520{
521#if 0
522 char szFormat[128];
523 if (GetClipboardFormatName(fmt, szFormat, sizeof(szFormat)))
524 LogFlowFunc(("wFormat=%RI16, szName=%s\n", fmt, szFormat));
525#endif
526
527 switch (fmt)
528 {
529
530 case 1:
531 return "CF_TEXT";
532 case 2:
533 return "CF_BITMAP";
534 case 3:
535 return "CF_METAFILEPICT";
536 case 4:
537 return "CF_SYLK";
538 case 5:
539 return "CF_DIF";
540 case 6:
541 return "CF_TIFF";
542 case 7:
543 return "CF_OEMTEXT";
544 case 8:
545 return "CF_DIB";
546 case 9:
547 return "CF_PALETTE";
548 case 10:
549 return "CF_PENDATA";
550 case 11:
551 return "CF_RIFF";
552 case 12:
553 return "CF_WAVE";
554 case 13:
555 return "CF_UNICODETEXT";
556 case 14:
557 return "CF_ENHMETAFILE";
558 case 15:
559 return "CF_HDROP";
560 case 16:
561 return "CF_LOCALE";
562 case 17:
563 return "CF_DIBV5";
564 case 18:
565 return "CF_MAX";
566 case 49158:
567 return "FileName";
568 case 49159:
569 return "FileNameW";
570 case 49161:
571 return "DATAOBJECT";
572 case 49171:
573 return "Ole Private Data";
574 case 49314:
575 return "Shell Object Offsets";
576 case 49316:
577 return "File Contents";
578 case 49317:
579 return "File Group Descriptor";
580 case 49323:
581 return "Preferred Drop Effect";
582 case 49380:
583 return "Shell Object Offsets";
584 case 49382:
585 return "FileContents";
586 case 49383:
587 return "FileGroupDescriptor";
588 case 49389:
589 return "Preferred DropEffect";
590 case 49268:
591 return "Shell IDList Array";
592 case 49619:
593 return "RenPrivateFileAttachments";
594 default:
595 break;
596 }
597
598 return "unknown";
599}
600
601bool VBoxDnDDataObject::LookupFormatEtc(LPFORMATETC pFormatEtc, ULONG *puIndex)
602{
603 AssertReturn(pFormatEtc, false);
604 /* puIndex is optional. */
605
606 for (ULONG i = 0; i < mcFormats; i++)
607 {
608 if( (pFormatEtc->tymed & mpFormatEtc[i].tymed)
609 && pFormatEtc->cfFormat == mpFormatEtc[i].cfFormat
610 && pFormatEtc->dwAspect == mpFormatEtc[i].dwAspect)
611 {
612 LogRel3(("DnD: Format found: tyMed=%RI32, cfFormat=%RI16, sFormats=%s, dwAspect=%RI32, ulIndex=%RU32\n",
613 pFormatEtc->tymed, pFormatEtc->cfFormat, VBoxDnDDataObject::ClipboardFormatToString(mpFormatEtc[i].cfFormat),
614 pFormatEtc->dwAspect, i));
615 if (puIndex)
616 *puIndex = i;
617 return true;
618 }
619 }
620
621 LogRel3(("DnD: Format NOT found: tyMed=%RI32, cfFormat=%RI16, sFormats=%s, dwAspect=%RI32\n",
622 pFormatEtc->tymed, pFormatEtc->cfFormat, VBoxDnDDataObject::ClipboardFormatToString(pFormatEtc->cfFormat),
623 pFormatEtc->dwAspect));
624
625 return false;
626}
627
628/* static */
629HGLOBAL VBoxDnDDataObject::MemDup(HGLOBAL hMemSource)
630{
631 DWORD dwLen = GlobalSize(hMemSource);
632 AssertReturn(dwLen, NULL);
633 PVOID pvSource = GlobalLock(hMemSource);
634 if (pvSource)
635 {
636 PVOID pvDest = GlobalAlloc(GMEM_FIXED, dwLen);
637 if (pvDest)
638 memcpy(pvDest, pvSource, dwLen);
639
640 GlobalUnlock(hMemSource);
641 return pvDest;
642 }
643
644 return NULL;
645}
646
647void VBoxDnDDataObject::RegisterFormat(LPFORMATETC pFormatEtc, CLIPFORMAT clipFormat,
648 TYMED tyMed, LONG lIndex, DWORD dwAspect,
649 DVTARGETDEVICE *pTargetDevice)
650{
651 AssertPtr(pFormatEtc);
652
653 pFormatEtc->cfFormat = clipFormat;
654 pFormatEtc->tymed = tyMed;
655 pFormatEtc->lindex = lIndex;
656 pFormatEtc->dwAspect = dwAspect;
657 pFormatEtc->ptd = pTargetDevice;
658
659 LogFlowFunc(("Registered format=%ld, sFormat=%s\n",
660 pFormatEtc->cfFormat, VBoxDnDDataObject::ClipboardFormatToString(pFormatEtc->cfFormat)));
661}
662
663void VBoxDnDDataObject::SetStatus(Status status)
664{
665 LogFlowFunc(("Setting status to %ld\n", status));
666 mStatus = status;
667}
668
669int VBoxDnDDataObject::Signal(const RTCString &strFormat,
670 const void *pvData, uint32_t cbData)
671{
672 LogFlowFunc(("Signalling ...\n"));
673
674 int rc;
675
676 mStatus = Dropped;
677 mstrFormat = strFormat;
678 if (cbData)
679 {
680 mpvData = RTMemAlloc(cbData);
681 if (mpvData)
682 {
683 memcpy(mpvData, pvData, cbData);
684 mcbData = cbData;
685 rc = VINF_SUCCESS;
686 }
687 else
688 rc = VERR_NO_MEMORY;
689 }
690 else
691 rc = VINF_SUCCESS;
692
693 if (RT_FAILURE(rc))
694 mStatus = Aborted;
695
696 /* Signal in any case. */
697 int rc2 = RTSemEventSignal(mSemEvent);
698 if (RT_SUCCESS(rc))
699 rc = rc2;
700
701 return rc;
702}
703
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