39 lines
877 B
C++
39 lines
877 B
C++
#pragma once
|
|
|
|
#include <QObject>
|
|
#include <QProcess>
|
|
#include <QString>
|
|
#include <QTemporaryDir>
|
|
#include <memory>
|
|
|
|
class PasswordManager : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit PasswordManager(QObject* parent = nullptr);
|
|
|
|
public:
|
|
bool password_empty() const;
|
|
bool check_running() const;
|
|
void check_password(const QString& password);
|
|
QString askpass_path();
|
|
void clear_askpass();
|
|
|
|
private:
|
|
QString write_askpass_helper(const QString& password);
|
|
void on_check_finished(int exit_code, QProcess::ExitStatus status);
|
|
void on_check_error(QProcess::ProcessError error);
|
|
|
|
private:
|
|
QString m_password;
|
|
QString m_candidate;
|
|
std::unique_ptr<QTemporaryDir> m_askpass_dir;
|
|
QProcess m_check;
|
|
bool m_check_running = false;
|
|
|
|
signals:
|
|
void password_accepted();
|
|
void password_rejected(const QString& reason);
|
|
};
|