Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove old updater code #458

Merged
merged 3 commits into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
68 changes: 20 additions & 48 deletions launcher/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@

#include "java/JavaUtils.h"

#include "updater/UpdateChecker.h"
#include "updater/ExternalUpdater.h"

#include "tools/JProfiler.h"
#include "tools/JVisualVM.h"
Expand All @@ -125,6 +125,10 @@
#include "MangoHud.h"
#endif

#ifdef Q_OS_MAC
#include "updater/MacSparkleUpdater.h"
#endif


#if defined Q_OS_WIN32
#ifndef WIN32_LEAN_AND_MEAN
Expand Down Expand Up @@ -155,45 +159,6 @@ void appDebugOutput(QtMsgType type, const QMessageLogContext &context, const QSt
fflush(stderr);
}

QString getIdealPlatform(QString currentPlatform) {
auto info = Sys::getKernelInfo();
switch(info.kernelType) {
case Sys::KernelType::Darwin: {
if(info.kernelMajor >= 17) {
// macOS 10.13 or newer
return "osx64-5.15.2";
}
else {
// macOS 10.12 or older
return "osx64";
}
}
case Sys::KernelType::Windows: {
// FIXME: 5.15.2 is not stable on Windows, due to a large number of completely unpredictable and hard to reproduce issues
break;
/*
if(info.kernelMajor == 6 && info.kernelMinor >= 1) {
// Windows 7
return "win32-5.15.2";
}
else if (info.kernelMajor > 6) {
// Above Windows 7
return "win32-5.15.2";
}
else {
// Below Windows 7
return "win32";
}
*/
}
case Sys::KernelType::Undetermined:
case Sys::KernelType::Linux: {
break;
}
}
return currentPlatform;
}

}

Application::Application(int &argc, char **argv) : QApplication(argc, argv)
Expand Down Expand Up @@ -503,10 +468,6 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
{
// Provide a fallback for migration from PolyMC
m_settings.reset(new INISettingsObject({ BuildConfig.LAUNCHER_CONFIGFILE, "polymc.cfg", "multimc.cfg" }, this));
// Updates
// Multiple channels are separated by spaces
m_settings->registerSetting("UpdateChannel", BuildConfig.VERSION_CHANNEL);
m_settings->registerSetting("AutoUpdate", true);

// Theming
m_settings->registerSetting("IconTheme", QString("pe_colored"));
Expand Down Expand Up @@ -740,10 +701,10 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
// initialize the updater
if(BuildConfig.UPDATER_ENABLED)
{
auto platform = getIdealPlatform(BuildConfig.BUILD_PLATFORM);
auto channelUrl = BuildConfig.UPDATER_BASE + platform + "/channels.json";
qDebug() << "Initializing updater with platform: " << platform << " -- " << channelUrl;
m_updateChecker.reset(new UpdateChecker(m_network, channelUrl, BuildConfig.VERSION_CHANNEL));
qDebug() << "Initializing updater";
#ifdef Q_OS_MAC
m_updater.reset(new MacSparkleUpdater());
#endif
qDebug() << "<> Updater started.";
}

Expand Down Expand Up @@ -1697,3 +1658,14 @@ bool Application::handleDataMigration(const QString& currentData,
}
return true;
}

void Application::triggerUpdateCheck()
{
if (m_updater) {
qDebug() << "Checking for updates.";
m_updater->setBetaAllowed(false); // There are no other channels than stable
m_updater->checkForUpdates();
} else {
qDebug() << "Updater not available.";
}
}
12 changes: 6 additions & 6 deletions launcher/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include <QIcon>
#include <QDateTime>
#include <QUrl>
#include <updater/GoUpdate.h>

#include <BaseInstance.h>

Expand All @@ -63,7 +62,7 @@ class AccountList;
class IconList;
class QNetworkAccessManager;
class JavaInstallList;
class UpdateChecker;
class ExternalUpdater;
class BaseProfilerFactory;
class BaseDetachedToolFactory;
class TranslationsModel;
Expand Down Expand Up @@ -126,10 +125,12 @@ class Application : public QApplication

void setApplicationTheme(const QString& name);

shared_qobject_ptr<UpdateChecker> updateChecker() {
return m_updateChecker;
shared_qobject_ptr<ExternalUpdater> updater() {
return m_updater;
}

void triggerUpdateCheck();

std::shared_ptr<TranslationsModel> translations();

std::shared_ptr<JavaInstallList> javalist();
Expand Down Expand Up @@ -251,7 +252,7 @@ private slots:

shared_qobject_ptr<QNetworkAccessManager> m_network;

shared_qobject_ptr<UpdateChecker> m_updateChecker;
shared_qobject_ptr<ExternalUpdater> m_updater;
shared_qobject_ptr<AccountList> m_accounts;

shared_qobject_ptr<HttpMetaCache> m_metacache;
Expand Down Expand Up @@ -310,4 +311,3 @@ private slots:
QString m_instanceIdToShowWindowOf;
std::unique_ptr<QFile> logFile;
};

11 changes: 0 additions & 11 deletions launcher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,6 @@ set(LAUNCH_SOURCES

# Old update system
set(UPDATE_SOURCES
updater/GoUpdate.h
updater/GoUpdate.cpp
updater/UpdateChecker.h
updater/UpdateChecker.cpp
updater/DownloadTask.h
updater/DownloadTask.cpp
updater/ExternalUpdater.h
)

Expand Down Expand Up @@ -621,8 +615,6 @@ SET(LAUNCHER_SOURCES
Application.cpp
DataMigrationTask.h
DataMigrationTask.cpp
UpdateController.cpp
UpdateController.h
ApplicationMessage.h
ApplicationMessage.cpp

Expand Down Expand Up @@ -868,8 +860,6 @@ SET(LAUNCHER_SOURCES
ui/dialogs/ProgressDialog.h
ui/dialogs/ReviewMessageBox.cpp
ui/dialogs/ReviewMessageBox.h
ui/dialogs/UpdateDialog.cpp
ui/dialogs/UpdateDialog.h
ui/dialogs/VersionSelectDialog.cpp
ui/dialogs/VersionSelectDialog.h
ui/dialogs/SkinUploadDialog.cpp
Expand Down Expand Up @@ -986,7 +976,6 @@ qt_wrap_ui(LAUNCHER_UI
ui/dialogs/ProfileSetupDialog.ui
ui/dialogs/ProgressDialog.ui
ui/dialogs/NewInstanceDialog.ui
ui/dialogs/UpdateDialog.ui
ui/dialogs/NewComponentDialog.ui
ui/dialogs/NewsDialog.ui
ui/dialogs/ProfileSelectDialog.ui
Expand Down