| 1 | /*-------------------------main.cpp------------------------------------------ |
| 2 | Main project is "luckyBackup" |
| 3 | a backup and sync tool |
| 4 | project version : 0.5.0 |
| 5 | |
| 6 | =============================================================================================================================== |
| 7 | =============================================================================================================================== |
| 8 | This file is part of "luckyBackup" project |
| 9 | Copyright, Loukas Avgeriou |
| 10 | luckyBackup is distributed under the terms of the GNU General Public License |
| 11 | luckyBackup is free software: you can redistribute it and/or modify |
| 12 | it under the terms of the GNU General Public License as published by |
| 13 | the Free Software Foundation, either version 3 of the License, or |
| 14 | (at your option) any later version. |
| 15 | |
| 16 | luckyBackup is distributed in the hope that it will be useful, |
| 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | GNU General Public License for more details. |
| 20 | |
| 21 | You should have received a copy of the GNU General Public License |
| 22 | along with luckyBackup. If not, see <http://www.gnu.org/licenses/>. |
| 23 | |
| 24 | developer : luckyb |
| 25 | last modified : 2 Nov 2018 |
| 26 | =============================================================================================================================== |
| 27 | =============================================================================================================================== |
| 28 | */ |
| 29 | |
| 30 | // Perform various initial checks |
| 31 | // include the qt libraries needed & the main window header file |
| 32 | // show the main window or execute in command line mode |
| 33 | |
| 34 | #include <QApplication> |
| 35 | #include <QTranslator> |
| 36 | |
| 37 | #include "luckybackupwindow.h"cxx . . $ `<file>/src/luckybackupwindow.h`/ |
| 38 | #include "global.h"cxx . . $ `<file>/src/global.h`/ |
| 39 | #include "commandline.h"cxx . . $ `<file>/src/commandline.h`/ |
| 40 | |
| 41 | QCoreApplicationcxx . . $ QCoreApplication#* createApplicationcxx . . $ createApplication(57527db2a07c7b19).(int &argc, char *argv[]) |
| 42 | { |
| 43 | // just copy&paste from Qt docu http://doc.qt.io/qt-5/qapplication.html |
| 44 | for (int i = 1; i < argc; ++i) |
| 45 | if (!qstrcmpcxx . . $ qstrcmp(5ae29d726ae57f88).(argv[i], "-c") || !(qstrcmpcxx . . $ qstrcmp(5ae29d726ae57f88).(argv[i], "--no-questions"))) |
| 46 | return new QCoreApplicationcxx . . $ QCoreApplication#QCoreApplication(6e9b1c7df49e191d).(argc, argv); |
| 47 | |
| 48 | return new QApplicationcxx . . $ QApplication#QApplication(6e9b1c7df49e191d).(argc, argv); |
| 49 | } |
| 50 | |
| 51 | int maincxx . . $ main(afcd3168fc1188a4).(int argc, char *argv[]) |
| 52 | { |
| 53 | QScopedPointercxx . . $ QScopedPointer#<QCoreApplicationcxx . . $ QCoreApplication#> appcxx . . $ QScopedPointer#QScopedPointer(6f97683fca3ece44).(createApplicationcxx . . $ createApplication(57527db2a07c7b19).(argc, argv)); |
| 54 | |
| 55 | //arguments test |
| 56 | if (!argumentsTestcxx . . $ Global/argumentsTest(999dbd1e14140801).(argc,argv)) |
| 57 | return 1; // error code1: something wrong with the command arguments - app fail to start (or just --help or --version given as args) |
| 58 | |
| 59 | //profile validity check for console mode or gui-no profile specified (will use default) |
| 60 | if ( (runImmediatelycxx . . $ Global/runImmediately.) && (!loadCurrentProfilecxx . . $ Global/loadCurrentProfile(c9857a73d68e59ba).()) ) |
| 61 | return 2; // profile is not valid or does not exist |
| 62 | |
| 63 | // task list validity check |
| 64 | if ( (runImmediatelycxx . . $ Global/runImmediately.) && (!check_listcxx . . $ Global/check_list(c9857a73d68e59ba).()) ) |
| 65 | return 3; // task list is not ok |
| 66 | |
| 67 | // declared directories check |
| 68 | if ( (runImmediatelycxx . . $ Global/runImmediately.) && (!check_dirscxx . . $ Global/check_dirs(c9857a73d68e59ba).()) ) |
| 69 | return 4; // declared dirs are not ok |
| 70 | |
| 71 | // declare the rsync & ssh commands for use either at console or gui mode |
| 72 | declareRsyncCommandcxx . . $ Global/declareRsyncCommand(49f6e7a06ebc5aa8).(); |
| 73 | |
| 74 | // if (!console) //execute gui |
| 75 | if (qobject_castcxx . . $ qobject_cast(c988cfc0ca08742e).<QApplicationcxx . . $ QApplication# *>(app.datacxx . . $ QScopedPointer#data(34d6acfd341ba7ab).())) //execute gui |
| 76 | { |
| 77 | // QApplication app(argc, argv); |
| 78 | |
| 79 | //translation |
| 80 | QStringcxx . . $ QString# locale = QLocalecxx . . $ QLocale#::systemcxx . . $ QLocale#system(7171962d3a2fd395).().namecxx . . $ QLocale#name(6ef7b6c27b00b43d).(); |
| 81 | |
| 82 | // Load standard Qt appTranslator |
| 83 | translator_qtcxx . . $ Global/translator_qt..loadcxx . . $ QTranslator#load(142924642d8b819d).(QStringcxx . . $ QString#QString(85c52e162fed56f9).("qt_") +cxx . . $ operator+(fab9b4f80031f353). locale, QLibraryInfocxx . . $ QLibraryInfo#::locationcxx . . $ QLibraryInfo#location(dd7ac78f10b8a525).(QLibraryInfocxx . . $ QLibraryInfo#::TranslationsPathcxx . . $ QLibraryInfo#TranslationsPath.)); |
| 84 | app->cxx . . $ QScopedPointer#`operator->`(34d6acfd341ba7ab).installTranslatorcxx . . $ QCoreApplication#installTranslator(d376406de50edad7).(&translator_qtcxx . . $ Global/translator_qt.); |
| 85 | |
| 86 | //load LB translator |
| 87 | transDircxx . . $ Global/transDir..setPathcxx . . $ QDir#setPath(3520e46b33348bf6).(relativeTransDircxx . . $ Global/relativeTransDir.); |
| 88 | if (transDircxx . . $ Global/transDir..existscxx . . $ QDir#exists(50ce9a9e25b4a850).()) |
| 89 | appTranslatorcxx . . $ Global/appTranslator..loadcxx . . $ QTranslator#load(142924642d8b819d).(QStringcxx . . $ QString#QString(85c52e162fed56f9).("luckybackup_") +cxx . . $ operator+(fab9b4f80031f353). locale, relativeTransDircxx . . $ Global/relativeTransDir.); |
| 90 | else |
| 91 | appTranslatorcxx . . $ Global/appTranslator..loadcxx . . $ QTranslator#load(142924642d8b819d).(QStringcxx . . $ QString#QString(85c52e162fed56f9).("luckybackup_") +cxx . . $ operator+(fab9b4f80031f353). locale, systemTransDircxx . . $ Global/systemTransDir.); |
| 92 | app->cxx . . $ QScopedPointer#`operator->`(34d6acfd341ba7ab).installTranslatorcxx . . $ QCoreApplication#installTranslator(d376406de50edad7).(&appTranslatorcxx . . $ Global/appTranslator.); |
| 93 | |
| 94 | // windows related stuff |
| 95 | /* appPath = app->applicationDirPath(); // This is used for windows app path. It's also causing a ... |
| 96 | //"QCoreApplication::applicationDirPath: Please instantiate the QApplication object first" WARNING message |
| 97 | rsyncDefaultWinCommand = appPath+"/rsync.exe"; // Holds the default rsync command for windows |
| 98 | sshDefaultWinCommand = appPath+"/ssh.exe"; // Holds the default ssh command for windows |
| 99 | mapdrive="w"; |
| 100 | vshadowDir= appPath; |
| 101 | vshadowDefaultDir= appPath; |
| 102 | dosdevCommand= appPath+"/dosdev.exe"; |
| 103 | dosdevDefaultCommand= appPath+"/dosdev.exe"; |
| 104 | cygpathCommand= appPath+"/cygpath.exe"; |
| 105 | cygpathDefaultCommand= appPath+"/cygpath.exe"; |
| 106 | */ |
| 107 | // end of windows stuff ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 108 | |
| 109 | luckyBackupWindowcxx . . $ luckyBackupWindow# luckybackupcxx . . $ luckyBackupWindow#luckyBackupWindow(f2c32f691ede4a4e).; |
| 110 | if (!silentModecxx . . $ Global/silentMode.) |
| 111 | luckybackup.showcxx . . $ QWidget#show(49f6e7a06ebc5aa8).(); |
| 112 | return app->cxx . . $ QScopedPointer#`operator->`(34d6acfd341ba7ab).execcxx . . $ QCoreApplication#exec(b126dc7c1de90089).(); |
| 113 | } |
| 114 | else |
| 115 | //execute luckybackup in console mode |
| 116 | { |
| 117 | commandlinecxx . . $ commandline# commandLinecxx . . $ commandline#commandline(49f6e7a06ebc5aa8).; |
| 118 | return commandLine.resultcxx . . $ commandline#result(b126dc7c1de90089).(); //then execute anything necessary |
| 119 | } |
| 120 | |
| 121 | return 1; |
| 122 | } |
| 123 | |
| 124 | // end of main.cpp--------------------------------------------------------- |