GH-4071 Heavily refactor and rearchitect account system

This makes the account system much more modular
and makes it treat errors as something recoverable,
unless they come directly from the MSA refresh token
becoming invalid.
This commit is contained in:
Petr Mrázek
2021-12-04 01:18:05 +01:00
parent ffcef673de
commit 3c46d8a412
68 changed files with 2105 additions and 1446 deletions

View File

@@ -67,6 +67,8 @@ public:
MinecraftAccountPtr getAccountByProfileName(const QString &profileName) const;
QStringList profileNames() const;
void requestRefresh(QString accountId);
/*!
* Sets the path to load/save the list file from/to.
* If autosave is true, this list will automatically save to the given path whenever it changes.
@@ -85,10 +87,20 @@ public:
void setDefaultAccount(MinecraftAccountPtr profileId);
bool anyAccountIsValid();
bool isActive() const;
protected:
void beginActivity();
void endActivity();
private:
const char* m_name;
uint32_t m_activityCount = 0;
signals:
void listChanged();
void listActivityChanged();
void defaultAccountChanged();
void activityChanged(bool active);
public slots:
/**
@@ -101,7 +113,23 @@ public slots:
*/
void accountActivityChanged(bool active);
/**
* This is initially to run background account refresh tasks, or on a hourly timer
*/
void fillQueue();
private slots:
void tryNext();
void authSucceeded();
void authFailed(QString reason);
protected:
QList<QString> m_refreshQueue;
QTimer *m_refreshTimer;
QTimer *m_nextTimer;
shared_qobject_ptr<AccountTask> m_currentTask;
/*!
* Called whenever the list changes.
* This emits the listChanged() signal and autosaves the list (if autosave is enabled).