VirtualBox

Changeset 92630 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Nov 29, 2021 4:25:42 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
148522
Message:

FE/Qt: bugref:9371. File manager opens it own session.

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

Legend:

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

    r92616 r92630  
    4040
    4141/* COM includes: */
     42#include "CConsole.h"
    4243#include "CFsObjInfo.h"
    4344#include "CGuestDirectory.h"
     
    112113
    113114UIFileManager::UIFileManager(EmbedTo enmEmbedding, UIActionPool *pActionPool,
    114                                                      const CGuest &comGuest, QWidget *pParent, bool fShowToolbar /* = true */)
     115                                                     const CMachine &comMachine, QWidget *pParent, bool fShowToolbar /* = true */)
    115116    : QIWithRetranslateUI<QWidget>(pParent)
    116     , m_comGuest(comGuest)
     117    , m_comMachine(comMachine)
    117118    , m_pMainLayout(0)
    118119    , m_pVerticalSplitter(0)
     
    131132{
    132133    loadOptions();
    133     prepareGuestListener();
    134134    prepareObjects();
    135135    prepareConnections();
     
    160160void UIFileManager::retranslateUi()
    161161{
    162 }
    163 
    164 void UIFileManager::prepareGuestListener()
    165 {
    166     if (m_comGuest.isOk())
    167     {
    168         QVector<KVBoxEventType> eventTypes;
    169         eventTypes << KVBoxEventType_OnGuestSessionRegistered;
    170 
    171         prepareListener(m_pQtGuestListener, m_comGuestListener,
    172                         m_comGuest.GetEventSource(), eventTypes);
    173     }
    174162}
    175163
     
    329317void UIFileManager::prepareConnections()
    330318{
    331     if (m_pQtGuestListener)
    332         connect(m_pQtGuestListener->getWrapped(), &UIMainEventListener::sigGuestSessionUnregistered,
    333                 this, &UIFileManager::sltGuestSessionUnregistered);
    334319
    335320    if (m_pGuestSessionPanel)
     
    402387        m_comGuestSession.detach();
    403388        postGuestSessionClosed();
    404     }
    405 }
     389        appendLog("Guest session unregistered", FileManagerLogType_Info);
     390    }
     391}
     392
     393void UIFileManager::sltGuestSessionRegistered(CGuestSession guestSession)
     394{
     395    if (guestSession == m_comGuestSession && !m_comGuestSession.isNull())
     396        appendLog("Guest session registered", FileManagerLogType_Info);
     397}
     398
    406399
    407400void UIFileManager::sltCreateGuestSession(QString strUserName, QString strPassword)
    408401{
    409     if (!UIGuestControlInterface::isGuestAdditionsAvailable(m_comGuest))
    410     {
    411         appendLog("Could not find Guest Additions", FileManagerLogType_Error);
    412         postGuestSessionClosed();
    413         if (m_pGuestSessionPanel)
    414             m_pGuestSessionPanel->markForError(true);
    415         return;
    416     }
    417402    if (strUserName.isEmpty())
    418403    {
     
    423408    }
    424409    if (m_pGuestSessionPanel)
    425         m_pGuestSessionPanel->markForError(!createGuestSession(strUserName, strPassword));
     410        m_pGuestSessionPanel->markForError(!openSession(strUserName, strPassword));
    426411}
    427412
     
    460445            postGuestSessionCreated();
    461446        }
    462         appendLog(QString("%1: %2").arg("Session status has changed").arg(gpConverter->toString(m_comGuestSession.GetStatus())),
     447        appendLog(QString("%1: %2").arg("Guest session status has changed").arg(gpConverter->toString(m_comGuestSession.GetStatus())),
    463448                  FileManagerLogType_Info);
    464449    }
     
    596581}
    597582
    598 bool UIFileManager::createGuestSession(const QString& strUserName, const QString& strPassword,
    599                                   const QString& strDomain /* not used currently */)
    600 {
    601     if (!m_comGuest.isOk())
     583bool UIFileManager::openSession(const QString& strUserName, const QString& strPassword)
     584{
     585    m_comSession = uiCommon().openSession(m_comMachine.GetId(), KLockType_Shared);
     586    AssertReturn(!m_comSession.isNull(), false);
     587
     588    CConsole comConsole = m_comSession.GetConsole();
     589    AssertReturn(!comConsole.isNull(), false);
     590    m_comGuest = comConsole.GetGuest();
     591    AssertReturn(!m_comGuest.isNull(), false);
     592
     593    if (!UIGuestControlInterface::isGuestAdditionsAvailable(m_comGuest))
     594    {
     595        appendLog("Could not find Guest Additions", FileManagerLogType_Error);
     596        postGuestSessionClosed();
     597        if (m_pGuestSessionPanel)
     598            m_pGuestSessionPanel->markForError(true);
    602599        return false;
     600    }
     601
     602    QVector<KVBoxEventType> eventTypes;
     603    eventTypes << KVBoxEventType_OnGuestSessionRegistered;
     604
     605    prepareListener(m_pQtGuestListener, m_comGuestListener,
     606                    m_comGuest.GetEventSource(), eventTypes);
     607    connect(m_pQtGuestListener->getWrapped(), &UIMainEventListener::sigGuestSessionUnregistered,
     608            this, &UIFileManager::sltGuestSessionUnregistered);
     609
     610    connect(m_pQtGuestListener->getWrapped(), &UIMainEventListener::sigGuestSessionRegistered,
     611            this, &UIFileManager::sltGuestSessionRegistered);
     612
    603613    m_comGuestSession = m_comGuest.CreateSession(strUserName, strPassword,
    604                                                                strDomain, "File Manager Session");
     614                                                 QString() /* Domain */, "File Manager Session");
    605615
    606616    if (!m_comGuestSession.isOk())
     
    609619        return false;
    610620    }
    611     appendLog("Guest session has been created", FileManagerLogType_Info);
     621
    612622    if (m_pGuestSessionPanel)
    613623        m_pGuestSessionPanel->switchSessionCloseMode();
    614624
    615     /* Prepare session listener */
    616     QVector<KVBoxEventType> eventTypes;
     625    /* Prepare guest session listener */
     626    eventTypes.clear();
    617627    eventTypes << KVBoxEventType_OnGuestSessionStateChanged;
    618     //<< KVBoxEventType_OnGuestProcessRegistered;
     628
    619629    prepareListener(m_pQtSessionListener, m_comSessionListener,
    620630                    m_comGuestSession.GetEventSource(), eventTypes);
    621631
    622     /* Connect to session listener */
    623632    qRegisterMetaType<CGuestSessionStateChangedEvent>();
    624 
    625633    connect(m_pQtSessionListener->getWrapped(), &UIMainEventListener::sigGuestSessionStatedChanged,
    626634            this, &UIFileManager::sltGuestSessionStateChanged);
    627 #if 0
    628     /* Wait session to start. For some reason we cannot get GuestSessionStatusChanged event
    629         consistently. So we wait: */
    630     appendLog("Waiting the guest session to start", FileManagerLogType_Info);
    631     const ULONG waitTimeout = 2000;
    632     KGuestSessionWaitResult waitResult = m_comGuestSession.WaitFor(KGuestSessionWaitForFlag_Start, waitTimeout);
    633     if (waitResult != KGuestSessionWaitResult_Start)
    634     {
    635         appendLog("The guest session did not start", FileManagerLogType_Error);
    636         sltCloseGuestSession();
    637         return false;
    638     }
    639 #endif
     635
    640636    return true;
    641637}
     638
     639
     640void UIFileManager::closeSession()
     641{
     642}
     643
    642644
    643645void UIFileManager::prepareListener(ComObjPtr<UIMainEventListenerImpl> &QtListener,
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManager.h

    r92616 r92630  
    3131#include "CEventSource.h"
    3232#include "CGuest.h"
     33#include "CMachine.h"
    3334#include "CGuestSession.h"
    3435
     
    9293
    9394    UIFileManager(EmbedTo enmEmbedding, UIActionPool *pActionPool,
    94                               const CGuest &comGuest, QWidget *pParent, bool fShowToolbar = true);
     95                              const CMachine &comMachine, QWidget *pParent, bool fShowToolbar = true);
    9596    ~UIFileManager();
    9697    QMenu *menu() const;
     
    110111
    111112    void sltGuestSessionUnregistered(CGuestSession guestSession);
     113    void sltGuestSessionRegistered(CGuestSession guestSession);
    112114    void sltCreateGuestSession(QString strUserName, QString strPassword);
    113115    void sltCloseGuestSession();
     
    127129
    128130    void prepareObjects();
    129     void prepareGuestListener();
    130131    void prepareConnections();
    131132    void prepareVerticalToolBar(QHBoxLayout *layout);
    132133    void prepareToolBar();
    133     bool createGuestSession(const QString& strUserName, const QString& strPassword,
    134                        const QString& strDomain = QString() /* not used currently */);
     134
     135    /** Creates a shared machine session, opens a guest session and registers event listeners. */
     136    bool openSession(const QString& strUserName, const QString& strPassword);
     137    void closeSession();
    135138
    136139    void prepareListener(ComObjPtr<UIMainEventListenerImpl> &Qtistener,
     
    172175    CGuest                    m_comGuest;
    173176    CGuestSession             m_comGuestSession;
     177    CSession                  m_comSession;
     178    CMachine                  m_comMachine;
    174179    QVBoxLayout              *m_pMainLayout;
    175180    QSplitter                *m_pVerticalSplitter;
     
    177182    QIToolBar                *m_pVerticalToolBar;
    178183
    179     UIFileManagerGuestTable         *m_pGuestFileTable;
     184    UIFileManagerGuestTable  *m_pGuestFileTable;
    180185    UIFileManagerHostTable   *m_pHostFileTable;
    181186
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerDialog.cpp

    r92510 r92630  
    3636*********************************************************************************************************************************/
    3737
    38 UIFileManagerDialogFactory::UIFileManagerDialogFactory(UIActionPool *pActionPool /* = 0 */,
    39                                                          const CGuest &comGuest /* = CGuest() */,
    40                                                          const QString &strMachineName /* = QString() */)
     38UIFileManagerDialogFactory::UIFileManagerDialogFactory(UIActionPool *pActionPool,
     39                                                       const CMachine &comMachine,
     40                                                       const QString &strMachineName)
    4141    : m_pActionPool(pActionPool)
    42     , m_comGuest(comGuest)
     42    , m_comMachine(comMachine)
    4343    , m_strMachineName(strMachineName)
     44{
     45}
     46
     47
     48UIFileManagerDialogFactory::UIFileManagerDialogFactory()
     49    : m_pActionPool(0)
     50    , m_comMachine(CMachine())
    4451{
    4552}
     
    4754void UIFileManagerDialogFactory::create(QIManagerDialog *&pDialog, QWidget *pCenterWidget)
    4855{
    49     pDialog = new UIFileManagerDialog(pCenterWidget, m_pActionPool, m_comGuest, m_strMachineName);
     56    pDialog = new UIFileManagerDialog(pCenterWidget, m_pActionPool, m_comMachine, m_strMachineName);
    5057}
    5158
     
    5764UIFileManagerDialog::UIFileManagerDialog(QWidget *pCenterWidget,
    5865                                           UIActionPool *pActionPool,
    59                                            const CGuest &comGuest,
    60                                            const QString &strMachineName /* = QString() */)
     66                                           const CMachine &comMachine,
     67                                           const QString &strMachineName)
    6168    : QIWithRetranslateUI<QIManagerDialog>(pCenterWidget)
    6269    , m_pActionPool(pActionPool)
    63     , m_comGuest(comGuest)
     70    , m_comMachine(comMachine)
    6471    , m_strMachineName(strMachineName)
    6572{
     
    106113    /* Create widget: */
    107114    UIFileManager *pWidget = new UIFileManager(EmbedTo_Dialog, m_pActionPool,
    108                                                                        m_comGuest, this);
     115                                                                       m_comMachine, this);
    109116
    110117    if (pWidget)
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerDialog.h

    r89111 r92630  
    3131/* COM includes: */
    3232#include "COMEnums.h"
    33 #include "CGuest.h"
     33#include "CMachine.h"
    3434
    3535/* Forward declarations: */
     
    3838class UIActionPool;
    3939class UIFileManagerDialog;
    40 class CGuest;
     40class CMachine;
    4141
    4242
     
    4646public:
    4747
    48     UIFileManagerDialogFactory(UIActionPool *pActionPool = 0, const CGuest &comGuest = CGuest(), const QString &strMachineName = QString());
     48    UIFileManagerDialogFactory(UIActionPool *pActionPool, const CMachine &comMachine, const QString &strMachineName);
     49    UIFileManagerDialogFactory();
    4950
    5051protected:
     
    5556
    5657    UIActionPool *m_pActionPool;
    57     CGuest        m_comGuest;
     58    CMachine      m_comMachine;
    5859    QString       m_strMachineName;
    5960};
     
    6970      * @param  pCenterWidget  Passes the widget reference to center according to.
    7071      * @param  pActionPool    Passes the action-pool reference.
    71       * @param  comGuest       Passes the com-guest reference. */
    72     UIFileManagerDialog(QWidget *pCenterWidget, UIActionPool *pActionPool, const CGuest &comGuest, const QString &strMachineName = QString());
     72      * @param  comMachine     Passes the machine reference. */
     73    UIFileManagerDialog(QWidget *pCenterWidget, UIActionPool *pActionPool, const CMachine &comMachine, const QString &strMachineName);
    7374    ~UIFileManagerDialog();
    7475
     
    110111    void manageEscapeShortCut();
    111112    UIActionPool *m_pActionPool;
    112     CGuest      m_comGuest;
     113    CMachine    m_comMachine;
    113114    QString     m_strMachineName;
    114115};
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r92609 r92630  
    17811781
    17821782    QIManagerDialog *pFileManagerDialog;
    1783     UIFileManagerDialogFactory dialogFactory(actionPool(), console().GetGuest(), machine().GetName());
     1783    UIFileManagerDialogFactory dialogFactory(actionPool(), machine(), machine().GetName());
    17841784    dialogFactory.prepare(pFileManagerDialog, activeMachineWindow());
    17851785    if (pFileManagerDialog)
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