summaryrefslogtreecommitdiffstats
path: root/mmc_updater/src/UpdateDialogAscii.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-12-02 00:55:24 +0100
committerPetr Mrázek <peterix@gmail.com>2013-12-02 00:55:24 +0100
commit6aa9bd0f77dcb5128167fae62e32aa5252fe85c6 (patch)
tree632994a61888929af9289927d338bd19a2b3f32c /mmc_updater/src/UpdateDialogAscii.cpp
parent613699b3626aea750093ab7eaaeccaa28c0e87c6 (diff)
downloadMultiMC-6aa9bd0f77dcb5128167fae62e32aa5252fe85c6.tar
MultiMC-6aa9bd0f77dcb5128167fae62e32aa5252fe85c6.tar.gz
MultiMC-6aa9bd0f77dcb5128167fae62e32aa5252fe85c6.tar.lz
MultiMC-6aa9bd0f77dcb5128167fae62e32aa5252fe85c6.tar.xz
MultiMC-6aa9bd0f77dcb5128167fae62e32aa5252fe85c6.zip
Renew the updater branch
Now with some actual consensus on what the updater will do!
Diffstat (limited to 'mmc_updater/src/UpdateDialogAscii.cpp')
-rw-r--r--mmc_updater/src/UpdateDialogAscii.cpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/mmc_updater/src/UpdateDialogAscii.cpp b/mmc_updater/src/UpdateDialogAscii.cpp
new file mode 100644
index 00000000..78eb7433
--- /dev/null
+++ b/mmc_updater/src/UpdateDialogAscii.cpp
@@ -0,0 +1,70 @@
+#include "UpdateDialogAscii.h"
+
+#include "AppInfo.h"
+#include "ProcessUtils.h"
+#include "StringUtils.h"
+
+const char* introMessage =
+ "%s (ASCII-art edition)\n"
+ "====================================\n"
+ "\n"
+ "We have a nice graphical interface for the %s, but unfortunately\n"
+ "we can't show it to you :(\n"
+ "\n"
+ "You can fix this by installing the GTK 2 libraries.\n\n"
+ "Installing Updates...\n";
+
+void UpdateDialogAscii::init(int /* argc */, char** /* argv */)
+{
+ const char* path = "/tmp/update-progress";
+ m_output.open(path);
+
+ char message[4096];
+ sprintf(message,introMessage,AppInfo::name().c_str());
+ m_output << message;
+
+ std::string command = "xterm";
+ std::list<std::string> args;
+ args.push_back("-hold");
+ args.push_back("-T");
+ args.push_back(AppInfo::name());
+ args.push_back("-e");
+ args.push_back("tail");
+ args.push_back("-n+1");
+ args.push_back("-f");
+ args.push_back(path);
+
+ ProcessUtils::runAsync(command,args);
+}
+
+void UpdateDialogAscii::updateError(const std::string& errorMessage)
+{
+ m_mutex.lock();
+ m_output << "\nThere was a problem installing the update: " << errorMessage << std::endl;
+ m_mutex.unlock();
+}
+
+void UpdateDialogAscii::updateProgress(int percentage)
+{
+ m_mutex.lock();
+ m_output << "Update Progress: " << intToStr(percentage) << '%' << std::endl;
+ m_mutex.unlock();
+}
+
+void UpdateDialogAscii::updateFinished()
+{
+ m_mutex.lock();
+ m_output << "\nUpdate Finished. You can now restart " << AppInfo::appName() << "." << std::endl;
+ m_mutex.unlock();
+
+ UpdateDialog::updateFinished();
+}
+
+void UpdateDialogAscii::quit()
+{
+}
+
+void UpdateDialogAscii::exec()
+{
+}
+