diff options
Diffstat (limited to 'launcher/minecraft/auth/MinecraftAccount.h')
-rw-r--r-- | launcher/minecraft/auth/MinecraftAccount.h | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/launcher/minecraft/auth/MinecraftAccount.h b/launcher/minecraft/auth/MinecraftAccount.h index 5b0c1ec7..928d3742 100644 --- a/launcher/minecraft/auth/MinecraftAccount.h +++ b/launcher/minecraft/auth/MinecraftAccount.h @@ -27,12 +27,13 @@ #include "AuthSession.h" #include "Usable.h" #include "AccountData.h" +#include "QObjectPtr.h" class Task; class AccountTask; class MinecraftAccount; -typedef std::shared_ptr<MinecraftAccount> MinecraftAccountPtr; +typedef shared_qobject_ptr<MinecraftAccount> MinecraftAccountPtr; Q_DECLARE_METATYPE(MinecraftAccountPtr) /** @@ -63,8 +64,7 @@ enum AccountStatus */ class MinecraftAccount : public QObject, - public Usable, - public std::enable_shared_from_this<MinecraftAccount> + public Usable { Q_OBJECT public: /* construction */ @@ -90,11 +90,11 @@ 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. */ - std::shared_ptr<AccountTask> login(AuthSessionPtr session, QString password = QString()); + shared_qobject_ptr<AccountTask> login(AuthSessionPtr session, QString password); - std::shared_ptr<AccountTask> loginMSA(AuthSessionPtr session); + shared_qobject_ptr<AccountTask> loginMSA(AuthSessionPtr session); - std::shared_ptr<AccountTask> refresh(AuthSessionPtr session); + shared_qobject_ptr<AccountTask> refresh(AuthSessionPtr session); public: /* queries */ QString accountDisplayString() const { @@ -117,6 +117,8 @@ public: /* queries */ return data.profileName(); } + bool isActive() const; + bool canMigrate() const { return data.canMigrateToMSA; } @@ -153,19 +155,23 @@ public: /* queries */ return &data; } + bool shouldRefresh() const; + signals: /** * This signal is emitted when the account changes */ void changed(); + void activityChanged(bool active); + // TODO: better signalling for the various possible state changes - especially errors protected: /* variables */ AccountData data; // current task we are executing here - std::shared_ptr<AccountTask> m_currentTask; + shared_qobject_ptr<AccountTask> m_currentTask; protected: /* methods */ |