MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / getModFileChangelog

Method getModFileChangelog

launcher/modplatform/flame/FlameAPI.cpp:37–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 4

executeTaskMethod · 0.80
suggestVersionMethod · 0.80
checkCandidatesMethod · 0.80

Calls 11

QStringClass · 0.85
fromStdStringFunction · 0.85
networkMethod · 0.80
addNetActionMethod · 0.80
errorStringMethod · 0.80
objectMethod · 0.80
quitMethod · 0.80
getMethod · 0.45
failedMethod · 0.45
startMethod · 0.45
execMethod · 0.45

Tested by

no test coverage detected