mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-23 12:57:45 +00:00
Add preferred protocol developer setting
This commit is contained in:
parent
abeab75d99
commit
be14785e61
7 changed files with 62 additions and 7 deletions
|
@ -32,6 +32,9 @@ SPDX-License-Identifier: CC0-1.0
|
|||
<entry name="SquareEnixLoginServer" type="String">
|
||||
<default>square-enix.com</default>
|
||||
</entry>
|
||||
<entry name="PreferredProtocol" type="String">
|
||||
<default>https</default>
|
||||
</entry>
|
||||
<entry name="AutoLoginProfile" type="String">
|
||||
</entry>
|
||||
</group>
|
||||
|
|
|
@ -71,6 +71,7 @@ class LauncherCore : public QObject
|
|||
Q_PROPERTY(QString dalamudDistribServer READ dalamudDistribServer WRITE setDalamudDistribServer NOTIFY dalamudDistribServerChanged)
|
||||
Q_PROPERTY(QString squareEnixServer READ squareEnixServer WRITE setSquareEnixServer NOTIFY squareEnixServerChanged)
|
||||
Q_PROPERTY(QString squareEnixLoginServer READ squareEnixLoginServer WRITE setSquareEnixLoginServer NOTIFY squareEnixLoginServerChanged)
|
||||
Q_PROPERTY(QString preferredProtocol READ preferredProtocol WRITE setPreferredProtocol NOTIFY preferredProtocolChanged)
|
||||
Q_PROPERTY(Headline *headline READ headline NOTIFY newsChanged)
|
||||
Q_PROPERTY(Profile *currentProfile READ currentProfile WRITE setCurrentProfile NOTIFY currentProfileChanged)
|
||||
Q_PROPERTY(Profile *autoLoginProfile READ autoLoginProfile WRITE setAutoLoginProfile NOTIFY autoLoginProfileChanged)
|
||||
|
@ -116,6 +117,8 @@ public:
|
|||
|
||||
void buildRequest(const Profile &settings, QNetworkRequest &request);
|
||||
void setSSL(QNetworkRequest &request);
|
||||
void setupIgnoreSSL(QNetworkReply *reply);
|
||||
|
||||
void readInitialInformation();
|
||||
|
||||
[[nodiscard]] bool closeWhenLaunched() const;
|
||||
|
@ -139,6 +142,9 @@ public:
|
|||
[[nodiscard]] QString squareEnixLoginServer() const;
|
||||
void setSquareEnixLoginServer(const QString &value);
|
||||
|
||||
[[nodiscard]] QString preferredProtocol() const;
|
||||
void setPreferredProtocol(const QString &value);
|
||||
|
||||
[[nodiscard]] QString autoLoginProfileName() const;
|
||||
[[nodiscard]] Profile *autoLoginProfile() const;
|
||||
void setAutoLoginProfile(Profile *value);
|
||||
|
@ -175,6 +181,7 @@ signals:
|
|||
void dalamudDistribServerChanged();
|
||||
void squareEnixServerChanged();
|
||||
void squareEnixLoginServerChanged();
|
||||
void preferredProtocolChanged();
|
||||
void loginError(QString message);
|
||||
void stageChanged(QString message);
|
||||
void stageIndeterminate();
|
||||
|
|
|
@ -247,7 +247,7 @@ static const QMap<Profile::DalamudChannel, QString> channelToDistribPrefix = {{P
|
|||
QUrl AssetUpdater::dalamudVersionManifestUrl(const Profile::DalamudChannel channel) const
|
||||
{
|
||||
QUrl url;
|
||||
url.setScheme(QStringLiteral("https"));
|
||||
url.setScheme(launcher.preferredProtocol());
|
||||
url.setHost(launcher.dalamudDistribServer());
|
||||
url.setPath(QStringLiteral("/dalamud-distrib/%1version").arg(channelToDistribPrefix[channel]));
|
||||
|
||||
|
@ -257,7 +257,7 @@ QUrl AssetUpdater::dalamudVersionManifestUrl(const Profile::DalamudChannel chann
|
|||
QUrl AssetUpdater::dalamudLatestPackageUrl(Profile::DalamudChannel channel) const
|
||||
{
|
||||
QUrl url;
|
||||
url.setScheme(QStringLiteral("https"));
|
||||
url.setScheme(launcher.preferredProtocol());
|
||||
url.setHost(launcher.dalamudDistribServer());
|
||||
url.setPath(QStringLiteral("/dalamud-distrib/%1latest.zip").arg(channelToDistribPrefix[channel]));
|
||||
|
||||
|
@ -267,7 +267,7 @@ QUrl AssetUpdater::dalamudLatestPackageUrl(Profile::DalamudChannel channel) cons
|
|||
QUrl AssetUpdater::dalamudAssetManifestUrl() const
|
||||
{
|
||||
QUrl url;
|
||||
url.setScheme(QStringLiteral("https"));
|
||||
url.setScheme(launcher.preferredProtocol());
|
||||
url.setHost(launcher.dalamudDistribServer());
|
||||
url.setPath(QStringLiteral("/DalamudAssets/asset.json"));
|
||||
|
||||
|
|
|
@ -35,6 +35,15 @@ void LauncherCore::setSSL(QNetworkRequest &request)
|
|||
request.setSslConfiguration(config);
|
||||
}
|
||||
|
||||
void LauncherCore::setupIgnoreSSL(QNetworkReply *reply)
|
||||
{
|
||||
if (preferredProtocol() == QStringLiteral("http")) {
|
||||
connect(reply, &QNetworkReply::sslErrors, this, [reply](const QList<QSslError> &errors) {
|
||||
reply->ignoreSslErrors(errors);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void LauncherCore::buildRequest(const Profile &settings, QNetworkRequest &request)
|
||||
{
|
||||
setSSL(request);
|
||||
|
@ -587,6 +596,20 @@ void LauncherCore::setSquareEnixLoginServer(const QString &value)
|
|||
}
|
||||
}
|
||||
|
||||
QString LauncherCore::preferredProtocol() const
|
||||
{
|
||||
return Config::preferredProtocol();
|
||||
}
|
||||
|
||||
void LauncherCore::setPreferredProtocol(const QString &value)
|
||||
{
|
||||
if (value != Config::preferredProtocol()) {
|
||||
Config::setPreferredProtocol(value);
|
||||
Config::self()->save();
|
||||
Q_EMIT preferredProtocolChanged();
|
||||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] QString LauncherCore::autoLoginProfileName() const
|
||||
{
|
||||
return Config::autoLoginProfile();
|
||||
|
@ -629,7 +652,7 @@ QCoro::Task<> LauncherCore::fetchNews()
|
|||
query.addQueryItem(QStringLiteral("media"), QStringLiteral("pcapp"));
|
||||
|
||||
QUrl url;
|
||||
url.setScheme(QStringLiteral("https"));
|
||||
url.setScheme(preferredProtocol());
|
||||
url.setHost(QStringLiteral("frontier.%1").arg(squareEnixServer()));
|
||||
url.setPath(QStringLiteral("/news/headline.json"));
|
||||
url.setQuery(query);
|
||||
|
|
|
@ -67,7 +67,7 @@ QCoro::Task<> SquareBoot::checkGateStatus(const LoginInformation &info)
|
|||
qDebug() << "Checking gate...";
|
||||
|
||||
QUrl url;
|
||||
url.setScheme(QStringLiteral("https"));
|
||||
url.setScheme(window.preferredProtocol());
|
||||
url.setHost(QStringLiteral("frontier.%1").arg(window.squareEnixServer()));
|
||||
url.setPath(QStringLiteral("/worldStatus/gate_status.json"));
|
||||
url.setQuery(QString::number(QDateTime::currentMSecsSinceEpoch()));
|
||||
|
@ -78,6 +78,7 @@ QCoro::Task<> SquareBoot::checkGateStatus(const LoginInformation &info)
|
|||
window.buildRequest(*info.profile, request);
|
||||
|
||||
const auto reply = window.mgr->get(request);
|
||||
window.setupIgnoreSSL(reply);
|
||||
co_await reply;
|
||||
|
||||
const QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
|
||||
|
|
|
@ -57,7 +57,7 @@ QCoro::Task<std::optional<SquareLauncher::StoredInfo>> SquareLauncher::getStored
|
|||
}
|
||||
|
||||
QUrl url;
|
||||
url.setScheme(QStringLiteral("https"));
|
||||
url.setScheme(window.preferredProtocol());
|
||||
url.setHost(QStringLiteral("ffxiv-login.%1").arg(window.squareEnixLoginServer()));
|
||||
url.setPath(QStringLiteral("/oauth/ffxivarr/login/top"));
|
||||
url.setQuery(query);
|
||||
|
@ -124,6 +124,7 @@ QCoro::Task<> SquareLauncher::login(const LoginInformation &info)
|
|||
request.setRawHeader(QByteArrayLiteral("Cache-Control"), QByteArrayLiteral("no-cache"));
|
||||
|
||||
const auto reply = window.mgr->post(request, postData.toString(QUrl::FullyEncoded).toUtf8());
|
||||
window.setupIgnoreSSL(reply);
|
||||
co_await reply;
|
||||
|
||||
const QString str = reply->readAll();
|
||||
|
@ -186,7 +187,14 @@ QCoro::Task<> SquareLauncher::registerSession(const LoginInformation &info)
|
|||
co_await reply;
|
||||
|
||||
if (reply->error() == QNetworkReply::NoError) {
|
||||
QString patchUniqueId;
|
||||
if (reply->rawHeaderList().contains(QByteArrayLiteral("X-Patch-Unique-Id"))) {
|
||||
patchUniqueId = reply->rawHeader(QByteArrayLiteral("X-Patch-Unique-Id"));
|
||||
} else if (reply->rawHeaderList().contains(QByteArrayLiteral("x-patch-unique-id"))) {
|
||||
patchUniqueId = reply->rawHeader(QByteArrayLiteral("x-patch-unique-id"));
|
||||
}
|
||||
|
||||
if (!patchUniqueId.isEmpty()) {
|
||||
const QString body = reply->readAll();
|
||||
|
||||
if (!body.isEmpty()) {
|
||||
|
@ -199,7 +207,7 @@ QCoro::Task<> SquareLauncher::registerSession(const LoginInformation &info)
|
|||
patcher->deleteLater();
|
||||
}
|
||||
|
||||
auth.SID = reply->rawHeader(QByteArrayLiteral("X-Patch-Unique-Id"));
|
||||
auth.SID = patchUniqueId;
|
||||
|
||||
window.launchGame(*info.profile, auth);
|
||||
} else {
|
||||
|
|
|
@ -40,6 +40,19 @@ FormCard.FormCardPage {
|
|||
FormCard.FormCard {
|
||||
Layout.fillWidth: true
|
||||
|
||||
FormCard.FormTextFieldDelegate {
|
||||
id: preferredProtocolDelegate
|
||||
|
||||
label: i18n("Preferred Protocol")
|
||||
text: LauncherCore.preferredProtocol
|
||||
onTextChanged: LauncherCore.preferredProtocol = text
|
||||
}
|
||||
|
||||
FormCard.FormDelegateSeparator {
|
||||
above: preferredProtocolDelegate
|
||||
below: dalamudServerDelegate
|
||||
}
|
||||
|
||||
FormCard.FormTextFieldDelegate {
|
||||
id: dalamudServerDelegate
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue