Debian Codegraph @

src/main.cpp

raw symbols SCIP
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"
38 #include "global.h"
39 #include "commandline.h"
40
41 QCoreApplication* createApplication(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 (!qstrcmp(argv[i], "-c") || !(qstrcmp(argv[i], "--no-questions")))
46 return new QCoreApplication(argc, argv);
47
48 return new QApplication(argc, argv);
49 }
50
51 int main(int argc, char *argv[])
52 {
53 QScopedPointer<QCoreApplication> app(createApplication(argc, argv));
54
55 //arguments test
56 if (!argumentsTest(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 ( (runImmediately) && (!loadCurrentProfile()) )
61 return 2; // profile is not valid or does not exist
62
63 // task list validity check
64 if ( (runImmediately) && (!check_list()) )
65 return 3; // task list is not ok
66
67 // declared directories check
68 if ( (runImmediately) && (!check_dirs()) )
69 return 4; // declared dirs are not ok
70
71 // declare the rsync & ssh commands for use either at console or gui mode
72 declareRsyncCommand();
73
74 // if (!console) //execute gui
75 if (qobject_cast<QApplication *>(app.data())) //execute gui
76 {
77 // QApplication app(argc, argv);
78
79 //translation
80 QString locale = QLocale::system().name();
81
82 // Load standard Qt appTranslator
83 translator_qt.load(QString("qt_") + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
84 app->installTranslator(&translator_qt);
85
86 //load LB translator
87 transDir.setPath(relativeTransDir);
88 if (transDir.exists())
89 appTranslator.load(QString("luckybackup_") + locale, relativeTransDir);
90 else
91 appTranslator.load(QString("luckybackup_") + locale, systemTransDir);
92 app->installTranslator(&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 luckyBackupWindow luckybackup;
110 if (!silentMode)
111 luckybackup.show();
112 return app->exec();
113 }
114 else
115 //execute luckybackup in console mode
116 {
117 commandline commandLine;
118 return commandLine.result(); //then execute anything necessary
119 }
120
121 return 1;
122 }
123
124 // end of main.cpp---------------------------------------------------------