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

Method getModDescription

launcher/modplatform/flame/FlameAPI.cpp:72–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72QString FlameAPI::getModDescription(int modId)
73{
74 QEventLoop lock;
75 QString description;
76
77 auto netJob = makeShared<NetJob>(QString("Flame::ModDescription"), APPLICATION->network());
78 auto response = std::make_shared<QByteArray>();
79 netJob->addNetAction(Net::ApiDownload::makeByteArray(
80 QString("https://api.curseforge.com/v1/mods/%1/description").arg(QString::number(modId)), response));
81
82 QObject::connect(netJob.get(), &NetJob::succeeded, [&netJob, response, &description] {
83 QJsonParseError parse_error{};
84 QJsonDocument doc = QJsonDocument::fromJson(*response, &parse_error);
85 if (parse_error.error != QJsonParseError::NoError) {
86 qWarning() << "Error while parsing JSON response from Flame::ModDescription at " << parse_error.offset
87 << " reason: " << parse_error.errorString();
88 qWarning() << *response;
89
90 netJob->failed(parse_error.errorString());
91 return;
92 }
93
94 description = Json::ensureString(doc.object(), "data");
95 });
96
97 QObject::connect(netJob.get(), &NetJob::finished, [&lock] { lock.quit(); });
98
99 netJob->start();
100 lock.exec();
101
102 return description;
103}
104
105QList<ModPlatform::IndexedVersion> FlameAPI::getLatestVersions(VersionSearchArgs&& args)
106{

Callers 2

loadBodyMethod · 0.80
updateUiMethod · 0.80

Calls 10

QStringClass · 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