2021-07-22 18:15:20 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QList>
|
|
|
|
#include <QVector>
|
2021-08-30 22:55:56 +00:00
|
|
|
#include <QSet>
|
2021-07-22 18:15:20 +00:00
|
|
|
#include <QNetworkReply>
|
|
|
|
#include <QImage>
|
|
|
|
|
|
|
|
#include <katabasis/OAuth2.h>
|
2021-07-26 19:44:11 +00:00
|
|
|
#include "Yggdrasil.h"
|
|
|
|
#include "../AccountData.h"
|
|
|
|
#include "../AccountTask.h"
|
2021-07-22 18:15:20 +00:00
|
|
|
|
2021-07-26 19:44:11 +00:00
|
|
|
class AuthContext : public AccountTask
|
2021-07-22 18:15:20 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2021-07-26 19:44:11 +00:00
|
|
|
explicit AuthContext(AccountData * data, QObject *parent = 0);
|
2021-07-22 18:15:20 +00:00
|
|
|
|
|
|
|
bool isBusy() {
|
2021-07-26 19:44:11 +00:00
|
|
|
return m_activity != Katabasis::Activity::Idle;
|
2021-07-22 18:15:20 +00:00
|
|
|
};
|
|
|
|
Katabasis::Validity validity() {
|
2021-07-26 19:44:11 +00:00
|
|
|
return m_data->validity_;
|
2021-07-22 18:15:20 +00:00
|
|
|
};
|
|
|
|
|
2021-07-26 19:44:11 +00:00
|
|
|
//bool signOut();
|
|
|
|
|
|
|
|
QString getStateMessage() const override;
|
2021-07-22 18:15:20 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void activityChanged(Katabasis::Activity activity);
|
|
|
|
|
|
|
|
private slots:
|
2021-07-26 19:44:11 +00:00
|
|
|
// OAuth-specific callbacks
|
|
|
|
void onOAuthLinkingSucceeded();
|
|
|
|
void onOAuthLinkingFailed();
|
2021-08-22 18:01:18 +00:00
|
|
|
|
2021-07-22 18:15:20 +00:00
|
|
|
void onOAuthActivityChanged(Katabasis::Activity activity);
|
|
|
|
|
2021-07-26 19:44:11 +00:00
|
|
|
// Yggdrasil specific callbacks
|
|
|
|
void onMojangSucceeded();
|
|
|
|
void onMojangFailed();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void initMSA();
|
|
|
|
void initMojang();
|
|
|
|
|
2021-07-22 18:15:20 +00:00
|
|
|
void doUserAuth();
|
2021-08-30 22:55:56 +00:00
|
|
|
Q_SLOT void onUserAuthDone(QNetworkReply::NetworkError, QByteArray, QList<QNetworkReply::RawHeaderPair>);
|
|
|
|
|
|
|
|
void processSTSError(QNetworkReply::NetworkError, QByteArray, QList<QNetworkReply::RawHeaderPair>);
|
2021-07-22 18:15:20 +00:00
|
|
|
|
|
|
|
void doSTSAuthMinecraft();
|
2021-08-30 22:55:56 +00:00
|
|
|
Q_SLOT void onSTSAuthMinecraftDone(QNetworkReply::NetworkError, QByteArray, QList<QNetworkReply::RawHeaderPair>);
|
2021-07-22 18:15:20 +00:00
|
|
|
void doMinecraftAuth();
|
2021-08-30 22:55:56 +00:00
|
|
|
Q_SLOT void onMinecraftAuthDone(QNetworkReply::NetworkError, QByteArray, QList<QNetworkReply::RawHeaderPair>);
|
2021-07-22 18:15:20 +00:00
|
|
|
|
|
|
|
void doSTSAuthGeneric();
|
2021-08-30 22:55:56 +00:00
|
|
|
Q_SLOT void onSTSAuthGenericDone(QNetworkReply::NetworkError, QByteArray, QList<QNetworkReply::RawHeaderPair>);
|
2021-07-22 18:15:20 +00:00
|
|
|
void doXBoxProfile();
|
2021-08-30 22:55:56 +00:00
|
|
|
Q_SLOT void onXBoxProfileDone(QNetworkReply::NetworkError, QByteArray, QList<QNetworkReply::RawHeaderPair>);
|
2021-07-22 18:15:20 +00:00
|
|
|
|
2021-11-10 02:02:51 +00:00
|
|
|
void doEntitlements();
|
|
|
|
Q_SLOT void onEntitlementsDone(QNetworkReply::NetworkError, QByteArray, QList<QNetworkReply::RawHeaderPair>);
|
|
|
|
|
2021-07-22 18:15:20 +00:00
|
|
|
void doMinecraftProfile();
|
2021-08-30 22:55:56 +00:00
|
|
|
Q_SLOT void onMinecraftProfileDone(QNetworkReply::NetworkError, QByteArray, QList<QNetworkReply::RawHeaderPair>);
|
2021-07-22 18:15:20 +00:00
|
|
|
|
2021-08-29 20:55:33 +00:00
|
|
|
void doMigrationEligibilityCheck();
|
2021-08-30 22:55:56 +00:00
|
|
|
Q_SLOT void onMigrationEligibilityCheckDone(QNetworkReply::NetworkError, QByteArray, QList<QNetworkReply::RawHeaderPair>);
|
2021-08-29 20:55:33 +00:00
|
|
|
|
2021-07-22 18:15:20 +00:00
|
|
|
void doGetSkin();
|
2021-08-30 22:55:56 +00:00
|
|
|
Q_SLOT void onSkinDone(QNetworkReply::NetworkError, QByteArray, QList<QNetworkReply::RawHeaderPair>);
|
2021-07-22 18:15:20 +00:00
|
|
|
|
2021-11-10 02:02:51 +00:00
|
|
|
void succeed();
|
|
|
|
|
2021-08-30 22:55:56 +00:00
|
|
|
void failResult(bool & flag);
|
|
|
|
void succeedResult(bool & flag);
|
2021-07-22 18:15:20 +00:00
|
|
|
void checkResult();
|
|
|
|
|
2021-07-26 19:44:11 +00:00
|
|
|
protected:
|
2021-07-22 18:15:20 +00:00
|
|
|
void beginActivity(Katabasis::Activity activity);
|
|
|
|
void finishActivity();
|
|
|
|
void clearTokens();
|
|
|
|
|
2021-07-26 19:44:11 +00:00
|
|
|
protected:
|
|
|
|
Katabasis::OAuth2 *m_oauth2 = nullptr;
|
|
|
|
Yggdrasil *m_yggdrasil = nullptr;
|
|
|
|
|
|
|
|
int m_requestsDone = 0;
|
|
|
|
bool m_xboxProfileSucceeded = false;
|
|
|
|
bool m_mcAuthSucceeded = false;
|
2021-11-10 02:02:51 +00:00
|
|
|
QString entitlementsRequestId;
|
2021-08-30 22:55:56 +00:00
|
|
|
|
|
|
|
QSet<int64_t> stsErrors;
|
|
|
|
bool stsFailed = false;
|
|
|
|
|
2021-07-26 19:44:11 +00:00
|
|
|
Katabasis::Activity m_activity = Katabasis::Activity::Idle;
|
2021-08-22 18:01:18 +00:00
|
|
|
enum class AuthStage {
|
|
|
|
Initial,
|
2021-07-26 19:44:11 +00:00
|
|
|
UserAuth,
|
|
|
|
XboxAuth,
|
|
|
|
MinecraftProfile,
|
2021-08-29 20:55:33 +00:00
|
|
|
MigrationEligibility,
|
2021-08-22 18:01:18 +00:00
|
|
|
Skin,
|
|
|
|
Complete
|
|
|
|
} m_stage = AuthStage::Initial;
|
|
|
|
|
|
|
|
void setStage(AuthStage stage);
|
2021-07-22 18:15:20 +00:00
|
|
|
};
|