2023-05-17 23:28:27 +08:00
|
|
|
#ifndef INSTALLCONTROLLER_H
|
|
|
|
|
#define INSTALLCONTROLLER_H
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
2023-07-18 11:15:04 +09:00
|
|
|
#include <QProcess>
|
2023-05-17 23:28:27 +08:00
|
|
|
|
|
|
|
|
#include "containers/containers_defs.h"
|
2023-06-21 20:56:00 +09:00
|
|
|
#include "core/defs.h"
|
2023-05-17 23:28:27 +08:00
|
|
|
#include "ui/models/containers_model.h"
|
2023-06-21 20:56:00 +09:00
|
|
|
#include "ui/models/servers_model.h"
|
2023-09-08 21:31:47 +08:00
|
|
|
#include "ui/models/protocols_model.h"
|
2023-05-17 23:28:27 +08:00
|
|
|
|
|
|
|
|
class InstallController : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
explicit InstallController(const QSharedPointer<ServersModel> &serversModel,
|
|
|
|
|
const QSharedPointer<ContainersModel> &containersModel,
|
2023-09-08 21:31:47 +08:00
|
|
|
const QSharedPointer<ProtocolsModel> &protocolsModel,
|
2023-06-21 20:56:00 +09:00
|
|
|
const std::shared_ptr<Settings> &settings, QObject *parent = nullptr);
|
2023-07-24 16:31:04 +09:00
|
|
|
~InstallController();
|
2023-05-17 23:28:27 +08:00
|
|
|
|
|
|
|
|
public slots:
|
2023-05-25 15:40:17 +08:00
|
|
|
void install(DockerContainer container, int port, TransportProto transportProto);
|
2023-06-21 20:56:00 +09:00
|
|
|
void setCurrentlyInstalledServerCredentials(const QString &hostName, const QString &userName,
|
|
|
|
|
const QString &secretData);
|
2023-05-17 23:28:27 +08:00
|
|
|
void setShouldCreateServer(bool shouldCreateServer);
|
|
|
|
|
|
2023-06-21 20:56:00 +09:00
|
|
|
void scanServerForInstalledContainers();
|
|
|
|
|
|
2023-07-13 11:29:26 +09:00
|
|
|
void updateContainer(QJsonObject config);
|
|
|
|
|
|
2023-07-31 00:13:08 +09:00
|
|
|
void removeCurrentlyProcessedServer();
|
|
|
|
|
void removeAllContainers();
|
|
|
|
|
void removeCurrentlyProcessedContainer();
|
|
|
|
|
|
2023-06-21 20:56:00 +09:00
|
|
|
QRegularExpression ipAddressPortRegExp();
|
2023-07-31 00:13:08 +09:00
|
|
|
QRegularExpression ipAddressRegExp();
|
2023-06-21 20:56:00 +09:00
|
|
|
|
2023-07-18 11:15:04 +09:00
|
|
|
void mountSftpDrive(const QString &port, const QString &password, const QString &username);
|
|
|
|
|
|
2023-07-31 20:38:13 +09:00
|
|
|
bool checkSshConnection();
|
|
|
|
|
|
2023-08-02 20:37:43 +09:00
|
|
|
void setEncryptedPassphrase(QString passphrase);
|
|
|
|
|
|
2023-08-20 13:36:54 +05:00
|
|
|
void addEmptyServer();
|
|
|
|
|
|
2023-05-17 23:28:27 +08:00
|
|
|
signals:
|
2023-08-16 12:11:34 +05:00
|
|
|
void installContainerFinished(const QString &finishMessage, bool isServiceInstall);
|
2023-08-08 19:10:14 +05:00
|
|
|
void installServerFinished(const QString &finishMessage);
|
2023-06-21 20:56:00 +09:00
|
|
|
|
2023-07-13 11:29:26 +09:00
|
|
|
void updateContainerFinished();
|
|
|
|
|
|
2023-06-21 20:56:00 +09:00
|
|
|
void scanServerFinished(bool isInstalledContainerFound);
|
2023-05-25 15:40:17 +08:00
|
|
|
|
2023-08-08 19:10:14 +05:00
|
|
|
void removeCurrentlyProcessedServerFinished(const QString &finishedMessage);
|
|
|
|
|
void removeAllContainersFinished(const QString &finishedMessage);
|
|
|
|
|
void removeCurrentlyProcessedContainerFinished(const QString &finishedMessage);
|
2023-07-31 00:13:08 +09:00
|
|
|
|
2023-08-08 19:10:14 +05:00
|
|
|
void installationErrorOccurred(const QString &errorMessage);
|
2023-06-21 20:56:00 +09:00
|
|
|
|
|
|
|
|
void serverAlreadyExists(int serverIndex);
|
|
|
|
|
|
2023-08-02 20:37:43 +09:00
|
|
|
void passphraseRequestStarted();
|
|
|
|
|
void passphraseRequestFinished();
|
|
|
|
|
|
2023-08-16 23:48:25 +05:00
|
|
|
void serverIsBusy(const bool isBusy);
|
|
|
|
|
|
2023-05-17 23:28:27 +08:00
|
|
|
private:
|
2023-06-21 20:56:00 +09:00
|
|
|
void installServer(DockerContainer container, QJsonObject &config);
|
|
|
|
|
void installContainer(DockerContainer container, QJsonObject &config);
|
|
|
|
|
bool isServerAlreadyExists();
|
2023-05-17 23:28:27 +08:00
|
|
|
|
|
|
|
|
QSharedPointer<ServersModel> m_serversModel;
|
|
|
|
|
QSharedPointer<ContainersModel> m_containersModel;
|
2023-09-08 21:31:47 +08:00
|
|
|
QSharedPointer<ProtocolsModel> m_protocolModel;
|
2023-05-17 23:28:27 +08:00
|
|
|
std::shared_ptr<Settings> m_settings;
|
|
|
|
|
|
|
|
|
|
ServerCredentials m_currentlyInstalledServerCredentials;
|
|
|
|
|
|
|
|
|
|
bool m_shouldCreateServer;
|
2023-07-18 11:15:04 +09:00
|
|
|
|
2023-08-02 20:37:43 +09:00
|
|
|
QString m_privateKeyPassphrase;
|
|
|
|
|
|
2023-07-31 00:13:08 +09:00
|
|
|
#ifndef Q_OS_IOS
|
2023-07-18 11:15:04 +09:00
|
|
|
QList<QSharedPointer<QProcess>> m_sftpMountProcesses;
|
2023-07-31 00:13:08 +09:00
|
|
|
#endif
|
2023-05-17 23:28:27 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // INSTALLCONTROLLER_H
|