VirtualBox

Changeset 100651 in vbox


Ignore:
Timestamp:
Jul 19, 2023 11:52:59 AM (18 months ago)
Author:
vboxsync
Message:

Shared Clipboard: Also give the registered service extension the chance of calling an optional callback. Only used by VRDE so far (and probably never will be used by anything else, historical reasons). bugref:9437

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/GuestShClPrivate.h

    r100606 r100651  
    3232#endif
    3333
     34#include <VBox/HostServices/VBoxClipboardExt.h>
     35
    3436/**
    3537 * Forward prototype declarations.
     
    4446    /** Service extension callback function.
    4547     *  Setting this to NULL deactivates the extension. */
    46     PFNHGCMSVCEXT    pfnExt;
     48    PFNHGCMSVCEXT      pfnExt;
    4749    /** User-supplied service extension data. Might be NULL if not being used. */
    48     void            *pvExt;
     50    void            *  pvExt;
     51    /** Pointer to an optional extension callback.
     52     *  Might be NULL if not being used. */
     53    PFNSHCLEXTCALLBACK pfnExtCallback;
    4954};
    5055/** Pointer to a Shared Clipboard service extension. */
     
    136141    /** Pointer an additional service extension handle to serve (daisy chaining).
    137142     *
    138      *  This currently only is being used by the Console VRDP server helper class.
    139      *  We might want to transform this into a map later if we (ever) need more than one service extension. */
     143     *  This currently only is being used by the Console VRDP server helper class (historical reasons).
     144     *  We might want to transform this into a map later if we (ever) need more than one service extension,
     145     *  or drop this concept althogether when we move the service stuff out of the VM process (later). */
    140146    SHCLSVCEXT                  m_SvcExtVRDP;
     147    /** Pointer to an optional extension callback.
     148     *  Might be NULL if not being used. */
     149    PFNSHCLEXTCALLBACK          m_pfnExtCallback;
    141150    /** @}  */
    142151
  • trunk/src/VBox/Main/src-client/GuestShClPrivate.cpp

    r100619 r100651  
    6060GuestShCl::GuestShCl(Console *pConsole)
    6161    : m_pConsole(pConsole)
     62    , m_pfnExtCallback(NULL)
    6263{
    6364    LogFlowFuncEnter();
     
    8687
    8788    RT_ZERO(m_SvcExtVRDP);
     89
     90    m_pfnExtCallback = NULL;
    8891}
    8992
     
    122125{
    123126    AssertPtrReturn(pfnExtension, VERR_INVALID_POINTER);
     127    /* pvExtension is optional. */
    124128
    125129    lock();
    126130
     131    LogFlowFunc(("m_pfnExtCallback=%p\n", this->m_pfnExtCallback));
     132
    127133    PSHCLSVCEXT pExt = &this->m_SvcExtVRDP; /* Currently we only have one extension only. */
    128134
    129135    Assert(pExt->pfnExt == NULL);
    130136
    131     pExt->pfnExt = pfnExtension;
    132     pExt->pvExt  = pvExtension;
     137    pExt->pfnExt         = pfnExtension;
     138    pExt->pvExt          = pvExtension;
     139    pExt->pfnExtCallback = this->m_pfnExtCallback; /* Assign callback function. Optional and can be NULL. */
     140
     141    if (pExt->pfnExtCallback)
     142    {
     143        /* Make sure to also give the extension the ability to use the callback. */
     144        SHCLEXTPARMS parms;
     145        RT_ZERO(parms);
     146
     147        parms.u.SetCallback.pfnCallback = pExt->pfnExtCallback;
     148
     149        /* ignore rc, callback is optional */ pExt->pfnExt(pExt->pvExt,
     150                                                           VBOX_CLIPBOARD_EXT_FN_SET_CALLBACK, &parms, sizeof(parms));
     151    }
    133152
    134153    unlock();
     
    153172    AssertReturnStmt(pExt->pfnExt == pfnExtension, unlock(), VERR_INVALID_PARAMETER);
    154173    AssertPtr(pExt->pfnExt);
     174
     175    /* Unregister the callback (setting to NULL). */
     176    SHCLEXTPARMS parms;
     177    RT_ZERO(parms);
     178
     179    /* ignore rc, callback is optional */ pExt->pfnExt(pExt->pvExt,
     180                                                       VBOX_CLIPBOARD_EXT_FN_SET_CALLBACK, &parms, sizeof(parms));
    155181
    156182    RT_BZERO(pExt, sizeof(SHCLSVCEXT));
     
    244270    switch (u32Function)
    245271    {
     272        case VBOX_CLIPBOARD_EXT_FN_SET_CALLBACK:
     273            pThis->m_pfnExtCallback = pParms->u.SetCallback.pfnCallback;
     274            vrc = VINF_SUCCESS;
     275            break;
     276
    246277        case VBOX_CLIPBOARD_EXT_FN_ERROR:
    247278        {
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