Changeset 92630 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Nov 29, 2021 4:25:42 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 148522
- 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 40 40 41 41 /* COM includes: */ 42 #include "CConsole.h" 42 43 #include "CFsObjInfo.h" 43 44 #include "CGuestDirectory.h" … … 112 113 113 114 UIFileManager::UIFileManager(EmbedTo enmEmbedding, UIActionPool *pActionPool, 114 const C Guest &comGuest, QWidget *pParent, bool fShowToolbar /* = true */)115 const CMachine &comMachine, QWidget *pParent, bool fShowToolbar /* = true */) 115 116 : QIWithRetranslateUI<QWidget>(pParent) 116 , m_com Guest(comGuest)117 , m_comMachine(comMachine) 117 118 , m_pMainLayout(0) 118 119 , m_pVerticalSplitter(0) … … 131 132 { 132 133 loadOptions(); 133 prepareGuestListener();134 134 prepareObjects(); 135 135 prepareConnections(); … … 160 160 void UIFileManager::retranslateUi() 161 161 { 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 }174 162 } 175 163 … … 329 317 void UIFileManager::prepareConnections() 330 318 { 331 if (m_pQtGuestListener)332 connect(m_pQtGuestListener->getWrapped(), &UIMainEventListener::sigGuestSessionUnregistered,333 this, &UIFileManager::sltGuestSessionUnregistered);334 319 335 320 if (m_pGuestSessionPanel) … … 402 387 m_comGuestSession.detach(); 403 388 postGuestSessionClosed(); 404 } 405 } 389 appendLog("Guest session unregistered", FileManagerLogType_Info); 390 } 391 } 392 393 void UIFileManager::sltGuestSessionRegistered(CGuestSession guestSession) 394 { 395 if (guestSession == m_comGuestSession && !m_comGuestSession.isNull()) 396 appendLog("Guest session registered", FileManagerLogType_Info); 397 } 398 406 399 407 400 void UIFileManager::sltCreateGuestSession(QString strUserName, QString strPassword) 408 401 { 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 }417 402 if (strUserName.isEmpty()) 418 403 { … … 423 408 } 424 409 if (m_pGuestSessionPanel) 425 m_pGuestSessionPanel->markForError(! createGuestSession(strUserName, strPassword));410 m_pGuestSessionPanel->markForError(!openSession(strUserName, strPassword)); 426 411 } 427 412 … … 460 445 postGuestSessionCreated(); 461 446 } 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())), 463 448 FileManagerLogType_Info); 464 449 } … … 596 581 } 597 582 598 bool UIFileManager::createGuestSession(const QString& strUserName, const QString& strPassword, 599 const QString& strDomain /* not used currently */) 600 { 601 if (!m_comGuest.isOk()) 583 bool 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); 602 599 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 603 613 m_comGuestSession = m_comGuest.CreateSession(strUserName, strPassword, 604 strDomain, "File Manager Session");614 QString() /* Domain */, "File Manager Session"); 605 615 606 616 if (!m_comGuestSession.isOk()) … … 609 619 return false; 610 620 } 611 appendLog("Guest session has been created", FileManagerLogType_Info); 621 612 622 if (m_pGuestSessionPanel) 613 623 m_pGuestSessionPanel->switchSessionCloseMode(); 614 624 615 /* Prepare session listener */616 QVector<KVBoxEventType> eventTypes;625 /* Prepare guest session listener */ 626 eventTypes.clear(); 617 627 eventTypes << KVBoxEventType_OnGuestSessionStateChanged; 618 //<< KVBoxEventType_OnGuestProcessRegistered; 628 619 629 prepareListener(m_pQtSessionListener, m_comSessionListener, 620 630 m_comGuestSession.GetEventSource(), eventTypes); 621 631 622 /* Connect to session listener */623 632 qRegisterMetaType<CGuestSessionStateChangedEvent>(); 624 625 633 connect(m_pQtSessionListener->getWrapped(), &UIMainEventListener::sigGuestSessionStatedChanged, 626 634 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 640 636 return true; 641 637 } 638 639 640 void UIFileManager::closeSession() 641 { 642 } 643 642 644 643 645 void UIFileManager::prepareListener(ComObjPtr<UIMainEventListenerImpl> &QtListener, -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManager.h
r92616 r92630 31 31 #include "CEventSource.h" 32 32 #include "CGuest.h" 33 #include "CMachine.h" 33 34 #include "CGuestSession.h" 34 35 … … 92 93 93 94 UIFileManager(EmbedTo enmEmbedding, UIActionPool *pActionPool, 94 const C Guest &comGuest, QWidget *pParent, bool fShowToolbar = true);95 const CMachine &comMachine, QWidget *pParent, bool fShowToolbar = true); 95 96 ~UIFileManager(); 96 97 QMenu *menu() const; … … 110 111 111 112 void sltGuestSessionUnregistered(CGuestSession guestSession); 113 void sltGuestSessionRegistered(CGuestSession guestSession); 112 114 void sltCreateGuestSession(QString strUserName, QString strPassword); 113 115 void sltCloseGuestSession(); … … 127 129 128 130 void prepareObjects(); 129 void prepareGuestListener();130 131 void prepareConnections(); 131 132 void prepareVerticalToolBar(QHBoxLayout *layout); 132 133 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(); 135 138 136 139 void prepareListener(ComObjPtr<UIMainEventListenerImpl> &Qtistener, … … 172 175 CGuest m_comGuest; 173 176 CGuestSession m_comGuestSession; 177 CSession m_comSession; 178 CMachine m_comMachine; 174 179 QVBoxLayout *m_pMainLayout; 175 180 QSplitter *m_pVerticalSplitter; … … 177 182 QIToolBar *m_pVerticalToolBar; 178 183 179 UIFileManagerGuestTable 184 UIFileManagerGuestTable *m_pGuestFileTable; 180 185 UIFileManagerHostTable *m_pHostFileTable; 181 186 -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerDialog.cpp
r92510 r92630 36 36 *********************************************************************************************************************************/ 37 37 38 UIFileManagerDialogFactory::UIFileManagerDialogFactory(UIActionPool *pActionPool /* = 0 */,39 const CGuest &comGuest /* = CGuest() */,40 const QString &strMachineName /* = QString() */)38 UIFileManagerDialogFactory::UIFileManagerDialogFactory(UIActionPool *pActionPool, 39 const CMachine &comMachine, 40 const QString &strMachineName) 41 41 : m_pActionPool(pActionPool) 42 , m_com Guest(comGuest)42 , m_comMachine(comMachine) 43 43 , m_strMachineName(strMachineName) 44 { 45 } 46 47 48 UIFileManagerDialogFactory::UIFileManagerDialogFactory() 49 : m_pActionPool(0) 50 , m_comMachine(CMachine()) 44 51 { 45 52 } … … 47 54 void UIFileManagerDialogFactory::create(QIManagerDialog *&pDialog, QWidget *pCenterWidget) 48 55 { 49 pDialog = new UIFileManagerDialog(pCenterWidget, m_pActionPool, m_com Guest, m_strMachineName);56 pDialog = new UIFileManagerDialog(pCenterWidget, m_pActionPool, m_comMachine, m_strMachineName); 50 57 } 51 58 … … 57 64 UIFileManagerDialog::UIFileManagerDialog(QWidget *pCenterWidget, 58 65 UIActionPool *pActionPool, 59 const C Guest &comGuest,60 const QString &strMachineName /* = QString() */)66 const CMachine &comMachine, 67 const QString &strMachineName) 61 68 : QIWithRetranslateUI<QIManagerDialog>(pCenterWidget) 62 69 , m_pActionPool(pActionPool) 63 , m_com Guest(comGuest)70 , m_comMachine(comMachine) 64 71 , m_strMachineName(strMachineName) 65 72 { … … 106 113 /* Create widget: */ 107 114 UIFileManager *pWidget = new UIFileManager(EmbedTo_Dialog, m_pActionPool, 108 m_com Guest, this);115 m_comMachine, this); 109 116 110 117 if (pWidget) -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerDialog.h
r89111 r92630 31 31 /* COM includes: */ 32 32 #include "COMEnums.h" 33 #include "C Guest.h"33 #include "CMachine.h" 34 34 35 35 /* Forward declarations: */ … … 38 38 class UIActionPool; 39 39 class UIFileManagerDialog; 40 class C Guest;40 class CMachine; 41 41 42 42 … … 46 46 public: 47 47 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(); 49 50 50 51 protected: … … 55 56 56 57 UIActionPool *m_pActionPool; 57 C Guest m_comGuest;58 CMachine m_comMachine; 58 59 QString m_strMachineName; 59 60 }; … … 69 70 * @param pCenterWidget Passes the widget reference to center according to. 70 71 * @param pActionPool Passes the action-pool reference. 71 * @param com Guest Passes the com-guestreference. */72 UIFileManagerDialog(QWidget *pCenterWidget, UIActionPool *pActionPool, const C Guest &comGuest, const QString &strMachineName = QString());72 * @param comMachine Passes the machine reference. */ 73 UIFileManagerDialog(QWidget *pCenterWidget, UIActionPool *pActionPool, const CMachine &comMachine, const QString &strMachineName); 73 74 ~UIFileManagerDialog(); 74 75 … … 110 111 void manageEscapeShortCut(); 111 112 UIActionPool *m_pActionPool; 112 C Guest m_comGuest;113 CMachine m_comMachine; 113 114 QString m_strMachineName; 114 115 }; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r92609 r92630 1781 1781 1782 1782 QIManagerDialog *pFileManagerDialog; 1783 UIFileManagerDialogFactory dialogFactory(actionPool(), console().GetGuest(), machine().GetName());1783 UIFileManagerDialogFactory dialogFactory(actionPool(), machine(), machine().GetName()); 1784 1784 dialogFactory.prepare(pFileManagerDialog, activeMachineWindow()); 1785 1785 if (pFileManagerDialog)
Note:
See TracChangeset
for help on using the changeset viewer.