From 6aa9bd0f77dcb5128167fae62e32aa5252fe85c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 2 Dec 2013 00:55:24 +0100 Subject: Renew the updater branch Now with some actual consensus on what the updater will do! --- mmc_updater/src/UpdateInstaller.h | 70 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 mmc_updater/src/UpdateInstaller.h (limited to 'mmc_updater/src/UpdateInstaller.h') diff --git a/mmc_updater/src/UpdateInstaller.h b/mmc_updater/src/UpdateInstaller.h new file mode 100644 index 00000000..5dfa263e --- /dev/null +++ b/mmc_updater/src/UpdateInstaller.h @@ -0,0 +1,70 @@ +#pragma once + +#include "Platform.h" +#include "FileUtils.h" +#include "UpdateScript.h" + +#include +#include +#include + +class UpdateObserver; + +/** Central class responsible for installing updates, + * launching an elevated copy of the updater if required + * and restarting the main application once the update + * is installed. + */ +class UpdateInstaller +{ + public: + enum Mode + { + Setup, + Main + }; + + UpdateInstaller(); + void setInstallDir(const std::string& path); + void setPackageDir(const std::string& path); + void setBackupDir(const std::string& path); + void setMode(Mode mode); + void setScript(UpdateScript* script); + void setWaitPid(PLATFORM_PID pid); + void setForceElevated(bool elevated); + void setAutoClose(bool autoClose); + + void setObserver(UpdateObserver* observer); + + void run() throw (); + + void restartMainApp(); + + private: + void cleanup(); + void revert(); + void removeBackups(); + bool checkAccess(); + + void installFiles(); + void uninstallFiles(); + void installFile(const UpdateScriptFile& file); + void backupFile(const std::string& path); + void reportError(const std::string& error); + void postInstallUpdate(); + + std::list updaterArgs() const; + std::string friendlyErrorForError(const FileUtils::IOException& ex) const; + + Mode m_mode; + std::string m_installDir; + std::string m_packageDir; + std::string m_backupDir; + PLATFORM_PID m_waitPid; + UpdateScript* m_script; + UpdateObserver* m_observer; + std::map m_backups; + bool m_forceElevated; + bool m_autoClose; +}; + -- cgit v1.2.3 From e90f1a27569ac6b9e9782646c9de92fc9534b1d2 Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 5 Dec 2013 20:32:12 -0600 Subject: Implement update installer --- mmc_updater/src/UpdateInstaller.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'mmc_updater/src/UpdateInstaller.h') diff --git a/mmc_updater/src/UpdateInstaller.h b/mmc_updater/src/UpdateInstaller.h index 5dfa263e..1eca0bc7 100644 --- a/mmc_updater/src/UpdateInstaller.h +++ b/mmc_updater/src/UpdateInstaller.h @@ -33,6 +33,7 @@ class UpdateInstaller void setWaitPid(PLATFORM_PID pid); void setForceElevated(bool elevated); void setAutoClose(bool autoClose); + void setFinishCmd(const std::string& cmd); void setObserver(UpdateObserver* observer); @@ -60,6 +61,7 @@ class UpdateInstaller std::string m_installDir; std::string m_packageDir; std::string m_backupDir; + std::string m_finishCmd; PLATFORM_PID m_waitPid; UpdateScript* m_script; UpdateObserver* m_observer; -- cgit v1.2.3