Path: blob/master/src/duckstation-qt/autoupdaterdialog.h
7666 views
// SPDX-FileCopyrightText: 2019-2025 Connor McLaughlin <[email protected]>1// SPDX-License-Identifier: CC-BY-NC-ND-4.023#pragma once45#include "ui_autoupdaterdialog.h"67#include "common/types.h"89#include <QtCore/QTimer>10#include <string>11#include <string_view>12#include <vector>1314class Error;15class HTTPDownloader;16class QtProgressCallback;1718class CoreThread;1920class AutoUpdaterDialog final : public QDialog21{22Q_OBJECT2324public:25~AutoUpdaterDialog();2627static AutoUpdaterDialog* create(QWidget* const parent, Error* const error);2829ALWAYS_INLINE bool areUpdatesAvailable() const { return m_updates_available; }3031void queueUpdateCheck(bool display_errors, bool ignore_skipped_updates);32void queueGetLatestRelease();3334void cancel();3536// (channel name, channel display name)37static std::vector<std::pair<QString, QString>> getChannelList();3839static std::string getDefaultTag();40static std::string getCurrentUpdateTag();41static void cleanupAfterUpdate();42static void warnAboutUnofficialBuild();4344Q_SIGNALS:45/// Emitted just before the update check finishes, before any messages are displayed.46void updateCheckAboutToComplete();4748/// Update check completed, might have an update available.49void updateCheckCompleted(bool update_available);5051/// Update was available, but the window was closed.52void closed();5354protected:55void closeEvent(QCloseEvent* event) override;5657private:58AutoUpdaterDialog(QWidget* const parent, Error* const error);5960void setDownloadSectionVisibility(bool visible);6162void reportError(const std::string_view msg);63void ensureHttpPollingActive();64void httpPollTimerPoll();65bool handleCancelledRequest(s32 status_code);6667void downloadUpdateClicked();68void skipThisUpdateClicked();69void remindMeLaterClicked();7071bool updateNeeded() const;7273void getLatestTagComplete(s32 status_code, const Error& error, std::vector<u8> response, bool display_errors);74void getLatestReleaseComplete(s32 status_code, const Error& error, std::vector<u8> response);7576void queueGetChanges();77void getChangesComplete(s32 status_code, const Error& error, std::vector<u8> response);7879bool processUpdate(const std::vector<u8>& update_data);8081#ifdef _WIN3282bool doesUpdaterNeedElevation(const std::string& application_dir) const;83bool doUpdate(const std::string& application_dir, const std::string& zip_path, const std::string& updater_path,84const std::string& program_path);85bool extractUpdater(const std::string& zip_path, const std::string& destination_path,86const std::string_view check_for_file, Error* error);87#endif8889Ui::AutoUpdaterDialog m_ui;9091std::unique_ptr<HTTPDownloader> m_http;92QTimer* m_http_poll_timer = nullptr;93QtProgressCallback* m_download_progress_callback = nullptr;94QString m_latest_sha;95QString m_download_url;96int m_download_size = 0;9798bool m_cancelled = true;99bool m_updates_available = false;100};101102103