summaryrefslogtreecommitdiffstats
path: root/logic/auth/MojangAccount.cpp
diff options
context:
space:
mode:
authorAndrew <forkk@forkk.net>2013-11-14 14:32:43 -0600
committerAndrew <forkk@forkk.net>2013-11-14 14:32:43 -0600
commitad8aeb0b2bdfd7586beab0be31bc36c64da31092 (patch)
tree2cafff53b8c1504662770f124341b41954429795 /logic/auth/MojangAccount.cpp
parent9cfd5ae4654a128af5c0ed26d2b1fb0d3a6d96fc (diff)
downloadMultiMC-ad8aeb0b2bdfd7586beab0be31bc36c64da31092.tar
MultiMC-ad8aeb0b2bdfd7586beab0be31bc36c64da31092.tar.gz
MultiMC-ad8aeb0b2bdfd7586beab0be31bc36c64da31092.tar.lz
MultiMC-ad8aeb0b2bdfd7586beab0be31bc36c64da31092.tar.xz
MultiMC-ad8aeb0b2bdfd7586beab0be31bc36c64da31092.zip
Implement auth task's response processing.
The authenticate task can now successfully log a user in.
Diffstat (limited to 'logic/auth/MojangAccount.cpp')
-rw-r--r--logic/auth/MojangAccount.cpp74
1 files changed, 74 insertions, 0 deletions
diff --git a/logic/auth/MojangAccount.cpp b/logic/auth/MojangAccount.cpp
index f796794e..8856047e 100644
--- a/logic/auth/MojangAccount.cpp
+++ b/logic/auth/MojangAccount.cpp
@@ -26,6 +26,8 @@ MojangAccount::MojangAccount(const QString& username, QObject* parent) :
m_clientToken = QUuid::createUuid().toString();
m_username = username;
+
+ m_currentProfile = -1;
}
MojangAccount::MojangAccount(const QString& username, const QString& clientToken,
@@ -35,6 +37,8 @@ MojangAccount::MojangAccount(const QString& username, const QString& clientToken
m_username = username;
m_clientToken = clientToken;
m_accessToken = accessToken;
+
+ m_currentProfile = -1;
}
@@ -48,8 +52,78 @@ QString MojangAccount::clientToken() const
return m_clientToken;
}
+void MojangAccount::setClientToken(const QString& clientToken)
+{
+ m_clientToken = clientToken;
+}
+
+
QString MojangAccount::accessToken() const
{
return m_accessToken;
}
+void MojangAccount::setAccessToken(const QString& accessToken)
+{
+ m_accessToken = accessToken;
+}
+
+
+const QList<AccountProfile> MojangAccount::profiles() const
+{
+ return m_profiles;
+}
+
+const AccountProfile* MojangAccount::currentProfile() const
+{
+ if (m_currentProfile < 0)
+ return nullptr;
+ else
+ return &m_profiles.at(m_currentProfile);
+}
+
+bool MojangAccount::setProfile(const QString& profileId)
+{
+ const QList<AccountProfile>& profiles = this->profiles();
+ for (int i = 0; i < profiles.length(); i++)
+ {
+ if (profiles.at(i).id() == profileId)
+ {
+ m_currentProfile = i;
+ return true;
+ }
+ }
+ return false;
+}
+
+void MojangAccount::loadProfiles(const ProfileList& profiles)
+{
+ m_profiles.clear();
+ for (auto profile : profiles)
+ m_profiles.append(profile);
+}
+
+
+AccountProfile::AccountProfile(const QString& id, const QString& name)
+{
+ m_id = id;
+ m_name = name;
+}
+
+AccountProfile::AccountProfile(const AccountProfile& other)
+{
+ m_id = other.m_id;
+ m_name = other.m_name;
+}
+
+QString AccountProfile::id() const
+{
+ return m_id;
+}
+
+QString AccountProfile::name() const
+{
+ return m_name;
+}
+
+