VirtualBox

Changeset 100606 in vbox for trunk/src/VBox/Main/src-client


Ignore:
Timestamp:
Jul 17, 2023 4:32:44 PM (21 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
158436
Message:

Shared Clipboard/Main + FE/Qt: Added clipboard error propagation from the host service via a newly added ClipboardErrorEvent. For that we now have a generic (private) Shared Clipboard handling class within Main, which does the HGCM service callback dispatching. The VRDP console object, which was in charge for this before, now is daisy-chained to this new class as a service extension. FE/QT in turn then shows the error(s) via the notification center. bugref:9437

Location:
trunk/src/VBox/Main/src-client
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r100521 r100606  
    9090#ifdef VBOX_WITH_VIRT_ARMV8
    9191# include "ResourceStoreImpl.h"
     92#endif
     93#ifdef VBOX_WITH_SHARED_CLIPBOARD
     94# include "GuestShClPrivate.h"
    9295#endif
    9396#include "StringifyEnums.h"
     
    56535656        alock.release();
    56545657        ::FireCPUExecutionCapChangedEvent(mEventSource, aExecutionCap);
     5658    }
     5659
     5660    LogFlowThisFunc(("Leaving hrc=%#x\n", hrc));
     5661    return hrc;
     5662}
     5663
     5664/**
     5665 * Called by IInternalSessionControl::OnClipboardError().
     5666 *
     5667 * @note Locks this object for writing.
     5668 */
     5669HRESULT Console::i_onClipboardError(const Utf8Str &aId, const Utf8Str &aErrMsg, LONG aRc)
     5670{
     5671    LogFlowThisFunc(("\n"));
     5672
     5673    AutoCaller autoCaller(this);
     5674    AssertComRCReturnRC(autoCaller.hrc());
     5675
     5676    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     5677
     5678    HRESULT hrc = S_OK;
     5679
     5680    /* don't trigger the drag and drop mode change if the VM isn't running */
     5681    SafeVMPtrQuiet ptrVM(this);
     5682    if (ptrVM.isOk())
     5683    {
     5684        if (   mMachineState == MachineState_Running
     5685            || mMachineState == MachineState_Teleporting
     5686            || mMachineState == MachineState_LiveSnapshotting)
     5687        {
     5688        }
     5689        else
     5690            hrc = i_setInvalidMachineStateError();
     5691        ptrVM.release();
     5692    }
     5693
     5694    /* notify console callbacks on success */
     5695    if (SUCCEEDED(hrc))
     5696    {
     5697        alock.release();
     5698        ::FireClipboardErrorEvent(mEventSource, aId, aErrMsg, aRc);
    56555699    }
    56565700
     
    89458989        alock.release();
    89468990
    8947 # ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
    8948         /** @todo Deregister area callbacks?   */
    8949 # endif
     8991# ifdef VBOX_WITH_SHARED_CLIPBOARD
     8992        if (m_hHgcmSvcExtShCl)
     8993        {
     8994            HGCMHostUnregisterServiceExtension(m_hHgcmSvcExtShCl);
     8995            m_hHgcmSvcExtShCl = NULL;
     8996        }
     8997        GuestShCl::destroyInstance();
     8998#endif
     8999
    89509000# ifdef VBOX_WITH_DRAG_AND_DROP
    89519001        if (m_hHgcmSvcExtDragAndDrop)
  • trunk/src/VBox/Main/src-client/ConsoleImplConfigX86.cpp

    r99913 r100606  
    4747#include "DisplayImpl.h"
    4848#include "NvramStoreImpl.h"
     49#ifdef VBOX_WITH_SHARED_CLIPBOARD
     50# include "GuestShClPrivate.h"
     51#endif
    4952#ifdef VBOX_WITH_DRAG_AND_DROP
    5053# include "GuestImpl.h"
     
    31163119                AssertLogRelMsg(RT_SUCCESS(vrc), ("Shared Clipboard: Failed to set initial file transfers mode (%u): vrc=%Rrc\n",
    31173120                                                 fFileTransfersEnabled, vrc));
    3118 
    3119                 /** @todo Register area callbacks? (See also deregistration todo in Console::i_powerDown.) */
    31203121# endif
     3122                GuestShCl::createInstance(this /* pConsole */);
     3123                vrc = HGCMHostRegisterServiceExtension(&m_hHgcmSvcExtShCl, "VBoxSharedClipboard",
     3124                                                       &GuestShCl::hgcmDispatcher,
     3125                                                       GuestShClInst());
     3126                if (RT_FAILURE(vrc))
     3127                    Log(("Cannot register VBoxSharedClipboard extension, vrc=%Rrc\n", vrc));
    31213128            }
    31223129            else
  • trunk/src/VBox/Main/src-client/ConsoleVRDPServer.cpp

    r98278 r100606  
    3232#include "ConsoleImpl.h"
    3333#include "DisplayImpl.h"
     34#ifdef VBOX_WITH_SHARED_CLIPBOARD
     35# include "GuestShClPrivate.h" /* For (un-)registering the service extension. */
     36#endif
    3437#include "KeyboardImpl.h"
    3538#include "MouseImpl.h"
     
    13461349
    13471350ConsoleVRDPServer::ConsoleVRDPServer(Console *console)
    1348     : mhClipboard(NULL)
    13491351{
    13501352    mConsole = console;
     
    34123414        if (mcClipboardRefs == 0)
    34133415        {
    3414             vrc = HGCMHostRegisterServiceExtension(&mhClipboard, "VBoxSharedClipboard", ClipboardServiceExtension, this);
     3416#ifdef VBOX_WITH_SHARED_CLIPBOARD
     3417            vrc = GuestShClInst()->RegisterServiceExtension(ClipboardServiceExtension, this /* pvExtension */);
    34153418            AssertRC(vrc);
     3419#endif /* VBOX_WITH_SHARED_CLIPBOARD */
    34163420        }
    34173421
     
    34333437            mcClipboardRefs--;
    34343438
    3435             if (mcClipboardRefs == 0 && mhClipboard)
    3436             {
    3437                 HGCMHostUnregisterServiceExtension(mhClipboard);
    3438                 mhClipboard = NULL;
     3439            if (mcClipboardRefs == 0)
     3440            {
     3441#ifdef VBOX_WITH_SHARED_CLIPBOARD
     3442                GuestShClInst()->UnregisterServiceExtension(ClipboardServiceExtension);
     3443#endif /* VBOX_WITH_SHARED_CLIPBOARD */
    34393444            }
    34403445        }
Note: See TracChangeset for help on using the changeset viewer.

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