1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-20 11:47:46 +00:00

Dynamically grab frontier URL from the existing launcher

Yet another thing we no longer have to worry about updating manually,
at least as often.

Fixes #8
This commit is contained in:
Joshua Goins 2024-06-29 20:08:17 -04:00
parent 8c956d96c2
commit b0b5b2916e
4 changed files with 29 additions and 9 deletions

2
external/libphysis vendored

@ -1 +1 @@
Subproject commit 0b098928db2fb8cfbffdef9b9a420847bdde1e8e
Subproject commit c3ad93addb1204808c680d3dd7db9a2086392a53

View file

@ -135,6 +135,8 @@ public:
[[nodiscard]] int numInstalledExpansions() const;
[[nodiscard]] QString expansionVersion(int index) const;
[[nodiscard]] QString frontierUrl() const;
[[nodiscard]] int dalamudAssetVersion() const;
void setDalamudAssetVersion(int version);
@ -209,6 +211,8 @@ private:
QString m_compatibilityToolVersion;
bool m_dalamudApplicable = false;
QString m_frontierUrl;
bool m_loggedIn = false;
LauncherCore &m_launcher;

View file

@ -406,10 +406,11 @@ QCoro::Task<> LauncherCore::fetchNews()
QNetworkRequest headlineRequest(QUrl(QStringLiteral("%1&%2").arg(headlineUrl.toString(), QString::number(QDateTime::currentMSecsSinceEpoch()))));
headlineRequest.setRawHeader(QByteArrayLiteral("Accept"), QByteArrayLiteral("application/json, text/plain, */*"));
headlineRequest.setRawHeader(QByteArrayLiteral("Origin"), QByteArrayLiteral("https://launcher.finalfantasyxiv.com"));
headlineRequest.setRawHeader(QByteArrayLiteral("Referer"),
QStringLiteral("https://launcher.finalfantasyxiv.com/v600/index.html?rc_lang=%1&time=%2")
.arg(QStringLiteral("en-us"), QDateTime::currentDateTimeUtc().toString(QStringLiteral("yyyy-MM-dd-HH")))
.toUtf8());
headlineRequest.setRawHeader(
QByteArrayLiteral("Referer"),
QStringLiteral("%1/index.html?rc_lang=%2&time=%3")
.arg(currentProfile()->frontierUrl(), QStringLiteral("en-us"), QDateTime::currentDateTimeUtc().toString(QStringLiteral("yyyy-MM-dd-HH")))
.toUtf8());
Utility::printRequest(QStringLiteral("GET"), headlineRequest);
auto headlineReply = mgr()->get(headlineRequest);
@ -424,10 +425,11 @@ QCoro::Task<> LauncherCore::fetchNews()
QNetworkRequest bannerRequest(QUrl(QStringLiteral("%1&_=%3").arg(bannerUrl.toString(), QString::number(QDateTime::currentMSecsSinceEpoch()))));
bannerRequest.setRawHeader(QByteArrayLiteral("Accept"), QByteArrayLiteral("application/json, text/plain, */*"));
bannerRequest.setRawHeader(QByteArrayLiteral("Origin"), QByteArrayLiteral("https://launcher.finalfantasyxiv.com"));
bannerRequest.setRawHeader(QByteArrayLiteral("Referer"),
QStringLiteral("https://launcher.finalfantasyxiv.com/v700/index.html?rc_lang=%1&time=%2")
.arg(QStringLiteral("en-us"), QDateTime::currentDateTimeUtc().toString(QStringLiteral("yyyy-MM-dd-HH")))
.toUtf8());
bannerRequest.setRawHeader(
QByteArrayLiteral("Referer"),
QStringLiteral("%1/v700/index.html?rc_lang=%2&time=%3")
.arg(currentProfile()->frontierUrl(), QStringLiteral("en-us"), QDateTime::currentDateTimeUtc().toString(QStringLiteral("yyyy-MM-dd-HH")))
.toUtf8());
Utility::printRequest(QStringLiteral("GET"), bannerRequest);
auto bannerReply = mgr()->get(bannerRequest);

View file

@ -420,6 +420,10 @@ void Profile::readGameVersion()
readGameData();
}
// Extract frontier url if possible
const QString launcherPath = QString(gamePath() + QStringLiteral("/boot/ffxivlauncher64.exe"));
m_frontierUrl = QString::fromUtf8(physis_extract_frontier_url(launcherPath.toStdString().c_str()));
Q_EMIT gameInstallChanged();
}
@ -533,6 +537,16 @@ QString Profile::expansionVersion(const int index) const
return QString::fromLatin1(m_repositories.repositories[index + 1].version);
}
QString Profile::frontierUrl() const
{
if (m_frontierUrl.isEmpty()) {
// fallback url
return QStringLiteral("https://launcher.finalfantasyxiv.com/v600/");
} else {
return m_frontierUrl;
}
}
int Profile::dalamudAssetVersion() const
{
return m_dalamudAssetVersion;