VirtualBox

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


Ignore:
Timestamp:
May 31, 2019 3:23:14 PM (6 years ago)
Author:
vboxsync
Message:

Shared Clipboard/URI: Update.

Location:
trunk/src/VBox/Additions/common/VBoxGuest/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/lib/Makefile.kmk

    r78618 r78897  
    147147endif
    148148ifdef VBOX_WITH_SHARED_CLIPBOARD
     149 VBoxGuestR3Lib_DEFS      += VBOX_WITH_SHARED_CLIPBOARD_GUEST
    149150 VBoxGuestR3Lib_SOURCES   += \
    150151        VBoxGuestR3LibClipboard.cpp
     152 ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
     153 VBoxGuestR3Lib_SOURCES   += \
     154        $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardMetaData.cpp \
     155        $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardMIME.cpp
     156 endif
    151157endif
    152158ifdef VBOX_WITH_SHARED_FOLDERS
  • trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibClipboard.cpp

    r78809 r78897  
    264264 * @param   idClient            The client id returned by VbglR3ClipboardConnect().
    265265 * @param   pDataHdr            Where to store the data header data.
    266  * @param   ppvData             Returns the received meta data. Needs to be free'd by the caller.
    267  * @param   pcbData             Where to store the size (in bytes) of the received meta data.
     266 * @param   pMetaData           Returns the received meta data. Needs to be free'd by the caller.
    268267 */
    269268static int vbglR3ClipboardReadMetaDataLoop(HGCMCLIENTID idClient, PVBOXCLIPBOARDDATAHDR pDataHdr,
    270                                            void **ppvData, uint64_t *pcbData)
    271 {
    272     AssertPtrReturn(pDataHdr, VERR_INVALID_POINTER);
    273     AssertPtrReturn(ppvData,  VERR_INVALID_POINTER);
    274     AssertPtrReturn(pcbData,  VERR_INVALID_POINTER);
     269                                           PSHAREDCLIPBOARDMETADATA pMetaData)
     270{
     271    AssertPtrReturn(pDataHdr,  VERR_INVALID_POINTER);
     272    AssertPtrReturn(pMetaData, VERR_INVALID_POINTER);
    275273
    276274    int rc;
     
    318316                LogFlowFunc(("Received %RU64 bytes of data\n", cbDataTmp));
    319317
    320                 *ppvData = pvDataTmp;
    321                 *pcbData = cbDataTmp;
     318                pMetaData->pvMeta = pvDataTmp;
     319                pMetaData->cbMeta = cbDataTmp;
     320                pMetaData->cbUsed = cbDataTmp;
    322321            }
    323322            else
     
    326325    }
    327326    else
    328     {
    329         *ppvData = NULL;
    330         *pcbData = 0;
    331     }
     327        SharedClipboardMetaDataDestroy(pMetaData);
    332328
    333329    LogFlowFuncLeaveRC(rc);
     
    336332
    337333/**
    338  * Main function for reading the actual meta data from the host, extended version.
    339  *
    340  * @returns IPRT status code.
    341  * @param   idClient            The client id returned by VbglR3ClipboardConnect().
    342  * @param   pEnmType            Where to store the meta data type. Optional.
    343  * @param   ppvData             Returns the received meta data. Needs to be free'd by the caller.  Optional.
    344  * @param   pcbData             Where to store the size (in bytes) of the received meta data. Optional.
    345  */
    346 static int vbglR3ClipboardReadMetaDataMainEx(HGCMCLIENTID                 idClient,
    347                                              VBGLR3GUESTDNDMETADATATYPE  *pEnmType,
    348                                              void                       **ppvData,
    349                                              uint32_t                    *pcbData)
     334 * Reads the actual meta data from the host, extended version.
     335 *
     336 * @returns IPRT status code.
     337 * @param   idClient            The client id returned by VbglR3ClipboardConnect().
     338 * @param   URIList             Where to store received meta data.
     339 */
     340static int vbglR3ClipboardReadMetaDataEx(HGCMCLIENTID idClient, SharedClipboardURIList &URIList)
    350341{
    351342    /* The rest is optional. */
     
    359350        return VERR_NO_MEMORY;
    360351
    361     SharedClipboardURIList lstURI;
    362 
    363     void    *pvData = NULL;
    364     uint64_t cbData = 0;
    365 
    366     int rc = vbglR3ClipboardReadMetaDataLoop(idClient, &dataHdr, &pvData, &cbData);
     352    SHAREDCLIPBOARDMETADATA dataMeta;
     353    SharedClipboardMetaDataInit(&dataMeta);
     354
     355    int rc = vbglR3ClipboardReadMetaDataLoop(idClient, &dataHdr, &dataMeta);
    367356    if (RT_SUCCESS(rc))
    368357    {
     
    379368        if (SharedClipboardMIMEHasFileURLs((char *)dataHdr.pvMetaFmt, dataHdr.cbMetaFmt)) /* URI data. */
    380369        {
    381             AssertPtr(pvData);
    382             Assert(cbData);
    383 
    384             rc = lstURI.SetFromURIData(pvData, cbData, 0 /* fFlags */);
     370            rc = URIList.SetFromURIData(dataMeta.pvMeta, dataMeta.cbMeta, 0 /* fFlags */);
     371
     372        #if 0
    385373            if (RT_SUCCESS(rc))
    386374                rc = vbglR3ClipboardReadURIData(idClient, &dataHdr);
    387375
    388             if (RT_SUCCESS(rc)) /** @todo Remove this block as soon as we hand in DnDURIList. */
     376            if (RT_SUCCESS(rc))
    389377            {
    390378                if (pvData)
     
    406394                {
    407395                    memcpy(pvData, strData.c_str(), cbData);
    408 
    409                     if (pEnmType)
    410                         *pEnmType = VBGLR3GUESTDNDMETADATATYPE_URI_LIST;
    411396                }
    412397                else
     
    414399            #endif
    415400            }
     401        #endif
    416402        }
    417403        else /* Raw data. */
    418404        {
    419             if (pEnmType)
    420                 *pEnmType = VBGLR3GUESTDNDMETADATATYPE_RAW;
     405            /** @todo Implement this. */
    421406        }
     407
     408        SharedClipboardMetaDataDestroy(&dataMeta);
    422409    }
    423410
    424411    if (dataHdr.pvMetaFmt)
     412    {
    425413        RTMemFree(dataHdr.pvMetaFmt);
    426 
    427     if (RT_SUCCESS(rc))
    428     {
    429         if (   pvData
    430             && cbData)
    431         {
    432             if (pcbData)
    433                 *pcbData = cbData;
    434             if (ppvData)
    435                 *ppvData = pvData;
    436             else
    437                 RTMemFree(pvData);
    438         }
    439     }
    440     else if (   RT_FAILURE(rc)
    441              && rc != VERR_CANCELLED)
    442     {
    443         if (pvData)
    444             RTMemFree(pvData);
     414        dataHdr.pvMetaFmt = NULL;
    445415    }
    446416
     
    450420
    451421/**
    452  * Main function for reading the actual meta data from the host.
    453  *
    454  * @returns IPRT status code.
    455  * @param   idClient            The client id returned by VbglR3ClipboardConnect().
    456  * @param   pMeta               Where to store the actual meta data received from the host.
    457  */
    458 static int vbglR3ClipboardReadMetaDataMain(HGCMCLIENTID idClient, PVBGLR3GUESTDNDMETADATA pMeta)
    459 {
    460     AssertPtrReturn(pMeta, VERR_INVALID_POINTER);
    461 
    462     int rc = vbglR3ClipboardReadMetaDataMainEx(idClient,
    463                                                &pMeta->enmType,
    464                                                &pMeta->pvMeta,
    465                                                &pMeta->cbMeta);
    466     return rc;
     422 * Reads the actual meta data from the host.
     423 *
     424 * @returns IPRT status code.
     425 * @param   idClient            The client id returned by VbglR3ClipboardConnect().
     426 * @param   URIList             Where to store received meta data.
     427 */
     428VBGLR3DECL(int) VbglR3ClipboardReadMetaData(HGCMCLIENTID idClient, SharedClipboardURIList &URIList)
     429{
     430    return vbglR3ClipboardReadMetaDataEx(idClient, URIList);
     431}
     432
     433VBGLR3DECL(int) VbglR3ClipboardWriteMetaData(HGCMCLIENTID idClient, const SharedClipboardURIList &URIList)
     434{
     435    RT_NOREF(idClient, URIList);
     436    return 0;
    467437}
    468438
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