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

Function parseMinecraftEntitlements

launcher/minecraft/auth/Parsers.cpp:390–423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

388}
389
390bool parseMinecraftEntitlements(QByteArray & data, MinecraftEntitlement &output) {
391 qDebug() << "Parsing Minecraft entitlements...";
392#ifndef NDEBUG
393 qDebug() << data;
394#endif
395
396 QJsonParseError jsonError;
397 QJsonDocument doc = QJsonDocument::fromJson(data, &jsonError);
398 if(jsonError.error) {
399 qWarning() << "Failed to parse response from user.auth.xboxlive.com as JSON: " << jsonError.errorString();
400 return false;
401 }
402
403 auto obj = doc.object();
404 output.canPlayMinecraft = false;
405 output.ownsMinecraft = false;
406
407 auto itemsArray = obj.value("items").toArray();
408 for(auto item: itemsArray) {
409 auto itemObj = item.toObject();
410 QString name;
411 if(!getString(itemObj.value("name"), name)) {
412 continue;
413 }
414 if(name == "game_minecraft") {
415 output.canPlayMinecraft = true;
416 }
417 if(name == "product_minecraft") {
418 output.ownsMinecraft = true;
419 }
420 }
421 output.validity = Katabasis::Validity::Certain;
422 return true;
423}
424
425bool parseRolloutResponse(QByteArray & data, bool& result) {
426 qDebug() << "Parsing Rollout response...";

Callers 1

onRequestDoneMethod · 0.85

Calls 3

fromJsonFunction · 0.85
getStringFunction · 0.85
objectMethod · 0.80

Tested by

no test coverage detected