VirtualBox

Ignore:
Timestamp:
Sep 17, 2019 9:05:21 AM (5 years ago)
Author:
vboxsync
Message:

Shared Clipboard/URI: More code for transfer channel handling.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-common.cpp

    r80662 r80845  
    180180    RTListForEachSafe(&pSource->lstEvents, pEvIt, pEvItNext, SHCLEVENT, Node)
    181181    {
     182        RTListNodeRemove(&pEvIt->Node);
     183
    182184        SharedClipboardEventDestroy(pEvIt);
     185
    183186        RTMemFree(pEvIt);
     187        pEvIt = NULL;
    184188    }
    185189
     
    199203
    200204    LogFlowFunc(("uSource=%RU16: New event: %RU16\n", pSource->uID, pSource->uEventIDNext));
    201     return pSource->uEventIDNext++; /** @todo Handle rollovers? */
     205
     206    pSource->uEventIDNext++;
     207    if (pSource->uEventIDNext == VBOX_SHARED_CLIPBOARD_MAX_EVENTS)
     208        pSource->uEventIDNext = 0;
     209
     210    return pSource->uEventIDNext;
    202211}
    203212
     
    235244
    236245    return 0;
     246}
     247
     248/**
     249 * Detaches a payload from an event, internal version.
     250 *
     251 * @param   pEvent              Event to detach payload for.
     252 */
     253static void sharedClipboardEventPayloadDetachInternal(PSHCLEVENT pEvent)
     254{
     255    AssertPtrReturnVoid(pEvent);
     256
     257    pEvent->pPayload = NULL;
    237258}
    238259
     
    324345 * @param   uTimeoutMs          Timeout (in ms) to wait.
    325346 * @param   ppPayload           Where to store the (allocated) event payload on success. Needs to be free'd with
    326  *                              SharedClipboardPayloadFree().
     347 *                              SharedClipboardPayloadFree(). Optional.
    327348 */
    328349int SharedClipboardEventWait(PSHCLEVENTSOURCE pSource, SHCLEVENTID uID, RTMSINTERVAL uTimeoutMs,
     
    330351{
    331352    AssertPtrReturn(pSource, VERR_INVALID_POINTER);
     353    /** ppPayload is optional. */
    332354
    333355    LogFlowFuncEnter();
     
    341363        if (RT_SUCCESS(rc))
    342364        {
    343             *ppPayload = pEvent->pPayload;
    344 
    345             pEvent->pPayload = NULL;
     365            if (ppPayload)
     366            {
     367                *ppPayload = pEvent->pPayload;
     368
     369                /* Make sure to detach payload here, as the caller now owns the data. */
     370                sharedClipboardEventPayloadDetachInternal(pEvent);
     371            }
    346372        }
    347373    }
     
    402428    if (pEvent)
    403429    {
    404         pEvent->pPayload = NULL;
     430        sharedClipboardEventPayloadDetachInternal(pEvent);
    405431    }
    406432#ifdef DEBUG_andy
     
    803829        RT_CASE_RET_STR(VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA);
    804830        RT_CASE_RET_STR(VBOX_SHARED_CLIPBOARD_HOST_MSG_FORMATS_REPORT);
    805         RT_CASE_RET_STR(VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_TRANSFER_START);
     831        RT_CASE_RET_STR(VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_TRANSFER_STATUS);
    806832        RT_CASE_RET_STR(VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_ROOT_LIST_HDR_READ);
    807833        RT_CASE_RET_STR(VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_ROOT_LIST_HDR_WRITE);
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