34 lines
851 B
C++
34 lines
851 B
C++
|
|
#pragma once
|
||
|
|
#include <QString>
|
||
|
|
#include <QJsonObject>
|
||
|
|
#include <QDateTime>
|
||
|
|
|
||
|
|
class LocalStateHelper
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
explicit LocalStateHelper(const QString& baseDir);
|
||
|
|
|
||
|
|
bool loadState(const QString& relativePath = "config/local_state.json");
|
||
|
|
bool saveState() const;
|
||
|
|
bool isLoaded() const;
|
||
|
|
QString errorString() const;
|
||
|
|
|
||
|
|
qint64 maxPolicySeq() const;
|
||
|
|
QDateTime lastSuccessRunAt() const;
|
||
|
|
QDateTime lastOnlineVerifiedAt() const;
|
||
|
|
QString lastSuccessVersion() const;
|
||
|
|
|
||
|
|
bool isPolicySeqRolledBack(qint64 policySeq) const;
|
||
|
|
bool isSystemTimeRewound() const;
|
||
|
|
|
||
|
|
void updateAfterSuccessfulRun(const QString& currentVersion, qint64 policySeq);
|
||
|
|
void updateOnlineVerified(qint64 policySeq);
|
||
|
|
|
||
|
|
private:
|
||
|
|
QString m_baseDir;
|
||
|
|
QString m_filePath;
|
||
|
|
QString m_error;
|
||
|
|
QJsonObject m_state;
|
||
|
|
bool m_loaded = false;
|
||
|
|
};
|