aboutsummaryrefslogtreecommitdiff
path: root/launcher/minecraft/auth/MinecraftAccount.h
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2021-12-04 01:18:05 +0100
committerPetr Mrázek <peterix@gmail.com>2021-12-04 01:18:05 +0100
commit3c46d8a412956a759f61ae802c540ef72d00b35d (patch)
treef16564ba6be96b68ba5257a982c144320fff7911 /launcher/minecraft/auth/MinecraftAccount.h
parentffcef673de9fe848a92d23e02a2abed8df16eb9f (diff)
downloadPrismLauncher-3c46d8a412956a759f61ae802c540ef72d00b35d.tar.gz
PrismLauncher-3c46d8a412956a759f61ae802c540ef72d00b35d.tar.bz2
PrismLauncher-3c46d8a412956a759f61ae802c540ef72d00b35d.zip
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.
Diffstat (limited to 'launcher/minecraft/auth/MinecraftAccount.h')
-rw-r--r--launcher/minecraft/auth/MinecraftAccount.h37
1 files changed, 19 insertions, 18 deletions
diff --git a/launcher/minecraft/auth/MinecraftAccount.h b/launcher/minecraft/auth/MinecraftAccount.h
index 459ef903..18f142c4 100644
--- a/launcher/minecraft/auth/MinecraftAccount.h
+++ b/launcher/minecraft/auth/MinecraftAccount.h
@@ -24,6 +24,7 @@
#include <QPixmap>
#include <memory>
+
#include "AuthSession.h"
#include "Usable.h"
#include "AccountData.h"
@@ -50,12 +51,6 @@ struct AccountProfile
bool legacy;
};
-enum AccountStatus
-{
- NotVerified,
- Verified
-};
-
/**
* Object that stores information about a certain Mojang account.
*
@@ -90,15 +85,17 @@ public: /* manipulation */
* Attempt to login. Empty password means we use the token.
* If the attempt fails because we already are performing some task, it returns false.
*/
- shared_qobject_ptr<AccountTask> login(AuthSessionPtr session, QString password);
+ shared_qobject_ptr<AccountTask> login(QString password);
- shared_qobject_ptr<AccountTask> loginMSA(AuthSessionPtr session);
+ shared_qobject_ptr<AccountTask> loginMSA();
- shared_qobject_ptr<AccountTask> refresh(AuthSessionPtr session);
+ shared_qobject_ptr<AccountTask> refresh();
+
+ shared_qobject_ptr<AccountTask> currentTask();
public: /* queries */
QString internalId() const {
- return m_internalId;
+ return data.internalId;
}
QString accountDisplayString() const {
@@ -123,8 +120,6 @@ public: /* queries */
bool isActive() const;
- bool isExpired() const;
-
bool canMigrate() const {
return data.canMigrateToMSA;
}
@@ -133,6 +128,14 @@ public: /* queries */
return data.type == AccountType::MSA;
}
+ bool ownsMinecraft() const {
+ return data.minecraftEntitlement.ownsMinecraft;
+ }
+
+ bool hasProfile() const {
+ return data.profileId().size() != 0;
+ }
+
QString typeString() const {
switch(data.type) {
case AccountType::Mojang: {
@@ -154,8 +157,8 @@ public: /* queries */
QPixmap getFace() const;
- //! Returns whether the account is NotVerified, Verified or Online
- AccountStatus accountStatus() const;
+ //! Returns the current state of the account
+ AccountState accountState() const;
AccountData * accountData() {
return &data;
@@ -163,6 +166,8 @@ public: /* queries */
bool shouldRefresh() const;
+ void fillSession(AuthSessionPtr session);
+
signals:
/**
* This signal is emitted when the account changes
@@ -174,7 +179,6 @@ signals:
// TODO: better signalling for the various possible state changes - especially errors
protected: /* variables */
- QString m_internalId;
AccountData data;
// current task we are executing here
@@ -189,7 +193,4 @@ private
slots:
void authSucceeded();
void authFailed(QString reason);
-
-private:
- void fillSession(AuthSessionPtr session);
};