refactor: rename app class
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
parent
5627b4a9c5
commit
f619a04fe7
@ -567,12 +567,12 @@ set(LINKEXE_SOURCES
|
||||
DesktopServices.cpp
|
||||
)
|
||||
|
||||
set(WINDOWSUPDATEREXE_SOURCES
|
||||
updater/windows/WindowsUpdater.h
|
||||
updater/windows/WindowsUpdater.cpp
|
||||
updater/windows/UpdaterDialogs.h
|
||||
updater/windows/UpdaterDialogs.cpp
|
||||
updater/windows/GitHubRelease.h
|
||||
set(PRISMUPDATER_SOURCES
|
||||
updater/prismupdater/PrismUpdater.h
|
||||
updater/prismupdater/PrismUpdater.cpp
|
||||
updater/prismupdater/UpdaterDialogs.h
|
||||
updater/prismupdater/UpdaterDialogs.cpp
|
||||
updater/prismupdater/GitHubRelease.h
|
||||
Json.h
|
||||
Json.cpp
|
||||
FileSystem.h
|
||||
@ -1094,8 +1094,8 @@ qt_add_resources(LAUNCHER_RESOURCES
|
||||
../${Launcher_Branding_LogoQRC}
|
||||
)
|
||||
|
||||
qt_wrap_ui(WINDOWSUPDATER_UI
|
||||
updater/windows/SelectReleaseDialog.ui
|
||||
qt_wrap_ui(PRISMUPDATER_UI
|
||||
updater/prismupdater/SelectReleaseDialog.ui
|
||||
)
|
||||
|
||||
######## Windows resource files ########
|
||||
@ -1183,9 +1183,9 @@ install(TARGETS ${Launcher_Name}
|
||||
|
||||
if(WIN32 OR (DEFINED Launcher_BUILD_UPDATER AND Launcher_BUILD_UPDATER) )
|
||||
# Updater
|
||||
add_library(windows_updater_logic STATIC ${WINDOWSUPDATEREXE_SOURCES} ${WINDOWSUPDATER_UI})
|
||||
target_include_directories(windows_updater_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(windows_updater_logic
|
||||
add_library(prism_updater_logic STATIC ${PRISMUPDATER_SOURCES} ${PRISMUPDATER_UI})
|
||||
target_include_directories(prism_updater_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(prism_updater_logic
|
||||
systeminfo
|
||||
BuildConfig
|
||||
ghcFilesystem::ghc_filesystem
|
||||
@ -1196,8 +1196,8 @@ if(WIN32 OR (DEFINED Launcher_BUILD_UPDATER AND Launcher_BUILD_UPDATER) )
|
||||
cmark::cmark
|
||||
)
|
||||
|
||||
add_executable("${Launcher_Name}_updater" WIN32 updater/windows/windows_main.cpp)
|
||||
target_link_libraries("${Launcher_Name}_updater" windows_updater_logic)
|
||||
add_executable("${Launcher_Name}_updater" WIN32 updater/prismupdater/updater_main.cpp)
|
||||
target_link_libraries("${Launcher_Name}_updater" prism_updater_logic)
|
||||
|
||||
if(DEFINED Launcher_APP_BINARY_NAME)
|
||||
set_target_properties("${Launcher_Name}_updater" PROPERTIES OUTPUT_NAME "${Launcher_APP_BINARY_NAME}_updater")
|
||||
@ -1229,7 +1229,7 @@ if(WIN32 OR (DEFINED Launcher_BUILD_FILELINKER AND Launcher_BUILD_FILELINKER))
|
||||
${Launcher_QT_LIBS}
|
||||
)
|
||||
|
||||
add_executable("${Launcher_Name}_filelink" WIN32 filelink/main.cpp)
|
||||
add_executable("${Launcher_Name}_filelink" WIN32 filelink/filelink_main.cpp)
|
||||
|
||||
target_sources("${Launcher_Name}_filelink" PRIVATE filelink/filelink.exe.manifest)
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "WindowsUpdater.h"
|
||||
#include "PrismUpdater.h"
|
||||
#include "BuildConfig.h"
|
||||
|
||||
#include <cstdlib>
|
||||
@ -68,7 +68,7 @@ namespace fs = ghc::filesystem;
|
||||
|
||||
#include <DesktopServices.h>
|
||||
|
||||
#include "UpdaterDialogs.h"
|
||||
#include "updater/prismupdater/UpdaterDialogs.h"
|
||||
|
||||
#include "FileSystem.h"
|
||||
#include "Json.h"
|
||||
@ -83,7 +83,7 @@ void appDebugOutput(QtMsgType type, const QMessageLogContext& context, const QSt
|
||||
QString out = qFormatLogMessage(type, context, msg);
|
||||
out += QChar::LineFeed;
|
||||
|
||||
WindowsUpdaterApp* app = static_cast<WindowsUpdaterApp*>(QCoreApplication::instance());
|
||||
PrismUpdaterApp* app = static_cast<PrismUpdaterApp*>(QCoreApplication::instance());
|
||||
app->logFile->write(out.toUtf8());
|
||||
app->logFile->flush();
|
||||
if (app->logToConsole) {
|
||||
@ -92,7 +92,7 @@ void appDebugOutput(QtMsgType type, const QMessageLogContext& context, const QSt
|
||||
}
|
||||
}
|
||||
|
||||
WindowsUpdaterApp::WindowsUpdaterApp(int& argc, char** argv) : QApplication(argc, argv)
|
||||
PrismUpdaterApp::PrismUpdaterApp(int& argc, char** argv) : QApplication(argc, argv)
|
||||
{
|
||||
#if defined Q_OS_WIN32
|
||||
// attach the parent console
|
||||
@ -313,7 +313,7 @@ WindowsUpdaterApp::WindowsUpdaterApp(int& argc, char** argv) : QApplication(argc
|
||||
loadReleaseList();
|
||||
}
|
||||
|
||||
WindowsUpdaterApp::~WindowsUpdaterApp()
|
||||
PrismUpdaterApp::~PrismUpdaterApp()
|
||||
{
|
||||
qDebug() << "updater shutting down";
|
||||
// Shut down logger by setting the logger function to nothing
|
||||
@ -334,21 +334,21 @@ WindowsUpdaterApp::~WindowsUpdaterApp()
|
||||
m_reply->deleteLater();
|
||||
}
|
||||
|
||||
void WindowsUpdaterApp::fail(const QString& reason)
|
||||
void PrismUpdaterApp::fail(const QString& reason)
|
||||
{
|
||||
qCritical() << qPrintable(reason);
|
||||
m_status = Failed;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void WindowsUpdaterApp::abort(const QString& reason)
|
||||
void PrismUpdaterApp::abort(const QString& reason)
|
||||
{
|
||||
qCritical() << qPrintable(reason);
|
||||
m_status = Aborted;
|
||||
exit(2);
|
||||
}
|
||||
|
||||
void WindowsUpdaterApp::showFatalErrorMessage(const QString& title, const QString& content)
|
||||
void PrismUpdaterApp::showFatalErrorMessage(const QString& title, const QString& content)
|
||||
{
|
||||
m_status = Failed;
|
||||
auto msgBox = new QMessageBox();
|
||||
@ -362,7 +362,7 @@ void WindowsUpdaterApp::showFatalErrorMessage(const QString& title, const QStrin
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void WindowsUpdaterApp::run()
|
||||
void PrismUpdaterApp::run()
|
||||
{
|
||||
qDebug() << "found" << m_releases.length() << "releases on github";
|
||||
qDebug() << "loading exe at " << m_prismExecutable;
|
||||
@ -424,14 +424,14 @@ void WindowsUpdaterApp::run()
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void WindowsUpdaterApp::printReleases()
|
||||
void PrismUpdaterApp::printReleases()
|
||||
{
|
||||
for (auto release : m_releases) {
|
||||
std::cout << release.name.toStdString() << " Version: " << release.tag_name.toStdString() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
QList<GitHubRelease> WindowsUpdaterApp::nonDraftReleases()
|
||||
QList<GitHubRelease> PrismUpdaterApp::nonDraftReleases()
|
||||
{
|
||||
QList<GitHubRelease> nonDraft;
|
||||
for (auto rls : m_releases) {
|
||||
@ -441,7 +441,7 @@ QList<GitHubRelease> WindowsUpdaterApp::nonDraftReleases()
|
||||
return nonDraft;
|
||||
}
|
||||
|
||||
QList<GitHubRelease> WindowsUpdaterApp::newerReleases()
|
||||
QList<GitHubRelease> PrismUpdaterApp::newerReleases()
|
||||
{
|
||||
QList<GitHubRelease> newer;
|
||||
for (auto rls : nonDraftReleases()) {
|
||||
@ -451,7 +451,7 @@ QList<GitHubRelease> WindowsUpdaterApp::newerReleases()
|
||||
return newer;
|
||||
}
|
||||
|
||||
GitHubRelease WindowsUpdaterApp::selectRelease()
|
||||
GitHubRelease PrismUpdaterApp::selectRelease()
|
||||
{
|
||||
QList<GitHubRelease> releases;
|
||||
|
||||
@ -475,12 +475,12 @@ GitHubRelease WindowsUpdaterApp::selectRelease()
|
||||
return release;
|
||||
}
|
||||
|
||||
void WindowsUpdaterApp::performUpdate(const GitHubRelease& release)
|
||||
void PrismUpdaterApp::performUpdate(const GitHubRelease& release)
|
||||
{
|
||||
qDebug() << "Updating to" << release.tag_name;
|
||||
}
|
||||
|
||||
void WindowsUpdaterApp::loadPrismVersionFromExe(const QString& exe_path)
|
||||
void PrismUpdaterApp::loadPrismVersionFromExe(const QString& exe_path)
|
||||
{
|
||||
QProcess proc = QProcess();
|
||||
proc.start(exe_path, { "-v" });
|
||||
@ -509,7 +509,7 @@ void WindowsUpdaterApp::loadPrismVersionFromExe(const QString& exe_path)
|
||||
m_prismGitCommit = lines.takeFirst().simplified();
|
||||
}
|
||||
|
||||
void WindowsUpdaterApp::loadReleaseList()
|
||||
void PrismUpdaterApp::loadReleaseList()
|
||||
{
|
||||
auto github_repo = m_prismRepoUrl;
|
||||
if (github_repo.host() != "github.com")
|
||||
@ -526,7 +526,7 @@ void WindowsUpdaterApp::loadReleaseList()
|
||||
downloadReleasePage(api_url, 1);
|
||||
}
|
||||
|
||||
void WindowsUpdaterApp::downloadReleasePage(const QString& api_url, int page)
|
||||
void PrismUpdaterApp::downloadReleasePage(const QString& api_url, int page)
|
||||
{
|
||||
int per_page = 30;
|
||||
auto page_url = QString("%1?per_page=%2&page=%3").arg(api_url).arg(QString::number(per_page)).arg(QString::number(page));
|
||||
@ -549,18 +549,18 @@ void WindowsUpdaterApp::downloadReleasePage(const QString& api_url, int page)
|
||||
}
|
||||
});
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) // QNetworkReply::errorOccurred added in 5.15
|
||||
connect(rep, &QNetworkReply::errorOccurred, this, &WindowsUpdaterApp::downloadError);
|
||||
connect(rep, &QNetworkReply::errorOccurred, this, &PrismUpdaterApp::downloadError);
|
||||
#else
|
||||
connect(rep, QOverload<QNetworkReply::NetworkError>::of(&QNetworkReply::error), this, &WindowsUpdaterApp::downloadError);
|
||||
#endif
|
||||
connect(rep, &QNetworkReply::sslErrors, this, &WindowsUpdaterApp::sslErrors);
|
||||
connect(rep, &QNetworkReply::sslErrors, this, &PrismUpdaterApp::sslErrors);
|
||||
connect(rep, &QNetworkReply::readyRead, this, [this, responce]() {
|
||||
auto data = m_reply->readAll();
|
||||
responce->append(data);
|
||||
});
|
||||
}
|
||||
|
||||
int WindowsUpdaterApp::parseReleasePage(const QByteArray* responce)
|
||||
int PrismUpdaterApp::parseReleasePage(const QByteArray* responce)
|
||||
{
|
||||
if (responce->isEmpty()) // empty page
|
||||
return 0;
|
||||
@ -607,7 +607,7 @@ int WindowsUpdaterApp::parseReleasePage(const QByteArray* responce)
|
||||
return num_releases;
|
||||
}
|
||||
|
||||
GitHubRelease WindowsUpdaterApp::getLatestRelease()
|
||||
GitHubRelease PrismUpdaterApp::getLatestRelease()
|
||||
{
|
||||
GitHubRelease latest;
|
||||
for (auto release : m_releases) {
|
||||
@ -618,13 +618,13 @@ GitHubRelease WindowsUpdaterApp::getLatestRelease()
|
||||
return latest;
|
||||
}
|
||||
|
||||
bool WindowsUpdaterApp::needUpdate(const GitHubRelease& release)
|
||||
bool PrismUpdaterApp::needUpdate(const GitHubRelease& release)
|
||||
{
|
||||
auto current_ver = Version(QString("%1.%2").arg(QString::number(m_prismVersionMajor)).arg(QString::number(m_prismVersionMinor)));
|
||||
return current_ver < release.version;
|
||||
}
|
||||
|
||||
void WindowsUpdaterApp::downloadError(QNetworkReply::NetworkError error)
|
||||
void PrismUpdaterApp::downloadError(QNetworkReply::NetworkError error)
|
||||
{
|
||||
if (error == QNetworkReply::OperationCanceledError) {
|
||||
abort(QString("Aborted %1").arg(m_reply->url().toString()));
|
||||
@ -633,7 +633,7 @@ void WindowsUpdaterApp::downloadError(QNetworkReply::NetworkError error)
|
||||
}
|
||||
}
|
||||
|
||||
void WindowsUpdaterApp::sslErrors(const QList<QSslError>& errors)
|
||||
void PrismUpdaterApp::sslErrors(const QList<QSslError>& errors)
|
||||
{
|
||||
int i = 1;
|
||||
QString err_msg;
|
||||
|
@ -39,15 +39,15 @@
|
||||
#define PRISM_EXTERNAL_EXE
|
||||
#include "FileSystem.h"
|
||||
|
||||
#include "updater/windows/GitHubRelease.h"
|
||||
#include "updater/prismupdater/GitHubRelease.h"
|
||||
|
||||
class WindowsUpdaterApp : public QApplication {
|
||||
class PrismUpdaterApp : public QApplication {
|
||||
// friends for the purpose of limiting access to deprecated stuff
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Status { Starting, Failed, Succeeded, Initialized, Aborted };
|
||||
WindowsUpdaterApp(int& argc, char** argv);
|
||||
virtual ~WindowsUpdaterApp();
|
||||
PrismUpdaterApp(int& argc, char** argv);
|
||||
virtual ~PrismUpdaterApp();
|
||||
void loadReleaseList();
|
||||
void run();
|
||||
Status status() const { return m_status; }
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <QTreeWidgetItem>
|
||||
|
||||
#include "Version.h"
|
||||
#include "updater/windows/GitHubRelease.h"
|
||||
#include "updater/prismupdater/GitHubRelease.h"
|
||||
|
||||
namespace Ui {
|
||||
class SelectReleaseDialog;
|
||||
|
@ -22,20 +22,20 @@
|
||||
|
||||
|
||||
|
||||
#include "updater/windows/WindowsUpdater.h"
|
||||
#include "updater/prismupdater/PrismUpdater.h"
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
WindowsUpdaterApp wUpApp(argc, argv);
|
||||
PrismUpdaterApp wUpApp(argc, argv);
|
||||
|
||||
switch(wUpApp.status()) {
|
||||
case WindowsUpdaterApp::Starting:
|
||||
case WindowsUpdaterApp::Initialized:
|
||||
case PrismUpdaterApp::Starting:
|
||||
case PrismUpdaterApp::Initialized:
|
||||
{
|
||||
return wUpApp.exec();
|
||||
}
|
||||
case WindowsUpdaterApp::Failed:
|
||||
case PrismUpdaterApp::Failed:
|
||||
return 1;
|
||||
case WindowsUpdaterApp::Succeeded:
|
||||
case PrismUpdaterApp::Succeeded:
|
||||
return 0;
|
||||
default:
|
||||
return -1;
|
Loading…
Reference in New Issue
Block a user