#ifndef SSHMANAGER_H
#define SSHMANAGER_H

#include <QObject>
#include <QString>
#include <memory>
#include <libssh/libssh.h>
#include <libssh/sftp.h>

class SSHManager : public QObject
{
    Q_OBJECT

public:
    explicit SSHManager(QObject *parent = nullptr);
    ~SSHManager();

    bool connectToHost(const QString &hostname, const QString &username, const QString &password);
    bool disconnectFromHost();
    bool executeCommand(const QString &command, QString &output);
    bool uploadFile(const QString &localPath, const QString &remotePath);
    bool downloadFile(const QString &remotePath, const QString &localPath);

signals:
    void connectionStatusChanged(bool connected);
    void errorOccurred(const QString &error);

private:
    std::unique_ptr<ssh_session_struct, void(*)(ssh_session)> m_sshSession;
    std::unique_ptr<sftp_session_struct, void(*)(sftp_session)> m_sftpSession;

    bool initializeSFTP();
};

#endif // SSHMANAGER_H

