VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.h@ 102493

Last change on this file since 102493 was 102485, checked in by vboxsync, 9 months ago

FE/Qt: bugref:10561. Some refactoring.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.7 KB
Line 
1/* $Id: UIFileManagerGuestTable.h 102485 2023-12-05 17:37:02Z 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 "COMEnums.h"
39#include "CEventListener.h"
40#include "CEventSource.h"
41#include "CGuest.h"
42#include "CGuestSession.h"
43#include "CMachine.h"
44#include "CSession.h"
45#include "CConsole.h"
46
47
48/* GUI includes: */
49#include "UIFileManagerTable.h"
50#include "UIMainEventListener.h"
51
52/* Forward declarations: */
53class CGuestSessionStateChangedEvent;
54class UIActionPool;
55class UIFileSystemItem;
56class UIGuestSessionWidget;
57
58/** This class scans the guest file system by using the VBox Guest Control API
59 * and populates the UIGuestControlFileModel*/
60class UIFileManagerGuestTable : public UIFileManagerTable
61{
62 Q_OBJECT;
63
64signals:
65
66 void sigNewFileOperation(const CProgress &comProgress, const QString &strTableName);
67 void sigStateChanged(bool fSessionRunning);
68
69public:
70
71 UIFileManagerGuestTable(UIActionPool *pActionPool, const CMachine &comMachine, QWidget *pParent = 0);
72 ~UIFileManagerGuestTable();
73 void copyGuestToHost(const QString& hostDestinationPath);
74 void copyHostToGuest(const QStringList &hostSourcePathList,
75 const QString &strDestination = QString());
76 QUuid machineId();
77 bool isGuestSessionRunning() const;
78 void setIsCurrent(bool fIsCurrent);
79
80protected:
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 virtual bool isWindowsFileSystem() const override final;
104
105private slots:
106
107 void sltGuestSessionPanelToggled(bool fChecked);
108 void sltGuestSessionUnregistered(CGuestSession guestSession);
109 void sltGuestSessionRegistered(CGuestSession guestSession);
110 void sltGuestSessionStateChanged(const CGuestSessionStateChangedEvent &cEvent);
111 void sltOpenGuestSession(QString strUserName, QString strPassword);
112 void sltHandleCloseSessionRequest();
113 void sltMachineStateChange(const QUuid &uMachineId, const KMachineState state);
114 void sltCommitDataSignalReceived();
115 void sltAdditionsStateChange();
116
117private:
118
119 enum State
120 {
121 State_InvalidMachineReference,
122 State_MachineNotRunning,
123 State_NoGuestAdditions,
124 State_GuestAdditionsTooOld,
125 State_SessionPossible,
126 State_SessionRunning,
127 State_MachinePaused,
128 State_SessionError,
129 State_Max
130 };
131
132 KFsObjType fileType(const CFsObjInfo &fsInfo);
133 KFsObjType fileType(const CGuestFsObjInfo &fsInfo);
134
135 void prepareActionConnections();
136 bool checkGuestSession();
137 QString permissionString(const CFsObjInfo &fsInfo);
138 bool isFileObjectHidden(const CFsObjInfo &fsInfo);
139
140 void prepareListener(ComObjPtr<UIMainEventListenerImpl> &Qtistener,
141 CEventListener &comEventListener,
142 CEventSource comEventSource, QVector<KVBoxEventType>& eventTypes);
143
144 void cleanupListener(ComObjPtr<UIMainEventListenerImpl> &QtListener,
145 CEventListener &comEventListener,
146 CEventSource comEventSource);
147 void cleanupGuestListener();
148 void cleanupGuestSessionListener();
149 void cleanupConsoleListener();
150 void prepareGuestSessionPanel();
151 bool openGuestSession(const QString& strUserName, const QString& strPassword);
152 void closeGuestSession();
153 bool openMachineSession();
154 bool closeMachineSession();
155 /* Return 0 if GA is not detected, -1 if it is there but older than @p pszMinimumGuestAdditionVersion, and 1 otherwise. */
156 int isGuestAdditionsAvailable(const char* pszMinimumVersion);
157 void setStateAndEnableWidgets();
158
159 void initFileTable();
160 void cleanAll();
161 void manageConnection(bool fConnect, QAction *pAction, void (UIFileManagerGuestTable::*fptr)(void));
162 CGuest m_comGuest;
163 CGuestSession m_comGuestSession;
164 CSession m_comSession;
165 CMachine m_comMachine;
166 CConsole m_comConsole;
167
168 ComObjPtr<UIMainEventListenerImpl> m_pQtGuestListener;
169 ComObjPtr<UIMainEventListenerImpl> m_pQtSessionListener;
170 ComObjPtr<UIMainEventListenerImpl> m_pQtConsoleListener;
171 CEventListener m_comSessionListener;
172 CEventListener m_comGuestListener;
173 CEventListener m_comConsoleListener;
174 UIGuestSessionWidget *m_pGuestSessionWidget;
175 /** True if this table is the current table in parents tab widget. */
176 bool m_fIsCurrent;
177 State m_enmState;
178 const char *pszMinimumGuestAdditionVersion;
179};
180
181#endif /* !FEQT_INCLUDED_SRC_guestctrl_UIFileManagerGuestTable_h */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle
ContactPrivacy/Do Not Sell My InfoTerms of Use