diff options
author | Petr Mrázek <peterix@gmail.com> | 2013-12-10 07:22:22 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2013-12-10 07:22:22 +0100 |
commit | aa61bbe9e414648399aff2802df5b587dee1a084 (patch) | |
tree | ff7809bea445bb76c9fd27a3245e1b2cb7c72596 /mmc_updater/src/UpdateInstaller.h | |
parent | 3f5c46a1c4b27e82976e0067e4ec2d6abfffd9ba (diff) | |
parent | 712b87c643bbd7bc4ed2cfd459d0b9fdb69e5f0d (diff) | |
download | MultiMC-aa61bbe9e414648399aff2802df5b587dee1a084.tar MultiMC-aa61bbe9e414648399aff2802df5b587dee1a084.tar.gz MultiMC-aa61bbe9e414648399aff2802df5b587dee1a084.tar.lz MultiMC-aa61bbe9e414648399aff2802df5b587dee1a084.tar.xz MultiMC-aa61bbe9e414648399aff2802df5b587dee1a084.zip |
Merge branch 'develop' of github.com:MultiMC/MultiMC5 into develop
Conflicts:
CMakeLists.txt
gui/MainWindow.cpp
Diffstat (limited to 'mmc_updater/src/UpdateInstaller.h')
-rw-r--r-- | mmc_updater/src/UpdateInstaller.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/mmc_updater/src/UpdateInstaller.h b/mmc_updater/src/UpdateInstaller.h new file mode 100644 index 00000000..1eca0bc7 --- /dev/null +++ b/mmc_updater/src/UpdateInstaller.h @@ -0,0 +1,72 @@ +#pragma once + +#include "Platform.h" +#include "FileUtils.h" +#include "UpdateScript.h" + +#include <list> +#include <string> +#include <map> + +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 setFinishCmd(const std::string& cmd); + + 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<std::string> 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; + std::string m_finishCmd; + PLATFORM_PID m_waitPid; + UpdateScript* m_script; + UpdateObserver* m_observer; + std::map<std::string,std::string> m_backups; + bool m_forceElevated; + bool m_autoClose; +}; + |