summaryrefslogtreecommitdiff
path: root/client/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'client/main.cpp')
-rw-r--r--client/main.cpp33
1 files changed, 27 insertions, 6 deletions
diff --git a/client/main.cpp b/client/main.cpp
index dc007a2..a1904ae 100644
--- a/client/main.cpp
+++ b/client/main.cpp
@@ -2,14 +2,17 @@
#include <stdio.h>
#ifdef WINDOWS
#include <direct.h>
- #define GetCurrentDir _getcwd
+ #define GetCurrentDir _getcwd
+ #define UpdaterName "updater.exe"
#else
#include <unistd.h>
- #define GetCurrentDir getcwd
+ #define GetCurrentDir getcwd
+ #define UpdaterName "updater"
#endif
#include <errno.h>
-#include <QString>
#include <QFileInfo>
+#include <QProcess>
+#include <QString>
#include "ProxyClientApp.h"
#include "client.h"
@@ -23,10 +26,28 @@ int main(int argc, char *argv[])
{
return errno;
}
+ QString cwd = currentPath;
+
+ // check if client should be updated
+ QFileInfo newClient(cwd + "/client.bin.latest");
+ if (newClient.exists())
+ {
+ Logger::Info("New client version found!\n");
+ QString updater = cwd + "/" UpdaterName;
+ if (QProcess::startDetached(updater))
+ {
+ Logger::Info("Updater launched\n");
+ return 0;
+ }
+ else
+ {
+ Logger::Error("Can't launch updater to update client app\n");
+ }
+ }
+
// check if initial config exists (config.cfg)
// without it application is useless
- QString configPath = QString::fromLocal8Bit(currentPath) + "/config.cfg";
- QFileInfo configInfo(configPath);
+ QFileInfo configInfo(cwd + "/config.cfg");
if (! configInfo.exists())
{
Logger::Fatal("Initial configuration file (config.cfg) do not exist!\n");
@@ -34,6 +55,6 @@ int main(int argc, char *argv[])
return -1;
}
- this_app = new ProxyClientApp(argc, argv);
+ this_app = new ProxyClientApp(argc, argv);
return this_app->exec();
}