summaryrefslogtreecommitdiffstats
path: root/mmc_updater/src/UpdateInstaller.h
diff options
context:
space:
mode:
authorAndrew <forkk@forkk.net>2013-12-09 12:04:05 -0600
committerAndrew <forkk@forkk.net>2013-12-09 12:04:05 -0600
commit7f52bed9e3f559adcbcf3f3c1c7ac2251964db8c (patch)
tree52097b57dc7d18ec4e35ef3a8e554af2d91545e8 /mmc_updater/src/UpdateInstaller.h
parent9410dd042ea62224fa3e0eb3b525abbdf0c316ee (diff)
parent220e07aef4a34dca9f31ae0c5bb994e5c594125d (diff)
downloadMultiMC-7f52bed9e3f559adcbcf3f3c1c7ac2251964db8c.tar
MultiMC-7f52bed9e3f559adcbcf3f3c1c7ac2251964db8c.tar.gz
MultiMC-7f52bed9e3f559adcbcf3f3c1c7ac2251964db8c.tar.lz
MultiMC-7f52bed9e3f559adcbcf3f3c1c7ac2251964db8c.tar.xz
MultiMC-7f52bed9e3f559adcbcf3f3c1c7ac2251964db8c.zip
Merge branch 'feature_updater' into develop
Diffstat (limited to 'mmc_updater/src/UpdateInstaller.h')
-rw-r--r--mmc_updater/src/UpdateInstaller.h72
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;
+};
+