| 53 | } |
| 54 | |
| 55 | void NetworkModAPI::getVersions(VersionSearchArgs&& args, std::function<void(QJsonDocument&, QString)> callback) const |
| 56 | { |
| 57 | auto netJob = new NetJob(QString("ModVersions(%2)").arg(args.addonId), APPLICATION->network()); |
| 58 | auto response = new QByteArray(); |
| 59 | |
| 60 | netJob->addNetAction(Net::Download::makeByteArray(getVersionsURL(args), response)); |
| 61 | |
| 62 | QObject::connect(netJob, &NetJob::succeeded, [response, callback, args] { |
| 63 | QJsonParseError parse_error{}; |
| 64 | QJsonDocument doc = QJsonDocument::fromJson(*response, &parse_error); |
| 65 | if (parse_error.error != QJsonParseError::NoError) { |
| 66 | qWarning() << "Error while parsing JSON response for getting versions at " << parse_error.offset |
| 67 | << " reason: " << parse_error.errorString(); |
| 68 | qWarning() << *response; |
| 69 | return; |
| 70 | } |
| 71 | |
| 72 | callback(doc, args.addonId); |
| 73 | }); |
| 74 | |
| 75 | QObject::connect(netJob, &NetJob::finished, [response, netJob] { |
| 76 | netJob->deleteLater(); |
| 77 | delete response; |
| 78 | }); |
| 79 | |
| 80 | netJob->start(); |
| 81 | } |
| 82 | |
| 83 | auto NetworkModAPI::getProject(QString addonId, QByteArray* response) const -> NetJob* |
| 84 | { |
no test coverage detected