Téléverser les fichiers vers "workstation-setup/src"
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QProcess>
|
||||
#include <QString>
|
||||
|
||||
class ProvisioningBackend final : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(bool busy READ busy NOTIFY busyChanged)
|
||||
Q_PROPERTY(bool passwordDone READ passwordDone NOTIFY stateChanged)
|
||||
Q_PROPERTY(bool pinDone READ pinDone NOTIFY stateChanged)
|
||||
Q_PROPERTY(bool complete READ complete NOTIFY stateChanged)
|
||||
Q_PROPERTY(QString currentUser READ currentUser CONSTANT)
|
||||
Q_PROPERTY(QString targetUser READ targetUser CONSTANT)
|
||||
Q_PROPERTY(bool authorizedUser READ authorizedUser CONSTANT)
|
||||
|
||||
public:
|
||||
explicit ProvisioningBackend(QObject *parent = nullptr);
|
||||
|
||||
bool busy() const { return m_busy; }
|
||||
bool passwordDone() const { return m_passwordDone; }
|
||||
bool pinDone() const { return m_pinDone; }
|
||||
bool complete() const { return m_passwordDone && m_pinDone; }
|
||||
QString currentUser() const { return m_currentUser; }
|
||||
QString targetUser() const { return m_targetUser; }
|
||||
bool authorizedUser() const { return m_authorizedUser; }
|
||||
|
||||
Q_INVOKABLE void changePassword(const QString ¤tPassword,
|
||||
const QString &newPassword,
|
||||
const QString &confirmation);
|
||||
|
||||
Q_INVOKABLE void changePin(const QString ¤tPin,
|
||||
const QString &newPin,
|
||||
const QString &confirmation);
|
||||
|
||||
signals:
|
||||
void busyChanged();
|
||||
void stateChanged();
|
||||
void passwordChangeFinished(bool success, const QString &message);
|
||||
void pinChangeFinished(bool success, const QString &message);
|
||||
|
||||
private:
|
||||
enum class Operation {
|
||||
Password,
|
||||
Pin
|
||||
};
|
||||
|
||||
void startHelper(Operation operation,
|
||||
const QString &helperPath,
|
||||
const QString &firstSecret,
|
||||
const QString &secondSecret,
|
||||
const QString &thirdSecret);
|
||||
|
||||
void setBusy(bool busy);
|
||||
void refreshState();
|
||||
bool ensureStateWritable();
|
||||
bool createMarker(const QString &path);
|
||||
QString stateDirectory() const;
|
||||
QString passwordMarker() const;
|
||||
QString pinMarker() const;
|
||||
QString safeMessageForFailure(Operation operation,
|
||||
int exitCode,
|
||||
const QByteArray &stderrData) const;
|
||||
|
||||
static QString effectiveUserName();
|
||||
static void secureClear(QByteArray &data);
|
||||
|
||||
bool m_busy = false;
|
||||
bool m_passwordDone = false;
|
||||
bool m_pinDone = false;
|
||||
bool m_authorizedUser = false;
|
||||
QString m_currentUser;
|
||||
QString m_targetUser;
|
||||
QProcess *m_process = nullptr;
|
||||
Operation m_operation = Operation::Password;
|
||||
};
|
||||
Reference in New Issue
Block a user