1 | /* $Id: UIFileManagerGuestTable.h 103803 2024-03-12 11:15:18Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIFileManagerGuestTable class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2016-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef FEQT_INCLUDED_SRC_guestctrl_UIFileManagerGuestTable_h
|
---|
29 | #define FEQT_INCLUDED_SRC_guestctrl_UIFileManagerGuestTable_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* Qt includes: */
|
---|
35 | # include <QUuid>
|
---|
36 |
|
---|
37 | /* COM includes: */
|
---|
38 | #include "CEventListener.h"
|
---|
39 | #include "CEventSource.h"
|
---|
40 | #include "CGuest.h"
|
---|
41 | #include "CGuestSession.h"
|
---|
42 | #include "CMachine.h"
|
---|
43 | #include "CSession.h"
|
---|
44 | #include "CConsole.h"
|
---|
45 |
|
---|
46 |
|
---|
47 | /* GUI includes: */
|
---|
48 | #include "UIFileManagerTable.h"
|
---|
49 | #include "UIMainEventListener.h"
|
---|
50 |
|
---|
51 | /* Forward declarations: */
|
---|
52 | class CGuestSessionStateChangedEvent;
|
---|
53 | class UIActionPool;
|
---|
54 | class UIFileSystemItem;
|
---|
55 | class UIGuestSessionWidget;
|
---|
56 |
|
---|
57 | /** This class scans the guest file system by using the VBox Guest Control API
|
---|
58 | * and populates the UIGuestControlFileModel*/
|
---|
59 | class UIFileManagerGuestTable : public UIFileManagerTable
|
---|
60 | {
|
---|
61 | Q_OBJECT;
|
---|
62 |
|
---|
63 | signals:
|
---|
64 |
|
---|
65 | void sigNewFileOperation(const CProgress &comProgress, const QString &strTableName);
|
---|
66 | void sigStateChanged(bool fSessionRunning);
|
---|
67 |
|
---|
68 | public:
|
---|
69 |
|
---|
70 | UIFileManagerGuestTable(UIActionPool *pActionPool, const CMachine &comMachine, QWidget *pParent = 0);
|
---|
71 | ~UIFileManagerGuestTable();
|
---|
72 | void copyGuestToHost(const QString& hostDestinationPath);
|
---|
73 | void copyHostToGuest(const QStringList &hostSourcePathList,
|
---|
74 | const QString &strDestination = QString());
|
---|
75 | QUuid machineId();
|
---|
76 | bool isGuestSessionRunning() const;
|
---|
77 | void setIsCurrent(bool fIsCurrent);
|
---|
78 | virtual bool isWindowsFileSystem() const override final;
|
---|
79 |
|
---|
80 | protected:
|
---|
81 |
|
---|
82 | void retranslateUi() override final;
|
---|
83 | virtual bool readDirectory(const QString& strPath, UIFileSystemItem *parent, bool isStartDir = false) override final;
|
---|
84 | virtual void deleteByItem(UIFileSystemItem *item) override final;
|
---|
85 | virtual void goToHomeDirectory() override final;
|
---|
86 | virtual bool renameItem(UIFileSystemItem *item, const QString &strOldPath) override final;
|
---|
87 | virtual bool createDirectory(const QString &path, const QString &directoryName) override final;
|
---|
88 | virtual QString fsObjectPropertyString() override final;
|
---|
89 | virtual void showProperties() override final;
|
---|
90 | virtual void determineDriveLetters() override final;
|
---|
91 | virtual void determinePathSeparator() override final;
|
---|
92 | virtual void prepareToolbar() override final;
|
---|
93 | virtual void createFileViewContextMenu(const QWidget *pWidget, const QPoint &point) override final;
|
---|
94 | /** @name Copy/Cut guest-to-guest stuff.
|
---|
95 | * @{ */
|
---|
96 | /** Disable/enable paste action depending on the m_eFileOperationType. */
|
---|
97 | virtual void setPasteActionEnabled(bool fEnabled) override final;
|
---|
98 | virtual void pasteCutCopiedObjects() override final;
|
---|
99 | /** @} */
|
---|
100 | virtual void toggleForwardBackwardActions() override final;
|
---|
101 | virtual void setState();
|
---|
102 | virtual void setSessionDependentWidgetsEnabled();
|
---|
103 |
|
---|
104 | private slots:
|
---|
105 |
|
---|
106 | void sltGuestSessionPanelToggled(bool fChecked);
|
---|
107 | void sltGuestSessionUnregistered(CGuestSession guestSession);
|
---|
108 | void sltGuestSessionRegistered(CGuestSession guestSession);
|
---|
109 | void sltGuestSessionStateChanged(const CGuestSessionStateChangedEvent &cEvent);
|
---|
110 | void sltOpenGuestSession(QString strUserName, QString strPassword);
|
---|
111 | void sltHandleCloseSessionRequest();
|
---|
112 | void sltMachineStateChange(const QUuid &uMachineId, const KMachineState state);
|
---|
113 | void sltCommitDataSignalReceived();
|
---|
114 | void sltAdditionsStateChange();
|
---|
115 |
|
---|
116 | private:
|
---|
117 |
|
---|
118 | enum State
|
---|
119 | {
|
---|
120 | State_InvalidMachineReference,
|
---|
121 | State_MachineNotRunning,
|
---|
122 | State_NoGuestAdditions,
|
---|
123 | State_GuestAdditionsTooOld,
|
---|
124 | State_SessionPossible,
|
---|
125 | State_SessionRunning,
|
---|
126 | State_MachinePaused,
|
---|
127 | State_SessionError,
|
---|
128 | State_Max
|
---|
129 | };
|
---|
130 |
|
---|
131 | KFsObjType fileType(const CFsObjInfo &fsInfo);
|
---|
132 | KFsObjType fileType(const CGuestFsObjInfo &fsInfo);
|
---|
133 |
|
---|
134 | void prepareActionConnections();
|
---|
135 | bool checkGuestSession();
|
---|
136 | QString permissionString(const CFsObjInfo &fsInfo);
|
---|
137 | bool isFileObjectHidden(const CFsObjInfo &fsInfo);
|
---|
138 |
|
---|
139 | void prepareListener(ComObjPtr<UIMainEventListenerImpl> &Qtistener,
|
---|
140 | CEventListener &comEventListener,
|
---|
141 | CEventSource comEventSource, QVector<KVBoxEventType>& eventTypes);
|
---|
142 |
|
---|
143 | void cleanupListener(ComObjPtr<UIMainEventListenerImpl> &QtListener,
|
---|
144 | CEventListener &comEventListener,
|
---|
145 | CEventSource comEventSource);
|
---|
146 | void cleanupGuestListener();
|
---|
147 | void cleanupGuestSessionListener();
|
---|
148 | void cleanupConsoleListener();
|
---|
149 | void prepareGuestSessionPanel();
|
---|
150 | bool openGuestSession(const QString& strUserName, const QString& strPassword);
|
---|
151 | void closeGuestSession();
|
---|
152 | bool openMachineSession();
|
---|
153 | bool closeMachineSession();
|
---|
154 | /* Return 0 if GA is not detected, -1 if it is there but older than @p pszMinimumGuestAdditionVersion, and 1 otherwise. */
|
---|
155 | int isGuestAdditionsAvailable(const char* pszMinimumVersion);
|
---|
156 | void setStateAndEnableWidgets();
|
---|
157 |
|
---|
158 | void initFileTable();
|
---|
159 | void cleanAll();
|
---|
160 | void manageConnection(bool fConnect, QAction *pAction, void (UIFileManagerGuestTable::*fptr)(void));
|
---|
161 | CGuest m_comGuest;
|
---|
162 | CGuestSession m_comGuestSession;
|
---|
163 | CSession m_comSession;
|
---|
164 | CMachine m_comMachine;
|
---|
165 | CConsole m_comConsole;
|
---|
166 |
|
---|
167 | ComObjPtr<UIMainEventListenerImpl> m_pQtGuestListener;
|
---|
168 | ComObjPtr<UIMainEventListenerImpl> m_pQtSessionListener;
|
---|
169 | ComObjPtr<UIMainEventListenerImpl> m_pQtConsoleListener;
|
---|
170 | CEventListener m_comSessionListener;
|
---|
171 | CEventListener m_comGuestListener;
|
---|
172 | CEventListener m_comConsoleListener;
|
---|
173 | UIGuestSessionWidget *m_pGuestSessionWidget;
|
---|
174 | /** True if this table is the current table in parents tab widget. */
|
---|
175 | bool m_fIsCurrent;
|
---|
176 | State m_enmState;
|
---|
177 | const char *pszMinimumGuestAdditionVersion;
|
---|
178 | };
|
---|
179 |
|
---|
180 | #endif /* !FEQT_INCLUDED_SRC_guestctrl_UIFileManagerGuestTable_h */
|
---|