GuestDnDTargetImpl.cpp revision c8e3a310b008bd03e42089b1e7e8adc16daaf077
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync * VBox Console COM Class implementation - Guest drag'n drop target.
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync * Copyright (C) 2014 Oracle Corporation
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync * available from http://www.virtualbox.org. This file is free software;
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync * you can redistribute it and/or modify it under the terms of the GNU
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync * General Public License (GPL) as published by the Free Software
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync/*******************************************************************************
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync* Header Files *
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync*******************************************************************************/
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync// constructor / destructor
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync/////////////////////////////////////////////////////////////////////////////
d23a94a28e59f64d02905f20bb8f3b23f1c9eb17vboxsync// public initializer/uninitializer for internal purposes only
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync/////////////////////////////////////////////////////////////////////////////
d23a94a28e59f64d02905f20bb8f3b23f1c9eb17vboxsyncint GuestDnDTarget::init(const ComObjPtr<Guest>& pGuest)
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync /* Enclose the state transition NotReady->InInit->Ready. */
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync /* Confirm a successful initialization when it's the case. */
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync * Uninitializes the instance.
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync * Called from FinalRelease().
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync /* Enclose the state transition Ready->InUninit->NotReady. */
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync// implementation of wrapped private getters/setters for attributes
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync/////////////////////////////////////////////////////////////////////////////
5c1381fc884d30a749517579368ff6cb4b43e809vboxsyncHRESULT GuestDnDTarget::enter(ULONG aScreenId, ULONG aX, ULONG aY,
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync#if !defined(VBOX_WITH_DRAG_AND_DROP) || !defined(VBOX_WITH_DRAG_AND_DROP_GH)
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync#else /* VBOX_WITH_DRAG_AND_DROP */
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync /* Input validation. */
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync return setError(E_INVALIDARG, tr("No default action specified"));
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync return setError(E_INVALIDARG, tr("Number of allowed actions is empty"));
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync return setError(E_INVALIDARG, tr("Number of supported formats is empty"));
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync /* Default action is ignoring. */
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync /* Check & convert the drag & drop actions */
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync GuestDnD::toHGCMActions(aDefaultAction, &uDefAction,
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync /* If there is no usable action, ignore this request. */
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync /* Make a flat data string out of the supported format list. */
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync Utf8Str strFormats = GuestDnD::toFormatString(GuestDnDInst()->supportedFormats(),
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync /* If there is no valid supported format, ignore this request. */
d23a94a28e59f64d02905f20bb8f3b23f1c9eb17vboxsync /* Adjust the coordinates in a multi-monitor setup. */
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync int rc = GuestDnDInst()->adjustScreenCoordinates(aScreenId, &aX, &aY);
d23a94a28e59f64d02905f20bb8f3b23f1c9eb17vboxsync paParms[i++].setPointer((void*)strFormats.c_str(), strFormats.length() + 1);
d23a94a28e59f64d02905f20bb8f3b23f1c9eb17vboxsync rc = GuestDnDInst()->hostCall(DragAndDropSvc::HOST_DND_HG_EVT_ENTER,
d23a94a28e59f64d02905f20bb8f3b23f1c9eb17vboxsync GuestDnDResponse *pResp = GuestDnDInst()->response();
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync if (pResp && RT_SUCCESS(pResp->waitForGuestResponse()))
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync resAction = GuestDnD::toMainAction(pResp->defAction());
5c1381fc884d30a749517579368ff6cb4b43e809vboxsync LogFlowFunc(("hr=%Rhrc, resAction=%ld\n", hr, resAction));
return hr;
return S_OK;
aFormats);
return S_OK;
i, paParms);
if (aResultAction)
return hr;
if (pResp)
return hr;
return S_OK;
aFormats);
return S_OK;
i, paParms);
if (aResultAction)
return hr;
if (pResp)
/* Note: The actual data transfer of files/directoies is performed by the
i, paParms);
if (aProgress)
return hr;