VirtualBox

Changeset 94089 in vbox for trunk


Ignore:
Timestamp:
Mar 4, 2022 2:06:52 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9722: VirtualBox Manager: Adding possibility to call for simple cloud console history browser.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
6 edited

Legend:

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

    r94014 r94089  
    15821582    /** Holds whether this command is for unix. */
    15831583    bool  m_fUnix;
     1584};
     1585
     1586/** Simple action extension, used as 'Show Log' action class. */
     1587class UIActionSimpleManagerConsolePerformShowLog : public UIActionSimple
     1588{
     1589    Q_OBJECT;
     1590
     1591public:
     1592
     1593    /** Constructs action passing @a pParent to the base-class. */
     1594    UIActionSimpleManagerConsolePerformShowLog(UIActionPool *pParent)
     1595        : UIActionSimple(pParent,
     1596                         ":/vm_show_logs_16px.png",
     1597                         ":/vm_show_logs_disabled_16px.png")
     1598    {}
     1599
     1600protected:
     1601
     1602    /** Returns shortcut extra-data ID. */
     1603    virtual QString shortcutExtraDataID() const RT_OVERRIDE
     1604    {
     1605        return QString("ShowConsoleLog");
     1606    }
     1607
     1608    /** Handles translation event. */
     1609    virtual void retranslateUi() RT_OVERRIDE
     1610    {
     1611        setName(QApplication::translate("UIActionPool", "Show &Log"));
     1612        setStatusTip(QApplication::translate("UIActionPool", "Show cloud console log"));
     1613    }
    15841614};
    15851615
     
    36133643    m_pool[UIActionIndexMN_M_Machine_M_Console_S_CopyCommandVNCWindows] = new UIActionSimpleManagerConsolePerformCopyCommand(this, false, false);
    36143644    m_pool[UIActionIndexMN_M_Machine_M_Console_S_ConfigureApplications] = new UIActionSimpleManagerConsolePerformConfigureApplications(this);
     3645    m_pool[UIActionIndexMN_M_Machine_M_Console_S_ShowLog] = new UIActionSimpleManagerConsolePerformShowLog(this);
    36153646    m_pool[UIActionIndexMN_M_Machine_M_Close] = new UIActionMenuManagerClose(this);
    36163647    m_pool[UIActionIndexMN_M_Machine_M_Close_S_Detach] = new UIActionSimpleManagerClosePerformDetach(this);
     
    39283959                    << action(UIActionIndexMN_M_Machine_M_Console_S_CopyCommandVNCWindows)
    39293960                    << action(UIActionIndexMN_M_Machine_M_Console_S_ConfigureApplications)
     3961                    << action(UIActionIndexMN_M_Machine_M_Console_S_ShowLog)
    39303962                    // << action(UIActionIndexMN_M_Machine_M_Close_S_Detach)
    39313963                    << action(UIActionIndexMN_M_Machine_M_Close_S_SaveState)
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.h

    r93990 r94089  
    118118    UIActionIndexMN_M_Machine_M_Console_S_CopyCommandVNCWindows,
    119119    UIActionIndexMN_M_Machine_M_Console_S_ConfigureApplications,
     120    UIActionIndexMN_M_Machine_M_Console_S_ShowLog,
    120121    UIActionIndexMN_M_Machine_M_Close,
    121122    UIActionIndexMN_M_Machine_M_Close_S_Detach,
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r94014 r94089  
    15001500}
    15011501
     1502void UIVirtualBoxManager::sltPerformShowLog()
     1503{
     1504    /* Get current item: */
     1505    UIVirtualMachineItem *pItem = currentItem();
     1506    AssertMsgReturnVoid(pItem, ("Current item should be selected!\n"));
     1507    UIVirtualMachineItemCloud *pCloudItem = pItem->toCloud();
     1508    AssertPtrReturnVoid(pCloudItem);
     1509
     1510    /* Acquire cloud machine: */
     1511    CCloudMachine comMachine = pCloudItem->machine();
     1512
     1513    /* Requesting cloud console log: */
     1514    UINotificationProgressCloudConsoleLogAcquire *pNotification = new UINotificationProgressCloudConsoleLogAcquire(comMachine);
     1515    connect(pNotification, &UINotificationProgressCloudConsoleLogAcquire::sigLogRead,
     1516            this, &UIVirtualBoxManager::sltHandleConsoleLogRead);
     1517    gpNotificationCenter->append(pNotification);
     1518}
     1519
     1520void UIVirtualBoxManager::sltHandleConsoleLogRead(const QString &strName, const QString &strLog)
     1521{
     1522    /* Prepare dialog: */
     1523    QDialog *pDialog = new QDialog(this);
     1524    if (pDialog)
     1525    {
     1526        pDialog->setAttribute(Qt::WA_DeleteOnClose);
     1527        pDialog->setWindowTitle(QString("%1 - Console Log").arg(strName));
     1528
     1529        QVBoxLayout *pLayout = new QVBoxLayout(pDialog);
     1530        if (pLayout)
     1531        {
     1532            QTextEdit *pTextEdit = new QTextEdit(pDialog);
     1533            if (pTextEdit)
     1534            {
     1535                pTextEdit->setText(strLog);
     1536                pLayout->addWidget(pTextEdit);
     1537            }
     1538        }
     1539    }
     1540
     1541    /* Show dialog: */
     1542    pDialog->show();
     1543}
     1544
    15021545void UIVirtualBoxManager::sltPerformDiscardMachineState()
    15031546{
     
    22762319    connect(actionPool()->action(UIActionIndexMN_M_Machine_M_Console_S_ConfigureApplications), &UIAction::triggered,
    22772320            this, &UIVirtualBoxManager::sltOpenManagerWindowDefault);
     2321    connect(actionPool()->action(UIActionIndexMN_M_Machine_M_Console_S_ShowLog), &UIAction::triggered,
     2322            this, &UIVirtualBoxManager::sltPerformShowLog);
    22782323
    22792324    /* 'Group/Close' menu connections: */
     
    29462991        pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_Console_S_DeleteConnection));
    29472992    }
     2993
     2994    /* Show console log action: */
     2995    pMenu->addSeparator();
     2996    pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_Console_S_ShowLog));
    29482997}
    29492998
     
    31113160    actionPool()->action(UIActionIndexMN_M_Machine_M_Console_S_CopyCommandVNCWindows)->setEnabled(isActionEnabled(UIActionIndexMN_M_Machine_M_Console_S_CopyCommandVNCWindows, items));
    31123161    actionPool()->action(UIActionIndexMN_M_Machine_M_Console_S_ConfigureApplications)->setEnabled(isActionEnabled(UIActionIndexMN_M_Machine_M_Console_S_ConfigureApplications, items));
     3162    actionPool()->action(UIActionIndexMN_M_Machine_M_Console_S_ShowLog)->setEnabled(isActionEnabled(UIActionIndexMN_M_Machine_M_Console_S_ShowLog, items));
    31133163
    31143164    /* Enable/disable group-close actions: */
     
    33823432        case UIActionIndexMN_M_Machine_M_Console_S_CopyCommandVNCWindows:
    33833433        case UIActionIndexMN_M_Machine_M_Console_S_ConfigureApplications:
     3434        case UIActionIndexMN_M_Machine_M_Console_S_ShowLog:
    33843435        {
    33853436            return isAtLeastOneItemStarted(items);
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h

    r93990 r94089  
    249249        /** Handles call to copy VNC console command for Windows. */
    250250        void sltPerformCopyCommandVNCWindows();
     251        /** Handles call to show console log. */
     252        void sltPerformShowLog();
     253        /** Handles call about console @a strLog for cloud VM with @a strName read. */
     254        void sltHandleConsoleLogRead(const QString &strName, const QString &strLog);
    251255        /** Handles call to execute external application. */
    252256        void sltExecuteExternalApplication();
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp

    r93328 r94089  
    32563256    /* Return progress-wrapper: */
    32573257    return comProgress;
     3258}
     3259
     3260
     3261/*********************************************************************************************************************************
     3262*   Class UINotificationProgressCloudConsoleLogAcquire implementation.                                                           *
     3263*********************************************************************************************************************************/
     3264
     3265UINotificationProgressCloudConsoleLogAcquire::UINotificationProgressCloudConsoleLogAcquire(const CCloudMachine &comMachine)
     3266    : m_comMachine(comMachine)
     3267{
     3268    connect(this, &UINotificationProgress::sigProgressFinished,
     3269            this, &UINotificationProgressCloudConsoleLogAcquire::sltHandleProgressFinished);
     3270}
     3271
     3272QString UINotificationProgressCloudConsoleLogAcquire::name() const
     3273{
     3274    return UINotificationProgress::tr("Acquire cloud console log ...");
     3275}
     3276
     3277QString UINotificationProgressCloudConsoleLogAcquire::details() const
     3278{
     3279    return UINotificationProgress::tr("<b>Cloud VM Name:</b> %1").arg(m_strName);
     3280}
     3281
     3282CProgress UINotificationProgressCloudConsoleLogAcquire::createProgress(COMResult &comResult)
     3283{
     3284    /* Acquire cloud VM name: */
     3285    m_strName = m_comMachine.GetName();
     3286    if (!m_comMachine.isOk())
     3287    {
     3288        comResult = m_comMachine;
     3289        return CProgress();
     3290    }
     3291
     3292    /* Initialize progress-wrapper: */
     3293    CProgress comProgress = m_comMachine.GetConsoleHistory(m_comStream);
     3294    /* Store COM result: */
     3295    comResult = m_comMachine;
     3296    /* Return progress-wrapper: */
     3297    return comProgress;
     3298}
     3299
     3300void UINotificationProgressCloudConsoleLogAcquire::sltHandleProgressFinished()
     3301{
     3302    /* Read the byte array: */
     3303    QVector<BYTE> byteArray;
     3304    while (true)
     3305    {
     3306        const QVector<BYTE> byteChunk = m_comStream.Read(64 * _1K, 0);
     3307        if (byteChunk.size() == 0)
     3308            break;
     3309        byteArray += byteChunk;
     3310    }
     3311    if (byteArray.size() == 0)
     3312        return;
     3313
     3314    /* Convert it to string and send away: */
     3315    const QString strLog = QString::fromUtf8(reinterpret_cast<const char *>(byteArray.data()), byteArray.size());
     3316    emit sigLogRead(m_strName, strLog);
    32583317}
    32593318
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h

    r93328 r94089  
    3535#include "CCloudMachine.h"
    3636#include "CConsole.h"
     37#include "CDataStream.h"
    3738#include "CExtPackFile.h"
    3839#include "CExtPackManager.h"
     
    19451946};
    19461947
     1948/** UINotificationProgress extension for cloud console log acquire functionality. */
     1949class SHARED_LIBRARY_STUFF UINotificationProgressCloudConsoleLogAcquire : public UINotificationProgress
     1950{
     1951    Q_OBJECT;
     1952
     1953signals:
     1954
     1955    /** Notifies listeners about console @a strLog for cloud VM with @a strName read. */
     1956    void sigLogRead(const QString &strName, const QString &strLog);
     1957
     1958public:
     1959
     1960    /** Constructs cloud console log acquire notification-progress.
     1961      * @param  comMachine  Brings the cloud machine for which console log being acquired. */
     1962    UINotificationProgressCloudConsoleLogAcquire(const CCloudMachine &comMachine);
     1963
     1964protected:
     1965
     1966    /** Returns object name. */
     1967    virtual QString name() const /* override final */;
     1968    /** Returns object details. */
     1969    virtual QString details() const /* override final */;
     1970    /** Creates and returns started progress-wrapper. */
     1971    virtual CProgress createProgress(COMResult &comResult) /* override final */;
     1972
     1973private slots:
     1974
     1975    /** Handles signal about progress being finished. */
     1976    void sltHandleProgressFinished();
     1977
     1978private:
     1979
     1980    /** Holds the cloud machine for which console log being acquired. */
     1981    CCloudMachine  m_comMachine;
     1982    /** Holds the cloud machine name. */
     1983    QString        m_strName;
     1984    /** Holds the stream log being read to. */
     1985    CDataStream    m_comStream;
     1986};
     1987
    19471988/** UINotificationProgress extension for snapshot take functionality. */
    19481989class SHARED_LIBRARY_STUFF UINotificationProgressSnapshotTake : public UINotificationProgress
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