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

Method getModFileChangelog

launcher/modplatform/flame/FlameAPI.cpp:32–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32auto FlameAPI::getModFileChangelog(int modId, int fileId) -> QString
33{
34 QEventLoop lock;
35 QString changelog;
36
37 auto* netJob = new NetJob(QString("Flame::FileChangelog"), APPLICATION->network());
38 auto* response = new QByteArray();
39 netJob->addNetAction(Net::Download::makeByteArray(
40 QString("https://api.curseforge.com/v1/mods/%1/files/%2/changelog")
41 .arg(QString::fromStdString(std::to_string(modId)), QString::fromStdString(std::to_string(fileId))),
42 response));
43
44 QObject::connect(netJob, &NetJob::succeeded, [netJob, response, &changelog] {
45 QJsonParseError parse_error{};
46 QJsonDocument doc = QJsonDocument::fromJson(*response, &parse_error);
47 if (parse_error.error != QJsonParseError::NoError) {
48 qWarning() << "Error while parsing JSON response from Flame::FileChangelog at " << parse_error.offset
49 << " reason: " << parse_error.errorString();
50 qWarning() << *response;
51
52 netJob->failed(parse_error.errorString());
53 return;
54 }
55
56 changelog = Json::ensureString(doc.object(), "data");
57 });
58
59 QObject::connect(netJob, &NetJob::finished, [response, &lock] {
60 delete response;
61 lock.quit();
62 });
63
64 netJob->start();
65 lock.exec();
66
67 return changelog;
68}
69
70auto FlameAPI::getModDescription(int modId) -> QString
71{

Callers 2

executeTaskMethod · 0.80

Calls 7

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

Tested by

no test coverage detected