[71025] | 1 | /* $Id: UIGuestControlInterface.h 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
| 2 | /** @file
|
---|
| 3 | * VBox Qt GUI - UIGuestControlInterface class declaration.
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[106061] | 7 | * Copyright (C) 2016-2024 Oracle and/or its affiliates.
|
---|
[71025] | 8 | *
|
---|
[96407] | 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
|
---|
[71025] | 26 | */
|
---|
| 27 |
|
---|
[76581] | 28 | #ifndef FEQT_INCLUDED_SRC_guestctrl_UIGuestControlInterface_h
|
---|
| 29 | #define FEQT_INCLUDED_SRC_guestctrl_UIGuestControlInterface_h
|
---|
[76532] | 30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 31 | # pragma once
|
---|
| 32 | #endif
|
---|
[71025] | 33 |
|
---|
| 34 |
|
---|
| 35 | /* Qt includes: */
|
---|
| 36 | #include <QObject>
|
---|
| 37 | #include <QMap>
|
---|
| 38 |
|
---|
| 39 | /* COM includes: */
|
---|
| 40 | #include "CGuest.h"
|
---|
[103803] | 41 | #include "KFsObjType.h"
|
---|
[71025] | 42 |
|
---|
| 43 | class UIGuestControlSubCommandBase;
|
---|
| 44 | class CommandData;
|
---|
[71067] | 45 |
|
---|
| 46 | /** UIGuestControlInterface parses a command string and issues API calls
|
---|
| 47 | accordingly to achive guest control related operations */
|
---|
[71025] | 48 | class UIGuestControlInterface : public QObject
|
---|
| 49 | {
|
---|
| 50 |
|
---|
| 51 | Q_OBJECT;
|
---|
| 52 |
|
---|
| 53 | signals:
|
---|
| 54 |
|
---|
| 55 | void sigOutputString(const QString &strOutput);
|
---|
| 56 |
|
---|
| 57 | public:
|
---|
| 58 |
|
---|
| 59 | UIGuestControlInterface(QObject *parent, const CGuest &comGeust);
|
---|
| 60 | ~UIGuestControlInterface();
|
---|
| 61 |
|
---|
| 62 | /** Receives a command string */
|
---|
| 63 | void putCommand(const QString &strCommand);
|
---|
| 64 |
|
---|
[71169] | 65 | /** @name Some utility functions
|
---|
| 66 | * @{ */
|
---|
| 67 | /** Pass a non-const ref since for some reason CGuest::GetAdditionsStatus
|
---|
| 68 | is non-const?! */
|
---|
[100174] | 69 | static bool isGuestAdditionsAvailable(const CGuest &guest, const char *pszMinimumVersion);
|
---|
[71169] | 70 | static QString getFsObjTypeString(KFsObjType type);
|
---|
| 71 | /** @} */
|
---|
| 72 |
|
---|
[71025] | 73 | private slots:
|
---|
| 74 |
|
---|
| 75 | private:
|
---|
| 76 |
|
---|
| 77 | typedef bool (UIGuestControlInterface::*HandleFuncPtr)(int, char**);
|
---|
| 78 |
|
---|
[71089] | 79 | /** findOrCreateSession parses command options and determines if an existing session
|
---|
| 80 | to be returned or a new one to be created */
|
---|
[71138] | 81 | bool findOrCreateSession(const CommandData &commandData, CGuestSession &outGuestSession);
|
---|
[71169] | 82 | /** Search a valid gurst session among existing ones, assign @p outGuestSession if found and return true */
|
---|
[71138] | 83 | bool findAValidGuestSession(CGuestSession &outGuestSession);
|
---|
[71025] | 84 | bool findSession(const QString& strSessionName, CGuestSession& outSession);
|
---|
| 85 | bool findSession(ULONG strSessionId, CGuestSession& outSession);
|
---|
| 86 | bool createSession(const CommandData &commandData, CGuestSession &outSession);
|
---|
| 87 |
|
---|
| 88 | void prepareSubCommandHandlers();
|
---|
| 89 | bool startProcess(const CommandData &commandData, CGuestSession &guestSession);
|
---|
[71089] | 90 | bool createDirectory(const CommandData &commandData, CGuestSession &guestSession);
|
---|
[71025] | 91 |
|
---|
[71169] | 92 | /** Handles the 'start' process command */
|
---|
[71025] | 93 | bool handleStart(int, char**);
|
---|
| 94 | /* Handles the 'help' process command */
|
---|
| 95 | bool handleHelp(int, char**);
|
---|
[71169] | 96 | /** Handles the 'create' session command */
|
---|
[71067] | 97 | bool handleCreateSession(int, char**);
|
---|
[71169] | 98 | /** Handles the 'mkdir' session command to create guest directories */
|
---|
[71067] | 99 | bool handleMkdir(int, char**);
|
---|
[71135] | 100 | bool handleStat(int, char**);
|
---|
[77839] | 101 | /** Handles the list command and lists all the guest sessions and processes. */
|
---|
| 102 | bool handleList(int, char**);
|
---|
[71169] | 103 | template<typename T>
|
---|
| 104 | QString getFsObjInfoString(const T &fsObjectInfo) const;
|
---|
[71025] | 105 |
|
---|
| 106 | CGuest m_comGuest;
|
---|
| 107 | const QString m_strHelp;
|
---|
[71145] | 108 | QString m_strStatus;
|
---|
[71169] | 109 | /** A map of function pointers to handleXXXX functions */
|
---|
[71025] | 110 | QMap<QString, HandleFuncPtr> m_subCommandHandlers;
|
---|
| 111 | };
|
---|
| 112 |
|
---|
[76581] | 113 | #endif /* !FEQT_INCLUDED_SRC_guestctrl_UIGuestControlInterface_h */
|
---|