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

Method getVersions

launcher/modplatform/helpers/NetworkModAPI.cpp:55–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55void 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
83auto NetworkModAPI::getProject(QString addonId, QByteArray* response) const -> NetJob*
84{

Callers 1

requestModVersionsMethod · 0.80

Calls 5

QStringClass · 0.85
fromJsonFunction · 0.85
networkMethod · 0.80
addNetActionMethod · 0.80
startMethod · 0.45

Tested by

no test coverage detected