Index: /trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp	(revision 56655)
+++ /trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp	(revision 56656)
@@ -241,8 +241,8 @@
 
 HRESULT GuestDnDTarget::enter(ULONG aScreenId, ULONG aX, ULONG aY,
-                              DnDAction_T aDefaultAction,
-                              const std::vector<DnDAction_T> &aAllowedActions,
+                              DnDAction_T                      aDefaultAction,
+                              const std::vector<DnDAction_T>  &aAllowedActions,
                               const std::vector<com::Utf8Str> &aFormats,
-                              DnDAction_T *aResultAction)
+                              DnDAction_T                     *aResultAction)
 {
 #if !defined(VBOX_WITH_DRAG_AND_DROP)
@@ -281,5 +281,15 @@
     /* If there is no valid supported format, ignore this request. */
     if (strFormats.isEmpty())
-        return S_OK;
+        return setError(E_INVALIDARG, tr("Specified format(s) not supported"));
+
+    LogRel2(("DnD: Offered formats to guest:\n"));
+    RTCList<RTCString> lstFormats = strFormats.split("\r\n");
+    for (size_t i = 0; i < lstFormats.size(); i++)
+        LogRel2(("DnD: \t%s\n", lstFormats[i].c_str()));
+
+    /* Save the formats offered to the guest. This is needed to later
+     * decide what to do with the data when sending stuff to the guest. */
+    m_vecFmtOff = aFormats;
+    Assert(m_vecFmtOff.size());
 
     HRESULT hr = S_OK;
@@ -308,6 +318,12 @@
     }
 
-    if (aResultAction)
-        *aResultAction = resAction;
+    if (RT_FAILURE(rc))
+        hr = VBOX_E_IPRT_ERROR;
+
+    if (SUCCEEDED(hr))
+    {
+        if (aResultAction)
+            *aResultAction = resAction;
+    }
 
     LogFlowFunc(("hr=%Rhrc, resAction=%ld\n", hr, resAction));
@@ -317,8 +333,8 @@
 
 HRESULT GuestDnDTarget::move(ULONG aScreenId, ULONG aX, ULONG aY,
-                             DnDAction_T aDefaultAction,
-                             const std::vector<DnDAction_T> &aAllowedActions,
+                             DnDAction_T                      aDefaultAction,
+                             const std::vector<DnDAction_T>  &aAllowedActions,
                              const std::vector<com::Utf8Str> &aFormats,
-                             DnDAction_T *aResultAction)
+                             DnDAction_T                     *aResultAction)
 {
 #if !defined(VBOX_WITH_DRAG_AND_DROP)
@@ -347,5 +363,5 @@
     /* If there is no valid supported format, ignore this request. */
     if (strFormats.isEmpty())
-        return S_OK;
+        return setError(E_INVALIDARG, tr("Specified format(s) not supported"));
 
     HRESULT hr = S_OK;
@@ -373,6 +389,12 @@
     }
 
-    if (aResultAction)
-        *aResultAction = resAction;
+    if (RT_FAILURE(rc))
+        hr = VBOX_E_IPRT_ERROR;
+
+    if (SUCCEEDED(hr))
+    {
+        if (aResultAction)
+            *aResultAction = resAction;
+    }
 
     LogFlowFunc(("hr=%Rhrc, *pResultAction=%ld\n", hr, resAction));
@@ -400,4 +422,7 @@
     }
 
+    if (RT_FAILURE(rc))
+        hr = VBOX_E_IPRT_ERROR;
+
     LogFlowFunc(("hr=%Rhrc\n", hr));
     return hr;
@@ -406,8 +431,9 @@
 
 HRESULT GuestDnDTarget::drop(ULONG aScreenId, ULONG aX, ULONG aY,
-                             DnDAction_T aDefaultAction,
-                             const std::vector<DnDAction_T> &aAllowedActions,
+                             DnDAction_T                      aDefaultAction,
+                             const std::vector<DnDAction_T>  &aAllowedActions,
                              const std::vector<com::Utf8Str> &aFormats,
-                             com::Utf8Str &aFormat, DnDAction_T *aResultAction)
+                             com::Utf8Str                    &aFormat,
+                             DnDAction_T                     *aResultAction)
 {
 #if !defined(VBOX_WITH_DRAG_AND_DROP)
@@ -432,5 +458,10 @@
     /* If there is no usable action, ignore this request. */
     if (isDnDIgnoreAction(uDefAction))
+    {
+        aFormat = "";
+        if (aResultAction)
+            *aResultAction = DnDAction_Ignore;
         return S_OK;
+    }
 
     /* Make a flat data string out of the supported format list. */
@@ -438,5 +469,5 @@
     /* If there is no valid supported format, ignore this request. */
     if (strFormats.isEmpty())
-        return S_OK;
+        return setError(E_INVALIDARG, tr("Specified format(s) not supported"));
 
     HRESULT hr = S_OK;
@@ -471,7 +502,14 @@
     }
 
-    if (aResultAction)
-        *aResultAction = resAction;
-
+    if (RT_FAILURE(rc))
+        hr = VBOX_E_IPRT_ERROR;
+
+    if (SUCCEEDED(hr))
+    {
+        if (aResultAction)
+            *aResultAction = resAction;
+    }
+
+    LogFlowFunc(("Returning hr=%Rhrc\n", hr));
     return hr;
 #endif /* VBOX_WITH_DRAG_AND_DROP */
@@ -681,8 +719,4 @@
 {
     AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
-
-    GuestDnD *pInst = GuestDnDInst();
-    if (!pInst)
-        return VERR_INVALID_POINTER;
 
     int rc;
@@ -1301,5 +1335,8 @@
         *aVeto = FALSE; /** @todo */
 
-    return RT_SUCCESS(rc) ? S_OK : VBOX_E_IPRT_ERROR;
+    HRESULT hr = RT_SUCCESS(rc) ? S_OK : VBOX_E_IPRT_ERROR;
+
+    LogFlowFunc(("hr=%Rhrc\n", hr));
+    return hr;
 #endif /* VBOX_WITH_DRAG_AND_DROP */
 }
