VirtualBox

Changeset 56656 in vbox


Ignore:
Timestamp:
Jun 26, 2015 8:51:18 AM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
101292
Message:

DnD/Main: GuestDnDTargetImpl.cpp: Some more error checking, return values.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp

    r56655 r56656  
    241241
    242242HRESULT GuestDnDTarget::enter(ULONG aScreenId, ULONG aX, ULONG aY,
    243                               DnDAction_T aDefaultAction,
    244                               const std::vector<DnDAction_T> &aAllowedActions,
     243                              DnDAction_T                      aDefaultAction,
     244                              const std::vector<DnDAction_T>  &aAllowedActions,
    245245                              const std::vector<com::Utf8Str> &aFormats,
    246                               DnDAction_T *aResultAction)
     246                              DnDAction_T                     *aResultAction)
    247247{
    248248#if !defined(VBOX_WITH_DRAG_AND_DROP)
     
    281281    /* If there is no valid supported format, ignore this request. */
    282282    if (strFormats.isEmpty())
    283         return S_OK;
     283        return setError(E_INVALIDARG, tr("Specified format(s) not supported"));
     284
     285    LogRel2(("DnD: Offered formats to guest:\n"));
     286    RTCList<RTCString> lstFormats = strFormats.split("\r\n");
     287    for (size_t i = 0; i < lstFormats.size(); i++)
     288        LogRel2(("DnD: \t%s\n", lstFormats[i].c_str()));
     289
     290    /* Save the formats offered to the guest. This is needed to later
     291     * decide what to do with the data when sending stuff to the guest. */
     292    m_vecFmtOff = aFormats;
     293    Assert(m_vecFmtOff.size());
    284294
    285295    HRESULT hr = S_OK;
     
    308318    }
    309319
    310     if (aResultAction)
    311         *aResultAction = resAction;
     320    if (RT_FAILURE(rc))
     321        hr = VBOX_E_IPRT_ERROR;
     322
     323    if (SUCCEEDED(hr))
     324    {
     325        if (aResultAction)
     326            *aResultAction = resAction;
     327    }
    312328
    313329    LogFlowFunc(("hr=%Rhrc, resAction=%ld\n", hr, resAction));
     
    317333
    318334HRESULT GuestDnDTarget::move(ULONG aScreenId, ULONG aX, ULONG aY,
    319                              DnDAction_T aDefaultAction,
    320                              const std::vector<DnDAction_T> &aAllowedActions,
     335                             DnDAction_T                      aDefaultAction,
     336                             const std::vector<DnDAction_T>  &aAllowedActions,
    321337                             const std::vector<com::Utf8Str> &aFormats,
    322                              DnDAction_T *aResultAction)
     338                             DnDAction_T                     *aResultAction)
    323339{
    324340#if !defined(VBOX_WITH_DRAG_AND_DROP)
     
    347363    /* If there is no valid supported format, ignore this request. */
    348364    if (strFormats.isEmpty())
    349         return S_OK;
     365        return setError(E_INVALIDARG, tr("Specified format(s) not supported"));
    350366
    351367    HRESULT hr = S_OK;
     
    373389    }
    374390
    375     if (aResultAction)
    376         *aResultAction = resAction;
     391    if (RT_FAILURE(rc))
     392        hr = VBOX_E_IPRT_ERROR;
     393
     394    if (SUCCEEDED(hr))
     395    {
     396        if (aResultAction)
     397            *aResultAction = resAction;
     398    }
    377399
    378400    LogFlowFunc(("hr=%Rhrc, *pResultAction=%ld\n", hr, resAction));
     
    400422    }
    401423
     424    if (RT_FAILURE(rc))
     425        hr = VBOX_E_IPRT_ERROR;
     426
    402427    LogFlowFunc(("hr=%Rhrc\n", hr));
    403428    return hr;
     
    406431
    407432HRESULT GuestDnDTarget::drop(ULONG aScreenId, ULONG aX, ULONG aY,
    408                              DnDAction_T aDefaultAction,
    409                              const std::vector<DnDAction_T> &aAllowedActions,
     433                             DnDAction_T                      aDefaultAction,
     434                             const std::vector<DnDAction_T>  &aAllowedActions,
    410435                             const std::vector<com::Utf8Str> &aFormats,
    411                              com::Utf8Str &aFormat, DnDAction_T *aResultAction)
     436                             com::Utf8Str                    &aFormat,
     437                             DnDAction_T                     *aResultAction)
    412438{
    413439#if !defined(VBOX_WITH_DRAG_AND_DROP)
     
    432458    /* If there is no usable action, ignore this request. */
    433459    if (isDnDIgnoreAction(uDefAction))
     460    {
     461        aFormat = "";
     462        if (aResultAction)
     463            *aResultAction = DnDAction_Ignore;
    434464        return S_OK;
     465    }
    435466
    436467    /* Make a flat data string out of the supported format list. */
     
    438469    /* If there is no valid supported format, ignore this request. */
    439470    if (strFormats.isEmpty())
    440         return S_OK;
     471        return setError(E_INVALIDARG, tr("Specified format(s) not supported"));
    441472
    442473    HRESULT hr = S_OK;
     
    471502    }
    472503
    473     if (aResultAction)
    474         *aResultAction = resAction;
    475 
     504    if (RT_FAILURE(rc))
     505        hr = VBOX_E_IPRT_ERROR;
     506
     507    if (SUCCEEDED(hr))
     508    {
     509        if (aResultAction)
     510            *aResultAction = resAction;
     511    }
     512
     513    LogFlowFunc(("Returning hr=%Rhrc\n", hr));
    476514    return hr;
    477515#endif /* VBOX_WITH_DRAG_AND_DROP */
     
    681719{
    682720    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
    683 
    684     GuestDnD *pInst = GuestDnDInst();
    685     if (!pInst)
    686         return VERR_INVALID_POINTER;
    687721
    688722    int rc;
     
    13011335        *aVeto = FALSE; /** @todo */
    13021336
    1303     return RT_SUCCESS(rc) ? S_OK : VBOX_E_IPRT_ERROR;
     1337    HRESULT hr = RT_SUCCESS(rc) ? S_OK : VBOX_E_IPRT_ERROR;
     1338
     1339    LogFlowFunc(("hr=%Rhrc\n", hr));
     1340    return hr;
    13041341#endif /* VBOX_WITH_DRAG_AND_DROP */
    13051342}
Note: See TracChangeset for help on using the changeset viewer.

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