Path: blob/master/src/duckstation-qt/autoupdaterwindow.h
4246 views
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <[email protected]>1// SPDX-License-Identifier: CC-BY-NC-ND-4.023#pragma once45#include "common/types.h"67#include "ui_autoupdaterwindow.h"89#include <memory>10#include <string>11#include <string_view>1213#include <QtCore/QDateTime>14#include <QtCore/QStringList>15#include <QtCore/QTimer>16#include <QtWidgets/QDialog>1718class Error;19class HTTPDownloader;2021class EmuThread;2223class AutoUpdaterWindow final : public QWidget24{25Q_OBJECT2627public:28explicit AutoUpdaterWindow(QWidget* parent = nullptr);29~AutoUpdaterWindow();3031static bool isSupported();32static QStringList getTagList();33static std::string getDefaultTag();34static void cleanupAfterUpdate();35static bool isOfficialBuild();36static void warnAboutUnofficialBuild();3738Q_SIGNALS:39void updateCheckCompleted();4041public Q_SLOTS:42void queueUpdateCheck(bool display_errors);43void queueGetLatestRelease();4445private Q_SLOTS:46void httpPollTimerPoll();4748void downloadUpdateClicked();49void skipThisUpdateClicked();50void remindMeLaterClicked();5152protected:53void closeEvent(QCloseEvent* event) override;5455private:56void reportError(const std::string_view msg);5758bool ensureHttpReady();5960bool updateNeeded() const;61std::string getCurrentUpdateTag() const;6263void getLatestTagComplete(s32 status_code, const Error& error, std::vector<u8> response, bool display_errors);64void getLatestReleaseComplete(s32 status_code, const Error& error, std::vector<u8> response);6566void queueGetChanges();67void getChangesComplete(s32 status_code, const Error& error, std::vector<u8> response);6869bool processUpdate(const std::vector<u8>& update_data);7071#ifdef _WIN3272bool doesUpdaterNeedElevation(const std::string& application_dir) const;73bool doUpdate(const std::string& application_dir, const std::string& zip_path, const std::string& updater_path);74bool extractUpdater(const std::string& zip_path, const std::string& destination_path, Error* error);75#endif7677Ui::AutoUpdaterWindow m_ui;7879std::unique_ptr<HTTPDownloader> m_http;80QTimer* m_http_poll_timer = nullptr;81QString m_latest_sha;82QString m_download_url;83int m_download_size = 0;8485bool m_update_will_break_save_states = false;86};878889