VirtualBox

Changeset 79088 in vbox


Ignore:
Timestamp:
Jun 11, 2019 12:16:49 PM (6 years ago)
Author:
vboxsync
Message:

Shared Clipboard/URI: Update.

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/GuestHost/SharedClipboard-uri.h

    r79036 r79088  
    378378};
    379379
     380int SharedClipboardDataHeaderInit(PVBOXCLIPBOARDDATAHDR pDataHdr);
     381void SharedClipboardDataHeaderDestroy(PVBOXCLIPBOARDDATAHDR pDataHdr);
     382
    380383/**
    381384 * Structure for keeping Shared Clipboard meta data.
  • trunk/include/VBox/HostServices/VBoxClipboardExt.h

    r78683 r79088  
    8080typedef struct _VBOXCLIPBOARDEXTAREAPARMS
    8181{
    82     /** The clipboard area's ID. */
     82    /** The clipboard area's ID the callback is for. */
    8383    SHAREDCLIPBOARDAREAID uID;
    8484    union
     
    8888            void                              *pvData;
    8989            uint32_t                           cbData;
     90            /** Area register flags; not used yet and must be set to 0. */
    9091            VBOXCLIPBOARDEXTAREAREGISTETRFLAGS fFlags;
    9192        } fn_register;
    9293        struct
    9394        {
     95            /** Area attach flags; not used yet and must be set to 0. */
    9496            VBOXCLIPBOARDEXTAREAATTACHFLAGS    fFlags;
    9597        } fn_attach;
    9698    } u;
    9799} VBOXCLIPBOARDEXTAREAPARMS, *PVBOXCLIPBOARDEXTAREAPARMS;
    98 #endif
     100#endif /* VBOX_WITH_SHARED_CLIPBOARD_URI_LIST */
    99101
    100102#endif /* !VBOX_INCLUDED_HostServices_VBoxClipboardExt_h */
  • trunk/src/VBox/GuestHost/SharedClipboard/ClipboardProvider-HostService.cpp

    r79036 r79088  
    5555}
    5656
    57 int SharedClipboardProviderHostService::ReadMetaData(const PVBOXCLIPBOARDDATAHDR pDataHdr, void *pvMeta, uint32_t cbMeta, uint32_t *pcbRead,
    58                                                      uint32_t fFlags /* = 0 */)
     57int SharedClipboardProviderHostService::ReadMetaData(const PVBOXCLIPBOARDDATAHDR pDataHdr, void *pvMeta, uint32_t cbMeta,
     58                                                     uint32_t *pcbRead, uint32_t fFlags /* = 0 */)
    5959{
    6060    RT_NOREF(pDataHdr, pvMeta, cbMeta, pcbRead, fFlags);
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-common.cpp

    r79036 r79088  
    354354#ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
    355355/**
     356 * Initializes an URI data header struct.
     357 *
     358 * @returns VBox status code.
     359 * @param   pDataHdr            Data header struct to initialize.
     360 */
     361int SharedClipboardDataHeaderInit(PVBOXCLIPBOARDDATAHDR pDataHdr)
     362{
     363    AssertPtrReturn(pDataHdr, VERR_INVALID_POINTER);
     364
     365    RT_BZERO(pDataHdr, sizeof(VBOXCLIPBOARDDATAHDR));
     366
     367    return VINF_SUCCESS;
     368}
     369
     370/**
     371 * Destroys an URI data header struct.
     372 *
     373 * @param   pDataHdr            Data header struct to destroy.
     374 */
     375void SharedClipboardDataHeaderDestroy(PVBOXCLIPBOARDDATAHDR pDataHdr)
     376{
     377    if (!pDataHdr)
     378        return;
     379
     380    if (pDataHdr->pvMetaFmt)
     381    {
     382        Assert(pDataHdr->cbMetaFmt);
     383
     384        RTMemFree(pDataHdr->pvMetaFmt);
     385        pDataHdr->pvMetaFmt = NULL;
     386        pDataHdr->cbMetaFmt = 0;
     387    }
     388
     389    if (pDataHdr->pvChecksum)
     390    {
     391        Assert(pDataHdr->cbChecksum);
     392
     393        RTMemFree(pDataHdr->pvChecksum);
     394        pDataHdr->pvChecksum = NULL;
     395        pDataHdr->cbChecksum = 0;
     396    }
     397}
     398
     399/**
    356400 * Initializes an URI clipboard transfer struct.
    357401 *
     
    368412    AssertPtrReturn(ppTransfer, VERR_INVALID_POINTER);
    369413
     414    LogFlowFuncEnter();
     415
    370416    PSHAREDCLIPBOARDURITRANSFER pTransfer = (PSHAREDCLIPBOARDURITRANSFER)RTMemAlloc(sizeof(SHAREDCLIPBOARDURITRANSFER));
    371417    if (!pTransfer)
    372418        return VERR_NO_MEMORY;
    373419
    374     LogFlowFuncEnter();
    375 
    376420    pTransfer->enmDir = enmDir;
    377421
    378     SharedClipboardMetaDataInit(&pTransfer->Meta);
    379 
    380     pTransfer->pProvider = SharedClipboardProvider::Create(pCtx);
    381     if (!pTransfer->pProvider)
    382         return VERR_NO_MEMORY;
    383 
    384     pTransfer->Thread.hThread    = NIL_RTTHREAD;
    385     pTransfer->Thread.fCancelled = false;
    386     pTransfer->Thread.fStarted   = false;
    387 
    388     pTransfer->pvUser = NULL;
    389     pTransfer->cbUser = 0;
    390 
    391     *ppTransfer = pTransfer;
    392 
    393     LogFlowFuncLeave();
    394     return VINF_SUCCESS;
     422    int rc = SharedClipboardDataHeaderInit(&pTransfer->Header);
     423    if (RT_SUCCESS(rc))
     424    {
     425        rc = SharedClipboardMetaDataInit(&pTransfer->Meta);
     426        if (RT_SUCCESS(rc))
     427        {
     428            pTransfer->pProvider = SharedClipboardProvider::Create(pCtx);
     429            if (pTransfer->pProvider)
     430            {
     431                pTransfer->Thread.hThread    = NIL_RTTHREAD;
     432                pTransfer->Thread.fCancelled = false;
     433                pTransfer->Thread.fStarted   = false;
     434
     435                pTransfer->pvUser = NULL;
     436                pTransfer->cbUser = 0;
     437
     438                *ppTransfer = pTransfer;
     439            }
     440            else
     441                rc = VERR_NO_MEMORY;
     442        }
     443    }
     444
     445    LogFlowFuncLeaveRC(rc);
     446    return rc;
    395447}
    396448
     
    399451 *
    400452 * @returns VBox status code.
    401  * @param   pURI                URI clipboard transfer struct to destroy.
     453 * @param   pURI                URI clipboard transfer to destroy.
    402454 */
    403455int SharedClipboardURITransferDestroy(PSHAREDCLIPBOARDURITRANSFER pTransfer)
     
    412464        return rc;
    413465
     466    SharedClipboardDataHeaderDestroy(&pTransfer->Header);
    414467    SharedClipboardMetaDataDestroy(&pTransfer->Meta);
    415468
     
    431484 * Resets an clipboard URI transfer.
    432485 *
    433  * @param   pTransfer           URI clipboard transfer struct to reset.
     486 * @param   pTransfer           URI clipboard transfer to reset.
    434487 */
    435488void SharedClipboardURITransferReset(PSHAREDCLIPBOARDURITRANSFER pTransfer)
     
    451504 *
    452505 * @returns VBox status code.
    453  * @param   pTransfer           URI clipboard transfer struct to return current URI object for.
     506 * @param   pTransfer           URI clipboard transfer to return current URI object for.
    454507 */
    455508const SharedClipboardURIObject *SharedClipboardURITransferGetCurrentObject(PSHAREDCLIPBOARDURITRANSFER pTransfer)
     
    464517 *
    465518 * @returns VBox status code.
    466  * @param   pTransfer           URI clipboard transfer struct to return provider for.
     519 * @param   pTransfer           URI clipboard transfer to return provider for.
    467520 */
    468521SharedClipboardProvider *SharedClipboardURITransferGetProvider(PSHAREDCLIPBOARDURITRANSFER pTransfer)
     
    477530 *
    478531 * @returns Pointer to URI list.
    479  * @param   pTransfer           URI clipboard transfer struct to return URI list for.
     532 * @param   pTransfer           URI clipboard transfer to return URI list for.
    480533 */
    481534const SharedClipboardURIList *SharedClipboardURITransferGetList(PSHAREDCLIPBOARDURITRANSFER pTransfer)
     
    488541 *
    489542 * @returns Pointer to URI object.
    490  * @param   pTransfer           URI clipboard transfer struct to return URI object for.
     543 * @param   pTransfer           URI clipboard transfer to return URI object for.
    491544 */
    492545const SharedClipboardURIObject *SharedClipboardURITransferGetObject(PSHAREDCLIPBOARDURITRANSFER pTransfer, uint64_t uIdx)
     
    525578 *
    526579 * @returns VBox status code.
    527  * @param   pTransfer           URI clipboard transfer struct to set callbacks for.
     580 * @param   pTransfer           URI clipboard transfer to set callbacks for.
    528581 * @param   pCallbacks          Pointer to callback table to set. Specify NULL to unset existing callbacks.
    529582 */
     
    547600 *
    548601 * @returns VBox status code.
    549  * @param   pTransfer           URI clipboard transfer struct to create thread for.
     602 * @param   pTransfer           URI clipboard transfer to create thread for.
    550603 */
    551604static int sharedClipboardURITransferThreadCreate(PSHAREDCLIPBOARDURITRANSFER pTransfer)
     
    565618    int rc = RTThreadCreate(&pTransfer->Thread.hThread, pfnRTThread,
    566619                            pTransfer /* pvUser */, 0, RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE,
    567                             "vbxshclp");
     620                            "shclp");
    568621    if (RT_SUCCESS(rc))
    569622    {
     
    583636 *
    584637 * @returns VBox status code.
    585  * @param   pTransfer           URI clipboard transfer struct to destroy thread for.
     638 * @param   pTransfer           URI clipboard transfer to destroy thread for.
    586639 * @param   uTimeoutMs          Timeout (in ms) to wait for thread creation.
    587640 */
     
    664717 *
    665718 * @returns VBox status code.
    666  * @param   pTransfer           URI clipboard transfer struct to set meta data for.
     719 * @param   pTransfer           URI clipboard transfer to set meta data for.
    667720 * @param   pvMeta              Pointer to meta data buffer.
    668721 * @param   cbMeta              Size (in bytes) of meta data buffer.
     
    686739 *
    687740 * @returns VBox status code.
    688  * @param   pTransfer           URI clipboard transfer struct to set meta data for.
     741 * @param   pTransfer           URI clipboard transfer to set meta data for.
    689742 * @param   pvMeta              Pointer to meta data buffer.
    690743 * @param   cbMeta              Size (in bytes) of meta data buffer.
     
    700753}
    701754
     755/**
     756 * Reads meta for a clipboard URI transfer.
     757 *
     758 * @returns VBox status code.
     759 * @param   pTransfer           URI clipboard transfer to read meta data for.
     760 * @param   pcbRead             How much meta data (in bytes) was read on success.
     761 */
    702762int SharedClipboardURITransferMetaDataRead(PSHAREDCLIPBOARDURITRANSFER pTransfer, uint32_t *pcbRead)
    703763{
     
    935995    AssertPtrReturn(pTransfer, VERR_INVALID_POINTER);
    936996
     997    LogFlowFuncEnter();
     998
    937999    int rc = SharedClipboardURITransferMetaDataWrite(pTransfer, NULL /* pcbWritten */);
    9381000    if (RT_SUCCESS(rc))
     
    10101072 * @returns VBox status code.
    10111073 * @param   pURI                URI clipboard context to add transfer to.
    1012  * @param   pTransfer           Pointer to URI clipboard transfer struct to add.
     1074 * @param   pTransfer           Pointer to URI clipboard transfer to add.
    10131075 */
    10141076int SharedClipboardURICtxTransferAdd(PSHAREDCLIPBOARDURICTX pURI, PSHAREDCLIPBOARDURITRANSFER pTransfer)
     
    10331095 * @returns VBox status code.
    10341096 * @param   pURI                URI clipboard context to remove transfer from.
    1035  * @param   pTransfer           Pointer to URI clipboard transfer struct to remove.
     1097 * @param   pTransfer           Pointer to URI clipboard transfer to remove.
    10361098 */
    10371099int SharedClipboardURICtxTransferRemove(PSHAREDCLIPBOARDURICTX pURI, PSHAREDCLIPBOARDURITRANSFER pTransfer)
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-win.cpp

    r79036 r79088  
    2323
    2424#ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
     25# include <iprt/win/windows.h>
     26# include <iprt/win/shlobj.h> /* For CFSTR_FILEDESCRIPTORXXX + CFSTR_FILECONTENTS. */
    2527# include <iprt/utf16.h>
    2628#endif
     
    306308
    307309#ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
    308         /* Handles file system entries which are locally present
    309          * on source for transferring to the target. */
     310        /* CF_HDROP handles file system entries which are locally present
     311         * on source for transferring to the target.
     312         *
     313         * This does *not* invoke any IDataObject / IStream implementations! */
    310314        case CF_HDROP:
    311315            vboxFormat = VBOX_SHARED_CLIPBOARD_FMT_URI_LIST;
     
    324328                    if (RTStrCmp(szFormatName, VBOX_CLIPBOARD_WIN_REGFMT_HTML) == 0)
    325329                        vboxFormat = VBOX_SHARED_CLIPBOARD_FMT_HTML;
     330#ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
     331                    /* These types invoke our IDataObject / IStream implementations. */
     332                    else if (   (RTStrCmp(szFormatName, CFSTR_FILEDESCRIPTORA) == 0)
     333                             || (RTStrCmp(szFormatName, CFSTR_FILECONTENTS)    == 0))
     334                        vboxFormat = VBOX_SHARED_CLIPBOARD_FMT_URI_LIST;
     335                    /** @todo Do we need to handle CFSTR_FILEDESCRIPTORW here as well? */
     336#endif
    326337                }
    327338            }
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-win.cpp

    r79036 r79088  
    583583{
    584584    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     585
     586    LogFlowFuncEnter();
    585587
    586588    int rc;
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp

    r79036 r79088  
    208208    if (pClientData->State.fHostMsgQuit)
    209209    {
    210         LogFlowFunc(("vboxSvcClipboardReturnMsg: Quit\n"));
     210        LogFlowFunc(("VBOX_SHARED_CLIPBOARD_HOST_MSG_QUIT\n"));
    211211        VBoxHGCMParmUInt32Set(&paParms[0], VBOX_SHARED_CLIPBOARD_HOST_MSG_QUIT);
    212212        VBoxHGCMParmUInt32Set(&paParms[1], 0);
     
    217217        uint32_t fFormat = 0;
    218218
    219         LogFlowFunc(("vboxSvcClipboardReturnMsg: ReadData %02X\n", pClientData->State.u32RequestedFormat));
     219        LogFlowFunc(("VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA: u32RequestedFormat=%02X\n",
     220                     pClientData->State.u32RequestedFormat));
     221
    220222        if (pClientData->State.u32RequestedFormat & VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT)
    221223            fFormat = VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT;
     
    241243    else if (pClientData->State.fHostMsgFormats)
    242244    {
    243         LogFlowFunc(("vboxSvcClipboardReturnMsg: Formats %02X\n", pClientData->State.u32AvailableFormats));
     245        LogFlowFunc(("VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS: u32AvailableFormats=%02X\n",
     246                     pClientData->State.u32AvailableFormats));
     247
    244248        VBoxHGCMParmUInt32Set(&paParms[0], VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS);
    245249        VBoxHGCMParmUInt32Set(&paParms[1], pClientData->State.u32AvailableFormats);
     
    249253    {
    250254        /* No pending messages. */
    251         LogFlowFunc(("vboxSvcClipboardReturnMsg: no message\n"));
     255        LogFlowFunc(("No pending message\n"));
    252256        return false;
    253257    }
     
    263267    int rc = VINF_SUCCESS;
    264268
    265     LogFlowFunc(("u32Msg=%RU32\n", u32Msg));
     269    LogFlowFuncEnter();
    266270
    267271    if (VBoxSvcClipboardLock())
     
    271275            case VBOX_SHARED_CLIPBOARD_HOST_MSG_QUIT:
    272276            {
    273                 LogFlowFunc(("Quit\n"));
     277                LogFlowFunc(("VBOX_SHARED_CLIPBOARD_HOST_MSG_QUIT\n"));
    274278                pClientData->State.fHostMsgQuit = true;
    275279            } break;
     280
    276281            case VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA:
    277282            {
     
    283288                }
    284289
    285                 LogFlowFunc(("ReadData %02X\n", u32Formats));
     290                LogFlowFunc(("VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA: u32Formats=%02X\n", u32Formats));
    286291                pClientData->State.u32RequestedFormat = u32Formats;
    287292                pClientData->State.fHostMsgReadData = true;
    288293            } break;
     294
    289295            case VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS:
    290296            {
     
    296302                }
    297303
    298                 LogFlowFunc(("Formats %02X\n", u32Formats));
     304                LogFlowFunc(("VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS: u32Formats=%02X\n", u32Formats));
    299305                pClientData->State.u32AvailableFormats = u32Formats;
    300306                pClientData->State.fHostMsgFormats = true;
    301307            } break;
     308
    302309            default:
    303310            {
    304                 /* Invalid message. */
    305                 LogFlowFunc(("invalid message %d\n", u32Msg));
     311                AssertMsgFailed(("Invalid message %RU32\n", u32Msg));
     312                rc = VERR_INVALID_PARAMETER;
    306313            } break;
    307314        }
    308315
    309         if (pClientData->State.fAsync)
    310         {
    311             /* The client waits for a response. */
    312             bool fMessageReturned = vboxSvcClipboardReturnMsg(pClientData, pClientData->State.async.paParms);
    313 
    314             /* Make a copy of the handle. */
    315             VBOXHGCMCALLHANDLE callHandle = pClientData->State.async.callHandle;
    316 
    317             if (fMessageReturned)
    318             {
    319                 /* There is a response. */
    320                 pClientData->State.fAsync = false;
    321             }
    322 
    323             VBoxSvcClipboardUnlock();
    324 
    325             if (fMessageReturned)
    326             {
    327                 LogFlowFunc(("CallComplete\n"));
    328                 g_pHelpers->pfnCallComplete(callHandle, VINF_SUCCESS);
    329             }
     316        if (RT_SUCCESS(rc))
     317        {
     318            if (pClientData->State.fAsync)
     319            {
     320                /* The client waits for a response. */
     321                bool fMessageReturned = vboxSvcClipboardReturnMsg(pClientData, pClientData->State.async.paParms);
     322
     323                /* Make a copy of the handle. */
     324                VBOXHGCMCALLHANDLE callHandle = pClientData->State.async.callHandle;
     325
     326                if (fMessageReturned)
     327                {
     328                    /* There is a response. */
     329                    pClientData->State.fAsync = false;
     330                }
     331
     332                VBoxSvcClipboardUnlock();
     333
     334                if (fMessageReturned)
     335                {
     336                    LogFlowFunc(("CallComplete\n"));
     337                    g_pHelpers->pfnCallComplete(callHandle, VINF_SUCCESS);
     338                }
     339            }
     340            else
     341                VBoxSvcClipboardUnlock();
    330342        }
    331343        else
    332         {
    333344            VBoxSvcClipboardUnlock();
    334         }
    335345    }
    336346
     
    458468    int rc = VINF_SUCCESS;
    459469
    460     LogFunc(("u32ClientID = %d, fn = %d, cParms = %d, pparms = %d\n",
     470    LogFunc(("u32ClientID=%RU32, fn=%RU32, cParms=%RU32, paParms=%p\n",
    461471             u32ClientID, u32Function, cParms, paParms));
    462472
     
    469479    {
    470480        /** @todo parameters other than 32 bit */
    471         LogFunc(("    pparms[%d]: type %d value %d\n", i, paParms[i].type, paParms[i].u.uint32));
     481        LogFunc(("    paParms[%d]: type %RU32 - value %RU32\n", i, paParms[i].type, paParms[i].u.uint32));
    472482    }
    473483#endif
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r79041 r79088  
    82548254        alock.release();
    82558255
    8256 #ifdef VBOX_WITH_SHARED_CLIPBOARD
     8256# ifdef VBOX_WITH_SHARED_CLIPBOARD
    82578257        if (m_hHgcmSvcExtShrdClipboard)
    82588258        {
     
    82608260            m_hHgcmSvcExtShrdClipboard = NULL;
    82618261        }
    8262 #endif
    8263 #ifdef VBOX_WITH_DRAG_AND_DROP
     8262# endif
     8263# ifdef VBOX_WITH_DRAG_AND_DROP
    82648264        if (m_hHgcmSvcExtDragAndDrop)
    82658265        {
     
    82678267            m_hHgcmSvcExtDragAndDrop = NULL;
    82688268        }
    8269 #endif
     8269# endif
    82708270
    82718271        m_pVMMDev->hgcmShutdown();
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