2011-08-26 16:36:22 +00:00
|
|
|
#include "UpdateDialogAscii.h"
|
|
|
|
|
2011-08-26 17:20:38 +00:00
|
|
|
#include "AppInfo.h"
|
2011-08-26 16:36:22 +00:00
|
|
|
#include "ProcessUtils.h"
|
|
|
|
#include "StringUtils.h"
|
|
|
|
|
|
|
|
const char* introMessage =
|
2011-08-26 17:20:38 +00:00
|
|
|
"%s (ASCII-art edition)\n"
|
2011-08-26 16:36:22 +00:00
|
|
|
"====================================\n"
|
|
|
|
"\n"
|
2011-08-26 17:20:38 +00:00
|
|
|
"We have a nice graphical interface for the %s, but unfortunately\n"
|
2011-08-26 16:36:22 +00:00
|
|
|
"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()
|
|
|
|
{
|
|
|
|
const char* path = "/tmp/update-progress";
|
|
|
|
m_output.open(path);
|
2011-08-26 17:20:38 +00:00
|
|
|
|
|
|
|
char message[4096];
|
|
|
|
sprintf(message,introMessage,AppInfo::name().c_str());
|
|
|
|
m_output << message;
|
2011-08-26 16:36:22 +00:00
|
|
|
|
|
|
|
std::string command = "xterm";
|
|
|
|
std::list<std::string> args;
|
|
|
|
args.push_back("-hold");
|
|
|
|
args.push_back("-T");
|
2011-08-26 17:20:38 +00:00
|
|
|
args.push_back(AppInfo::name());
|
2011-08-26 16:36:22 +00:00
|
|
|
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 Mendeley Desktop." << std::endl;
|
|
|
|
m_mutex.unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
|