2021-07-22 23:45:20 +05:30
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QList>
|
|
|
|
#include <QVector>
|
|
|
|
#include <QNetworkReply>
|
|
|
|
#include <QImage>
|
|
|
|
|
|
|
|
#include <katabasis/OAuth2.h>
|
2021-07-27 01:14:11 +05:30
|
|
|
#include "Yggdrasil.h"
|
|
|
|
#include "../AccountData.h"
|
|
|
|
#include "../AccountTask.h"
|
2021-07-22 23:45:20 +05:30
|
|
|
|
2021-07-27 01:14:11 +05:30
|
|
|
class AuthContext : public AccountTask
|
2021-07-22 23:45:20 +05:30
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2021-07-27 01:14:11 +05:30
|
|
|
explicit AuthContext(AccountData * data, QObject *parent = 0);
|
2021-07-22 23:45:20 +05:30
|
|
|
|
|
|
|
bool isBusy() {
|
2021-07-27 01:14:11 +05:30
|
|
|
return m_activity != Katabasis::Activity::Idle;
|
2021-07-22 23:45:20 +05:30
|
|
|
};
|
|
|
|
Katabasis::Validity validity() {
|
2021-07-27 01:14:11 +05:30
|
|
|
return m_data->validity_;
|
2021-07-22 23:45:20 +05:30
|
|
|
};
|
|
|
|
|
2021-07-27 01:14:11 +05:30
|
|
|
//bool signOut();
|
|
|
|
|
|
|
|
QString getStateMessage() const override;
|
2021-07-22 23:45:20 +05:30
|
|
|
|
|
|
|
signals:
|
|
|
|
void activityChanged(Katabasis::Activity activity);
|
|
|
|
|
|
|
|
private slots:
|
2021-07-27 01:14:11 +05:30
|
|
|
// OAuth-specific callbacks
|
|
|
|
void onOAuthLinkingSucceeded();
|
|
|
|
void onOAuthLinkingFailed();
|
2021-07-22 23:45:20 +05:30
|
|
|
void onOpenBrowser(const QUrl &url);
|
|
|
|
void onCloseBrowser();
|
|
|
|
void onOAuthActivityChanged(Katabasis::Activity activity);
|
|
|
|
|
2021-07-27 01:14:11 +05:30
|
|
|
// Yggdrasil specific callbacks
|
|
|
|
void onMojangSucceeded();
|
|
|
|
void onMojangFailed();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void initMSA();
|
|
|
|
void initMojang();
|
|
|
|
|
2021-07-22 23:45:20 +05:30
|
|
|
void doUserAuth();
|
|
|
|
Q_SLOT void onUserAuthDone(int, QNetworkReply::NetworkError, QByteArray, QList<QNetworkReply::RawHeaderPair>);
|
|
|
|
|
|
|
|
void doSTSAuthMinecraft();
|
|
|
|
Q_SLOT void onSTSAuthMinecraftDone(int, QNetworkReply::NetworkError, QByteArray, QList<QNetworkReply::RawHeaderPair>);
|
|
|
|
void doMinecraftAuth();
|
|
|
|
Q_SLOT void onMinecraftAuthDone(int, QNetworkReply::NetworkError, QByteArray, QList<QNetworkReply::RawHeaderPair>);
|
|
|
|
|
|
|
|
void doSTSAuthGeneric();
|
|
|
|
Q_SLOT void onSTSAuthGenericDone(int, QNetworkReply::NetworkError, QByteArray, QList<QNetworkReply::RawHeaderPair>);
|
|
|
|
void doXBoxProfile();
|
|
|
|
Q_SLOT void onXBoxProfileDone(int, QNetworkReply::NetworkError, QByteArray, QList<QNetworkReply::RawHeaderPair>);
|
|
|
|
|
|
|
|
void doMinecraftProfile();
|
|
|
|
Q_SLOT void onMinecraftProfileDone(int, QNetworkReply::NetworkError, QByteArray, QList<QNetworkReply::RawHeaderPair>);
|
|
|
|
|
|
|
|
void doGetSkin();
|
|
|
|
Q_SLOT void onSkinDone(int, QNetworkReply::NetworkError, QByteArray, QList<QNetworkReply::RawHeaderPair>);
|
|
|
|
|
|
|
|
void checkResult();
|
|
|
|
|
2021-07-27 01:14:11 +05:30
|
|
|
protected:
|
2021-07-22 23:45:20 +05:30
|
|
|
void beginActivity(Katabasis::Activity activity);
|
|
|
|
void finishActivity();
|
|
|
|
void clearTokens();
|
|
|
|
|
2021-07-27 01:14:11 +05:30
|
|
|
protected:
|
|
|
|
Katabasis::OAuth2 *m_oauth2 = nullptr;
|
|
|
|
Yggdrasil *m_yggdrasil = nullptr;
|
|
|
|
|
|
|
|
int m_requestsDone = 0;
|
|
|
|
bool m_xboxProfileSucceeded = false;
|
|
|
|
bool m_mcAuthSucceeded = false;
|
|
|
|
Katabasis::Activity m_activity = Katabasis::Activity::Idle;
|
|
|
|
enum class MSAStage {
|
|
|
|
Idle,
|
|
|
|
UserAuth,
|
|
|
|
XboxAuth,
|
|
|
|
MinecraftProfile,
|
|
|
|
Skin
|
|
|
|
} m_stage = MSAStage::Idle;
|
2021-07-22 23:45:20 +05:30
|
|
|
|
|
|
|
QNetworkAccessManager *mgr = nullptr;
|
|
|
|
};
|