mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-24 05:17:46 +00:00
Move LauncherCore::mgr to private, add accessor function instead
This commit is contained in:
parent
5be109e60b
commit
f0d1e1bcbe
9 changed files with 26 additions and 21 deletions
|
@ -73,8 +73,7 @@ class LauncherCore : public QObject
|
|||
public:
|
||||
LauncherCore();
|
||||
|
||||
QNetworkAccessManager *mgr;
|
||||
|
||||
QNetworkAccessManager *mgr();
|
||||
LauncherSettings *settings();
|
||||
ProfileManager *profileManager();
|
||||
AccountManager *accountManager();
|
||||
|
@ -190,6 +189,7 @@ private:
|
|||
SquareBoot *m_squareBoot = nullptr;
|
||||
SquareLauncher *m_squareLauncher = nullptr;
|
||||
|
||||
QNetworkAccessManager *m_mgr = nullptr;
|
||||
Headline *m_headline = nullptr;
|
||||
LauncherSettings *m_settings = nullptr;
|
||||
|
||||
|
|
|
@ -238,14 +238,14 @@ void Account::fetchAvatar()
|
|||
QNetworkRequest request(url);
|
||||
Utility::printRequest(QStringLiteral("GET"), request);
|
||||
|
||||
const auto reply = m_launcher.mgr->get(request);
|
||||
const auto reply = m_launcher.mgr()->get(request);
|
||||
connect(reply, &QNetworkReply::finished, [this, filename, reply] {
|
||||
auto document = QJsonDocument::fromJson(reply->readAll());
|
||||
if (document.isObject()) {
|
||||
const QNetworkRequest avatarRequest(document.object()[QLatin1String("Character")].toObject()[QLatin1String("Avatar")].toString());
|
||||
Utility::printRequest(QStringLiteral("GET"), avatarRequest);
|
||||
|
||||
auto avatarReply = m_launcher.mgr->get(avatarRequest);
|
||||
auto avatarReply = m_launcher.mgr()->get(avatarRequest);
|
||||
QObject::connect(avatarReply, &QNetworkReply::finished, [this, filename, avatarReply] {
|
||||
QFile file(filename);
|
||||
file.open(QIODevice::ReadWrite);
|
||||
|
|
|
@ -63,7 +63,7 @@ QCoro::Task<bool> AssetUpdater::checkRemoteDalamudAssetVersion()
|
|||
const QNetworkRequest request(dalamudAssetManifestUrl());
|
||||
Utility::printRequest(QStringLiteral("GET"), request);
|
||||
|
||||
const auto reply = launcher.mgr->get(request);
|
||||
const auto reply = launcher.mgr()->get(request);
|
||||
co_await reply;
|
||||
|
||||
if (reply->error() != QNetworkReply::NetworkError::NoError) {
|
||||
|
@ -102,7 +102,7 @@ QCoro::Task<bool> AssetUpdater::checkRemoteDalamudVersion()
|
|||
remoteDalamudVersion.clear();
|
||||
remoteRuntimeVersion.clear();
|
||||
|
||||
const auto reply = launcher.mgr->get(request);
|
||||
const auto reply = launcher.mgr()->get(request);
|
||||
co_await reply;
|
||||
|
||||
if (reply->error() != QNetworkReply::NetworkError::NoError) {
|
||||
|
@ -143,7 +143,7 @@ QCoro::Task<bool> AssetUpdater::installDalamudAssets()
|
|||
const QNetworkRequest assetRequest(assetObject.toObject()[QLatin1String("url")].toString());
|
||||
Utility::printRequest(QStringLiteral("GET"), assetRequest);
|
||||
|
||||
const auto assetReply = launcher.mgr->get(assetRequest);
|
||||
const auto assetReply = launcher.mgr()->get(assetRequest);
|
||||
|
||||
const auto future = QtFuture::connect(assetReply, &QNetworkReply::finished).then([this, assetReply, assetObject] {
|
||||
const QString fileName = assetObject.toObject()[QLatin1String("fileName")].toString();
|
||||
|
@ -186,7 +186,7 @@ QCoro::Task<bool> AssetUpdater::installDalamud()
|
|||
const QNetworkRequest request(remoteDalamudDownloadUrl);
|
||||
Utility::printRequest(QStringLiteral("GET"), request);
|
||||
|
||||
const auto reply = launcher.mgr->get(request);
|
||||
const auto reply = launcher.mgr()->get(request);
|
||||
co_await reply;
|
||||
|
||||
qInfo(ASTRA_LOG) << "Finished downloading Dalamud";
|
||||
|
@ -219,7 +219,7 @@ QCoro::Task<bool> AssetUpdater::installRuntime()
|
|||
const QNetworkRequest request(dotnetRuntimePackageUrl(remoteRuntimeVersion));
|
||||
Utility::printRequest(QStringLiteral("GET"), request);
|
||||
|
||||
const auto reply = launcher.mgr->get(request);
|
||||
const auto reply = launcher.mgr()->get(request);
|
||||
co_await reply;
|
||||
|
||||
qInfo(ASTRA_LOG) << "Finished downloading Dotnet-core";
|
||||
|
@ -235,7 +235,7 @@ QCoro::Task<bool> AssetUpdater::installRuntime()
|
|||
const QNetworkRequest request(dotnetDesktopPackageUrl(remoteRuntimeVersion));
|
||||
Utility::printRequest(QStringLiteral("GET"), request);
|
||||
|
||||
const auto reply = launcher.mgr->get(request);
|
||||
const auto reply = launcher.mgr()->get(request);
|
||||
co_await reply;
|
||||
|
||||
qInfo(ASTRA_LOG) << "Finished downloading Dotnet-desktop";
|
||||
|
|
|
@ -30,7 +30,7 @@ void GameInstaller::installGame()
|
|||
|
||||
QNetworkRequest request((QUrl(installerUrl)));
|
||||
|
||||
auto reply = m_launcher.mgr->get(request);
|
||||
auto reply = m_launcher.mgr()->get(request);
|
||||
Utility::printRequest(QStringLiteral("GET"), request);
|
||||
|
||||
QObject::connect(reply, &QNetworkReply::finished, [this, reply, installDirectory] {
|
||||
|
|
|
@ -413,7 +413,7 @@ void LauncherCore::readInitialInformation()
|
|||
LauncherCore::LauncherCore()
|
||||
{
|
||||
m_settings = new LauncherSettings(this);
|
||||
mgr = new QNetworkAccessManager(this);
|
||||
m_mgr = new QNetworkAccessManager(this);
|
||||
m_sapphireLauncher = new SapphireLauncher(*this, this);
|
||||
m_squareLauncher = new SquareLauncher(*this, this);
|
||||
m_squareBoot = new SquareBoot(*this, *m_squareLauncher, this);
|
||||
|
@ -580,7 +580,7 @@ QCoro::Task<> LauncherCore::fetchNews()
|
|||
.toUtf8());
|
||||
Utility::printRequest(QStringLiteral("GET"), request);
|
||||
|
||||
auto reply = mgr->get(request);
|
||||
auto reply = mgr()->get(request);
|
||||
co_await reply;
|
||||
|
||||
auto document = QJsonDocument::fromJson(reply->readAll());
|
||||
|
@ -689,3 +689,8 @@ LauncherSettings *LauncherCore::settings()
|
|||
{
|
||||
return m_settings;
|
||||
}
|
||||
|
||||
QNetworkAccessManager *LauncherCore::mgr()
|
||||
{
|
||||
return m_mgr;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ QCoro::Task<bool> Patcher::patch(const PatchList &patchList)
|
|||
const auto patchRequest = QNetworkRequest(patch.url);
|
||||
Utility::printRequest(QStringLiteral("GET"), patchRequest);
|
||||
|
||||
auto patchReply = m_launcher.mgr->get(patchRequest);
|
||||
auto patchReply = m_launcher.mgr()->get(patchRequest);
|
||||
|
||||
connect(patchReply, &QNetworkReply::downloadProgress, this, [this, queuedPatch](int received, int total) {
|
||||
Q_EMIT m_launcher.stageChanged(i18n("Updating %1.\nDownloading %2", getBaseString(), queuedPatch.getVersion()));
|
||||
|
|
|
@ -25,7 +25,7 @@ void SapphireLauncher::login(const QString &lobbyUrl, const LoginInformation &in
|
|||
request.setHeader(QNetworkRequest::ContentTypeHeader, QByteArrayLiteral("application/x-www-form-urlencoded"));
|
||||
Utility::printRequest(QStringLiteral("POST"), request);
|
||||
|
||||
const auto reply = window.mgr->post(request, QJsonDocument(data).toJson(QJsonDocument::JsonFormat::Compact));
|
||||
const auto reply = window.mgr()->post(request, QJsonDocument(data).toJson(QJsonDocument::JsonFormat::Compact));
|
||||
|
||||
connect(reply, &QNetworkReply::finished, [this, reply, &info] {
|
||||
if (reply->error() != QNetworkReply::NetworkError::NoError) {
|
||||
|
@ -58,7 +58,7 @@ void SapphireLauncher::registerAccount(const QString &lobbyUrl, const LoginInfor
|
|||
|
||||
Utility::printRequest(QStringLiteral("POST"), request);
|
||||
|
||||
const auto reply = window.mgr->post(request, QJsonDocument(data).toJson(QJsonDocument::JsonFormat::Compact));
|
||||
const auto reply = window.mgr()->post(request, QJsonDocument(data).toJson(QJsonDocument::JsonFormat::Compact));
|
||||
connect(reply, &QNetworkReply::finished, [&] {
|
||||
const QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ QCoro::Task<> SquareBoot::bootCheck(const LoginInformation &info)
|
|||
request.setRawHeader(QByteArrayLiteral("Host"), QStringLiteral("patch-bootver.%1").arg(window.settings()->squareEnixServer()).toUtf8());
|
||||
Utility::printRequest(QStringLiteral("GET"), request);
|
||||
|
||||
const auto reply = window.mgr->get(request);
|
||||
const auto reply = window.mgr()->get(request);
|
||||
co_await reply;
|
||||
|
||||
const QString patchList = reply->readAll();
|
||||
|
@ -81,7 +81,7 @@ QCoro::Task<> SquareBoot::checkGateStatus(const LoginInformation &info)
|
|||
|
||||
Utility::printRequest(QStringLiteral("GET"), request);
|
||||
|
||||
const auto reply = window.mgr->get(request);
|
||||
const auto reply = window.mgr()->get(request);
|
||||
window.setupIgnoreSSL(reply);
|
||||
co_await reply;
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ QCoro::Task<std::optional<SquareLauncher::StoredInfo>> SquareLauncher::getStored
|
|||
|
||||
Utility::printRequest(QStringLiteral("GET"), request);
|
||||
|
||||
const auto reply = window.mgr->get(request);
|
||||
const auto reply = window.mgr()->get(request);
|
||||
co_await reply;
|
||||
|
||||
const QString str = reply->readAll();
|
||||
|
@ -128,7 +128,7 @@ QCoro::Task<> SquareLauncher::login(const LoginInformation &info)
|
|||
|
||||
Utility::printRequest(QStringLiteral("POST"), request);
|
||||
|
||||
const auto reply = window.mgr->post(request, postData.toString(QUrl::FullyEncoded).toUtf8());
|
||||
const auto reply = window.mgr()->post(request, postData.toString(QUrl::FullyEncoded).toUtf8());
|
||||
window.setupIgnoreSSL(reply);
|
||||
co_await reply;
|
||||
|
||||
|
@ -190,7 +190,7 @@ QCoro::Task<> SquareLauncher::registerSession(const LoginInformation &info)
|
|||
|
||||
Utility::printRequest(QStringLiteral("POST"), request);
|
||||
|
||||
const auto reply = window.mgr->post(request, report.toUtf8());
|
||||
const auto reply = window.mgr()->post(request, report.toUtf8());
|
||||
co_await reply;
|
||||
|
||||
if (reply->error() == QNetworkReply::NoError) {
|
||||
|
|
Loading…
Add table
Reference in a new issue