MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / onRequestDone

Method onRequestDone

launcher/minecraft/auth/steps/MinecraftProfileStep.cpp:35–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33}
34
35void MinecraftProfileStep::onRequestDone(
36 QNetworkReply::NetworkError error,
37 QByteArray data,
38 QList<QNetworkReply::RawHeaderPair> headers
39) {
40 auto requestor = qobject_cast<AuthRequest *>(QObject::sender());
41 requestor->deleteLater();
42
43#ifndef NDEBUG
44 qDebug() << data;
45#endif
46 if (error == QNetworkReply::ContentNotFoundError) {
47 // NOTE: Succeed even if we do not have a profile. This is a valid account state.
48 if(m_data->type == AccountType::Mojang) {
49 m_data->minecraftEntitlement.canPlayMinecraft = false;
50 m_data->minecraftEntitlement.ownsMinecraft = false;
51 }
52 m_data->minecraftProfile = MinecraftProfile();
53 emit finished(
54 AccountTaskState::STATE_SUCCEEDED,
55 tr("Account has no Minecraft profile.")
56 );
57 return;
58 }
59 if (error != QNetworkReply::NoError) {
60 qWarning() << "Error getting profile:";
61 qWarning() << " HTTP Status: " << requestor->httpStatus_;
62 qWarning() << " Internal error no.: " << error;
63 qWarning() << " Error string: " << requestor->errorString_;
64
65 qWarning() << " Response:";
66 qWarning() << QString::fromUtf8(data);
67
68 if (Net::isApplicationError(error)) {
69 emit finished(
70 AccountTaskState::STATE_FAILED_SOFT,
71 tr("Minecraft Java profile acquisition failed: %1").arg(requestor->errorString_)
72 );
73 }
74 else {
75 emit finished(
76 AccountTaskState::STATE_OFFLINE,
77 tr("Minecraft Java profile acquisition failed: %1").arg(requestor->errorString_)
78 );
79 }
80 return;
81 }
82 if(!Parsers::parseMinecraftProfile(data, m_data->minecraftProfile)) {
83 m_data->minecraftProfile = MinecraftProfile();
84 emit finished(
85 AccountTaskState::STATE_FAILED_SOFT,
86 tr("Minecraft Java profile response could not be parsed")
87 );
88 return;
89 }
90
91 if(m_data->type == AccountType::Mojang) {
92 auto validProfile = m_data->minecraftProfile.validity == Katabasis::Validity::Certain;

Callers

nothing calls this directly

Calls 3

MinecraftProfileClass · 0.85
isApplicationErrorFunction · 0.85
parseMinecraftProfileFunction · 0.85

Tested by

no test coverage detected