mirror of
https://git.citron-emu.org/citron/emulator
synced 2025-12-19 10:43:33 +00:00
Edit updater_service.h
This commit is contained in:
@@ -10,30 +10,33 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
// Forward declare to keep headers clean
|
#include <QString>
|
||||||
class QNetworkAccessManager;
|
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
|
||||||
namespace Updater {
|
namespace Updater {
|
||||||
|
|
||||||
std::string ExtractCommitHash(const std::string& version_string);
|
// Declaration for the helper function.
|
||||||
|
QString FormatDateTimeString(const std::string& iso_string);
|
||||||
|
std::string ExtractCommitHash(const std::string& version_string);
|
||||||
|
|
||||||
struct DownloadOption {
|
struct DownloadOption {
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string url;
|
std::string url;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct UpdateInfo {
|
struct UpdateInfo {
|
||||||
std::string version;
|
std::string version;
|
||||||
std::vector<DownloadOption> download_options; // Used for both Windows .zip and Linux .AppImage
|
std::vector<DownloadOption> download_options;
|
||||||
std::string changelog;
|
std::string changelog;
|
||||||
std::string release_date;
|
std::string release_date;
|
||||||
bool is_newer_version = false;
|
bool is_newer_version = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class UpdaterService : public QObject {
|
class UpdaterService : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum class UpdateResult { Success, Failed, Cancelled, NetworkError, ExtractionError, PermissionError, InvalidArchive, NoUpdateAvailable };
|
enum class UpdateResult { Success, Failed, Cancelled, NetworkError, ExtractionError, PermissionError, InvalidArchive, NoUpdateAvailable };
|
||||||
|
|
||||||
explicit UpdaterService(QObject* parent = nullptr);
|
explicit UpdaterService(QObject* parent = nullptr);
|
||||||
@@ -48,19 +51,19 @@ namespace Updater {
|
|||||||
static bool HasStagedUpdate(const std::filesystem::path& app_directory);
|
static bool HasStagedUpdate(const std::filesystem::path& app_directory);
|
||||||
static bool ApplyStagedUpdate(const std::filesystem::path& app_directory);
|
static bool ApplyStagedUpdate(const std::filesystem::path& app_directory);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void UpdateCheckCompleted(bool has_update, const UpdateInfo& update_info);
|
void UpdateCheckCompleted(bool has_update, const UpdateInfo& update_info);
|
||||||
void UpdateDownloadProgress(int percentage, qint64 bytes_received, qint64 bytes_total);
|
void UpdateDownloadProgress(int percentage, qint64 bytes_received, qint64 bytes_total);
|
||||||
void UpdateInstallProgress(int percentage, const QString& current_file);
|
void UpdateInstallProgress(int percentage, const QString& current_file);
|
||||||
void UpdateCompleted(UpdateResult result, const QString& message);
|
void UpdateCompleted(UpdateResult result, const QString& message);
|
||||||
void UpdateError(const QString& error_message);
|
void UpdateError(const QString& error_message);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void OnDownloadFinished();
|
void OnDownloadFinished();
|
||||||
void OnDownloadProgress(qint64 bytes_received, qint64 bytes_total);
|
void OnDownloadProgress(qint64 bytes_received, qint64 bytes_total);
|
||||||
void OnDownloadError(QNetworkReply::NetworkError error);
|
void OnDownloadError(QNetworkReply::NetworkError error);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InitializeSSL();
|
void InitializeSSL();
|
||||||
void ConfigureSSLForRequest(QNetworkRequest& request);
|
void ConfigureSSLForRequest(QNetworkRequest& request);
|
||||||
void ParseUpdateResponse(const QByteArray& response);
|
void ParseUpdateResponse(const QByteArray& response);
|
||||||
@@ -92,6 +95,6 @@ namespace Updater {
|
|||||||
|
|
||||||
static constexpr const char* CITRON_VERSION_FILE = "version.txt";
|
static constexpr const char* CITRON_VERSION_FILE = "version.txt";
|
||||||
static constexpr const char* BACKUP_DIRECTORY = "backup";
|
static constexpr const char* BACKUP_DIRECTORY = "backup";
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Updater
|
} // namespace Updater
|
||||||
|
|||||||
Reference in New Issue
Block a user