Edit updater_service.h

This commit is contained in:
collecting
2025-10-25 02:13:00 +00:00
parent 8050dc0cd2
commit 1175bf35b7

View File

@@ -10,30 +10,33 @@
#include <memory>
#include <vector>
// Forward declare to keep headers clean
class QNetworkAccessManager;
#include <QString>
#include <QNetworkAccessManager>
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 url;
};
};
struct UpdateInfo {
struct UpdateInfo {
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 release_date;
bool is_newer_version = false;
};
};
class UpdaterService : public QObject {
class UpdaterService : public QObject {
Q_OBJECT
public:
public:
enum class UpdateResult { Success, Failed, Cancelled, NetworkError, ExtractionError, PermissionError, InvalidArchive, NoUpdateAvailable };
explicit UpdaterService(QObject* parent = nullptr);
@@ -48,19 +51,19 @@ namespace Updater {
static bool HasStagedUpdate(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 UpdateDownloadProgress(int percentage, qint64 bytes_received, qint64 bytes_total);
void UpdateInstallProgress(int percentage, const QString& current_file);
void UpdateCompleted(UpdateResult result, const QString& message);
void UpdateError(const QString& error_message);
private slots:
private slots:
void OnDownloadFinished();
void OnDownloadProgress(qint64 bytes_received, qint64 bytes_total);
void OnDownloadError(QNetworkReply::NetworkError error);
private:
private:
void InitializeSSL();
void ConfigureSSLForRequest(QNetworkRequest& request);
void ParseUpdateResponse(const QByteArray& response);
@@ -92,6 +95,6 @@ namespace Updater {
static constexpr const char* CITRON_VERSION_FILE = "version.txt";
static constexpr const char* BACKUP_DIRECTORY = "backup";
};
};
} // namespace Updater