VirtualBox

Changeset 92733 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Dec 3, 2021 2:23:31 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9371. Working on guest session handling.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManager.cpp

    r92711 r92733  
    218218        if (m_pGuestTablesContainer)
    219219        {
     220            m_pGuestTablesContainer->setTabPosition(QTabWidget::East);
     221
    220222            m_pGuestTablesContainer->setTabBarAutoHide(true);
    221223            m_pFileTableSplitter->addWidget(m_pGuestTablesContainer);
     
    349351}
    350352
    351 void UIFileManager::sltReceieveLogOutput(QString strOutput, FileManagerLogType eLogType)
    352 {
    353     appendLog(strOutput, eLogType);
     353void UIFileManager::sltReceieveLogOutput(QString strOutput, const QString &strMachineName, FileManagerLogType eLogType)
     354{
     355    appendLog(strOutput, strMachineName, eLogType);
    354356}
    355357
     
    598600}
    599601
    600 void UIFileManager::appendLog(const QString &strLog, FileManagerLogType eLogType)
     602void UIFileManager::appendLog(const QString &strLog, const QString &strMachineName, FileManagerLogType eLogType)
    601603{
    602604    if (!m_pLogPanel)
    603605        return;
    604     m_pLogPanel->appendLog(strLog, eLogType);
     606    m_pLogPanel->appendLog(strLog, strMachineName, eLogType);
    605607}
    606608
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManager.h

    r92710 r92733  
    107107private slots:
    108108
    109     void sltReceieveLogOutput(QString strOutput, FileManagerLogType eLogType);
     109    void sltReceieveLogOutput(QString strOutput, const QString &strMachineName, FileManagerLogType eLogType);
    110110    void sltCopyGuestToHost();
    111111    void sltCopyHostToGuest();
     
    146146    template<typename T>
    147147    QStringList               getFsObjInfoStringList(const T &fsObjectInfo) const;
    148     void                      appendLog(const QString &strLog, FileManagerLogType eLogType);
     148    void                      appendLog(const QString &strLog, const QString &strMachineName, FileManagerLogType eLogType);
    149149    void                      savePanelVisibility();
    150150
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.cpp

    r92711 r92733  
    2525#include "QILabel.h"
    2626#include "UIActionPool.h"
     27#include "UIConverter.h"
     28#include "UICustomFileSystemModel.h"
    2729#include "UIErrorString.h"
    28 #include "UICustomFileSystemModel.h"
    2930#include "UIFileManager.h"
    3031#include "UIFileManagerGuestTable.h"
     
    3536
    3637/* COM includes: */
     38#include "CConsole.h"
    3739#include "CFsObjInfo.h"
    3840#include "CGuestFsObjInfo.h"
    3941#include "CGuestDirectory.h"
    4042#include "CProgress.h"
     43#include "CGuestSessionStateChangedEvent.h"
    4144
    4245#include <iprt/path.h>
     
    153156    , m_pGuestSessionPanel(0)
    154157{
     158    if (!m_comMachine.isNull())
     159        m_strTableName = m_comMachine.GetName();
    155160    prepareToolbar();
    156161    prepareGuestSessionPanel();
     
    159164}
    160165
    161 void UIFileManagerGuestTable::initGuestFileTable(const CGuestSession &session)
    162 {
    163     if (!session.isOk())
    164         return;
    165     if (session.GetStatus() != KGuestSessionStatus_Started)
    166         return;
    167     m_comGuestSession = session;
     166void UIFileManagerGuestTable::initFileTable()
     167{
     168    if (!m_comGuestSession.isOk() || m_comGuestSession.GetStatus() != KGuestSessionStatus_Started)
     169        return;
    168170    /* To determine the path separator we need to have a valid guest session: */
    169171    determinePathSeparator();
     
    191193    if (!m_comGuestSession.isOk())
    192194    {
    193         emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), FileManagerLogType_Error);
     195        emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), m_strTableName, FileManagerLogType_Error);
    194196        return;
    195197    }
     
    249251    if (!m_comGuestSession.isOk())
    250252    {
    251         emit sigLogOutput(QString(item->path()).append(" could not be deleted"), FileManagerLogType_Error);
    252         emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), FileManagerLogType_Error);
     253        emit sigLogOutput(QString(item->path()).append(" could not be deleted"), m_strTableName, FileManagerLogType_Error);
     254        emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), m_strTableName, FileManagerLogType_Error);
    253255    }
    254256}
     
    285287    if (!m_comGuestSession.isOk())
    286288    {
    287         emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), FileManagerLogType_Error);
     289        emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), m_strTableName, FileManagerLogType_Error);
    288290        return;
    289291    }
     
    304306    if (!m_comGuestSession.isOk())
    305307    {
    306         emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), FileManagerLogType_Error);
     308        emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), m_strTableName, FileManagerLogType_Error);
    307309        return false;
    308310    }
     
    320322    if (!m_comGuestSession.isOk())
    321323    {
    322         emit sigLogOutput(newDirectoryPath.append(" could not be created"), FileManagerLogType_Error);
    323         emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), FileManagerLogType_Error);
     324        emit sigLogOutput(newDirectoryPath.append(" could not be created"), m_strTableName, FileManagerLogType_Error);
     325        emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), m_strTableName, FileManagerLogType_Error);
    324326        return false;
    325327    }
    326     emit sigLogOutput(newDirectoryPath.append(" has been created"), FileManagerLogType_Info);
     328    emit sigLogOutput(newDirectoryPath.append(" has been created"), m_strTableName, FileManagerLogType_Info);
    327329    return true;
    328330}
     
    342344    if (strDestinationPath.isEmpty())
    343345    {
    344         emit sigLogOutput("No destination for copy operation", FileManagerLogType_Error);
     346        emit sigLogOutput("No destination for copy operation", m_strTableName, FileManagerLogType_Error);
    345347        return;
    346348    }
    347349    if (hostSourcePathList.empty())
    348350    {
    349         emit sigLogOutput("No source for copy operation", FileManagerLogType_Error);
     351        emit sigLogOutput("No source for copy operation", m_strTableName, FileManagerLogType_Error);
    350352        return;
    351353    }
     
    366368        else
    367369            emit sigLogOutput(QString("Querying information for host item \"%s\" failed with %Rrc").arg(strSource.toStdString().c_str(), vrc),
    368                               FileManagerLogType_Error);
     370                              m_strTableName, FileManagerLogType_Error);
    369371    }
    370372
     
    392394    if (hostDestinationPath.isEmpty())
    393395    {
    394         emit sigLogOutput("No destination for copy operation", FileManagerLogType_Error);
     396        emit sigLogOutput("No destination for copy operation", m_strTableName, FileManagerLogType_Error);
    395397        return;
    396398    }
    397399    if (sourcePaths.empty())
    398400    {
    399         emit sigLogOutput("No source for copy operation", FileManagerLogType_Error);
     401        emit sigLogOutput("No source for copy operation", m_strTableName, FileManagerLogType_Error);
    400402        return;
    401403    }
     
    410412        if (!m_comGuestSession.isOk())
    411413        {
    412             emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), FileManagerLogType_Error);
     414            emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), m_strTableName, FileManagerLogType_Error);
    413415            return;
    414416        }
     
    469471        if (!m_comGuestSession.isOk())
    470472        {
    471             emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), FileManagerLogType_Error);
     473            emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), m_strTableName, FileManagerLogType_Error);
    472474            return QString();
    473475        }
     
    562564        if (!m_comGuestSession.isOk())
    563565        {
    564             emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), FileManagerLogType_Error);
     566            emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), m_strTableName, FileManagerLogType_Error);
    565567            continue;
    566568        }
     
    768770    if (!m_comGuestSession.isOk())
    769771    {
    770         emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), FileManagerLogType_Error);
     772        emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), m_strTableName, FileManagerLogType_Error);
    771773        return false;
    772774    }
     
    823825}
    824826
     827bool UIFileManagerGuestTable::openSession(const QString &strUserName, const QString &strPassword)
     828{
     829    if (m_comMachine.isNull())
     830    {
     831        emit sigLogOutput("Invalid machine reference", m_strTableName, FileManagerLogType_Error);
     832        return false;
     833    }
     834    m_comSession = uiCommon().openSession(m_comMachine.GetId(), KLockType_Shared);
     835    if (m_comSession.isNull())
     836    {
     837        emit sigLogOutput("Could not open machine session", m_strTableName, FileManagerLogType_Error);
     838        return false;
     839    }
     840
     841    CConsole comConsole = m_comSession.GetConsole();
     842    AssertReturn(!comConsole.isNull(), false);
     843    m_comGuest = comConsole.GetGuest();
     844    AssertReturn(!m_comGuest.isNull(), false);
     845
     846    if (!isGuestAdditionsAvailable(m_comGuest))
     847    {
     848        emit sigLogOutput("Could not find Guest Additions", m_strTableName, FileManagerLogType_Error);
     849        postGuestSessionClosed();
     850        if (m_pGuestSessionPanel)
     851            m_pGuestSessionPanel->markForError(true);
     852        return false;
     853    }
     854
     855    QVector<KVBoxEventType> eventTypes;
     856    eventTypes << KVBoxEventType_OnGuestSessionRegistered;
     857
     858    prepareListener(m_pQtGuestListener, m_comGuestListener,
     859                    m_comGuest.GetEventSource(), eventTypes);
     860
     861    connect(m_pQtGuestListener->getWrapped(), &UIMainEventListener::sigGuestSessionUnregistered,
     862            this, &UIFileManagerGuestTable::sltGuestSessionUnregistered);
     863    connect(m_pQtGuestListener->getWrapped(), &UIMainEventListener::sigGuestSessionRegistered,
     864            this, &UIFileManagerGuestTable::sltGuestSessionRegistered);
     865
     866    m_comGuestSession = m_comGuest.CreateSession(strUserName, strPassword,
     867                                                 QString() /* Domain */, "File Manager Session");
     868
     869    if (!m_comGuestSession.isOk())
     870    {
     871        emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), m_strTableName, FileManagerLogType_Error);
     872        cleanupGuestListener();
     873        return false;
     874    }
     875
     876    eventTypes.clear();
     877    eventTypes << KVBoxEventType_OnGuestSessionStateChanged;
     878
     879    prepareListener(m_pQtSessionListener, m_comSessionListener,
     880                    m_comGuestSession.GetEventSource(), eventTypes);
     881
     882    qRegisterMetaType<CGuestSessionStateChangedEvent>();
     883    connect(m_pQtSessionListener->getWrapped(), &UIMainEventListener::sigGuestSessionStatedChanged,
     884            this, &UIFileManagerGuestTable::sltGuestSessionStateChanged);
     885
     886    return true;
     887}
     888
     889bool UIFileManagerGuestTable::isGuestAdditionsAvailable(const CGuest &guest)
     890{
     891    if (!guest.isOk())
     892        return false;
     893    CGuest guestNonConst = const_cast<CGuest&>(guest);
     894    return guestNonConst.GetAdditionsStatus(guestNonConst.GetAdditionsRunLevel());
     895}
     896
     897
     898void UIFileManagerGuestTable::cleanupGuestListener()
     899{
     900    disconnect(m_pQtGuestListener->getWrapped(), &UIMainEventListener::sigGuestSessionUnregistered,
     901               this, &UIFileManagerGuestTable::sltGuestSessionUnregistered);
     902    disconnect(m_pQtGuestListener->getWrapped(), &UIMainEventListener::sigGuestSessionRegistered,
     903               this, &UIFileManagerGuestTable::sltGuestSessionRegistered);
     904    cleanupListener(m_pQtGuestListener, m_comGuestListener, m_comGuest.GetEventSource());
     905}
     906
     907
     908void UIFileManagerGuestTable::postGuestSessionCreated()
     909{
     910    if (m_pGuestSessionPanel)
     911        m_pGuestSessionPanel->switchSessionCloseMode();
     912    // if (m_pGuestFileTable)
     913    //     m_pGuestFileTable->setEnabled(true);
     914    // if (m_pVerticalToolBar)
     915    //     m_pVerticalToolBar->setEnabled(true);
     916}
     917
     918void UIFileManagerGuestTable::postGuestSessionClosed()
     919{
     920    if (m_pGuestSessionPanel)
     921        m_pGuestSessionPanel->switchSessionCreateMode();
     922    // if (m_pGuestFileTable)
     923    //     m_pGuestFileTable->setEnabled(false);
     924    // if (m_pVerticalToolBar)
     925    //     m_pVerticalToolBar->setEnabled(false);
     926}
     927
     928void UIFileManagerGuestTable::prepareListener(ComObjPtr<UIMainEventListenerImpl> &QtListener,
     929                                              CEventListener &comEventListener,
     930                                              CEventSource comEventSource, QVector<KVBoxEventType>& eventTypes)
     931{
     932    if (!comEventSource.isOk())
     933        return;
     934    /* Create event listener instance: */
     935    QtListener.createObject();
     936    QtListener->init(new UIMainEventListener, this);
     937    comEventListener = CEventListener(QtListener);
     938
     939    /* Register event listener for CProgress event source: */
     940    comEventSource.RegisterListener(comEventListener, eventTypes, FALSE /* active? */);
     941
     942    /* Register event sources in their listeners as well: */
     943    QtListener->getWrapped()->registerSource(comEventSource, comEventListener);
     944}
     945
     946void UIFileManagerGuestTable::sltGuestSessionUnregistered(CGuestSession guestSession)
     947{
     948    if (guestSession.isNull())
     949        return;
     950    if (guestSession == m_comGuestSession && !m_comGuestSession.isNull())
     951    {
     952        m_comGuestSession.detach();
     953        postGuestSessionClosed();
     954        emit sigLogOutput("Guest session unregistered", m_strTableName, FileManagerLogType_Info);
     955    }
     956}
     957
     958void UIFileManagerGuestTable::sltGuestSessionRegistered(CGuestSession guestSession)
     959{
     960    if (guestSession == m_comGuestSession && !m_comGuestSession.isNull())
     961        emit sigLogOutput("Guest session registered", m_strTableName, FileManagerLogType_Info);
     962}
     963
     964void UIFileManagerGuestTable::sltGuestSessionStateChanged(const CGuestSessionStateChangedEvent &cEvent)
     965{
     966    if (cEvent.isOk())
     967    {
     968        CVirtualBoxErrorInfo cErrorInfo = cEvent.GetError();
     969        if (cErrorInfo.isOk() && !cErrorInfo.GetText().contains("success", Qt::CaseInsensitive))
     970            emit sigLogOutput(cErrorInfo.GetText(), m_strTableName, FileManagerLogType_Error);
     971    }
     972    if (m_comGuestSession.isOk())
     973    {
     974        if (m_comGuestSession.GetStatus() == KGuestSessionStatus_Started)
     975        {
     976            initFileTable();
     977            postGuestSessionCreated();
     978        }
     979        emit sigLogOutput(QString("%1: %2").arg("Guest session status has changed").arg(gpConverter->toString(m_comGuestSession.GetStatus())),
     980                  m_strTableName, FileManagerLogType_Info);
     981    }
     982    else
     983        emit sigLogOutput("Guest session is not valid", m_strTableName, FileManagerLogType_Error);
     984}
     985
     986void UIFileManagerGuestTable::cleanupListener(ComObjPtr<UIMainEventListenerImpl> &QtListener,
     987                                              CEventListener &comEventListener,
     988                                              CEventSource comEventSource)
     989{
     990    if (!comEventSource.isOk())
     991        return;
     992    /* Unregister everything: */
     993    QtListener->getWrapped()->unregisterSources();
     994
     995    /* Make sure VBoxSVC is available: */
     996    if (!uiCommon().isVBoxSVCAvailable())
     997        return;
     998
     999    /* Unregister event listener for CProgress event source: */
     1000    comEventSource.UnregisterListener(comEventListener);
     1001}
     1002
    8251003/*////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
    8261004/*////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
    8271005/*////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
    8281006#if 0
    829     void initFileTable();
    830 void UIFileManager::initFileTable()
    831 {
    832     if (!m_comGuestSession.isOk() || m_comGuestSession.GetStatus() != KGuestSessionStatus_Started)
    833         return;
    834     if (!m_pGuestFileTable)
    835         return;
    836     m_pGuestFileTable->initGuestFileTable(m_comGuestSession);
    837 }
    838 
    839     /** @name Perform operations needed after creating/ending a guest control session
    840       * @{ */
    841         void postGuestSessionCreated();
    842         void postGuestSessionClosed();
    843     /** @} */
    844 
    845 void UIFileManager::postGuestSessionCreated()
    846 {
    847     if (m_pGuestSessionPanel)
    848         m_pGuestSessionPanel->switchSessionCloseMode();
    849     if (m_pGuestFileTable)
    850         m_pGuestFileTable->setEnabled(true);
    851     if (m_pVerticalToolBar)
    852         m_pVerticalToolBar->setEnabled(true);
    853 }
    854 
    855 void UIFileManager::postGuestSessionClosed()
    856 {
    857     if (m_pGuestSessionPanel)
    858         m_pGuestSessionPanel->switchSessionCreateMode();
    859     if (m_pGuestFileTable)
    860         m_pGuestFileTable->setEnabled(false);
    861     if (m_pVerticalToolBar)
    862         m_pVerticalToolBar->setEnabled(false);
    863 }
    864 
    865     /** Creates a shared machine session, opens a guest session and registers event listeners. */
    866     bool openSession(const QString& strUserName, const QString& strPassword);
    867     void closeSession();
    868 
    869 bool UIFileManager::openSession(const QString& strUserName, const QString& strPassword)
    870 {
    871     if (m_comMachine.isNull())
    872     {
    873         appendLog("Invalid machine reference", FileManagerLogType_Error);
    874         return false;
    875     }
    876     m_comSession = uiCommon().openSession(m_comMachine.GetId(), KLockType_Shared);
    877     if (m_comSession.isNull())
    878     {
    879         appendLog("Could not open machine session", FileManagerLogType_Error);
    880         return false;
    881     }
    882 
    883     CConsole comConsole = m_comSession.GetConsole();
    884     AssertReturn(!comConsole.isNull(), false);
    885     m_comGuest = comConsole.GetGuest();
    886     AssertReturn(!m_comGuest.isNull(), false);
    887 
    888     if (!isGuestAdditionsAvailable(m_comGuest))
    889     {
    890         appendLog("Could not find Guest Additions", FileManagerLogType_Error);
    891         postGuestSessionClosed();
     1007
     1008
     1009
     1010
     1011void UIFileManager::closeSession()
     1012{
     1013}
     1014
     1015
     1016void UIFileManagerGuestTable::sltCreateGuestSession(QString strUserName, QString strPassword)
     1017{
     1018    if (strUserName.isEmpty())
     1019    {
     1020        emit sigLogOutput("No user name is given", m_strTableName, FileManagerLogType_Error);
    8921021        if (m_pGuestSessionPanel)
    8931022            m_pGuestSessionPanel->markForError(true);
    894         return false;
    895     }
    896 
    897     QVector<KVBoxEventType> eventTypes;
    898     eventTypes << KVBoxEventType_OnGuestSessionRegistered;
    899 
    900     prepareListener(m_pQtGuestListener, m_comGuestListener,
    901                     m_comGuest.GetEventSource(), eventTypes);
    902     connect(m_pQtGuestListener->getWrapped(), &UIMainEventListener::sigGuestSessionUnregistered,
    903             this, &UIFileManager::sltGuestSessionUnregistered);
    904 
    905     connect(m_pQtGuestListener->getWrapped(), &UIMainEventListener::sigGuestSessionRegistered,
    906             this, &UIFileManager::sltGuestSessionRegistered);
    907 
    908     m_comGuestSession = m_comGuest.CreateSession(strUserName, strPassword,
    909                                                  QString() /* Domain */, "File Manager Session");
    910 
    911     if (!m_comGuestSession.isOk())
    912     {
    913         appendLog(UIErrorString::formatErrorInfo(m_comGuestSession), FileManagerLogType_Error);
    914         return false;
    915     }
    916 
    917     if (m_pGuestSessionPanel)
    918         m_pGuestSessionPanel->switchSessionCloseMode();
    919 
    920     /* Prepare guest session listener */
    921     eventTypes.clear();
    922     eventTypes << KVBoxEventType_OnGuestSessionStateChanged;
    923 
    924     prepareListener(m_pQtSessionListener, m_comSessionListener,
    925                     m_comGuestSession.GetEventSource(), eventTypes);
    926 
    927     qRegisterMetaType<CGuestSessionStateChangedEvent>();
    928     connect(m_pQtSessionListener->getWrapped(), &UIMainEventListener::sigGuestSessionStatedChanged,
    929             this, &UIFileManager::sltGuestSessionStateChanged);
    930 
    931     return true;
    932 }
    933 
    934 void UIFileManager::closeSession()
    935 {
    936 }
    937 
    938 void UIFileManager::prepareListener(ComObjPtr<UIMainEventListenerImpl> &QtListener,
    939                                     CEventListener &comEventListener,
    940                                     CEventSource comEventSource, QVector<KVBoxEventType>& eventTypes)
    941 {
    942     if (!comEventSource.isOk())
    943         return;
    944     /* Create event listener instance: */
    945     QtListener.createObject();
    946     QtListener->init(new UIMainEventListener, this);
    947     comEventListener = CEventListener(QtListener);
    948 
    949     /* Register event listener for CProgress event source: */
    950     comEventSource.RegisterListener(comEventListener, eventTypes, FALSE /* active? */);
    951 
    952     /* Register event sources in their listeners as well: */
    953     QtListener->getWrapped()->registerSource(comEventSource, comEventListener);
    954 }
    955 
    956 void UIFileManager::cleanupListener(ComObjPtr<UIMainEventListenerImpl> &QtListener,
    957                                                 CEventListener &comEventListener,
    958                                                 CEventSource comEventSource)
    959 {
    960     if (!comEventSource.isOk())
    961         return;
    962     /* Unregister everything: */
    963     QtListener->getWrapped()->unregisterSources();
    964 
    965     /* Make sure VBoxSVC is available: */
    966     if (!uiCommon().isVBoxSVCAvailable())
    967         return;
    968 
    969     /* Unregister event listener for CProgress event source: */
    970     comEventSource.UnregisterListener(comEventListener);
    971 }
    972 
    973 bool UIFileManager::isGuestAdditionsAvailable(const CGuest &guest)
    974 {
    975     if (!guest.isOk())
    976         return false;
    977     CGuest guestNonConst = const_cast<CGuest&>(guest);
    978     return guestNonConst.GetAdditionsStatus(guestNonConst.GetAdditionsRunLevel());
    979 }
    980 
    981 void UIFileManager::sltGuestSessionUnregistered(CGuestSession guestSession)
    982 {
    983     if (guestSession.isNull())
    984         return;
    985     if (guestSession == m_comGuestSession && !m_comGuestSession.isNull())
    986     {
    987         m_comGuestSession.detach();
    988         postGuestSessionClosed();
    989         appendLog("Guest session unregistered", FileManagerLogType_Info);
    990     }
    991 }
    992 
    993 void UIFileManager::sltGuestSessionRegistered(CGuestSession guestSession)
    994 {
    995     if (guestSession == m_comGuestSession && !m_comGuestSession.isNull())
    996         appendLog("Guest session registered", FileManagerLogType_Info);
    997 }
    998 
    999 
    1000 void UIFileManager::sltCreateGuestSession(QString strUserName, QString strPassword)
    1001 {
    1002     if (strUserName.isEmpty())
    1003     {
    1004         appendLog("No user name is given", FileManagerLogType_Error);
    1005         if (m_pGuestSessionPanel)
    1006             m_pGuestSessionPanel->markForError(true);
    10071023        return;
    10081024    }
     
    10151031    if (!m_comGuestSession.isOk())
    10161032    {
    1017         appendLog("Guest session is not valid", FileManagerLogType_Error);
     1033        emit sigLogOutput("Guest session is not valid", m_strTableName, FileManagerLogType_Error);
    10181034        postGuestSessionClosed();
    10191035        return;
     
    10261042
    10271043    m_comGuestSession.Close();
    1028     appendLog("Guest session is closed", FileManagerLogType_Info);
     1044    emit sigLogOutput("Guest session is closed", m_strTableName, FileManagerLogType_Info);
    10291045    postGuestSessionClosed();
    10301046}
    10311047
    1032 void UIFileManager::sltGuestSessionStateChanged(const CGuestSessionStateChangedEvent &cEvent)
    1033 {
    1034     if (cEvent.isOk())
    1035     {
    1036         CVirtualBoxErrorInfo cErrorInfo = cEvent.GetError();
    1037         if (cErrorInfo.isOk() && !cErrorInfo.GetText().contains("success", Qt::CaseInsensitive))
    1038             appendLog(cErrorInfo.GetText(), FileManagerLogType_Error);
    1039     }
    1040     if (m_comGuestSession.isOk())
    1041     {
    1042         if (m_comGuestSession.GetStatus() == KGuestSessionStatus_Started)
    1043         {
    1044             initFileTable();
    1045             postGuestSessionCreated();
    1046         }
    1047         appendLog(QString("%1: %2").arg("Guest session status has changed").arg(gpConverter->toString(m_comGuestSession.GetStatus())),
    1048                   FileManagerLogType_Info);
    1049     }
    1050     else
    1051         appendLog("Guest session is not valid", FileManagerLogType_Error);
    1052 }
    1053 
    1054 
    1055 
    1056     void sltGuestSessionUnregistered(CGuestSession guestSession);
    1057     void sltGuestSessionRegistered(CGuestSession guestSession);
     1048
     1049
    10581050    void sltCreateGuestSession(QString strUserName, QString strPassword);
    10591051    void sltCloseGuestSession();
    1060     void sltGuestSessionStateChanged(const CGuestSessionStateChangedEvent &cEvent);
    1061     void sltCleanupListenerAndGuest();
    10621052
    10631053
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.h

    r92711 r92733  
    4343class UICustomFileSystemItem;
    4444class UIFileManagerGuestSessionPanel;
     45class CGuestSessionStateChangedEvent;
    4546
    4647/** This class scans the guest file system by using the VBox Guest Control API
     
    5758
    5859    UIFileManagerGuestTable(UIActionPool *pActionPool, const CMachine &comMachine, QWidget *pParent = 0);
    59     void initGuestFileTable(const CGuestSession &session);
    6060    void copyGuestToHost(const QString& hostDestinationPath);
    6161    void copyHostToGuest(const QStringList &hostSourcePathList,
     
    9191    void sltHandleGuestSessionPanelShown();
    9292
     93    void sltGuestSessionUnregistered(CGuestSession guestSession);
     94    void sltGuestSessionRegistered(CGuestSession guestSession);
     95    void sltGuestSessionStateChanged(const CGuestSessionStateChangedEvent &cEvent);
     96
     97
    9398private:
    9499
     
    108113                         CEventListener &comEventListener,
    109114                         CEventSource comEventSource);
     115    void cleanupGuestListener();
     116
    110117    void prepareGuestSessionPanel();
     118    /** Creates a shared machine session, opens a guest session and registers event listeners. */
     119    bool openSession(const QString& strUserName, const QString& strPassword);
     120    bool isGuestAdditionsAvailable(const CGuest &guest);
     121
     122    /** @name Perform operations needed after creating/ending a guest control session
     123      * @{ */
     124        void postGuestSessionCreated();
     125        void postGuestSessionClosed();
     126    /** @} */
     127
     128    void initFileTable();
    111129
    112130    CGuest                    m_comGuest;
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerHostTable.cpp

    r92587 r92733  
    265265
    266266    if (!deleteSuccess)
    267         emit sigLogOutput(QString(item->path()).append(" could not be deleted"), FileManagerLogType_Error);
     267        emit sigLogOutput(QString(item->path()).append(" could not be deleted"), m_strTableName, FileManagerLogType_Error);
    268268}
    269269
     
    285285        }
    286286        if (!deleteSuccess)
    287             emit sigLogOutput(QString(strPath).append(" could not be deleted"), FileManagerLogType_Error);
     287            emit sigLogOutput(QString(strPath).append(" could not be deleted"), m_strTableName, FileManagerLogType_Error);
    288288    }
    289289}
     
    320320    if (!parentDir.mkdir(directoryName))
    321321    {
    322         emit sigLogOutput(UIPathOperations::mergePaths(path, directoryName).append(" could not be created"), FileManagerLogType_Error);
     322        emit sigLogOutput(UIPathOperations::mergePaths(path, directoryName).append(" could not be created"), m_strTableName, FileManagerLogType_Error);
    323323        return false;
    324324    }
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerLogPanel.cpp

    r82968 r92733  
    9090}
    9191
    92 void UIFileManagerLogPanel::appendLog(const QString &strLog, FileManagerLogType eLogType)
     92void UIFileManagerLogPanel::appendLog(const QString &strLog, const QString &strMachineName, FileManagerLogType eLogType)
    9393{
    9494    if (!m_pLogTextEdit)
     
    9999        strColorTag = "<font color=\"Red\">";
    100100    }
    101     QString strColoredLog = QString("%1 %2: %3 %4").arg(strColorTag).arg(QTime::currentTime().toString("hh:mm:ss")).arg(strLog).arg("</font>");
     101    QString strColoredLog = QString("%1 %2: %3 %4 %5").arg(strColorTag).arg(QTime::currentTime().toString("hh:mm:ss")).arg(strMachineName).arg(strLog).arg("</font>");
    102102    m_pLogTextEdit->append(strColoredLog);
    103103}
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerLogPanel.h

    r82968 r92733  
    3838
    3939    UIFileManagerLogPanel(QWidget *pParent = 0);
    40     void appendLog(const QString &str, FileManagerLogType);
     40    void appendLog(const QString &str, const QString &strMachineName, FileManagerLogType eLogType);
    4141    virtual QString panelName() const /* override */;
    4242
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerOperationsPanel.cpp

    r88793 r92733  
    5252
    5353    void sigProgressComplete(QUuid progressId);
    54     void sigProgressFail(QString strErrorString, FileManagerLogType eLogType);
     54    void sigProgressFail(QString strErrorString, QString strSourceTableName, FileManagerLogType eLogType);
    5555    void sigFocusIn(QWidget *pWidget);
    5656    void sigFocusOut(QWidget *pWidget);
     
    5858public:
    5959
    60     UIFileOperationProgressWidget(const CProgress &comProgress, QWidget *pParent = 0);
     60    UIFileOperationProgressWidget(const CProgress &comProgress, const QString &strSourceTableName, QWidget *pParent = 0);
    6161    ~UIFileOperationProgressWidget();
    6262    bool isCompleted() const;
     
    101101    QILabel                *m_pStatusLabel;
    102102    QILabel                *m_pOperationDescriptionLabel;
     103    /** Name of the table from which this operation has originated. */
     104    QString                 m_strSourceTableName;
    103105};
    104106
     
    108110*********************************************************************************************************************************/
    109111
    110 UIFileOperationProgressWidget::UIFileOperationProgressWidget(const CProgress &comProgress, QWidget *pParent /* = 0 */)
     112UIFileOperationProgressWidget::UIFileOperationProgressWidget(const CProgress &comProgress, const QString &strSourceTableName, QWidget *pParent /* = 0 */)
    111113    : QIWithRetranslateUI<QFrame>(pParent)
    112114    , m_eStatus(OperationStatus_NotStarted)
     
    118120    , m_pStatusLabel(0)
    119121    , m_pOperationDescriptionLabel(0)
     122    , m_strSourceTableName(strSourceTableName)
    120123{
    121124    prepare();
     
    276279    if (!m_comProgress.isOk() || m_comProgress.GetResultCode() != 0)
    277280    {
    278         emit sigProgressFail(UIErrorString::formatErrorInfo(m_comProgress), FileManagerLogType_Error);
     281        emit sigProgressFail(UIErrorString::formatErrorInfo(m_comProgress), m_strSourceTableName, FileManagerLogType_Error);
    279282        m_eStatus = OperationStatus_Failed;
    280283    }
     
    319322}
    320323
    321 void UIFileManagerOperationsPanel::addNewProgress(const CProgress &comProgress)
     324void UIFileManagerOperationsPanel::addNewProgress(const CProgress &comProgress, const QString &strSourceTableName)
    322325{
    323326    if (!m_pContainerLayout)
    324327        return;
    325328
    326     UIFileOperationProgressWidget *pOperationsWidget = new UIFileOperationProgressWidget(comProgress);
     329    UIFileOperationProgressWidget *pOperationsWidget = new UIFileOperationProgressWidget(comProgress, strSourceTableName);
    327330    if (!pOperationsWidget)
    328331        return;
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerOperationsPanel.h

    r82968 r92733  
    4949
    5050    void sigFileOperationComplete(QUuid progressId);
    51     void sigFileOperationFail(QString strErrorString, FileManagerLogType eLogType);
     51    void sigFileOperationFail(QString strErrorString, QString strSourceTableName, FileManagerLogType eLogType);
    5252
    5353public:
     
    5555    UIFileManagerOperationsPanel(QWidget *pParent = 0);
    5656    virtual QString panelName() const /* override */;
    57     void addNewProgress(const CProgress &comProgress);
     57    void addNewProgress(const CProgress &comProgress, const QString &strSourceTableName);
    5858
    5959protected:
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.cpp

    r92711 r92733  
    728728}
    729729
    730 void UIFileManagerTable::emitLogOutput(const QString& strOutput, FileManagerLogType eLogType)
    731 {
    732     emit sigLogOutput(strOutput, eLogType);
    733 }
    734 
    735730void UIFileManagerTable::prepareObjects()
    736731{
     
    12081203        pItem->setData(strOldName, static_cast<int>(UICustomFileSystemModelColumn_Name));
    12091204        relist();
    1210         sigLogOutput(QString(pItem->path()).append(" could not be renamed"), FileManagerLogType_Error);
     1205        emit sigLogOutput(QString(pItem->path()).append(" could not be renamed"), QString(), FileManagerLogType_Error);
    12111206    }
    12121207}
     
    12971292    if (pRootItem)
    12981293    {
    1299         pRootItem->setData(UICustomFileSystemModel::tr("Name"), UICustomFileSystemModelColumn_Name);
    1300         pRootItem->setData(UICustomFileSystemModel::tr("Size"), UICustomFileSystemModelColumn_Size);
    1301         pRootItem->setData(UICustomFileSystemModel::tr("Change Time"), UICustomFileSystemModelColumn_ChangeTime);
    1302         pRootItem->setData(UICustomFileSystemModel::tr("Owner"), UICustomFileSystemModelColumn_Owner);
    1303         pRootItem->setData(UICustomFileSystemModel::tr("Permissions"), UICustomFileSystemModelColumn_Permissions);
     1294        pRootItem->setData(UIFileManager::tr("Name"), UICustomFileSystemModelColumn_Name);
     1295        pRootItem->setData(UIFileManager::tr("Size"), UICustomFileSystemModelColumn_Size);
     1296        pRootItem->setData(UIFileManager::tr("Change Time"), UICustomFileSystemModelColumn_ChangeTime);
     1297        pRootItem->setData(UIFileManager::tr("Owner"), UICustomFileSystemModelColumn_Owner);
     1298        pRootItem->setData(UIFileManager::tr("Permissions"), UICustomFileSystemModelColumn_Permissions);
    13041299    }
    13051300    if (m_pWarningLabel)
    13061301        m_pWarningLabel->setText(UIFileManager::tr("<p>No Guest Session found! Please use the Session Panel to start a new guest session</p>"));
     1302    m_strTableName = UIFileManager::tr("Host");
    13071303}
    13081304
     
    14331429{
    14341430    foreach (QAction *pAction, m_selectionDependentActions)
    1435     {
    14361431        pAction->setEnabled(fIsEnabled);
    1437     }
    14381432}
    14391433
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.h

    r92710 r92733  
    136136signals:
    137137
    138     void sigLogOutput(QString strLog, FileManagerLogType eLogType);
     138    void sigLogOutput(QString strLog, const QString &strMachineName, FileManagerLogType eLogType);
    139139    void sigDeleteConfirmationOptionChanged();
    140140
     
    145145    /** Deletes all the tree nodes */
    146146    void        reset();
    147     void        emitLogOutput(const QString& strOutput, FileManagerLogType eLogType);
    148147    /** Returns the path of the rootIndex */
    149148    QString     currentDirectoryPath() const;
     
    252251     *  Currently only used by the guest side. */
    253252    QStringList              m_copyCutBuffer;
     253    /** This name is appended to the log messages which are shown in the log panel. */
     254    QString          m_strTableName;
    254255
    255256private slots:
     
    302303    QILabel         *m_pWarningLabel;
    303304    QChar            m_pathSeparator;
    304 
    305305    friend class     UICustomFileSystemModel;
    306306};
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