VirtualBox

Changeset 100606 in vbox


Ignore:
Timestamp:
Jul 17, 2023 4:32:44 PM (19 months ago)
Author:
vboxsync
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
Files:
2 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/log.h

    r100221 r100606  
    403403    /** Main group, IChoiceFormValue. */
    404404    LOG_GROUP_MAIN_CHOICEFORMVALUE,
     405    /** Main group, IClipboardErrorEvent. */
     406    LOG_GROUP_MAIN_CLIPBOARDERROREVENT,
     407    /** Main group, IClipboardEvent. */
     408    LOG_GROUP_MAIN_CLIPBOARDEVENT,
    405409    /** Main group, ICloudClient. */
    406410    LOG_GROUP_MAIN_CLOUDCLIENT,
     
    10151019    "MAIN_CERTIFICATE", \
    10161020    "MAIN_CHOICEFORMVALUE", \
     1021    "MAIN_CLIPBOARDERROREVENT", \
     1022    "MAIN_CLIPBOARDEVENT", \
    10171023    "MAIN_CLOUDCLIENT", \
    10181024    "MAIN_CLOUDMACHINE", \
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMainEventListener.cpp

    r98382 r100606  
    3838#include "COMEnums.h"
    3939#include "CCanShowWindowEvent.h"
     40#include "CClipboardErrorEvent.h"
    4041#include "CClipboardModeChangedEvent.h"
    4142#include "CCloudProfileChangedEvent.h"
     
    613614            break;
    614615        }
     616        case KVBoxEventType_OnClipboardError:
     617        {
     618            CClipboardErrorEvent comEventSpecific(pEvent);
     619            emit sigClipboardError(comEventSpecific.GetId(), comEventSpecific.GetMsg(), comEventSpecific.GetRcError());
     620            break;
     621        }
    615622        case KVBoxEventType_OnDnDModeChanged:
    616623        {
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMainEventListener.h

    r98382 r100606  
    200200        /** Notifies about the clipboard mode change. */
    201201        void sigClipboardModeChange(KClipboardMode enmClipboardMode);
     202        /** Notifies about a clipboard error. */
     203        void sigClipboardError(QString strId, QString strMsg, long rcError);
    202204        /** Notifies about the drag and drop mode change. */
    203205        void sigDnDModeChange(KDnDMode enmDnDMode);
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp

    r100064 r100606  
    140140        QApplication::translate("UIMessageCenter", "Encryption password for <nobr>ID = '%1'</nobr> is invalid.")
    141141                                                   .arg(strPasswordId));
     142}
     143
     144/* static */
     145void UINotificationMessage::showClipboardError(QString strId, QString strMsg, long rcError)
     146{
     147    RT_NOREF(strId, rcError);
     148
     149    UINotificationMessage::createMessage(
     150        QApplication::translate("UIMessageCenter", "Shared Clipboard Error"),
     151        QApplication::translate("UIMessageCenter", strMsg.toUtf8().constData()));
    142152}
    143153
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h

    r99664 r100606  
    108108          * @param  strPasswordId  Brings password ID. */
    109109        static void warnAboutInvalidEncryptionPassword(const QString &strPasswordId);
     110        /** Notifies about a clipboard error. */
     111        static void showClipboardError(QString strId, QString strMsg, long rcError);
    110112
    111113#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIConsoleEventHandler.cpp

    r98382 r100606  
    9898    /** Notifies clipboard mode change. */
    9999    void sigClipboardModeChange(KClipboardMode enmMode);
     100    /** Notifies about a clipboard error. */
     101    void sigClipboardError(QString strId, QString strMsg, long rcError);
    100102    /** Notifies drag and drop mode change. */
    101103    void sigDnDModeChange(KDnDMode enmMode);
     
    228230        << KVBoxEventType_OnAudioAdapterChanged
    229231        << KVBoxEventType_OnClipboardModeChanged
     232        << KVBoxEventType_OnClipboardError
    230233        << KVBoxEventType_OnDnDModeChanged
    231234    ;
     
    304307    connect(m_pQtListener->getWrapped(), &UIMainEventListener::sigClipboardModeChange,
    305308            this, &UIConsoleEventHandlerProxy::sigClipboardModeChange,
     309            Qt::DirectConnection);
     310    connect(m_pQtListener->getWrapped(), &UIMainEventListener::sigClipboardError,
     311            this, &UIConsoleEventHandlerProxy::sigClipboardError,
    306312            Qt::DirectConnection);
    307313    connect(m_pQtListener->getWrapped(), &UIMainEventListener::sigDnDModeChange,
     
    412418            this, &UIConsoleEventHandler::sigClipboardModeChange,
    413419            Qt::QueuedConnection);
     420    connect(m_pProxy, &UIConsoleEventHandlerProxy::sigClipboardError,
     421            this, &UIConsoleEventHandler::sigClipboardError,
     422            Qt::QueuedConnection);
    414423    connect(m_pProxy, &UIConsoleEventHandlerProxy::sigDnDModeChange,
    415424            this, &UIConsoleEventHandler::sigDnDModeChange,
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIConsoleEventHandler.h

    r98382 r100606  
    103103    /** Notifies clipboard mode change. */
    104104    void sigClipboardModeChange(KClipboardMode enmMode);
     105    /** Notifies about a clipboard error. */
     106    void sigClipboardError(QString strId, QString strMsg, long rcError);
    105107    /** Notifies drag and drop mode change. */
    106108    void sigDnDModeChange(KDnDMode enmMode);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r100064 r100606  
    10731073{
    10741074    uisession()->sltMountDVDAdHoc(strSource);
     1075}
     1076
     1077void UIMachine::sltClipboardError(QString strId, QString strMsg, long rcError)
     1078{
     1079    UINotificationMessage::showClipboardError(strId, strMsg, rcError);
    10751080}
    10761081
     
    15181523    connect(uisession(), &UISession::sigClipboardModeChange,
    15191524            this, &UIMachine::sigClipboardModeChange);
     1525    connect(uisession(), &UISession::sigClipboardError,
     1526            this, &UIMachine::sltClipboardError);
    15201527    connect(uisession(), &UISession::sigCPUExecutionCapChange,
    15211528            this, &UIMachine::sigCPUExecutionCapChange);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r100064 r100606  
    8686        /** Notifies about clipboard mode change. */
    8787        void sigClipboardModeChange(KClipboardMode enmMode);
     88        /** Notifies about a clipboard error. */
     89        void sigClipboardError(QString strId, QString strMsg, long rcError);
    8890        /** Notifies about CPU execution cap change. */
    8991        void sigCPUExecutionCapChange();
     
    725727    /** @} */
    726728
     729    /** @name Clipboard stuff.
     730     ** @{ */
     731        /** Handles clipboard errors. */
     732        void sltClipboardError(QString strId, QString strMsg, long rcError);
     733    /** @} */
     734
    727735    /** @name Keyboard stuff.
    728736     ** @{ */
     
    778786        /** Handles host-screen available-area change. */
    779787        void sltHandleHostScreenAvailableAreaChange();
    780 
    781788#ifdef VBOX_WS_MAC
    782789        /** macOS X: Restarts display-reconfiguration watchdog timer from the beginning.
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r100064 r100606  
    25152515    connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigClipboardModeChange,
    25162516            this, &UISession::sigClipboardModeChange);
     2517    connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigClipboardError,
     2518            this, &UISession::sigClipboardError);
    25172519    connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigCPUExecutionCapChange,
    25182520            this, &UISession::sigCPUExecutionCapChange);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r98940 r100606  
    9292        /** Notifies about clipboard mode change. */
    9393        void sigClipboardModeChange(KClipboardMode enmMode);
     94        /** Notifies about a clipboard error. */
     95        void sigClipboardError(QString strId, QString strMsg, long rcError);
    9496        /** Notifies about CPU execution cap change. */
    9597        void sigCPUExecutionCapChange();
  • trunk/src/VBox/Main/Makefile.kmk

    r100038 r100606  
    12231223        src-client/GuestSessionImpl.cpp
    12241224 endif
     1225 ifdef VBOX_WITH_SHARED_CLIPBOARD
     1226  VBoxC_SOURCES += \
     1227        src-client/GuestShClPrivate.cpp
     1228 endif
    12251229 ifdef VBOX_WITH_DRAG_AND_DROP
    12261230  VBoxC_SOURCES += \
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r100038 r100606  
    2639626396  <enum
    2639726397    name="VBoxEventType"
    26398     uuid="03b0e6ea-28fe-4f0a-a3ec-1a21703da6f7"
     26398    uuid="f698ab32-91e4-4379-b99c-174cebecfa5e"
    2639926399    >
    2640026400
     
    2691226912      </desc>
    2691326913    </const>
     26914    <const name="OnClipboardError" value="122">
     26915      <desc>
     26916        See <link to="IClipboardErrorEvent">IClipboardErrorEvent</link>.
     26917      </desc>
     26918    </const>
    2691426919    <!-- End event marker -->
    26915     <const name="End" value="122">
     26920    <const name="End" value="123">
    2691626921      <desc>
    2691726922        Must be last event, used for iterations and structures relying on numerical event values.
     
    2776327768      </desc>
    2776427769    </attribute>
     27770  </interface>
     27771
     27772  <interface
     27773    name="IClipboardEvent" extends="IEvent"
     27774    uuid="f22dd3b4-e4d0-437a-bfdf-0372896ba162"
     27775    wsmap="managed">
     27776    <desc>
     27777      Abstract base interface for clipboard events.
     27778    </desc>
     27779    <attribute name="id" type="wstring" readonly="yes">
     27780      <desc>Name of the clipboard this event belongs to.
     27781
     27782      For Windows or macOS hosts / guests, this string is empty.
     27783      For X11-based hosts / guests, this can hold either "PRIMARY" or "SECONDARY".
     27784      </desc>
     27785    </attribute>
     27786  </interface>
     27787
     27788  <interface
     27789    name="IClipboardErrorEvent" extends="IClipboardEvent"
     27790    uuid="9e5f6f25-beda-46ad-8ddb-23c0268ac345"
     27791    wsmap="managed" autogen="VBoxEvent" id="OnClipboardError"
     27792    >
     27793    <desc>
     27794      Notification when a clipboard error occurred.
     27795    </desc>
     27796
     27797    <attribute name="msg" type="wstring" readonly="yes">
     27798      <desc>
     27799        Error message in human readable format.
     27800      </desc>
     27801    </attribute>
     27802
     27803    <attribute name="rcError" type="long" readonly="yes">
     27804      <desc>
     27805        IPRT-style error code.
     27806      </desc>
     27807    </attribute>
     27808
    2776527809  </interface>
    2776627810
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r100038 r100606  
    220220    HRESULT i_onCPUChange(ULONG aCPU, BOOL aRemove);
    221221    HRESULT i_onCPUExecutionCapChange(ULONG aExecutionCap);
     222    HRESULT i_onClipboardError(const Utf8Str &aId, const Utf8Str &aErrMsg, LONG aRc);
    222223    HRESULT i_onClipboardModeChange(ClipboardMode_T aClipboardMode);
    223224    HRESULT i_onClipboardFileTransferModeChange(bool aEnabled);
     
    11901191#endif
    11911192
     1193#ifdef VBOX_WITH_SHARED_CLIPBOARD
     1194# ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
     1195    /* Service extension for the Shared Clipboard HGCM service. */
     1196    HGCMSVCEXTHANDLE                    m_hHgcmSvcExtShCl;
     1197# endif
     1198#endif
     1199
    11921200#ifdef VBOX_WITH_DRAG_AND_DROP
    1193     HGCMSVCEXTHANDLE m_hHgcmSvcExtDragAndDrop;
    1194 #endif
    1195 
     1201    /* Service extension for the Drag'n Drop HGCM service. */
     1202    HGCMSVCEXTHANDLE                    m_hHgcmSvcExtDragAndDrop;
     1203#endif
    11961204    /** Pointer to the progress object of a live cancelable task.
    11971205     *
  • trunk/src/VBox/Main/include/ConsoleVRDPServer.h

    r98296 r100606  
    232232
    233233    int mcClipboardRefs;
    234     HGCMSVCEXTHANDLE mhClipboard;
    235234    PFNVRDPCLIPBOARDEXTCALLBACK mpfnClipboardCallback;
    236235
  • 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.

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