diff options
Diffstat (limited to 'launcher/minecraft')
-rw-r--r-- | launcher/minecraft/auth/AccountData.cpp | 78 | ||||
-rw-r--r-- | launcher/minecraft/auth/AccountData.h | 4 | ||||
-rw-r--r-- | launcher/minecraft/auth/AccountTask.h | 4 | ||||
-rw-r--r-- | launcher/minecraft/auth/flows/AuthContext.cpp | 123 | ||||
-rw-r--r-- | launcher/minecraft/auth/flows/AuthContext.h | 14 | ||||
-rw-r--r-- | launcher/minecraft/services/CapeChange.cpp | 67 | ||||
-rw-r--r-- | launcher/minecraft/services/CapeChange.h | 32 |
7 files changed, 225 insertions, 97 deletions
diff --git a/launcher/minecraft/auth/AccountData.cpp b/launcher/minecraft/auth/AccountData.cpp index 77c73c1b..5c6de9df 100644 --- a/launcher/minecraft/auth/AccountData.cpp +++ b/launcher/minecraft/auth/AccountData.cpp @@ -78,8 +78,8 @@ void profileToJSONV3(QJsonObject &parent, MinecraftProfile p, const char * token QJsonObject out; out["id"] = QJsonValue(p.id); out["name"] = QJsonValue(p.name); - if(p.currentCape != -1) { - out["cape"] = p.capes[p.currentCape].id; + if(!p.currentCape.isEmpty()) { + out["cape"] = p.currentCape; } { @@ -155,41 +155,53 @@ MinecraftProfile profileFromJSONV3(const QJsonObject &parent, const char * token } } - auto capesV = tokenObject.value("capes"); - if(!capesV.isArray()) { - qWarning() << "capes is not an array!"; - return MinecraftProfile(); - } - auto capesArray = capesV.toArray(); - for(auto capeV: capesArray) { - if(!capeV.isObject()) { - qWarning() << "cape is not an object!"; - return MinecraftProfile(); - } - auto capeObj = capeV.toObject(); - auto idV = capeObj.value("id"); - auto urlV = capeObj.value("url"); - auto aliasV = capeObj.value("alias"); - if(!idV.isString() || !urlV.isString() || !aliasV.isString()) { - qWarning() << "mandatory skin attributes are missing or of unexpected type"; + { + auto capesV = tokenObject.value("capes"); + if(!capesV.isArray()) { + qWarning() << "capes is not an array!"; return MinecraftProfile(); } - Cape cape; - cape.id = idV.toString(); - cape.url = urlV.toString(); - cape.alias = aliasV.toString(); - - // data for cape is optional. - auto dataV = capeObj.value("data"); - if(dataV.isString()) { - // TODO: validate base64 - cape.data = QByteArray::fromBase64(dataV.toString().toLatin1()); + auto capesArray = capesV.toArray(); + for(auto capeV: capesArray) { + if(!capeV.isObject()) { + qWarning() << "cape is not an object!"; + return MinecraftProfile(); + } + auto capeObj = capeV.toObject(); + auto idV = capeObj.value("id"); + auto urlV = capeObj.value("url"); + auto aliasV = capeObj.value("alias"); + if(!idV.isString() || !urlV.isString() || !aliasV.isString()) { + qWarning() << "mandatory skin attributes are missing or of unexpected type"; + return MinecraftProfile(); + } + Cape cape; + cape.id = idV.toString(); + cape.url = urlV.toString(); + cape.alias = aliasV.toString(); + + // data for cape is optional. + auto dataV = capeObj.value("data"); + if(dataV.isString()) { + // TODO: validate base64 + cape.data = QByteArray::fromBase64(dataV.toString().toLatin1()); + } + else if (!dataV.isUndefined()) { + qWarning() << "cape data is something unexpected"; + return MinecraftProfile(); + } + out.capes[cape.id] = cape; } - else if (!dataV.isUndefined()) { - qWarning() << "cape data is something unexpected"; - return MinecraftProfile(); + } + // current cape + { + auto capeV = tokenObject.value("cape"); + if(capeV.isString()) { + auto currentCape = capeV.toString(); + if(out.capes.contains(currentCape)) { + out.currentCape = currentCape; + } } - out.capes.push_back(cape); } out.validity = Katabasis::Validity::Assumed; return out; diff --git a/launcher/minecraft/auth/AccountData.h b/launcher/minecraft/auth/AccountData.h index b2d09cb0..cf58fb76 100644 --- a/launcher/minecraft/auth/AccountData.h +++ b/launcher/minecraft/auth/AccountData.h @@ -25,8 +25,8 @@ struct MinecraftProfile { QString id; QString name; Skin skin; - int currentCape = -1; - QVector<Cape> capes; + QString currentCape; + QMap<QString, Cape> capes; Katabasis::Validity validity = Katabasis::Validity::None; }; diff --git a/launcher/minecraft/auth/AccountTask.h b/launcher/minecraft/auth/AccountTask.h index 3f08096f..fc3488eb 100644 --- a/launcher/minecraft/auth/AccountTask.h +++ b/launcher/minecraft/auth/AccountTask.h @@ -83,6 +83,10 @@ public: return m_accountState; } +signals: + void showVerificationUriAndCode(const QUrl &uri, const QString &code, int expiresIn); + void hideVerificationUriAndCode(); + protected: /** diff --git a/launcher/minecraft/auth/flows/AuthContext.cpp b/launcher/minecraft/auth/flows/AuthContext.cpp index 859060d6..ecd7e310 100644 --- a/launcher/minecraft/auth/flows/AuthContext.cpp +++ b/launcher/minecraft/auth/flows/AuthContext.cpp @@ -43,7 +43,7 @@ void AuthContext::finishActivity() { throw 0; } m_activity = Katabasis::Activity::Idle; - m_stage = MSAStage::Idle; + setStage(AuthStage::Complete); m_data->validity_ = m_data->minecraftProfile.validity; emit activityChanged(m_activity); } @@ -55,16 +55,16 @@ void AuthContext::initMSA() { Katabasis::OAuth2::Options opts; opts.scope = "XboxLive.signin offline_access"; opts.clientIdentifier = BuildConfig.MSA_CLIENT_ID; - opts.authorizationUrl = "https://login.live.com/oauth20_authorize.srf"; - opts.accessTokenUrl = "https://login.live.com/oauth20_token.srf"; + opts.authorizationUrl = "https://login.microsoftonline.com/consumers/oauth2/v2.0/devicecode"; + opts.accessTokenUrl = "https://login.microsoftonline.com/consumers/oauth2/v2.0/token"; opts.listenerPorts = {28562, 28563, 28564, 28565, 28566}; m_oauth2 = new OAuth2(opts, m_data->msaToken, this, mgr); + m_oauth2->setGrantFlow(Katabasis::OAuth2::GrantFlowDevice); connect(m_oauth2, &OAuth2::linkingFailed, this, &AuthContext::onOAuthLinkingFailed); connect(m_oauth2, &OAuth2::linkingSucceeded, this, &AuthContext::onOAuthLinkingSucceeded); - connect(m_oauth2, &OAuth2::openBrowser, this, &AuthContext::onOpenBrowser); - connect(m_oauth2, &OAuth2::closeBrowser, this, &AuthContext::onCloseBrowser); + connect(m_oauth2, &OAuth2::showVerificationUriAndCode, this, &AuthContext::showVerificationUriAndCode); connect(m_oauth2, &OAuth2::activityChanged, this, &AuthContext::onOAuthActivityChanged); } @@ -106,20 +106,14 @@ bool AuthContext::signOut() { } */ -void AuthContext::onOpenBrowser(const QUrl &url) { - QDesktopServices::openUrl(url); -} - -void AuthContext::onCloseBrowser() { - -} - void AuthContext::onOAuthLinkingFailed() { + emit hideVerificationUriAndCode(); finishActivity(); changeState(STATE_FAILED_HARD, tr("Microsoft user authentication failed.")); } void AuthContext::onOAuthLinkingSucceeded() { + emit hideVerificationUriAndCode(); auto *o2t = qobject_cast<OAuth2 *>(sender()); if (!o2t->linked()) { finishActivity(); @@ -127,12 +121,14 @@ void AuthContext::onOAuthLinkingSucceeded() { return; } QVariantMap extraTokens = o2t->extraTokens(); +#ifndef NDEBUG if (!extraTokens.isEmpty()) { qDebug() << "Extra tokens in response:"; foreach (QString key, extraTokens.keys()) { qDebug() << "\t" << key << ":" << extraTokens.value(key); } } +#endif doUserAuth(); } @@ -141,7 +137,7 @@ void AuthContext::onOAuthActivityChanged(Katabasis::Activity activity) { } void AuthContext::doUserAuth() { - m_stage = MSAStage::UserAuth; + setStage(AuthStage::UserAuth); changeState(STATE_WORKING, tr("Starting user authentication")); QString xbox_auth_template = R"XXX( @@ -219,35 +215,34 @@ bool getNumber(QJsonValue value, double & out) { // 2148916238 = child account not linked to a family */ -bool parseXTokenResponse(QByteArray & data, Katabasis::Token &output) { +bool parseXTokenResponse(QByteArray & data, Katabasis::Token &output, const char * name) { + qDebug() << "Parsing" << name <<":"; +#ifndef NDEBUG + qDebug() << data; +#endif QJsonParseError jsonError; QJsonDocument doc = QJsonDocument::fromJson(data, &jsonError); if(jsonError.error) { qWarning() << "Failed to parse response from user.auth.xboxlive.com as JSON: " << jsonError.errorString(); - qDebug() << data; return false; } auto obj = doc.object(); if(!getDateTime(obj.value("IssueInstant"), output.issueInstant)) { qWarning() << "User IssueInstant is not a timestamp"; - qDebug() << data; return false; } if(!getDateTime(obj.value("NotAfter"), output.notAfter)) { qWarning() << "User NotAfter is not a timestamp"; - qDebug() << data; return false; } if(!getString(obj.value("Token"), output.token)) { qWarning() << "User Token is not a timestamp"; - qDebug() << data; return false; } auto arrayVal = obj.value("DisplayClaims").toObject().value("xui"); if(!arrayVal.isArray()) { qWarning() << "Missing xui claims array"; - qDebug() << data; return false; } bool foundUHS = false; @@ -266,7 +261,6 @@ bool parseXTokenResponse(QByteArray & data, Katabasis::Token &output) { QString claim; if(!getString(obj.value(iter.key()), claim)) { qWarning() << "display claim " << iter.key() << " is not a string..."; - qDebug() << data; return false; } output.extra[iter.key()] = claim; @@ -276,11 +270,10 @@ bool parseXTokenResponse(QByteArray & data, Katabasis::Token &output) { } if(!foundUHS) { qWarning() << "Missing uhs"; - qDebug() << data; return false; } output.validity = Katabasis::Validity::Certain; - qDebug() << data; + qDebug() << name << "is valid."; return true; } @@ -300,7 +293,7 @@ void AuthContext::onUserAuthDone( } Katabasis::Token temp; - if(!parseXTokenResponse(replyData, temp)) { + if(!parseXTokenResponse(replyData, temp, "UToken")) { qWarning() << "Could not parse user authentication response..."; finishActivity(); changeState(STATE_FAILED_HARD, tr("XBox user authentication response could not be understood.")); @@ -308,7 +301,7 @@ void AuthContext::onUserAuthDone( } m_data->userToken = temp; - m_stage = MSAStage::XboxAuth; + setStage(AuthStage::XboxAuth); changeState(STATE_WORKING, tr("Starting XBox authentication")); doSTSAuthMinecraft(); @@ -349,7 +342,7 @@ void AuthContext::doSTSAuthMinecraft() { connect(requestor, &Requestor::finished, this, &AuthContext::onSTSAuthMinecraftDone); requestor->post(request, xbox_auth_data.toUtf8()); - qDebug() << "Second layer of XBox auth ... commencing."; + qDebug() << "Getting Minecraft services STS token..."; } void AuthContext::onSTSAuthMinecraftDone( @@ -365,7 +358,7 @@ void AuthContext::onSTSAuthMinecraftDone( } Katabasis::Token temp; - if(!parseXTokenResponse(replyData, temp)) { + if(!parseXTokenResponse(replyData, temp, "STSAuthMinecraft")) { qWarning() << "Could not parse authorization response for access to mojang services..."; m_requestsDone ++; return; @@ -405,7 +398,7 @@ void AuthContext::doSTSAuthGeneric() { connect(requestor, &Requestor::finished, this, &AuthContext::onSTSAuthGenericDone); requestor->post(request, xbox_auth_data.toUtf8()); - qDebug() << "Second layer of XBox auth ... commencing."; + qDebug() << "Getting generic STS token..."; } void AuthContext::onSTSAuthGenericDone( @@ -421,7 +414,7 @@ void AuthContext::onSTSAuthGenericDone( } Katabasis::Token temp; - if(!parseXTokenResponse(replyData, temp)) { + if(!parseXTokenResponse(replyData, temp, "STSAuthGaneric")) { qWarning() << "Could not parse authorization response for access to xbox API..."; m_requestsDone ++; return; @@ -461,10 +454,13 @@ void AuthContext::doMinecraftAuth() { namespace { bool parseMojangResponse(QByteArray & data, Katabasis::Token &output) { QJsonParseError jsonError; + qDebug() << "Parsing Mojang response..."; +#ifndef NDEBUG + qDebug() << data; +#endif QJsonDocument doc = QJsonDocument::fromJson(data, &jsonError); if(jsonError.error) { - qWarning() << "Failed to parse response from user.auth.xboxlive.com as JSON: " << jsonError.errorString(); - qDebug() << data; + qWarning() << "Failed to parse response from api.minecraftservices.com/authentication/login_with_xbox as JSON: " << jsonError.errorString(); return false; } @@ -472,7 +468,6 @@ bool parseMojangResponse(QByteArray & data, Katabasis::Token &output) { double expires_in = 0; if(!getNumber(obj.value("expires_in"), expires_in)) { qWarning() << "expires_in is not a valid number"; - qDebug() << data; return false; } auto currentTime = QDateTime::currentDateTimeUtc(); @@ -482,18 +477,16 @@ bool parseMojangResponse(QByteArray & data, Katabasis::Token &output) { QString username; if(!getString(obj.value("username"), username)) { qWarning() << "username is not valid"; - qDebug() << data; return false; } // TODO: it's a JWT... validate it? if(!getString(obj.value("access_token"), output.token)) { qWarning() << "access_token is not valid"; - qDebug() << data; return false; } output.validity = Katabasis::Validity::Certain; - qDebug() << data; + qDebug() << "Mojang response is valid."; return true; } } @@ -508,13 +501,17 @@ void AuthContext::onMinecraftAuthDone( if (error != QNetworkReply::NoError) { qWarning() << "Reply error:" << error; +#ifndef NDEBUG qDebug() << replyData; +#endif return; } if(!parseMojangResponse(replyData, m_data->yggdrasilToken)) { qWarning() << "Could not parse login_with_xbox response..."; +#ifndef NDEBUG qDebug() << replyData; +#endif return; } m_mcAuthSucceeded = true; @@ -558,18 +555,24 @@ void AuthContext::onXBoxProfileDone( if (error != QNetworkReply::NoError) { qWarning() << "Reply error:" << error; +#ifndef NDEBUG qDebug() << replyData; +#endif return; } +#ifndef NDEBUG qDebug() << "XBox profile: " << replyData; +#endif m_xboxProfileSucceeded = true; checkResult(); } void AuthContext::checkResult() { + qDebug() << "AuthContext::checkResult called"; if(m_requestsDone != 2) { + qDebug() << "Number of ready results:" << m_requestsDone; return; } if(m_mcAuthSucceeded && m_xboxProfileSucceeded) { @@ -583,24 +586,26 @@ void AuthContext::checkResult() { namespace { bool parseMinecraftProfile(QByteArray & data, MinecraftProfile &output) { + qDebug() << "Parsing Minecraft profile..."; +#ifndef NDEBUG + qDebug() << data; +#endif + QJsonParseError jsonError; QJsonDocument doc = QJsonDocument::fromJson(data, &jsonError); if(jsonError.error) { qWarning() << "Failed to parse response from user.auth.xboxlive.com as JSON: " << jsonError.errorString(); - qDebug() << data; return false; } auto obj = doc.object(); if(!getString(obj.value("id"), output.id)) { - qWarning() << "minecraft profile id is not a string"; - qDebug() << data; + qWarning() << "Minecraft profile id is not a string"; return false; } if(!getString(obj.value("name"), output.name)) { - qWarning() << "minecraft profile name is not a string"; - qDebug() << data; + qWarning() << "Minecraft profile name is not a string"; return false; } @@ -629,10 +634,9 @@ bool parseMinecraftProfile(QByteArray & data, MinecraftProfile &output) { break; } auto capesArray = obj.value("capes").toArray(); - int i = -1; - int currentCape = -1; + + QString currentCape; for(auto cape: capesArray) { - i++; auto capeObj = cape.toObject(); Cape capeOut; if(!getString(capeObj.value("id"), capeOut.id)) { @@ -643,7 +647,7 @@ bool parseMinecraftProfile(QByteArray & data, MinecraftProfile &output) { continue; } if(state == "ACTIVE") { - currentCape = i; + currentCape = capeOut.id; } if(!getString(capeObj.value("url"), capeOut.url)) { continue; @@ -652,8 +656,7 @@ bool parseMinecraftProfile(QByteArray & data, MinecraftProfile &output) { continue; } - // we deal with only the active skin - output.capes.push_back(capeOut); + output.capes[capeOut.id] = capeOut; } output.currentCape = currentCape; output.validity = Katabasis::Validity::Certain; @@ -662,7 +665,7 @@ bool parseMinecraftProfile(QByteArray & data, MinecraftProfile &output) { } void AuthContext::doMinecraftProfile() { - m_stage = MSAStage::MinecraftProfile; + setStage(AuthStage::MinecraftProfile); changeState(STATE_WORKING, tr("Starting minecraft profile acquisition")); auto url = QUrl("https://api.minecraftservices.com/minecraft/profile"); @@ -683,25 +686,25 @@ void AuthContext::onMinecraftProfileDone(int, QNetworkReply::NetworkError error, if (error == QNetworkReply::ContentNotFoundError) { m_data->minecraftProfile = MinecraftProfile(); finishActivity(); - changeState(STATE_FAILED_HARD, tr("Account is missing a profile")); + changeState(STATE_FAILED_HARD, tr("Account is missing a Minecraft Java profile.\n\nWhile the Microsoft account is valid, it does not own the game.\n\nYou might own Bedrock on this account, but that does not give you access to Java currently.")); return; } if (error != QNetworkReply::NoError) { finishActivity(); - changeState(STATE_FAILED_HARD, tr("Profile acquisition failed")); + changeState(STATE_FAILED_HARD, tr("Minecraft Java profile acquisition failed.")); return; } if(!parseMinecraftProfile(data, m_data->minecraftProfile)) { m_data->minecraftProfile = MinecraftProfile(); finishActivity(); - changeState(STATE_FAILED_HARD, tr("Profile response could not be parsed")); + changeState(STATE_FAILED_HARD, tr("Minecraft Java profile response could not be parsed")); return; } doGetSkin(); } void AuthContext::doGetSkin() { - m_stage = MSAStage::Skin; + setStage(AuthStage::Skin); changeState(STATE_WORKING, tr("Fetching player skin")); auto url = QUrl(m_data->minecraftProfile.skin.url); @@ -721,12 +724,18 @@ void AuthContext::onSkinDone(int, QNetworkReply::NetworkError error, QByteArray changeState(STATE_SUCCEEDED, tr("Finished all authentication steps")); } +void AuthContext::setStage(AuthContext::AuthStage stage) { + m_stage = stage; + emit progress((int)m_stage, (int)AuthStage::Complete); +} + + QString AuthContext::getStateMessage() const { switch (m_accountState) { case STATE_WORKING: switch(m_stage) { - case MSAStage::Idle: { + case AuthStage::Initial: { QString loginMessage = tr("Logging in as %1 user"); if(m_data->type == AccountType::MSA) { return loginMessage.arg("Microsoft"); @@ -735,14 +744,16 @@ QString AuthContext::getStateMessage() const { return loginMessage.arg("Mojang"); } } - case MSAStage::UserAuth: + case AuthStage::UserAuth: return tr("Logging in as XBox user"); - case MSAStage::XboxAuth: + case AuthStage::XboxAuth: return tr("Logging in with XBox and Mojang services"); - case MSAStage::MinecraftProfile: + case AuthStage::MinecraftProfile: return tr("Getting Minecraft profile"); - case MSAStage::Skin: + case AuthStage::Skin: return tr("Getting Minecraft skin"); + case AuthStage::Complete: + return tr("Finished"); default: break; } diff --git a/launcher/minecraft/auth/flows/AuthContext.h b/launcher/minecraft/auth/flows/AuthContext.h index 5f99dba3..1d9f8f72 100644 --- a/launcher/minecraft/auth/flows/AuthContext.h +++ b/launcher/minecraft/auth/flows/AuthContext.h @@ -36,8 +36,7 @@ private slots: // OAuth-specific callbacks void onOAuthLinkingSucceeded(); void onOAuthLinkingFailed(); - void onOpenBrowser(const QUrl &url); - void onCloseBrowser(); + void onOAuthActivityChanged(Katabasis::Activity activity); // Yggdrasil specific callbacks @@ -82,13 +81,16 @@ protected: bool m_xboxProfileSucceeded = false; bool m_mcAuthSucceeded = false; Katabasis::Activity m_activity = Katabasis::Activity::Idle; - enum class MSAStage { - Idle, + enum class AuthStage { + Initial, UserAuth, XboxAuth, MinecraftProfile, - Skin - } m_stage = MSAStage::Idle; + Skin, + Complete + } m_stage = AuthStage::Initial; + + void setStage(AuthStage stage); QNetworkAccessManager *mgr = nullptr; }; diff --git a/launcher/minecraft/services/CapeChange.cpp b/launcher/minecraft/services/CapeChange.cpp new file mode 100644 index 00000000..c1d88d14 --- /dev/null +++ b/launcher/minecraft/services/CapeChange.cpp @@ -0,0 +1,67 @@ +#include "CapeChange.h" +#include <QNetworkRequest> +#include <QHttpMultiPart> +#include <Env.h> + +CapeChange::CapeChange(QObject *parent, AuthSessionPtr session, QString cape) + : Task(parent), m_capeId(cape), m_session(session) +{ +} + +void CapeChange::setCape(QString& cape) { + QNetworkRequest request(QUrl("https://api.minecraftservices.com/minecraft/profile/capes/active")); + auto requestString = QString("{\"capeId\":\"%1\"}").arg(m_capeId); + request.setRawHeader("Authorization", QString("Bearer %1").arg(m_session->access_token).toLocal8Bit()); + QNetworkReply *rep = ENV.qnam().put(request, requestString.toUtf8()); + + setStatus(tr("Equipping cape")); + + m_reply = std::shared_ptr<QNetworkReply>(rep); + connect(rep, &QNetworkReply::uploadProgress, this, &Task::setProgress); + connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError))); + connect(rep, SIGNAL(finished()), this, SLOT(downloadFinished())); +} + +void CapeChange::clearCape() { + QNetworkRequest request(QUrl("https://api.minecraftservices.com/minecraft/profile/capes/active")); + auto requestString = QString("{\"capeId\":\"%1\"}").arg(m_capeId); + request.setRawHeader("Authorization", QString("Bearer %1").arg(m_session->access_token).toLocal8Bit()); + QNetworkReply *rep = ENV.qnam().deleteResource(request); + + setStatus(tr("Removing cape")); + + m_reply = std::shared_ptr<QNetworkReply>(rep); + connect(rep, &QNetworkReply::uploadProgress, this, &Task::setProgress); + connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError))); + connect(rep, SIGNAL(finished()), this, SLOT(downloadFinished())); +} + + +void CapeChange::executeTask() +{ + if(m_capeId.isEmpty()) { + clearCape(); + } + else { + setCape(m_capeId); + } +} + +void CapeChange::downloadError(QNetworkReply::NetworkError error) +{ + // error happened during download. + qCritical() << "Network error: " << error; + emitFailed(m_reply->errorString()); +} + +void CapeChange::downloadFinished() +{ + // if the download failed + if (m_reply->error() != QNetworkReply::NetworkError::NoError) + { + emitFailed(QString("Network error: %1").arg(m_reply->errorString())); + m_reply.reset(); + return; + } + emitSucceeded(); +} diff --git a/launcher/minecraft/services/CapeChange.h b/launcher/minecraft/services/CapeChange.h new file mode 100644 index 00000000..1b6f2f72 --- /dev/null +++ b/launcher/minecraft/services/CapeChange.h @@ -0,0 +1,32 @@ +#pragma once + +#include <QFile> +#include <QtNetwork/QtNetwork> +#include <memory> +#include <minecraft/auth/AuthSession.h> +#include "tasks/Task.h" + +class CapeChange : public Task +{ + Q_OBJECT +public: + CapeChange(QObject *parent, AuthSessionPtr session, QString capeId); + virtual ~CapeChange() {} + +private: + void setCape(QString & cape); + void clearCape(); + +private: + QString m_capeId; + AuthSessionPtr m_session; + std::shared_ptr<QNetworkReply> m_reply; + +protected: + virtual void executeTask(); + +public slots: + void downloadError(QNetworkReply::NetworkError); + void downloadFinished(); +}; + |