VirtualBox

Changeset 94737 in vbox


Ignore:
Timestamp:
Apr 28, 2022 2:26:49 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
151118
Message:

Main/Update check: Take #2: Boilerplate code for update agent event handling in FE/Qt, along with an example -- this time the events are being emitted directly through Main / IVirtualBox. See @todos. bugref:7983

Location:
trunk/src/VBox
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMainEventListener.cpp

    r94734 r94737  
    6868#include "CStorageControllerChangedEvent.h"
    6969#include "CStorageDeviceChangedEvent.h"
     70#include "CUpdateAgent.h"
     71#include "CUpdateAgentAvailableEvent.h"
     72#include "CUpdateAgentErrorEvent.h"
     73#include "CUpdateAgentStateChangedEvent.h"
     74#include "CUpdateAgentSettingsChangedEvent.h"
    7075#include "CUSBDevice.h"
    7176#include "CUSBDeviceStateChangedEvent.h"
     
    215220    qRegisterMetaType<KGuestMonitorChangedEventType>("KGuestMonitorChangedEventType");
    216221    qRegisterMetaType<CGuestSession>("CGuestSession");
     222    qRegisterMetaType<CUpdateAgent>("CUpdateAgent");
     223    qRegisterMetaType<KUpdateChannel>("KUpdateChannel");
     224    qRegisterMetaType<KUpdateSeverity>("KUpdateSeverity");
     225    qRegisterMetaType<KUpdateState>("KUpdateState");
    217226}
    218227
     
    601610            break;
    602611        }
     612        case KVBoxEventType_OnUpdateAgentAvailable:
     613        {
     614            CUpdateAgentAvailableEvent comEventSpecific(pEvent);
     615            emit sigUpdateAgentAvailable(comEventSpecific.GetAgent(),
     616                                         comEventSpecific.GetVersion(), comEventSpecific.GetChannel(),
     617                                         comEventSpecific.GetSeverity(), comEventSpecific.GetDownloadURL(),
     618                                         comEventSpecific.GetWebURL(), comEventSpecific.GetReleaseNotes());
     619            break;
     620        }
     621        case KVBoxEventType_OnUpdateAgentError:
     622        {
     623            CUpdateAgentErrorEvent comEventSpecific(pEvent);
     624            emit sigUpdateAgentError(comEventSpecific.GetAgent(), comEventSpecific.GetMsg(), comEventSpecific.GetRcError());
     625            break;
     626        }
     627        case KVBoxEventType_OnUpdateAgentStateChanged:
     628        {
     629            CUpdateAgentStateChangedEvent comEventSpecific(pEvent);
     630            emit sigUpdateAgentStateChanged(comEventSpecific.GetAgent(), comEventSpecific.GetState());
     631            break;
     632        }
     633        case KVBoxEventType_OnUpdateAgentSettingsChanged:
     634        {
     635            CUpdateAgentSettingsChangedEvent comEventSpecific(pEvent);
     636            emit sigUpdateAgentSettingsChanged(comEventSpecific.GetAgent(), comEventSpecific.GetAttributeHint());
     637            break;
     638        }
    603639        default: break;
    604640    }
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMainEventListener.h

    r94734 r94737  
    3939#include "CNetworkAdapter.h"
    4040#include "CUSBDevice.h"
     41#include "CUpdateAgent.h"
    4142#include "CVirtualBoxErrorInfo.h"
    4243
     
    189190    /** @} */
    190191
     192    /** @name Update agent signals
     193     * @{ */
     194       /** Notifies about an available update of an update agent. */
     195       void sigUpdateAgentAvailable(CUpdateAgent, QString, KUpdateChannel, KUpdateSeverity, QString, QString, QString);
     196       /** Notifies about an error of an update agent. */
     197       void sigUpdateAgentError(CUpdateAgent, QString, long);
     198       /** Notifies about a state change of an update agent. */
     199       void sigUpdateAgentStateChanged(CUpdateAgent, KUpdateState);
     200       /** Notifies about update agent @a comAgent settings change. */
     201       void sigUpdateAgentSettingsChanged(CUpdateAgent comAgent, const QString &strAttributeHint);
     202    /** @} */
     203
    191204    /** @name Progress related signals
    192205      * @{ */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIVirtualBoxEventHandler.cpp

    r94734 r94737  
    7878      * @param  fRegistered    Brings whether medium is registered or unregistered. */
    7979    void sigMediumRegistered(const QUuid &uMediumId, KDeviceType enmMediumType, bool fRegistered);
     80    /** Notifies about an available update of an update agent. */
     81    void sigUpdateAgentAvailable(CUpdateAgent, QString, KUpdateChannel, KUpdateSeverity, QString, QString, QString);
     82    /** Notifies about an error of an update agent. */
     83    void sigUpdateAgentError(CUpdateAgent, QString, long);
     84    /** Notifies about a state change of an update agent. */
     85    void sigUpdateAgentStateChanged(CUpdateAgent, KUpdateState);
     86    /** Notifies about update agent @a comAgent settings change. */
     87    void sigUpdateAgentSettingsChanged(CUpdateAgent comAgent, const QString &strAttributeHint);
    8088
    8189public:
     
    174182        << KVBoxEventType_OnMediumChanged
    175183        << KVBoxEventType_OnMediumConfigChanged
    176         << KVBoxEventType_OnMediumRegistered;
     184        << KVBoxEventType_OnMediumRegistered
     185        << KVBoxEventType_OnUpdateAgentAvailable
     186        << KVBoxEventType_OnUpdateAgentStateChanged
     187        << KVBoxEventType_OnUpdateAgentError
     188        << KVBoxEventType_OnUpdateAgentSettingsChanged;
    177189
    178190    /* Register event listener for event source aggregator: */
     
    238250    connect(m_pQtListener->getWrapped(), SIGNAL(sigMediumRegistered(QUuid, KDeviceType, bool)),
    239251            this, SIGNAL(sigMediumRegistered(QUuid, KDeviceType, bool)),
     252            Qt::DirectConnection);
     253    connect(m_pQtListener->getWrapped(), SIGNAL(sigUpdateAgentAvailable(CUpdateAgent, QString, KUpdateChannel, KUpdateSeverity,
     254                                                                        QString, QString, QString)),
     255            this, SIGNAL(sigUpdateAgentAvailable(CUpdateAgent, QString, KUpdateChannel, KUpdateSeverity,
     256                                                 QString, QString, QString)),
     257            Qt::DirectConnection);
     258    connect(m_pQtListener->getWrapped(), SIGNAL(sigUpdateAgentError(CUpdateAgent, QString, long)),
     259            this, SIGNAL(sigUpdateAgentError(CUpdateAgent, QString, long)),
     260            Qt::DirectConnection);
     261    connect(m_pQtListener->getWrapped(), SIGNAL(sigUpdateAgentStateChanged(CUpdateAgent, KUpdateState)),
     262            this, SIGNAL(sigUpdateAgentStateChanged(CUpdateAgent, KUpdateState)),
     263            Qt::DirectConnection);
     264    connect(m_pQtListener->getWrapped(), SIGNAL(sigUpdateAgentSettingsChanged(CUpdateAgent, QString)),
     265            this, SIGNAL(sigUpdateAgentSettingsChanged(CUpdateAgent, QString)),
    240266            Qt::DirectConnection);
    241267}
     
    357383            this, SIGNAL(sigMediumRegistered(QUuid, KDeviceType, bool)),
    358384            Qt::QueuedConnection);
     385    connect(m_pProxy, SIGNAL(sigUpdateAgentAvailable(CUpdateAgent, QString, KUpdateChannel, KUpdateSeverity,
     386                                                     QString, QString, QString)),
     387            this, SIGNAL(sigUpdateAgentAvailable(CUpdateAgent, QString, KUpdateChannel, KUpdateSeverity,
     388                                                 QString, QString, QString)),
     389            Qt::DirectConnection);
     390    connect(m_pProxy, SIGNAL(sigUpdateAgentError(CUpdateAgent, QString, long)),
     391            this, SIGNAL(sigUpdateAgentError(CUpdateAgent, QString, long)),
     392            Qt::DirectConnection);
     393    connect(m_pProxy, SIGNAL(sigUpdateAgentStateChanged(CUpdateAgent, KUpdateState)),
     394            this, SIGNAL(sigUpdateAgentStateChanged(CUpdateAgent, KUpdateState)),
     395            Qt::DirectConnection);
     396    connect(m_pProxy, SIGNAL(sigUpdateAgentSettingsChanged(CUpdateAgent, QString)),
     397            this, SIGNAL(sigUpdateAgentSettingsChanged(CUpdateAgent, QString)),
     398            Qt::QueuedConnection);
    359399}
    360400
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIVirtualBoxEventHandler.h

    r94734 r94737  
    3232#include "CMedium.h"
    3333#include "CMediumAttachment.h"
     34#include "CUpdateAgent.h"
    3435
    3536/* Forward declarations: */
     
    8687      * @param  fRegistered    Brings whether medium is registered or unregistered. */
    8788    void sigMediumRegistered(const QUuid &uMediumId, KDeviceType enmMediumType, bool fRegistered);
     89    /** Notifies about an available update of an update agent. */
     90    void sigUpdateAgentAvailable(CUpdateAgent, QString, KUpdateChannel, KUpdateSeverity, QString, QString, QString);
     91    /** Notifies about an error of an update agent. */
     92    void sigUpdateAgentError(CUpdateAgent, QString, long);
     93    /** Notifies about a state change of an update agent. */
     94    void sigUpdateAgentStateChanged(CUpdateAgent, KUpdateState);
     95    /** Notifies about update agent @a comAgent settings change. */
     96    void sigUpdateAgentSettingsChanged(CUpdateAgent comAgent, const QString &strAttributeHint);
    8897
    8998public:
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationCenter.cpp

    r94734 r94737  
    3838#include "UINotificationObjectItem.h"
    3939#include "UINotificationModel.h"
     40#include "UIVirtualBoxEventHandler.h" /** @todo EXAMPLE -- REMOVE THIS */
     41#include "CUpdateAgent.h"             /** @todo EXAMPLE -- REMOVE THIS */
    4042
    4143/* Other VBox includes: */
     
    404406}
    405407
     408/** @todo EXAMPLE -- REMOVE THIS */
     409void UINotificationCenter::sltUpdateAgentAvailable(CUpdateAgent comAgent, QString strVer, KUpdateChannel, KUpdateSeverity, QString, QString, QString)
     410{
     411    RT_NOREF(comAgent, strVer);
     412}
     413
    406414void UINotificationCenter::sltHandleOpenButtonToggled(bool fToggled)
    407415{
     
    542550        connect(m_pModel, &UINotificationModel::sigItemRemoved,
    543551                this, &UINotificationCenter::sltHandleModelItemRemoved);
     552        /** @todo EXAMPLE -- REMOVE THIS */
     553        connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigUpdateAgentAvailable,
     554                this, &UINotificationCenter::sltUpdateAgentAvailable);
    544555    }
    545556}
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationCenter.h

    r94734 r94737  
    108108    /** Handles order changes. */
    109109    void sltHandleOrderChange();
     110
     111    /** @todo EXAMPLE -- REMOVE THIS */
     112    void sltUpdateAgentAvailable(CUpdateAgent comAgent, QString, KUpdateChannel, KUpdateSeverity, QString, QString, QString);
    110113
    111114    /** Issues request to make open button @a fToggled. */
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r94720 r94737  
    206206
    207207    void i_onLanguageChanged(const Utf8Str &aLanguageId);
     208
     209#ifdef VBOX_WITH_UPDATE_AGENT
     210    void i_onUpdateAgentAvailable(IUpdateAgent *aAgent,
     211                                  const Utf8Str &aVer, UpdateChannel_T aChannel, UpdateSeverity_T aSev,
     212                                  const Utf8Str &aDownloadURL, const Utf8Str &aWebURL, const Utf8Str &aReleaseNotes);
     213    void i_onUpdateAgentError(IUpdateAgent *aAgent, const Utf8Str &aErrMsg, LONG aRc);
     214    void i_onUpdateAgentStateChanged(IUpdateAgent *aAgent, UpdateState_T aState);
     215    void i_onUpdateAgentSettingsChanged(IUpdateAgent *aAgent, const Utf8Str &aAttributeHint);
     216#endif /* VBOX_WITH_UPDATE_AGENT */
    208217
    209218#ifdef VBOX_WITH_CLOUD_NET
  • trunk/src/VBox/Main/src-server/UpdateAgentImpl.cpp

    r94736 r94737  
    4444#include "VBoxEvents.h"
    4545#include "ThreadTask.h"
     46#include "VirtualBoxImpl.h"
    4647#include "VirtualBoxBase.h"
    4748
     
    726727    aLock.release();
    727728
    728     ::FireUpdateAgentSettingsChangedEvent(m_EventSource, this, "" /** @todo Include attribute hints */);
     729    m_VirtualBox->i_onUpdateAgentSettingsChanged(this, "" /** @todo Include attribute hints */);
    729730
    730731    AutoWriteLock vboxLock(m_VirtualBox COMMA_LOCKVAL_SRC_POS);
     
    759760    LogRel(("Update agent (%s): %s\n", mData.m_strName.c_str(), strMsg.c_str()));
    760761
    761     ::FireUpdateAgentErrorEvent(m_EventSource, this, strMsg.c_str(), vrc);
     762    m_VirtualBox->i_onUpdateAgentError(this, strMsg.c_str(), vrc);
    762763
    763764    return setErrorBoth(VBOX_E_IPRT_ERROR, vrc, strMsg.c_str());
     
    10481049        alock.release(); /* Release lock before firing off event. */
    10491050
    1050         ::FireUpdateAgentStateChangedEvent(m_EventSource, this, UpdateState_NotAvailable);
     1051        m_VirtualBox->i_onUpdateAgentStateChanged(this, UpdateState_NotAvailable);
    10511052    }
    10521053    else
     
    10751076                alock.release(); /* Release lock before firing off events. */
    10761077
    1077                 ::FireUpdateAgentStateChangedEvent(m_EventSource, this, UpdateState_Available);
    1078                 ::FireUpdateAgentAvailableEvent(m_EventSource, this, mData.m_lastResult.strVer, m->enmChannel,
    1079                                                 mData.m_lastResult.enmSeverity, mData.m_lastResult.strDownloadUrl,
    1080                                                 mData.m_lastResult.strWebUrl, mData.m_lastResult.strReleaseNotes);
     1078                m_VirtualBox->i_onUpdateAgentStateChanged(this, UpdateState_Available);
     1079                m_VirtualBox->i_onUpdateAgentAvailable(this, mData.m_lastResult.strVer, m->enmChannel,
     1080                                                       mData.m_lastResult.enmSeverity, mData.m_lastResult.strDownloadUrl,
     1081                                                       mData.m_lastResult.strWebUrl, mData.m_lastResult.strReleaseNotes);
    10811082            }
    10821083            else
  • trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp

    r94721 r94737  
    37453745}
    37463746
     3747#ifdef VBOX_WITH_UPDATE_AGENT
     3748/**
     3749 *  @note Doesn't lock any object.
     3750 */
     3751void VirtualBox::i_onUpdateAgentAvailable(IUpdateAgent *aAgent,
     3752                                          const Utf8Str &aVer, UpdateChannel_T aChannel, UpdateSeverity_T aSev,
     3753                                          const Utf8Str &aDownloadURL, const Utf8Str &aWebURL, const Utf8Str &aReleaseNotes)
     3754{
     3755    ::FireUpdateAgentAvailableEvent(m->pEventSource, aAgent, aVer, aChannel, aSev,
     3756                                    aDownloadURL, aWebURL, aReleaseNotes);
     3757}
     3758
     3759/**
     3760 *  @note Doesn't lock any object.
     3761 */
     3762void VirtualBox::i_onUpdateAgentError(IUpdateAgent *aAgent, const Utf8Str &aErrMsg, LONG aRc)
     3763{
     3764    ::FireUpdateAgentErrorEvent(m->pEventSource, aAgent, aErrMsg, aRc);
     3765}
     3766
     3767/**
     3768 *  @note Doesn't lock any object.
     3769 */
     3770void VirtualBox::i_onUpdateAgentStateChanged(IUpdateAgent *aAgent, UpdateState_T aState)
     3771{
     3772    ::FireUpdateAgentStateChangedEvent(m->pEventSource, aAgent, aState);
     3773}
     3774
     3775/**
     3776 *  @note Doesn't lock any object.
     3777 */
     3778void VirtualBox::i_onUpdateAgentSettingsChanged(IUpdateAgent *aAgent, const Utf8Str &aAttributeHint)
     3779{
     3780    ::FireUpdateAgentSettingsChangedEvent(m->pEventSource, aAgent, aAttributeHint);
     3781}
     3782#endif /* VBOX_WITH_UPDATE_AGENT */
    37473783
    37483784/**
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