diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index 5a979b8d9..89dea0d11 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -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) diff --git a/launcher/filelink/main.cpp b/launcher/filelink/filelink_main.cpp similarity index 100% rename from launcher/filelink/main.cpp rename to launcher/filelink/filelink_main.cpp diff --git a/launcher/updater/prismupdater/PrismUpdater.cpp b/launcher/updater/prismupdater/PrismUpdater.cpp index f0ea9998c..923b891f9 100644 --- a/launcher/updater/prismupdater/PrismUpdater.cpp +++ b/launcher/updater/prismupdater/PrismUpdater.cpp @@ -20,7 +20,7 @@ * */ -#include "WindowsUpdater.h" +#include "PrismUpdater.h" #include "BuildConfig.h" #include @@ -68,7 +68,7 @@ namespace fs = ghc::filesystem; #include -#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(QCoreApplication::instance()); + PrismUpdaterApp* app = static_cast(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 WindowsUpdaterApp::nonDraftReleases() +QList PrismUpdaterApp::nonDraftReleases() { QList nonDraft; for (auto rls : m_releases) { @@ -441,7 +441,7 @@ QList WindowsUpdaterApp::nonDraftReleases() return nonDraft; } -QList WindowsUpdaterApp::newerReleases() +QList PrismUpdaterApp::newerReleases() { QList newer; for (auto rls : nonDraftReleases()) { @@ -451,7 +451,7 @@ QList WindowsUpdaterApp::newerReleases() return newer; } -GitHubRelease WindowsUpdaterApp::selectRelease() +GitHubRelease PrismUpdaterApp::selectRelease() { QList 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::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& errors) +void PrismUpdaterApp::sslErrors(const QList& errors) { int i = 1; QString err_msg; diff --git a/launcher/updater/prismupdater/PrismUpdater.h b/launcher/updater/prismupdater/PrismUpdater.h index b79a86271..da6b4bf71 100644 --- a/launcher/updater/prismupdater/PrismUpdater.h +++ b/launcher/updater/prismupdater/PrismUpdater.h @@ -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; } diff --git a/launcher/updater/prismupdater/UpdaterDialogs.h b/launcher/updater/prismupdater/UpdaterDialogs.h index 7481e499a..1449befbd 100644 --- a/launcher/updater/prismupdater/UpdaterDialogs.h +++ b/launcher/updater/prismupdater/UpdaterDialogs.h @@ -4,7 +4,7 @@ #include #include "Version.h" -#include "updater/windows/GitHubRelease.h" +#include "updater/prismupdater/GitHubRelease.h" namespace Ui { class SelectReleaseDialog; diff --git a/launcher/updater/prismupdater/windows_main.cpp b/launcher/updater/prismupdater/updater_main.cpp similarity index 80% rename from launcher/updater/prismupdater/windows_main.cpp rename to launcher/updater/prismupdater/updater_main.cpp index 31d7646b5..6bc7dd208 100644 --- a/launcher/updater/prismupdater/windows_main.cpp +++ b/launcher/updater/prismupdater/updater_main.cpp @@ -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;