| 551 | } |
| 552 | |
| 553 | void Backend::resolveAppNames() |
| 554 | { |
| 555 | QStringList ids; |
| 556 | for (const auto &app : m_apps) { |
| 557 | if (app.name.startsWith("App ") && !m_nameCache.contains(app.appId)) |
| 558 | ids.append(QString::number(app.appId)); |
| 559 | } |
| 560 | |
| 561 | if (ids.isEmpty()) { |
| 562 | emit appNamesResolved(); |
| 563 | return; |
| 564 | } |
| 565 | |
| 566 | // IStoreBrowseService/GetItems request |
| 567 | QJsonArray idsArray; |
| 568 | for (const auto &id : ids) { |
| 569 | QJsonObject idObj; |
| 570 | idObj["appid"] = id.toInt(); |
| 571 | idsArray.append(idObj); |
| 572 | } |
| 573 | |
| 574 | QJsonObject contextObj; |
| 575 | contextObj["language"] = "english"; |
| 576 | contextObj["country_code"] = "US"; |
| 577 | |
| 578 | QJsonObject dataRequestObj; |
| 579 | dataRequestObj["include_basic_info"] = true; |
| 580 | dataRequestObj["include_assets"] = true; |
| 581 | |
| 582 | QJsonObject requestObj; |
| 583 | requestObj["ids"] = idsArray; |
| 584 | requestObj["context"] = contextObj; |
| 585 | requestObj["data_request"] = dataRequestObj; |
| 586 | |
| 587 | QString inputJson = QString::fromUtf8(QJsonDocument(requestObj).toJson(QJsonDocument::Compact)); |
| 588 | QString encodedJson = QUrl::toPercentEncoding(inputJson); |
| 589 | QString url = "https://api.steampowered.com/IStoreBrowseService/GetItems/v1?input_json=" + encodedJson; |
| 590 | |
| 591 | QNetworkRequest req{QUrl{url}}; |
| 592 | QNetworkReply *reply = m_nam->get(req); |
| 593 | |
| 594 | connect(reply, &QNetworkReply::finished, this, [this, reply, ids]() { |
| 595 | reply->deleteLater(); |
| 596 | |
| 597 | if (reply->error() != QNetworkReply::NoError) { |
| 598 | emit appNamesResolved(); |
| 599 | return; |
| 600 | } |
| 601 | |
| 602 | QByteArray data = reply->readAll(); |
| 603 | QJsonDocument doc = QJsonDocument::fromJson(data); |
| 604 | QJsonObject root = doc.object(); |
| 605 | QJsonObject response = root["response"].toObject(); |
| 606 | QJsonArray storeItems = response["store_items"].toArray(); |
| 607 | |
| 608 | for (const auto &item : storeItems) { |
| 609 | QJsonObject itemObj = item.toObject(); |
| 610 | uint appId = itemObj["appid"].toInteger(); |
nothing calls this directly
no test coverage detected