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

Method getModDescription

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

Source from the content-addressed store, hash-verified

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

Callers 1

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