mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-20 19:57:45 +00:00
Adapt asset launcher, hook into login system
This commit is contained in:
parent
37119f01b9
commit
019933a103
2 changed files with 28 additions and 33 deletions
|
@ -45,7 +45,7 @@ void AssetUpdater::update()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// dialog = new QProgressDialog("Updating assets...", "Cancel", 0, 0);
|
Q_EMIT launcher.stageChanged("Updating assets...");
|
||||||
|
|
||||||
// first, we want to collect all of the remote versions
|
// first, we want to collect all of the remote versions
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ void AssetUpdater::update()
|
||||||
|
|
||||||
auto reply = launcher.mgr->get(request);
|
auto reply = launcher.mgr->get(request);
|
||||||
connect(reply, &QNetworkReply::finished, [reply, this] {
|
connect(reply, &QNetworkReply::finished, [reply, this] {
|
||||||
// dialog->setLabelText("Checking for Dalamud asset updates...");
|
Q_EMIT launcher.stageChanged("Checking for Dalamud asset updates...");
|
||||||
|
|
||||||
// TODO: handle asset failure
|
// TODO: handle asset failure
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(reply->readAll());
|
QJsonDocument doc = QJsonDocument::fromJson(reply->readAll());
|
||||||
|
@ -93,7 +93,7 @@ void AssetUpdater::update()
|
||||||
|
|
||||||
auto reply = launcher.mgr->get(request);
|
auto reply = launcher.mgr->get(request);
|
||||||
connect(reply, &QNetworkReply::finished, [this, reply] {
|
connect(reply, &QNetworkReply::finished, [this, reply] {
|
||||||
// dialog->setLabelText("Checking for Dalamud updates...");
|
Q_EMIT launcher.stageChanged("Checking for Dalamud updates...");
|
||||||
|
|
||||||
QByteArray str = reply->readAll();
|
QByteArray str = reply->readAll();
|
||||||
// for some god forsaken reason, the version string comes back as raw
|
// for some god forsaken reason, the version string comes back as raw
|
||||||
|
@ -153,9 +153,6 @@ void AssetUpdater::beginInstall()
|
||||||
|
|
||||||
void AssetUpdater::checkIfDalamudAssetsDone()
|
void AssetUpdater::checkIfDalamudAssetsDone()
|
||||||
{
|
{
|
||||||
// if (dialog->wasCanceled())
|
|
||||||
// return;
|
|
||||||
|
|
||||||
if (dalamudAssetNeededFilenames.empty()) {
|
if (dalamudAssetNeededFilenames.empty()) {
|
||||||
qInfo() << "Finished downloading Dalamud assets.";
|
qInfo() << "Finished downloading Dalamud assets.";
|
||||||
|
|
||||||
|
@ -172,16 +169,10 @@ void AssetUpdater::checkIfDalamudAssetsDone()
|
||||||
|
|
||||||
void AssetUpdater::checkIfFinished()
|
void AssetUpdater::checkIfFinished()
|
||||||
{
|
{
|
||||||
// if (dialog->wasCanceled())
|
|
||||||
// return;
|
|
||||||
|
|
||||||
if (doneDownloadingDalamud && doneDownloadingRuntimeCore && doneDownloadingRuntimeDesktop && dalamudAssetNeededFilenames.empty()) {
|
if (doneDownloadingDalamud && doneDownloadingRuntimeCore && doneDownloadingRuntimeDesktop && dalamudAssetNeededFilenames.empty()) {
|
||||||
if (needsRuntimeInstall || needsDalamudInstall) {
|
if (needsRuntimeInstall || needsDalamudInstall) {
|
||||||
beginInstall();
|
beginInstall();
|
||||||
} else {
|
} else {
|
||||||
// dialog->setLabelText("Finished!");
|
|
||||||
// dialog->close();
|
|
||||||
|
|
||||||
finishedUpdating();
|
finishedUpdating();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,9 +180,6 @@ void AssetUpdater::checkIfFinished()
|
||||||
|
|
||||||
void AssetUpdater::checkIfCheckingIsDone()
|
void AssetUpdater::checkIfCheckingIsDone()
|
||||||
{
|
{
|
||||||
// if (dialog->wasCanceled())
|
|
||||||
// return;
|
|
||||||
|
|
||||||
if (remoteDalamudVersion.isEmpty() || remoteRuntimeVersion.isEmpty() || remoteDalamudAssetVersion == -1) {
|
if (remoteDalamudVersion.isEmpty() || remoteRuntimeVersion.isEmpty() || remoteDalamudAssetVersion == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -199,7 +187,7 @@ void AssetUpdater::checkIfCheckingIsDone()
|
||||||
// now that we got all the information we need, let's check if anything is
|
// now that we got all the information we need, let's check if anything is
|
||||||
// updateable
|
// updateable
|
||||||
|
|
||||||
// dialog->setLabelText("Starting update...");
|
Q_EMIT launcher.stageChanged("Starting Dalamud update...");
|
||||||
|
|
||||||
// dalamud injector / net runtime
|
// dalamud injector / net runtime
|
||||||
if (m_profile.runtimeVersion != remoteRuntimeVersion) {
|
if (m_profile.runtimeVersion != remoteRuntimeVersion) {
|
||||||
|
@ -213,7 +201,7 @@ void AssetUpdater::checkIfCheckingIsDone()
|
||||||
connect(reply, &QNetworkReply::finished, [this, reply] {
|
connect(reply, &QNetworkReply::finished, [this, reply] {
|
||||||
qInfo() << "Dotnet-core finished downloading!";
|
qInfo() << "Dotnet-core finished downloading!";
|
||||||
|
|
||||||
// dialog->setLabelText("Updating Dotnet-core...");
|
Q_EMIT launcher.stageChanged("Updating Dotnet-core...");
|
||||||
|
|
||||||
QFile file(tempDir.path() + "/dotnet-core.zip");
|
QFile file(tempDir.path() + "/dotnet-core.zip");
|
||||||
file.open(QIODevice::WriteOnly);
|
file.open(QIODevice::WriteOnly);
|
||||||
|
@ -234,7 +222,7 @@ void AssetUpdater::checkIfCheckingIsDone()
|
||||||
connect(reply, &QNetworkReply::finished, [this, reply] {
|
connect(reply, &QNetworkReply::finished, [this, reply] {
|
||||||
qInfo() << "Dotnet-desktop finished downloading!";
|
qInfo() << "Dotnet-desktop finished downloading!";
|
||||||
|
|
||||||
// dialog->setLabelText("Updating Dotnet-desktop...");
|
Q_EMIT launcher.stageChanged("Updating Dotnet-desktop...");
|
||||||
|
|
||||||
QFile file(tempDir.path() + "/dotnet-desktop.zip");
|
QFile file(tempDir.path() + "/dotnet-desktop.zip");
|
||||||
file.open(QIODevice::WriteOnly);
|
file.open(QIODevice::WriteOnly);
|
||||||
|
@ -265,7 +253,7 @@ void AssetUpdater::checkIfCheckingIsDone()
|
||||||
connect(reply, &QNetworkReply::finished, [this, reply] {
|
connect(reply, &QNetworkReply::finished, [this, reply] {
|
||||||
qInfo() << "Dalamud finished downloading!";
|
qInfo() << "Dalamud finished downloading!";
|
||||||
|
|
||||||
// dialog->setLabelText("Updating Dalamud...");
|
Q_EMIT launcher.stageChanged("Updating Dalamud...");
|
||||||
|
|
||||||
QFile file(tempDir.path() + "/latest.zip");
|
QFile file(tempDir.path() + "/latest.zip");
|
||||||
file.open(QIODevice::WriteOnly);
|
file.open(QIODevice::WriteOnly);
|
||||||
|
@ -291,7 +279,7 @@ void AssetUpdater::checkIfCheckingIsDone()
|
||||||
if (remoteDalamudAssetVersion != m_profile.dalamudAssetVersion) {
|
if (remoteDalamudAssetVersion != m_profile.dalamudAssetVersion) {
|
||||||
qInfo() << "Dalamud assets out of date.";
|
qInfo() << "Dalamud assets out of date.";
|
||||||
|
|
||||||
// dialog->setLabelText("Updating Dalamud assets...");
|
Q_EMIT launcher.stageChanged("Updating Dalamud assets...");
|
||||||
|
|
||||||
dalamudAssetNeededFilenames.clear();
|
dalamudAssetNeededFilenames.clear();
|
||||||
|
|
||||||
|
|
|
@ -336,21 +336,28 @@ void LauncherCore::addRegistryKey(const Profile &settings, QString key, QString
|
||||||
|
|
||||||
void LauncherCore::login(Profile *profile, const QString &username, const QString &password, const QString &oneTimePassword)
|
void LauncherCore::login(Profile *profile, const QString &username, const QString &password, const QString &oneTimePassword)
|
||||||
{
|
{
|
||||||
auto loginInformation = new LoginInformation(this);
|
auto assetUpdater = new AssetUpdater(*profile, *this, this);
|
||||||
loginInformation->profile = profile;
|
assetUpdater->update();
|
||||||
loginInformation->username = username;
|
|
||||||
loginInformation->password = password;
|
|
||||||
loginInformation->oneTimePassword = oneTimePassword;
|
|
||||||
|
|
||||||
if (profile->account()->rememberPassword()) {
|
connect(assetUpdater, &AssetUpdater::finishedUpdating, this, [this, assetUpdater, profile, username, password, oneTimePassword] {
|
||||||
profile->account()->setPassword(password);
|
auto loginInformation = new LoginInformation(this);
|
||||||
}
|
loginInformation->profile = profile;
|
||||||
|
loginInformation->username = username;
|
||||||
|
loginInformation->password = password;
|
||||||
|
loginInformation->oneTimePassword = oneTimePassword;
|
||||||
|
|
||||||
if (loginInformation->profile->account()->isSapphire()) {
|
if (profile->account()->rememberPassword()) {
|
||||||
sapphireLauncher->login(loginInformation->profile->account()->lobbyUrl(), *loginInformation);
|
profile->account()->setPassword(password);
|
||||||
} else {
|
}
|
||||||
squareBoot->checkGateStatus(loginInformation);
|
|
||||||
}
|
if (loginInformation->profile->account()->isSapphire()) {
|
||||||
|
sapphireLauncher->login(loginInformation->profile->account()->lobbyUrl(), *loginInformation);
|
||||||
|
} else {
|
||||||
|
squareBoot->checkGateStatus(loginInformation);
|
||||||
|
}
|
||||||
|
|
||||||
|
assetUpdater->deleteLater();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LauncherCore::autoLogin(Profile &profile)
|
bool LauncherCore::autoLogin(Profile &profile)
|
||||||
|
|
Loading…
Add table
Reference in a new issue