mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-23 21:07: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">
|
<entry name="SquareEnixLoginServer" type="String">
|
||||||
<default>square-enix.com</default>
|
<default>square-enix.com</default>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry name="PreferredProtocol" type="String">
|
||||||
|
<default>https</default>
|
||||||
|
</entry>
|
||||||
<entry name="AutoLoginProfile" type="String">
|
<entry name="AutoLoginProfile" type="String">
|
||||||
</entry>
|
</entry>
|
||||||
</group>
|
</group>
|
||||||
|
|
|
@ -71,6 +71,7 @@ class LauncherCore : public QObject
|
||||||
Q_PROPERTY(QString dalamudDistribServer READ dalamudDistribServer WRITE setDalamudDistribServer NOTIFY dalamudDistribServerChanged)
|
Q_PROPERTY(QString dalamudDistribServer READ dalamudDistribServer WRITE setDalamudDistribServer NOTIFY dalamudDistribServerChanged)
|
||||||
Q_PROPERTY(QString squareEnixServer READ squareEnixServer WRITE setSquareEnixServer NOTIFY squareEnixServerChanged)
|
Q_PROPERTY(QString squareEnixServer READ squareEnixServer WRITE setSquareEnixServer NOTIFY squareEnixServerChanged)
|
||||||
Q_PROPERTY(QString squareEnixLoginServer READ squareEnixLoginServer WRITE setSquareEnixLoginServer NOTIFY squareEnixLoginServerChanged)
|
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(Headline *headline READ headline NOTIFY newsChanged)
|
||||||
Q_PROPERTY(Profile *currentProfile READ currentProfile WRITE setCurrentProfile NOTIFY currentProfileChanged)
|
Q_PROPERTY(Profile *currentProfile READ currentProfile WRITE setCurrentProfile NOTIFY currentProfileChanged)
|
||||||
Q_PROPERTY(Profile *autoLoginProfile READ autoLoginProfile WRITE setAutoLoginProfile NOTIFY autoLoginProfileChanged)
|
Q_PROPERTY(Profile *autoLoginProfile READ autoLoginProfile WRITE setAutoLoginProfile NOTIFY autoLoginProfileChanged)
|
||||||
|
@ -116,6 +117,8 @@ public:
|
||||||
|
|
||||||
void buildRequest(const Profile &settings, QNetworkRequest &request);
|
void buildRequest(const Profile &settings, QNetworkRequest &request);
|
||||||
void setSSL(QNetworkRequest &request);
|
void setSSL(QNetworkRequest &request);
|
||||||
|
void setupIgnoreSSL(QNetworkReply *reply);
|
||||||
|
|
||||||
void readInitialInformation();
|
void readInitialInformation();
|
||||||
|
|
||||||
[[nodiscard]] bool closeWhenLaunched() const;
|
[[nodiscard]] bool closeWhenLaunched() const;
|
||||||
|
@ -139,6 +142,9 @@ public:
|
||||||
[[nodiscard]] QString squareEnixLoginServer() const;
|
[[nodiscard]] QString squareEnixLoginServer() const;
|
||||||
void setSquareEnixLoginServer(const QString &value);
|
void setSquareEnixLoginServer(const QString &value);
|
||||||
|
|
||||||
|
[[nodiscard]] QString preferredProtocol() const;
|
||||||
|
void setPreferredProtocol(const QString &value);
|
||||||
|
|
||||||
[[nodiscard]] QString autoLoginProfileName() const;
|
[[nodiscard]] QString autoLoginProfileName() const;
|
||||||
[[nodiscard]] Profile *autoLoginProfile() const;
|
[[nodiscard]] Profile *autoLoginProfile() const;
|
||||||
void setAutoLoginProfile(Profile *value);
|
void setAutoLoginProfile(Profile *value);
|
||||||
|
@ -175,6 +181,7 @@ signals:
|
||||||
void dalamudDistribServerChanged();
|
void dalamudDistribServerChanged();
|
||||||
void squareEnixServerChanged();
|
void squareEnixServerChanged();
|
||||||
void squareEnixLoginServerChanged();
|
void squareEnixLoginServerChanged();
|
||||||
|
void preferredProtocolChanged();
|
||||||
void loginError(QString message);
|
void loginError(QString message);
|
||||||
void stageChanged(QString message);
|
void stageChanged(QString message);
|
||||||
void stageIndeterminate();
|
void stageIndeterminate();
|
||||||
|
|
|
@ -247,7 +247,7 @@ static const QMap<Profile::DalamudChannel, QString> channelToDistribPrefix = {{P
|
||||||
QUrl AssetUpdater::dalamudVersionManifestUrl(const Profile::DalamudChannel channel) const
|
QUrl AssetUpdater::dalamudVersionManifestUrl(const Profile::DalamudChannel channel) const
|
||||||
{
|
{
|
||||||
QUrl url;
|
QUrl url;
|
||||||
url.setScheme(QStringLiteral("https"));
|
url.setScheme(launcher.preferredProtocol());
|
||||||
url.setHost(launcher.dalamudDistribServer());
|
url.setHost(launcher.dalamudDistribServer());
|
||||||
url.setPath(QStringLiteral("/dalamud-distrib/%1version").arg(channelToDistribPrefix[channel]));
|
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 AssetUpdater::dalamudLatestPackageUrl(Profile::DalamudChannel channel) const
|
||||||
{
|
{
|
||||||
QUrl url;
|
QUrl url;
|
||||||
url.setScheme(QStringLiteral("https"));
|
url.setScheme(launcher.preferredProtocol());
|
||||||
url.setHost(launcher.dalamudDistribServer());
|
url.setHost(launcher.dalamudDistribServer());
|
||||||
url.setPath(QStringLiteral("/dalamud-distrib/%1latest.zip").arg(channelToDistribPrefix[channel]));
|
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 AssetUpdater::dalamudAssetManifestUrl() const
|
||||||
{
|
{
|
||||||
QUrl url;
|
QUrl url;
|
||||||
url.setScheme(QStringLiteral("https"));
|
url.setScheme(launcher.preferredProtocol());
|
||||||
url.setHost(launcher.dalamudDistribServer());
|
url.setHost(launcher.dalamudDistribServer());
|
||||||
url.setPath(QStringLiteral("/DalamudAssets/asset.json"));
|
url.setPath(QStringLiteral("/DalamudAssets/asset.json"));
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,15 @@ void LauncherCore::setSSL(QNetworkRequest &request)
|
||||||
request.setSslConfiguration(config);
|
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)
|
void LauncherCore::buildRequest(const Profile &settings, QNetworkRequest &request)
|
||||||
{
|
{
|
||||||
setSSL(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
|
[[nodiscard]] QString LauncherCore::autoLoginProfileName() const
|
||||||
{
|
{
|
||||||
return Config::autoLoginProfile();
|
return Config::autoLoginProfile();
|
||||||
|
@ -629,7 +652,7 @@ QCoro::Task<> LauncherCore::fetchNews()
|
||||||
query.addQueryItem(QStringLiteral("media"), QStringLiteral("pcapp"));
|
query.addQueryItem(QStringLiteral("media"), QStringLiteral("pcapp"));
|
||||||
|
|
||||||
QUrl url;
|
QUrl url;
|
||||||
url.setScheme(QStringLiteral("https"));
|
url.setScheme(preferredProtocol());
|
||||||
url.setHost(QStringLiteral("frontier.%1").arg(squareEnixServer()));
|
url.setHost(QStringLiteral("frontier.%1").arg(squareEnixServer()));
|
||||||
url.setPath(QStringLiteral("/news/headline.json"));
|
url.setPath(QStringLiteral("/news/headline.json"));
|
||||||
url.setQuery(query);
|
url.setQuery(query);
|
||||||
|
|
|
@ -67,7 +67,7 @@ QCoro::Task<> SquareBoot::checkGateStatus(const LoginInformation &info)
|
||||||
qDebug() << "Checking gate...";
|
qDebug() << "Checking gate...";
|
||||||
|
|
||||||
QUrl url;
|
QUrl url;
|
||||||
url.setScheme(QStringLiteral("https"));
|
url.setScheme(window.preferredProtocol());
|
||||||
url.setHost(QStringLiteral("frontier.%1").arg(window.squareEnixServer()));
|
url.setHost(QStringLiteral("frontier.%1").arg(window.squareEnixServer()));
|
||||||
url.setPath(QStringLiteral("/worldStatus/gate_status.json"));
|
url.setPath(QStringLiteral("/worldStatus/gate_status.json"));
|
||||||
url.setQuery(QString::number(QDateTime::currentMSecsSinceEpoch()));
|
url.setQuery(QString::number(QDateTime::currentMSecsSinceEpoch()));
|
||||||
|
@ -78,6 +78,7 @@ QCoro::Task<> SquareBoot::checkGateStatus(const LoginInformation &info)
|
||||||
window.buildRequest(*info.profile, request);
|
window.buildRequest(*info.profile, request);
|
||||||
|
|
||||||
const auto reply = window.mgr->get(request);
|
const auto reply = window.mgr->get(request);
|
||||||
|
window.setupIgnoreSSL(reply);
|
||||||
co_await reply;
|
co_await reply;
|
||||||
|
|
||||||
const QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
|
const QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
|
||||||
|
|
|
@ -57,7 +57,7 @@ QCoro::Task<std::optional<SquareLauncher::StoredInfo>> SquareLauncher::getStored
|
||||||
}
|
}
|
||||||
|
|
||||||
QUrl url;
|
QUrl url;
|
||||||
url.setScheme(QStringLiteral("https"));
|
url.setScheme(window.preferredProtocol());
|
||||||
url.setHost(QStringLiteral("ffxiv-login.%1").arg(window.squareEnixLoginServer()));
|
url.setHost(QStringLiteral("ffxiv-login.%1").arg(window.squareEnixLoginServer()));
|
||||||
url.setPath(QStringLiteral("/oauth/ffxivarr/login/top"));
|
url.setPath(QStringLiteral("/oauth/ffxivarr/login/top"));
|
||||||
url.setQuery(query);
|
url.setQuery(query);
|
||||||
|
@ -124,6 +124,7 @@ QCoro::Task<> SquareLauncher::login(const LoginInformation &info)
|
||||||
request.setRawHeader(QByteArrayLiteral("Cache-Control"), QByteArrayLiteral("no-cache"));
|
request.setRawHeader(QByteArrayLiteral("Cache-Control"), QByteArrayLiteral("no-cache"));
|
||||||
|
|
||||||
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;
|
co_await reply;
|
||||||
|
|
||||||
const QString str = reply->readAll();
|
const QString str = reply->readAll();
|
||||||
|
@ -186,7 +187,14 @@ QCoro::Task<> SquareLauncher::registerSession(const LoginInformation &info)
|
||||||
co_await reply;
|
co_await reply;
|
||||||
|
|
||||||
if (reply->error() == QNetworkReply::NoError) {
|
if (reply->error() == QNetworkReply::NoError) {
|
||||||
|
QString patchUniqueId;
|
||||||
if (reply->rawHeaderList().contains(QByteArrayLiteral("X-Patch-Unique-Id"))) {
|
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();
|
const QString body = reply->readAll();
|
||||||
|
|
||||||
if (!body.isEmpty()) {
|
if (!body.isEmpty()) {
|
||||||
|
@ -199,7 +207,7 @@ QCoro::Task<> SquareLauncher::registerSession(const LoginInformation &info)
|
||||||
patcher->deleteLater();
|
patcher->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
auth.SID = reply->rawHeader(QByteArrayLiteral("X-Patch-Unique-Id"));
|
auth.SID = patchUniqueId;
|
||||||
|
|
||||||
window.launchGame(*info.profile, auth);
|
window.launchGame(*info.profile, auth);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -40,6 +40,19 @@ FormCard.FormCardPage {
|
||||||
FormCard.FormCard {
|
FormCard.FormCard {
|
||||||
Layout.fillWidth: true
|
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 {
|
FormCard.FormTextFieldDelegate {
|
||||||
id: dalamudServerDelegate
|
id: dalamudServerDelegate
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue