VirtualBox

Changeset 97748 in vbox for trunk/src/VBox/Additions/common


Ignore:
Timestamp:
Dec 6, 2022 9:26:48 AM (2 years ago)
Author:
vboxsync
Message:

DnD: Renamed GUEST_DND_FN_GH_EVT_ERROR -> GUEST_DND_FN_EVT_ERROR to make this message more generic and not only bound to guest -> host (G->H) transfers. We also need a way to pass back errors for host -> guest (H->G) transfers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibDragAndDrop.cpp

    r97746 r97748  
    103103
    104104    } while (rc == VERR_INTERRUPTED);
     105
     106    return rc;
     107}
     108
     109
     110/**
     111 * Sends a DnD error back to the host.
     112 *
     113 * @returns IPRT status code.
     114 * @param   pCtx                DnD context to use.
     115 * @param   rcErr               Error (IPRT-style) to send.
     116 */
     117VBGLR3DECL(int) VbglR3DnDSendError(PVBGLR3GUESTDNDCMDCTX pCtx, int rcErr)
     118{
     119    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     120
     121    HGCMMsgGHError Msg;
     122    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_DND_FN_EVT_ERROR, 2);
     123    /** @todo Context ID not used yet. */
     124    Msg.u.v3.uContext.SetUInt32(0);
     125    Msg.u.v3.rc.SetUInt32((uint32_t)rcErr); /* uint32_t vs. int. */
     126
     127    int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
     128
     129    /*
     130     * Never return an error if the host did not accept the error at the current
     131     * time.  This can be due to the host not having any appropriate callbacks
     132     * set which would handle that error.
     133     *
     134     * bird: Looks like VERR_NOT_SUPPORTED is what the host will return if it
     135     *       doesn't an appropriate callback.  The code used to ignore ALL errors
     136     *       the host would return, also relevant ones.
     137     */
     138    if (RT_FAILURE(rc))
     139        LogFlowFunc(("Sending error %Rrc failed with rc=%Rrc\n", rcErr, rc));
     140    if (rc == VERR_NOT_SUPPORTED)
     141        rc = VINF_SUCCESS;
    105142
    106143    return rc;
     
    18821919        if (rc != VERR_CANCELLED)
    18831920        {
    1884             int rc2 = VbglR3DnDGHSendError(pCtx, rc);
     1921            int rc2 = VbglR3DnDSendError(pCtx, rc);
    18851922            if (RT_FAILURE(rc2))
    18861923                LogFlowFunc(("Unable to send error (%Rrc) to host, rc=%Rrc\n", rc, rc2));
     
    18901927    return rc;
    18911928}
    1892 
    1893 /**
    1894  * Guest -> Host
    1895  * Send an error back to the host.
    1896  *
    1897  * @returns IPRT status code.
    1898  * @param   pCtx                DnD context to use.
    1899  * @param   rcErr               Error (IPRT-style) to send.
    1900  */
    1901 VBGLR3DECL(int) VbglR3DnDGHSendError(PVBGLR3GUESTDNDCMDCTX pCtx, int rcErr)
    1902 {
    1903     AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
    1904 
    1905     HGCMMsgGHError Msg;
    1906     VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_DND_FN_GH_EVT_ERROR, 2);
    1907     /** @todo Context ID not used yet. */
    1908     Msg.u.v3.uContext.SetUInt32(0);
    1909     Msg.u.v3.rc.SetUInt32((uint32_t)rcErr); /* uint32_t vs. int. */
    1910 
    1911     int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
    1912 
    1913     /*
    1914      * Never return an error if the host did not accept the error at the current
    1915      * time.  This can be due to the host not having any appropriate callbacks
    1916      * set which would handle that error.
    1917      *
    1918      * bird: Looks like VERR_NOT_SUPPORTED is what the host will return if it
    1919      *       doesn't an appropriate callback.  The code used to ignore ALL errors
    1920      *       the host would return, also relevant ones.
    1921      */
    1922     if (RT_FAILURE(rc))
    1923         LogFlowFunc(("Sending error %Rrc failed with rc=%Rrc\n", rcErr, rc));
    1924     if (rc == VERR_NOT_SUPPORTED)
    1925         rc = VINF_SUCCESS;
    1926 
    1927     return rc;
    1928 }
    19291929#endif /* VBOX_WITH_DRAG_AND_DROP_GH */
    19301930
Note: See TracChangeset for help on using the changeset viewer.

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