| 1 | /* ------------------ global.h -------------------------------------------------------------------------------------- |
| 2 | header file for luckyBackup project |
| 3 | |
| 4 | =============================================================================================================================== |
| 5 | =============================================================================================================================== |
| 6 | This file is part of "luckyBackup" project |
| 7 | Copyright, Loukas Avgeriou |
| 8 | luckyBackup is distributed under the terms of the GNU General Public License |
| 9 | luckyBackup is free software: you can redistribute it and/or modify |
| 10 | it under the terms of the GNU General Public License as published by |
| 11 | the Free Software Foundation, either version 3 of the License, or |
| 12 | (at your option) any later version. |
| 13 | |
| 14 | luckyBackup is distributed in the hope that it will be useful, |
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | GNU General Public License for more details. |
| 18 | |
| 19 | You should have received a copy of the GNU General Public License |
| 20 | along with luckyBackup. If not, see <http://www.gnu.org/licenses/>. |
| 21 | |
| 22 | |
| 23 | project version : Please see "main.cpp" for project version |
| 24 | |
| 25 | developer : luckyb |
| 26 | last modified : 22 May 2016 |
| 27 | =============================================================================================================================== |
| 28 | =============================================================================================================================== |
| 29 | */ |
| 30 | |
| 31 | |
| 32 | #ifndef GLOBAL_H |
| 33 | #define GLOBAL_Hcxx . . $ `src/global.h:33:9`! |
| 34 | |
| 35 | #include <QString> |
| 36 | #include <QDir> |
| 37 | #include <QFile> |
| 38 | #include <QLocale> |
| 39 | #include <QTranslator> |
| 40 | #include <QLibraryInfo> |
| 41 | #include <QCoreApplication> |
| 42 | |
| 43 | class operationcxx . . $ operation#; |
| 44 | |
| 45 | namespace Globalcxx . . $ Global/ { |
| 46 | extern QStringcxx . . $ QString# myHomecxx . . $ Global/myHome.; // user's home directory |
| 47 | extern QStringcxx . . $ QString# currentUsercxx . . $ Global/currentUser.; // will hold the current username (definition at luckybackupwindow.cpp) |
| 48 | extern QStringcxx . . $ QString# const appNamecxx . . $ Global/appName.; // application name |
| 49 | extern double const appVersioncxx . . $ Global/appVersion.; // application version |
| 50 | extern QStringcxx . . $ QString# appVersionStringcxx . . $ Global/appVersionString.; // application version |
| 51 | extern double const validProfileVersioncxx . . $ Global/validProfileVersion.; // profile version before this a profile won't be loaded |
| 52 | extern double const validScheduleVersioncxx . . $ Global/validScheduleVersion.; // schedule version before this a schedule won't be loaded |
| 53 | extern double const validSettingsVersioncxx . . $ Global/validSettingsVersion.; // Settings file valid version |
| 54 | extern QStringcxx . . $ QString# luckyBackupDircxx . . $ Global/luckyBackupDir.; // app working directory |
| 55 | extern QStringcxx . . $ QString# luckyBackupDefaultDircxx . . $ Global/luckyBackupDefaultDir.; // same as above. WINDOWS use |
| 56 | extern QStringcxx . . $ QString# settingsFilecxx . . $ Global/settingsFile.; // settings file |
| 57 | extern QStringcxx . . $ QString# profileDircxx . . $ Global/profileDir.; // profiles directory |
| 58 | extern QStringcxx . . $ QString# defaultProfilecxx . . $ Global/defaultProfile.; // default profile |
| 59 | extern QStringcxx . . $ QString# standardDefaultProfilecxx . . $ Global/standardDefaultProfile.; // standard default profile |
| 60 | extern QStringcxx . . $ QString# logDircxx . . $ Global/logDir.; // logs directory |
| 61 | extern QStringcxx . . $ QString# logfilenamecxx . . $ Global/logfilename.; // logfile filename - this will change according to the profile an task executed |
| 62 | extern QStringcxx . . $ QString# cronlogStringcxx . . $ Global/cronlogString.; // cron logfile full filename: "ProfileName-LastCronLog.log" |
| 63 | extern QStringcxx . . $ QString# emailLogStringcxx . . $ Global/emailLogString.; // logfile to send by email (all task logs merged) full filename: "ProfileName-email.log" |
| 64 | extern QStringcxx . . $ QString# emailLastLogStringcxx . . $ Global/emailLastLogString.; // email logfile full filename: "ProfileName-email-LastLog.log" |
| 65 | extern QStringcxx . . $ QString# snapDefaultDircxx . . $ Global/snapDefaultDir.; // This is the directory where snapshots are placed. It lies inside the destination |
| 66 | extern QStringcxx . . $ QString# snapChangesDircxx . . $ Global/snapChangesDir.; // Snapshots changes files are stored here. It lies inside ~ |
| 67 | extern QStringcxx . . $ QString# snapEmptyDircxx . . $ Global/snapEmptyDir.; // empty directory used to delete older snapshots |
| 68 | extern QStringcxx . . $ QString# snapchangesfilenamecxx . . $ Global/snapchangesfilename.; // Snapshot changes filename. This will change according to the snapshot |
| 69 | extern QStringcxx . . $ QString# snapChangesStringcxx . . $ Global/snapChangesString.; // The log lines format of the "changes" file that stores changes made for every snapshot |
| 70 | extern QStringcxx . . $ QString# scheduleDircxx . . $ Global/scheduleDir.; // schedule directory |
| 71 | extern QStringcxx . . $ QString# schedulefilenamecxx . . $ Global/schedulefilename.; // cron data filename |
| 72 | extern QStringcxx . . $ QString# cronfilenamecxx . . $ Global/cronfilename.; // cron filename |
| 73 | extern QStringcxx . . $ QString# relativeTransDircxx . . $ Global/relativeTransDir.; // translation directory when app executed but not installed |
| 74 | extern QStringcxx . . $ QString# systemTransDircxx . . $ Global/systemTransDir.; // system translation directory (when app is installed) |
| 75 | extern QDircxx . . $ QDir# transDircxx . . $ Global/transDir.; // the current translations directory |
| 76 | extern QTranslatorcxx . . $ QTranslator# appTranslatorcxx . . $ Global/appTranslator.; // QTranslator that holds the applications translation |
| 77 | extern QTranslatorcxx . . $ QTranslator# translator_qtcxx . . $ Global/translator_qt.; //QTranslator that holds the standard Qt translations |
| 78 | extern QStringcxx . . $ QString# localecxx . . $ Global/locale.; // String that holds the current language locale |
| 79 | extern QStringcxx . . $ QString# relativeLicensecxx . . $ Global/relativeLicense.; // licence directory when app executed but not installed |
| 80 | extern QStringcxx . . $ QString# systemLicensecxx . . $ Global/systemLicense.; // system licence directory (when app is installed) |
| 81 | extern QStringcxx . . $ QString# suseLicensecxx . . $ Global/suseLicense.; // system licence directory (when app is installed) - openSuse |
| 82 | extern QStringcxx . . $ QString# debianLicensecxx . . $ Global/debianLicense.; // system licence directory (when app is installed) - debian |
| 83 | extern QStringcxx . . $ QString# relativeManualcxx . . $ Global/relativeManual.; // manual directory when app executed but not installed |
| 84 | extern QStringcxx . . $ QString# systemManualcxx . . $ Global/systemManual.; // system manual directory (when app is installed) |
| 85 | extern QStringcxx . . $ QString# suseManualcxx . . $ Global/suseManual.; // system manual directory (when app is installed) - opensuse |
| 86 | |
| 87 | extern QStringcxx . . $ QString# countStrcxx . . $ Global/countStr.; // this helps displaying integers as strings |
| 88 | extern QStringcxx . . $ QString# messagecxx . . $ Global/message.; // this is really handy to hold messages for dialogs |
| 89 | extern QStringcxx . . $ QString# messageCLIcxx . . $ Global/messageCLI.; // this is really handy to hold messages for the Command-Line |
| 90 | extern int errorsFoundcxx . . $ Global/errorsFound.; // count errors when executing rync or pre/post command |
| 91 | extern int filesTransferedcxx . . $ Global/filesTransfered.; // count files transfered when executing rync |
| 92 | extern unsigned long long int bytesTransferedcxx . . $ Global/bytesTransfered.; // count bytes transfered when executing rync |
| 93 | |
| 94 | // Useful variables for operations --------------------------------------------------------------------------------------------------- |
| 95 | extern int const maxOperationscxx . . $ Global/maxOperations.; // The maximum number or operations permitted |
| 96 | extern int TotalOperationscxx . . $ Global/TotalOperations.; // The number of available operations "operations list"- starts from 1 |
| 97 | extern int currentOperationcxx . . $ Global/currentOperation.; // this holds the current row from the operations list- starts from 0 |
| 98 | extern int removeCharLimitcxx . . $ Global/removeCharLimit.; // No of characters to remove from lines inside snapshot .changes file |
| 99 | extern bool modifyOKcxx . . $ Global/modifyOK.; // bool variable that says create or modify opeartion went ok |
| 100 | extern bool modifyConnectedcxx . . $ Global/modifyConnected.; // if the operation under modification is connected to another op, this becomes true |
| 101 | extern bool DryRuncxx . . $ Global/DryRun.; // shows if dry-run is checked |
| 102 | extern bool askcxx . . $ Global/ask.; // becomes true if we want to ask the user if he/she wants to continue with the execution of operations or not |
| 103 | extern bool newTaskThisIscxx . . $ Global/newTaskThisIs.; // becomes true if "add task" is pressed and false if "modify" task is pressed |
| 104 | extern bool NothingToDocxx . . $ Global/NothingToDo.; // Becomes true if there is nothing to do when start button pressed |
| 105 | extern bool NothingIncludedcxx . . $ Global/NothingIncluded.; // Becomes true if there is nothing checked ("include" checkboxes) |
| 106 | extern bool crontabUpdatedcxx . . $ Global/crontabUpdated.; // Becomes true if the user's crontab is updated |
| 107 | extern QStringcxx . . $ QString# currentProfilecxx . . $ Global/currentProfile.; // This holds the filename of the currently used profile |
| 108 | extern QStringcxx . . $ QString# profileNamecxx . . $ Global/profileName.; // just holds the profile name not the full path+filename.profile |
| 109 | extern QStringcxx . . $ QString# profileDescriptioncxx . . $ Global/profileDescription.; // holds a description of the profile |
| 110 | extern QFilecxx . . $ QFile# profilecxx . . $ Global/profile.; // this is the profile QFile |
| 111 | extern QFilecxx . . $ QFile# logfilecxx . . $ Global/logfile.; // this is the logfile QFile |
| 112 | extern QFilecxx . . $ QFile# snapfilecxx . . $ Global/snapfile.; // this is the snapshot changes QFile |
| 113 | extern QStringcxx . . $ QString# CheckedDatacxx . . $ Global/CheckedData.; // String holding the current task message (OK - WARNING - CRITICAL) for info window display |
| 114 | extern QStringcxx . . $ QString# CheckedDataCLIcxx . . $ Global/CheckedDataCLI.; // String holding the current task message (OK - WARNING - CRITICAL) for CLI display |
| 115 | extern operationcxx . . $ operation# *Operationcxx . . $ Global/Operation.[]; //The array that holds name, source, destination & arguments of "Opereations list" |
| 116 | |
| 117 | extern bool consolecxx . . $ Global/console.; // these become true depending on the argument given at command line |
| 118 | extern bool NoQuestionscxx . . $ Global/NoQuestions.; // do not ask any questions at console mode |
| 119 | extern bool SkipCriticalcxx . . $ Global/SkipCritical.; // skip critical tasks |
| 120 | extern bool silentModecxx . . $ Global/silentMode.; // start at silent mode |
| 121 | extern bool runImmediatelycxx . . $ Global/runImmediately.; // execute a profile immediately after gui loads |
| 122 | extern bool validationcxx . . $ Global/validation.; // becomes true if "validation check" button is pressed |
| 123 | extern bool KDErunningcxx . . $ Global/KDErunning.; // becomes true if desktop running is KDE |
| 124 | extern bool GNOMErunningcxx . . $ Global/GNOMErunning.; // becomes true if desktop running is GNOME |
| 125 | |
| 126 | // functions ------------------------------------------------------------------------------------------------------------------------ |
| 127 | extern bool argumentsTestcxx . . $ Global/argumentsTest(999dbd1e14140801).(int , char**); // checks the arguments given at command-line and returns true if everything is ok |
| 128 | extern bool loadCurrentProfilecxx . . $ Global/loadCurrentProfile(c9857a73d68e59ba).(); // loads an already created profile |
| 129 | void declareRsyncCommandcxx . . $ Global/declareRsyncCommand(49f6e7a06ebc5aa8).(); // Declares the rsync & ssh commands (full path for windows) |
| 130 | extern bool check_listcxx . . $ Global/check_list(c9857a73d68e59ba).(); // check the operations list |
| 131 | extern bool check_dirscxx . . $ Global/check_dirs(c9857a73d68e59ba).(); // check directories of declared profile data |
| 132 | |
| 133 | void helpcxx . . $ Global/help(49f6e7a06ebc5aa8).(); // Displayes command-line usage |
| 134 | void checkSyncDirscxx . . $ Global/checkSyncDirs(3458fe3960d5051).(QStringcxx . . $ QString#, QStringcxx . . $ QString#); // function to check if the directories to be synced exist or are empty |
| 135 | void checkBackupDirscxx . . $ Global/checkBackupDirs(3458fe3960d5051).(QStringcxx . . $ QString#, QStringcxx . . $ QString#); // function to check if the source & dest dirs exist and are not empty |
| 136 | int loadProfilecxx . . $ Global/loadProfile(87a9b7c6fe1ccdba).(QStringcxx . . $ QString#); // loads an existing profile - text mode |
| 137 | int loadProfileQVcxx . . $ Global/loadProfileQV(87a9b7c6fe1ccdba).(QStringcxx . . $ QString#); // loads an existing profile - data mode |
| 138 | extern bool saveProfilecxx . . $ Global/saveProfile(7dc6c9a0b6a7270f).(QStringcxx . . $ QString#); // saves an existing profile |
| 139 | extern bool exportFullProfilecxx . . $ Global/exportFullProfile(80825a4bb658cac2).(QStringcxx . . $ QString#,QStringcxx . . $ QString#); // function to export the .profile file + logs + snaps |
| 140 | extern int importFullProfilecxx . . $ Global/importFullProfile(cf8c7f074bbf9512).(QStringcxx . . $ QString#,QStringcxx . . $ QString#); // function to import the .profile file + logs + snaps (whatever is available) |
| 141 | extern bool checkTaskListcxx . . $ Global/checkTaskList(c9857a73d68e59ba).(); // Checks if the Task list is ok to proceed |
| 142 | extern bool checkDeclaredDirscxx . . $ Global/checkDeclaredDirs(efaadfb7dc14930a).(bool); // Check if the declared data are ok by calling checkBackupDirs or checkSyncDirs |
| 143 | QStringListcxx . . $ QStringList# AppendArgumentscxx . . $ Global/AppendArguments(20f639a182fdbea2).(operationcxx . . $ operation#*); // Set command's (normally rsync) arguments |
| 144 | extern bool writeToLogcxx . . $ Global/writeToLog.; // if the log file is ok to write this becomes true |
| 145 | extern QStringcxx . . $ QString# logFileUpdatecxx . . $ Global/logFileUpdate(5faf0f1f209776e3).(QStringcxx . . $ QString#, QStringcxx . . $ QString#, int); // Update the logfile with some string |
| 146 | extern bool checkMountPointcxx . . $ Global/checkMountPoint(7dc6c9a0b6a7270f).(QStringcxx . . $ QString#); // Check if a path belongs to a mountpoint or is a mountpoint itself |
| 147 | void setTextMessagescxx . . $ Global/setTextMessages(8b26822d2f26f476).(QStringcxx . . $ QString#,QStringcxx . . $ QString#,bool,bool,QStringcxx . . $ QString#,QStringcxx . . $ QString#,QStringcxx . . $ QString#); // function to set text feedback for the user |
| 148 | extern QStringcxx . . $ QString# fixWinPathForRsynccxx . . $ Global/fixWinPathForRsync(afa4754008a97e3f).(QStringcxx . . $ QString#,bool); // Fixes a windows path for rsync use |
| 149 | extern QStringcxx . . $ QString# calculateLastPathcxx . . $ Global/calculateLastPath(f7f320d754b8fd09).(QStringcxx . . $ QString#); // Calculates the last part of a path eg path=user@host:destination\path\here -> returns "here" |
| 150 | |
| 151 | extern QStringcxx . . $ QString# emailCommandcxx . . $ Global/emailCommand.; |
| 152 | extern QStringcxx . . $ QString# emailArgumentscxx . . $ Global/emailArguments.; |
| 153 | extern bool emailNevercxx . . $ Global/emailNever.; |
| 154 | extern bool emailErrorcxx . . $ Global/emailError.; |
| 155 | extern bool emailSchedulecxx . . $ Global/emailSchedule.; |
| 156 | extern bool emailTLScxx . . $ Global/emailTLS.; |
| 157 | extern QStringcxx . . $ QString# emailFromcxx . . $ Global/emailFrom.; |
| 158 | extern QStringcxx . . $ QString# emailTocxx . . $ Global/emailTo.; |
| 159 | extern QStringcxx . . $ QString# emailSubjectcxx . . $ Global/emailSubject.; |
| 160 | extern QStringcxx . . $ QString# emailSMTPcxx . . $ Global/emailSMTP.; |
| 161 | extern QStringcxx . . $ QString# emailBodycxx . . $ Global/emailBody.; |
| 162 | extern QStringcxx . . $ QString# emailDefaultSubjectcxx . . $ Global/emailDefaultSubject.; // Holds the default subject |
| 163 | extern QStringcxx . . $ QString# emailDefaultBodycxx . . $ Global/emailDefaultBody.; // Holds the default body text |
| 164 | extern QStringcxx . . $ QString# emailDefaultCommandcxx . . $ Global/emailDefaultCommand.; // Holds the default email command |
| 165 | extern QStringcxx . . $ QString# emailDefaultArgumentscxx . . $ Global/emailDefaultArguments.; // Holds the default email arguments |
| 166 | extern QStringcxx . . $ QString# emailDefaultWinCommandcxx . . $ Global/emailDefaultWinCommand.; // Holds the default email command - WINDOWS |
| 167 | extern QStringcxx . . $ QString# emailDefaultWinArgumentscxx . . $ Global/emailDefaultWinArguments.; // Holds the default email arguments - WINDOWS |
| 168 | extern QStringcxx . . $ QString# sendEmailNowcxx . . $ Global/sendEmailNow(f4d483874300e612).(bool); // Send an email after a profile run. bool is true if called for testing purposes |
| 169 | |
| 170 | extern QStringcxx . . $ QString# rsyncDefaultCommandcxx . . $ Global/rsyncDefaultCommand.; // Holds the default rsync command |
| 171 | extern QStringcxx . . $ QString# sshDefaultCommandcxx . . $ Global/sshDefaultCommand.; // Holds the default ssh command |
| 172 | |
| 173 | // WINDOWS related variables. Also search variables above for "WINDOWS use" |
| 174 | extern QStringcxx . . $ QString# rsyncDefaultWinCommandcxx . . $ Global/rsyncDefaultWinCommand.; // Holds the default rsync command for windows |
| 175 | extern QStringcxx . . $ QString# sshDefaultWinCommandcxx . . $ Global/sshDefaultWinCommand.; // Holds the default ssh command for windows |
| 176 | extern QStringcxx . . $ QString# appPathcxx . . $ Global/appPath.; // This is used for windows app path. It's also causing a ... |
| 177 | //"QCoreApplication::applicationDirPath: Please instantiate the QApplication object first" WARNING message |
| 178 | //extern QString rsyncDefaultWinCommand; // Holds the default rsync command for windows |
| 179 | //extern QString sshDefaultWinCommand; // Holds the default ssh command for windows |
| 180 | extern QStringcxx . . $ QString# mapdrivecxx . . $ Global/mapdrive.; |
| 181 | extern QStringcxx . . $ QString# vshadowDircxx . . $ Global/vshadowDir.; |
| 182 | extern QStringcxx . . $ QString# vshadowDefaultDircxx . . $ Global/vshadowDefaultDir.; |
| 183 | extern QStringcxx . . $ QString# dosdevCommandcxx . . $ Global/dosdevCommand.; |
| 184 | extern QStringcxx . . $ QString# dosdevDefaultCommandcxx . . $ Global/dosdevDefaultCommand.; |
| 185 | extern QStringcxx . . $ QString# cygpathCommandcxx . . $ Global/cygpathCommand.; |
| 186 | extern QStringcxx . . $ QString# cygpathDefaultCommandcxx . . $ Global/cygpathDefaultCommand.; |
| 187 | extern bool isTempDirPathcxx . . $ Global/isTempDirPath.; |
| 188 | extern QStringcxx . . $ QString# tempDirPathcxx . . $ Global/tempDirPath.; |
| 189 | extern QStringcxx . . $ QString# tempDefaultDirPathcxx . . $ Global/tempDefaultDirPath.; |
| 190 | void setAppDircxx . . $ Global/setAppDir(7df51288a9ebd664).(QStringcxx . . $ QString# s); |
| 191 | /* disable vss until |
| 192 | int doVss=0; |
| 193 | int vssPos=0; |
| 194 | int vssErrPos=0; |
| 195 | QTimer *vssTimer; |
| 196 | int vssSleepTime=50; |
| 197 | int vssReadSize=400; |
| 198 | QFile *pipeVssFile; |
| 199 | QFile *pipeVssErrFile;*/ |
| 200 | //QString createWinMkdirCommand(QString tempPath,bool vss,QStringList rsyncArgs,bool logGui); |
| 201 | extern QStringcxx . . $ QString# createWinRsyncCommandcxx . . $ Global/createWinRsyncCommand(f72b83e3d8c9da9d).(QStringcxx . . $ QString# tempPath,bool vss,QStringListcxx . . $ QStringList# rsyncArgs,bool logGui=true); |
| 202 | // END of Windows related variables |
| 203 | |
| 204 | extern QStringcxx . . $ QString# rsyncCommandPathcxx . . $ Global/rsyncCommandPath.; // holds the full path of the rsync command for WINDOWS or just "rsync" for *nix |
| 205 | extern QStringcxx . . $ QString# sshCommandPathcxx . . $ Global/sshCommandPath.; // holds the full path of the ssh command for WINDOWS or just "ssh" for *nix |
| 206 | |
| 207 | extern QStringcxx . . $ QString# XnixSLASHcxx . . $ Global/XnixSLASH.; // holds the default Xnix slash which is / |
| 208 | |
| 209 | extern bool OS2runningcxx . . $ Global/OS2running.; |
| 210 | extern QStringcxx . . $ QString# SLASHcxx . . $ Global/SLASH.; |
| 211 | extern bool WINrunningcxx . . $ Global/WINrunning.; |
| 212 | extern bool notXnixRunningcxx . . $ Global/notXnixRunning.; |
| 213 | } |
| 214 | using namespace Global; |
| 215 | #endif |
| 216 | // end of global.h-------------------------------------------------------------- |