Skip to content

Commit

Permalink
refactor: remove old updater
Browse files Browse the repository at this point in the history
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
  • Loading branch information
Scrumplex committed Nov 16, 2022
1 parent debc165 commit b37762c
Show file tree
Hide file tree
Showing 33 changed files with 58 additions and 2,230 deletions.
68 changes: 20 additions & 48 deletions launcher/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@

#include "java/JavaUtils.h"

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

#include "tools/JProfiler.h"
#include "tools/JVisualVM.h"
Expand All @@ -120,6 +120,10 @@
#include "gamemode_client.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 @@ -490,10 +455,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 @@ -724,10 +685,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 @@ -1605,3 +1566,14 @@ int Application::suitableMaxMem()

return maxMemoryAlloc;
}

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 @@ -124,10 +123,12 @@ class Application : public QApplication

void setApplicationTheme(const QString& name, bool initial);

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 @@ -247,7 +248,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 @@ -306,4 +307,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 @@ -149,12 +149,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 @@ -575,8 +569,6 @@ SET(LAUNCHER_SOURCES
# Application base
Application.h
Application.cpp
UpdateController.cpp
UpdateController.h
ApplicationMessage.h
ApplicationMessage.cpp

Expand Down Expand Up @@ -809,8 +801,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 @@ -932,7 +922,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

0 comments on commit b37762c

Please sign in to comment.