File indexing completed on 2024-03-24 17:22:55

0001 // SPDX-FileCopyrightText: 2020 Simon Persson <simon.persson@mykolab.com>
0002 //
0003 // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004 
0005 #ifndef BACKUPJOB_H
0006 #define BACKUPJOB_H
0007 
0008 #include "backupplan.h"
0009 
0010 #include <KJob>
0011 
0012 #include <QFile>
0013 #include <QStringList>
0014 #include <QTextStream>
0015 
0016 class KupDaemon;
0017 
0018 class BackupJob : public KJob
0019 {
0020     Q_OBJECT
0021 public:
0022     enum ErrorCodes {
0023         ErrorWithLog = UserDefinedError,
0024         ErrorWithoutLog,
0025         ErrorSuggestRepair,
0026         ErrorSourcesConfig
0027     };
0028 
0029     void start() override;
0030 
0031 protected slots:
0032     virtual void performJob() = 0;
0033 
0034 protected:
0035     BackupJob(BackupPlan &pBackupPlan, QString pDestinationPath, QString pLogFilePath, KupDaemon *pKupDaemon);
0036     static void makeNice(int pPid);
0037     static QString quoteArgs(const QStringList &pCommand);
0038     void jobFinishedSuccess();
0039     void jobFinishedError(ErrorCodes pErrorCode, const QString &pErrorText);
0040     BackupPlan &mBackupPlan;
0041     QString mDestinationPath;
0042     QString mLogFilePath;
0043     QFile mLogFile;
0044     QTextStream mLogStream;
0045     KupDaemon *mKupDaemon;
0046 };
0047 
0048 #endif // BACKUPJOB_H