Changeset 92733 in vbox for trunk/src/VBox
- Timestamp:
- Dec 3, 2021 2:23:31 PM (3 years ago)
- 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 218 218 if (m_pGuestTablesContainer) 219 219 { 220 m_pGuestTablesContainer->setTabPosition(QTabWidget::East); 221 220 222 m_pGuestTablesContainer->setTabBarAutoHide(true); 221 223 m_pFileTableSplitter->addWidget(m_pGuestTablesContainer); … … 349 351 } 350 352 351 void UIFileManager::sltReceieveLogOutput(QString strOutput, FileManagerLogType eLogType)352 { 353 appendLog(strOutput, eLogType);353 void UIFileManager::sltReceieveLogOutput(QString strOutput, const QString &strMachineName, FileManagerLogType eLogType) 354 { 355 appendLog(strOutput, strMachineName, eLogType); 354 356 } 355 357 … … 598 600 } 599 601 600 void UIFileManager::appendLog(const QString &strLog, FileManagerLogType eLogType)602 void UIFileManager::appendLog(const QString &strLog, const QString &strMachineName, FileManagerLogType eLogType) 601 603 { 602 604 if (!m_pLogPanel) 603 605 return; 604 m_pLogPanel->appendLog(strLog, eLogType);606 m_pLogPanel->appendLog(strLog, strMachineName, eLogType); 605 607 } 606 608 -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManager.h
r92710 r92733 107 107 private slots: 108 108 109 void sltReceieveLogOutput(QString strOutput, FileManagerLogType eLogType);109 void sltReceieveLogOutput(QString strOutput, const QString &strMachineName, FileManagerLogType eLogType); 110 110 void sltCopyGuestToHost(); 111 111 void sltCopyHostToGuest(); … … 146 146 template<typename T> 147 147 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); 149 149 void savePanelVisibility(); 150 150 -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.cpp
r92711 r92733 25 25 #include "QILabel.h" 26 26 #include "UIActionPool.h" 27 #include "UIConverter.h" 28 #include "UICustomFileSystemModel.h" 27 29 #include "UIErrorString.h" 28 #include "UICustomFileSystemModel.h"29 30 #include "UIFileManager.h" 30 31 #include "UIFileManagerGuestTable.h" … … 35 36 36 37 /* COM includes: */ 38 #include "CConsole.h" 37 39 #include "CFsObjInfo.h" 38 40 #include "CGuestFsObjInfo.h" 39 41 #include "CGuestDirectory.h" 40 42 #include "CProgress.h" 43 #include "CGuestSessionStateChangedEvent.h" 41 44 42 45 #include <iprt/path.h> … … 153 156 , m_pGuestSessionPanel(0) 154 157 { 158 if (!m_comMachine.isNull()) 159 m_strTableName = m_comMachine.GetName(); 155 160 prepareToolbar(); 156 161 prepareGuestSessionPanel(); … … 159 164 } 160 165 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; 166 void UIFileManagerGuestTable::initFileTable() 167 { 168 if (!m_comGuestSession.isOk() || m_comGuestSession.GetStatus() != KGuestSessionStatus_Started) 169 return; 168 170 /* To determine the path separator we need to have a valid guest session: */ 169 171 determinePathSeparator(); … … 191 193 if (!m_comGuestSession.isOk()) 192 194 { 193 emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), FileManagerLogType_Error);195 emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), m_strTableName, FileManagerLogType_Error); 194 196 return; 195 197 } … … 249 251 if (!m_comGuestSession.isOk()) 250 252 { 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); 253 255 } 254 256 } … … 285 287 if (!m_comGuestSession.isOk()) 286 288 { 287 emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), FileManagerLogType_Error);289 emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), m_strTableName, FileManagerLogType_Error); 288 290 return; 289 291 } … … 304 306 if (!m_comGuestSession.isOk()) 305 307 { 306 emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), FileManagerLogType_Error);308 emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), m_strTableName, FileManagerLogType_Error); 307 309 return false; 308 310 } … … 320 322 if (!m_comGuestSession.isOk()) 321 323 { 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); 324 326 return false; 325 327 } 326 emit sigLogOutput(newDirectoryPath.append(" has been created"), FileManagerLogType_Info);328 emit sigLogOutput(newDirectoryPath.append(" has been created"), m_strTableName, FileManagerLogType_Info); 327 329 return true; 328 330 } … … 342 344 if (strDestinationPath.isEmpty()) 343 345 { 344 emit sigLogOutput("No destination for copy operation", FileManagerLogType_Error);346 emit sigLogOutput("No destination for copy operation", m_strTableName, FileManagerLogType_Error); 345 347 return; 346 348 } 347 349 if (hostSourcePathList.empty()) 348 350 { 349 emit sigLogOutput("No source for copy operation", FileManagerLogType_Error);351 emit sigLogOutput("No source for copy operation", m_strTableName, FileManagerLogType_Error); 350 352 return; 351 353 } … … 366 368 else 367 369 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); 369 371 } 370 372 … … 392 394 if (hostDestinationPath.isEmpty()) 393 395 { 394 emit sigLogOutput("No destination for copy operation", FileManagerLogType_Error);396 emit sigLogOutput("No destination for copy operation", m_strTableName, FileManagerLogType_Error); 395 397 return; 396 398 } 397 399 if (sourcePaths.empty()) 398 400 { 399 emit sigLogOutput("No source for copy operation", FileManagerLogType_Error);401 emit sigLogOutput("No source for copy operation", m_strTableName, FileManagerLogType_Error); 400 402 return; 401 403 } … … 410 412 if (!m_comGuestSession.isOk()) 411 413 { 412 emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), FileManagerLogType_Error);414 emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), m_strTableName, FileManagerLogType_Error); 413 415 return; 414 416 } … … 469 471 if (!m_comGuestSession.isOk()) 470 472 { 471 emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), FileManagerLogType_Error);473 emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), m_strTableName, FileManagerLogType_Error); 472 474 return QString(); 473 475 } … … 562 564 if (!m_comGuestSession.isOk()) 563 565 { 564 emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), FileManagerLogType_Error);566 emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), m_strTableName, FileManagerLogType_Error); 565 567 continue; 566 568 } … … 768 770 if (!m_comGuestSession.isOk()) 769 771 { 770 emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), FileManagerLogType_Error);772 emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), m_strTableName, FileManagerLogType_Error); 771 773 return false; 772 774 } … … 823 825 } 824 826 827 bool 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 889 bool 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 898 void 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 908 void 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 918 void 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 928 void 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 946 void 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 958 void 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 964 void 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 986 void 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 825 1003 /*////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/ 826 1004 /*////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/ 827 1005 /*////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/ 828 1006 #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 1011 void UIFileManager::closeSession() 1012 { 1013 } 1014 1015 1016 void UIFileManagerGuestTable::sltCreateGuestSession(QString strUserName, QString strPassword) 1017 { 1018 if (strUserName.isEmpty()) 1019 { 1020 emit sigLogOutput("No user name is given", m_strTableName, FileManagerLogType_Error); 892 1021 if (m_pGuestSessionPanel) 893 1022 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);1007 1023 return; 1008 1024 } … … 1015 1031 if (!m_comGuestSession.isOk()) 1016 1032 { 1017 appendLog("Guest session is not valid", FileManagerLogType_Error);1033 emit sigLogOutput("Guest session is not valid", m_strTableName, FileManagerLogType_Error); 1018 1034 postGuestSessionClosed(); 1019 1035 return; … … 1026 1042 1027 1043 m_comGuestSession.Close(); 1028 appendLog("Guest session is closed", FileManagerLogType_Info);1044 emit sigLogOutput("Guest session is closed", m_strTableName, FileManagerLogType_Info); 1029 1045 postGuestSessionClosed(); 1030 1046 } 1031 1047 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 1058 1050 void sltCreateGuestSession(QString strUserName, QString strPassword); 1059 1051 void sltCloseGuestSession(); 1060 void sltGuestSessionStateChanged(const CGuestSessionStateChangedEvent &cEvent);1061 void sltCleanupListenerAndGuest();1062 1052 1063 1053 -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.h
r92711 r92733 43 43 class UICustomFileSystemItem; 44 44 class UIFileManagerGuestSessionPanel; 45 class CGuestSessionStateChangedEvent; 45 46 46 47 /** This class scans the guest file system by using the VBox Guest Control API … … 57 58 58 59 UIFileManagerGuestTable(UIActionPool *pActionPool, const CMachine &comMachine, QWidget *pParent = 0); 59 void initGuestFileTable(const CGuestSession &session);60 60 void copyGuestToHost(const QString& hostDestinationPath); 61 61 void copyHostToGuest(const QStringList &hostSourcePathList, … … 91 91 void sltHandleGuestSessionPanelShown(); 92 92 93 void sltGuestSessionUnregistered(CGuestSession guestSession); 94 void sltGuestSessionRegistered(CGuestSession guestSession); 95 void sltGuestSessionStateChanged(const CGuestSessionStateChangedEvent &cEvent); 96 97 93 98 private: 94 99 … … 108 113 CEventListener &comEventListener, 109 114 CEventSource comEventSource); 115 void cleanupGuestListener(); 116 110 117 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(); 111 129 112 130 CGuest m_comGuest; -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerHostTable.cpp
r92587 r92733 265 265 266 266 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); 268 268 } 269 269 … … 285 285 } 286 286 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); 288 288 } 289 289 } … … 320 320 if (!parentDir.mkdir(directoryName)) 321 321 { 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); 323 323 return false; 324 324 } -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerLogPanel.cpp
r82968 r92733 90 90 } 91 91 92 void UIFileManagerLogPanel::appendLog(const QString &strLog, FileManagerLogType eLogType)92 void UIFileManagerLogPanel::appendLog(const QString &strLog, const QString &strMachineName, FileManagerLogType eLogType) 93 93 { 94 94 if (!m_pLogTextEdit) … … 99 99 strColorTag = "<font color=\"Red\">"; 100 100 } 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>"); 102 102 m_pLogTextEdit->append(strColoredLog); 103 103 } -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerLogPanel.h
r82968 r92733 38 38 39 39 UIFileManagerLogPanel(QWidget *pParent = 0); 40 void appendLog(const QString &str, FileManagerLogType);40 void appendLog(const QString &str, const QString &strMachineName, FileManagerLogType eLogType); 41 41 virtual QString panelName() const /* override */; 42 42 -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerOperationsPanel.cpp
r88793 r92733 52 52 53 53 void sigProgressComplete(QUuid progressId); 54 void sigProgressFail(QString strErrorString, FileManagerLogType eLogType);54 void sigProgressFail(QString strErrorString, QString strSourceTableName, FileManagerLogType eLogType); 55 55 void sigFocusIn(QWidget *pWidget); 56 56 void sigFocusOut(QWidget *pWidget); … … 58 58 public: 59 59 60 UIFileOperationProgressWidget(const CProgress &comProgress, QWidget *pParent = 0);60 UIFileOperationProgressWidget(const CProgress &comProgress, const QString &strSourceTableName, QWidget *pParent = 0); 61 61 ~UIFileOperationProgressWidget(); 62 62 bool isCompleted() const; … … 101 101 QILabel *m_pStatusLabel; 102 102 QILabel *m_pOperationDescriptionLabel; 103 /** Name of the table from which this operation has originated. */ 104 QString m_strSourceTableName; 103 105 }; 104 106 … … 108 110 *********************************************************************************************************************************/ 109 111 110 UIFileOperationProgressWidget::UIFileOperationProgressWidget(const CProgress &comProgress, QWidget *pParent /* = 0 */)112 UIFileOperationProgressWidget::UIFileOperationProgressWidget(const CProgress &comProgress, const QString &strSourceTableName, QWidget *pParent /* = 0 */) 111 113 : QIWithRetranslateUI<QFrame>(pParent) 112 114 , m_eStatus(OperationStatus_NotStarted) … … 118 120 , m_pStatusLabel(0) 119 121 , m_pOperationDescriptionLabel(0) 122 , m_strSourceTableName(strSourceTableName) 120 123 { 121 124 prepare(); … … 276 279 if (!m_comProgress.isOk() || m_comProgress.GetResultCode() != 0) 277 280 { 278 emit sigProgressFail(UIErrorString::formatErrorInfo(m_comProgress), FileManagerLogType_Error);281 emit sigProgressFail(UIErrorString::formatErrorInfo(m_comProgress), m_strSourceTableName, FileManagerLogType_Error); 279 282 m_eStatus = OperationStatus_Failed; 280 283 } … … 319 322 } 320 323 321 void UIFileManagerOperationsPanel::addNewProgress(const CProgress &comProgress )324 void UIFileManagerOperationsPanel::addNewProgress(const CProgress &comProgress, const QString &strSourceTableName) 322 325 { 323 326 if (!m_pContainerLayout) 324 327 return; 325 328 326 UIFileOperationProgressWidget *pOperationsWidget = new UIFileOperationProgressWidget(comProgress );329 UIFileOperationProgressWidget *pOperationsWidget = new UIFileOperationProgressWidget(comProgress, strSourceTableName); 327 330 if (!pOperationsWidget) 328 331 return; -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerOperationsPanel.h
r82968 r92733 49 49 50 50 void sigFileOperationComplete(QUuid progressId); 51 void sigFileOperationFail(QString strErrorString, FileManagerLogType eLogType);51 void sigFileOperationFail(QString strErrorString, QString strSourceTableName, FileManagerLogType eLogType); 52 52 53 53 public: … … 55 55 UIFileManagerOperationsPanel(QWidget *pParent = 0); 56 56 virtual QString panelName() const /* override */; 57 void addNewProgress(const CProgress &comProgress );57 void addNewProgress(const CProgress &comProgress, const QString &strSourceTableName); 58 58 59 59 protected: -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.cpp
r92711 r92733 728 728 } 729 729 730 void UIFileManagerTable::emitLogOutput(const QString& strOutput, FileManagerLogType eLogType)731 {732 emit sigLogOutput(strOutput, eLogType);733 }734 735 730 void UIFileManagerTable::prepareObjects() 736 731 { … … 1208 1203 pItem->setData(strOldName, static_cast<int>(UICustomFileSystemModelColumn_Name)); 1209 1204 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); 1211 1206 } 1212 1207 } … … 1297 1292 if (pRootItem) 1298 1293 { 1299 pRootItem->setData(UI CustomFileSystemModel::tr("Name"), UICustomFileSystemModelColumn_Name);1300 pRootItem->setData(UI CustomFileSystemModel::tr("Size"), UICustomFileSystemModelColumn_Size);1301 pRootItem->setData(UI CustomFileSystemModel::tr("Change Time"), UICustomFileSystemModelColumn_ChangeTime);1302 pRootItem->setData(UI CustomFileSystemModel::tr("Owner"), UICustomFileSystemModelColumn_Owner);1303 pRootItem->setData(UI CustomFileSystemModel::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); 1304 1299 } 1305 1300 if (m_pWarningLabel) 1306 1301 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"); 1307 1303 } 1308 1304 … … 1433 1429 { 1434 1430 foreach (QAction *pAction, m_selectionDependentActions) 1435 {1436 1431 pAction->setEnabled(fIsEnabled); 1437 }1438 1432 } 1439 1433 -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerTable.h
r92710 r92733 136 136 signals: 137 137 138 void sigLogOutput(QString strLog, FileManagerLogType eLogType);138 void sigLogOutput(QString strLog, const QString &strMachineName, FileManagerLogType eLogType); 139 139 void sigDeleteConfirmationOptionChanged(); 140 140 … … 145 145 /** Deletes all the tree nodes */ 146 146 void reset(); 147 void emitLogOutput(const QString& strOutput, FileManagerLogType eLogType);148 147 /** Returns the path of the rootIndex */ 149 148 QString currentDirectoryPath() const; … … 252 251 * Currently only used by the guest side. */ 253 252 QStringList m_copyCutBuffer; 253 /** This name is appended to the log messages which are shown in the log panel. */ 254 QString m_strTableName; 254 255 255 256 private slots: … … 302 303 QILabel *m_pWarningLabel; 303 304 QChar m_pathSeparator; 304 305 305 friend class UICustomFileSystemModel; 306 306 };
Note:
See TracChangeset
for help on using the changeset viewer.