File indexing completed on 2024-04-28 08:51:02

0001 /*
0002     SPDX-FileCopyrightText: 2018 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
0003     Work sponsored by the LiMux project of the city of Munich
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef VNCSSHTUNNELTHREAD_H
0009 #define VNCSSHTUNNELTHREAD_H
0010 
0011 #include <QThread>
0012 
0013 #include <QByteArray>
0014 #include <QString>
0015 
0016 #include <atomic>
0017 
0018 #include <libssh/libssh.h>
0019 
0020 class VncSshTunnelThread : public QThread
0021 {
0022     Q_OBJECT
0023 public:
0024     VncSshTunnelThread(const QByteArray &host, int vncPort, int tunnelPort, int sshPort, const QByteArray &sshUserName, bool loopback);
0025     ~VncSshTunnelThread() override;
0026 
0027     enum PasswordOrigin {
0028         PasswordFromWallet,
0029         PasswordFromDialog
0030     };
0031 
0032     enum PasswordRequestFlags {
0033         NoFlags,
0034         IgnoreWallet
0035     };
0036 
0037     int tunnelPort() const;
0038 
0039     QString password() const;
0040     void setPassword(const QString &password, PasswordOrigin origin);
0041     void userCanceledPasswordRequest();
0042 
0043     void run() override;
0044 
0045 Q_SIGNALS:
0046     void passwordRequest(PasswordRequestFlags flags);
0047     void listenReady();
0048     void errorMessage(const QString &message);
0049 
0050 private:
0051     QByteArray m_host;
0052     int m_vncPort;
0053     int m_tunnelPort;
0054     int m_sshPort;
0055     QByteArray m_sshUserName;
0056     bool m_loopback;
0057     QString m_password;
0058     PasswordOrigin m_passwordOrigin;
0059     bool m_passwordRequestCanceledByUser;
0060 
0061     std::atomic_bool m_stop_thread;
0062 };
0063 
0064 #endif