MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / fetchFinished

Method fetchFinished

Telegram/SourceFiles/storage/localstorage.cpp:1363–1389  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1361}
1362
1363void CustomLangPack::fetchFinished() {
1364 if (!_chkReply) return;
1365
1366 QString langPackBaseId = Lang::GetInstance().baseId();
1367 QString langPackId = Lang::GetInstance().id();
1368 auto statusCode = _chkReply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
1369
1370 if (statusCode == 404 && !langPackId.isEmpty() && !langPackBaseId.isEmpty() && !needFallback) {
1371 LOG(("64Gram Language pack not found! Fallback to main language: %1...").arg(langPackBaseId));
1372 needFallback = true;
1373 _chkReply->disconnect();
1374 fetchCustomLangPack("", langPackBaseId);
1375 }
1376 else {
1377 QByteArray result = _chkReply->readAll().trimmed();
1378 QJsonParseError error{};
1379 QJsonDocument str = QJsonDocument::fromJson(result, &error);
1380 if (error.error == QJsonParseError::NoError) {
1381 parseLangFile(str);
1382 } else {
1383 LOG(("Incorrect JSON File. Fallback to default language: English..."));
1384 loadDefaultLangFile();
1385 }
1386
1387 _chkReply = nullptr;
1388 }
1389}
1390
1391void CustomLangPack::fetchError(QNetworkReply::NetworkError e) {
1392 LOG(("Network error: %1").arg(e));

Callers

nothing calls this directly

Calls 3

baseIdMethod · 0.80
idMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected