summaryrefslogtreecommitdiffstats
path: root/logic/auth
diff options
context:
space:
mode:
authorAndrew <forkk@forkk.net>2013-11-18 12:05:35 -0600
committerAndrew <forkk@forkk.net>2013-11-18 12:05:35 -0600
commitcdca53013990ac85967394529476712e6695bbf9 (patch)
treed251fa7f180280ea0dc2db2ce5213930caf02278 /logic/auth
parentad8aeb0b2bdfd7586beab0be31bc36c64da31092 (diff)
downloadMultiMC-cdca53013990ac85967394529476712e6695bbf9.tar
MultiMC-cdca53013990ac85967394529476712e6695bbf9.tar.gz
MultiMC-cdca53013990ac85967394529476712e6695bbf9.tar.lz
MultiMC-cdca53013990ac85967394529476712e6695bbf9.tar.xz
MultiMC-cdca53013990ac85967394529476712e6695bbf9.zip
Implement account list and account list dialog
Diffstat (limited to 'logic/auth')
-rw-r--r--logic/auth/AuthenticateTask.cpp2
-rw-r--r--logic/auth/AuthenticateTask.h2
-rw-r--r--logic/auth/MojangAccount.cpp10
-rw-r--r--logic/auth/MojangAccount.h9
-rw-r--r--logic/auth/YggdrasilTask.cpp4
-rw-r--r--logic/auth/YggdrasilTask.h9
6 files changed, 27 insertions, 9 deletions
diff --git a/logic/auth/AuthenticateTask.cpp b/logic/auth/AuthenticateTask.cpp
index db4b0d92..a9c2c03f 100644
--- a/logic/auth/AuthenticateTask.cpp
+++ b/logic/auth/AuthenticateTask.cpp
@@ -26,7 +26,7 @@
#include "logger/QsLog.h"
-AuthenticateTask::AuthenticateTask(MojangAccount* account, const QString& password, QObject* parent) :
+AuthenticateTask::AuthenticateTask(MojangAccountPtr account, const QString& password, QObject* parent) :
YggdrasilTask(account, parent), m_password(password)
{
}
diff --git a/logic/auth/AuthenticateTask.h b/logic/auth/AuthenticateTask.h
index 4169ad5f..54a6b79a 100644
--- a/logic/auth/AuthenticateTask.h
+++ b/logic/auth/AuthenticateTask.h
@@ -29,7 +29,7 @@ class AuthenticateTask : public YggdrasilTask
{
Q_OBJECT
public:
- AuthenticateTask(MojangAccount* account, const QString& password, QObject* parent=0);
+ AuthenticateTask(MojangAccountPtr account, const QString& password, QObject* parent=0);
protected:
virtual QJsonObject getRequestContent() const;
diff --git a/logic/auth/MojangAccount.cpp b/logic/auth/MojangAccount.cpp
index 8856047e..936046fb 100644
--- a/logic/auth/MojangAccount.cpp
+++ b/logic/auth/MojangAccount.cpp
@@ -41,6 +41,16 @@ MojangAccount::MojangAccount(const QString& username, const QString& clientToken
m_currentProfile = -1;
}
+MojangAccount::MojangAccount(const MojangAccount& other, QObject* parent)
+{
+ m_username = other.username();
+ m_clientToken = other.clientToken();
+ m_accessToken = other.accessToken();
+
+ m_profiles = other.m_profiles;
+ m_currentProfile = other.m_currentProfile;
+}
+
QString MojangAccount::username() const
{
diff --git a/logic/auth/MojangAccount.h b/logic/auth/MojangAccount.h
index c5a26736..a38cb8f7 100644
--- a/logic/auth/MojangAccount.h
+++ b/logic/auth/MojangAccount.h
@@ -19,6 +19,7 @@
#include <QString>
#include <QList>
+#include <memory>
/**
* Class that represents a profile within someone's Mojang account.
@@ -65,6 +66,11 @@ public:
*/
explicit MojangAccount(const QString& username, const QString& clientToken, const QString& accessToken, QObject* parent = 0);
+ /**
+ * Constructs a new MojangAccount matching the given account.
+ */
+ MojangAccount(const MojangAccount& other, QObject* parent);
+
/**
* This MojangAccount's username. May be an email address if the account is migrated.
@@ -124,3 +130,6 @@ protected:
ProfileList m_profiles; // List of available profiles.
};
+typedef std::shared_ptr<MojangAccount> MojangAccountPtr;
+Q_DECLARE_METATYPE(MojangAccountPtr)
+
diff --git a/logic/auth/YggdrasilTask.cpp b/logic/auth/YggdrasilTask.cpp
index a023b07e..39dfb749 100644
--- a/logic/auth/YggdrasilTask.cpp
+++ b/logic/auth/YggdrasilTask.cpp
@@ -25,7 +25,7 @@
#include <MultiMC.h>
#include <logic/auth/MojangAccount.h>
-YggdrasilTask::YggdrasilTask(MojangAccount* account, QObject* parent) : Task(parent)
+YggdrasilTask::YggdrasilTask(MojangAccountPtr account, QObject* parent) : Task(parent)
{
m_error = nullptr;
m_account = account;
@@ -175,7 +175,7 @@ YggdrasilTask::Error *YggdrasilTask::getError() const
return this->m_error;
}
-MojangAccount* YggdrasilTask::getMojangAccount() const
+MojangAccountPtr YggdrasilTask::getMojangAccount() const
{
return this->m_account;
}
diff --git a/logic/auth/YggdrasilTask.h b/logic/auth/YggdrasilTask.h
index 64632d44..6aebae16 100644
--- a/logic/auth/YggdrasilTask.h
+++ b/logic/auth/YggdrasilTask.h
@@ -20,8 +20,7 @@
#include <QString>
#include <QJsonObject>
-
-class MojangAccount;
+#include "logic/auth/MojangAccount.h"
class QNetworkReply;
@@ -33,7 +32,7 @@ class YggdrasilTask : public Task
{
Q_OBJECT
public:
- explicit YggdrasilTask(MojangAccount* account, QObject* parent=0);
+ explicit YggdrasilTask(MojangAccountPtr account, QObject* parent=0);
~YggdrasilTask();
/**
@@ -61,7 +60,7 @@ public:
/**
* Gets the Mojang account that this task is operating on.
*/
- virtual MojangAccount* getMojangAccount() const;
+ virtual MojangAccountPtr getMojangAccount() const;
/**
* Returns a pointer to a YggdrasilTask::Error object if an error has occurred.
@@ -117,7 +116,7 @@ protected:
*/
virtual QString getStateMessage(const State state) const;
- MojangAccount* m_account;
+ MojangAccountPtr m_account;
QNetworkReply* m_netReply;