File indexing completed on 2024-03-24 05:49:24

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 BACKUPPLAN_H
0006 #define BACKUPPLAN_H
0007 
0008 #include <KCoreConfigSkeleton>
0009 
0010 class Schedule;
0011 
0012 class BackupPlan : public KCoreConfigSkeleton
0013 {
0014 public:
0015     BackupPlan(int pPlanNumber, KSharedConfigPtr pConfig, QObject *pParent = nullptr);
0016     int planNumber() const {return mPlanNumber;}
0017     virtual void setPlanNumber(int pPlanNumber);
0018     QString statusText();
0019     void removePlanFromConfig();
0020     void copyFrom(const BackupPlan &pPlan);
0021 
0022     QString mDescription;
0023     QStringList mPathsIncluded;
0024     QStringList mPathsExcluded;
0025     enum BackupType {BupType = 0, RsyncType};
0026     qint32 mBackupType{};
0027     qint32 mBackupVersion{};
0028 
0029     enum ScheduleType {MANUAL=0, INTERVAL, USAGE};
0030     qint32 mScheduleType{};
0031     qint32 mScheduleInterval{};
0032     qint32 mScheduleIntervalUnit{};
0033     qint32 mUsageLimit{}; // in hours
0034     bool mAskBeforeTakingBackup{};
0035 
0036     qint32 mDestinationType{};
0037     QUrl mFilesystemDestinationPath;
0038     QString mExternalUUID;
0039     QString mExternalDestinationPath;
0040     QString mExternalVolumeLabel;
0041     QString mExternalDeviceDescription;
0042     int mExternalPartitionNumber{};
0043     int mExternalPartitionsOnDrive{};
0044     qulonglong mExternalVolumeCapacity{};
0045 
0046     bool mShowHiddenFolders{};
0047     bool mGenerateRecoveryInfo{};
0048     bool mCheckBackups{};
0049     bool mExcludePatterns{};
0050     QString mExcludePatternsPath;
0051 
0052     QDateTime mLastCompleteBackup;
0053     // Size of the last backup in bytes.
0054     double mLastBackupSize{};
0055     // Last known available space on destination
0056     double mLastAvailableSpace{};
0057     // How long has Kup been running since last backup (s)
0058     quint32 mAccumulatedUsageTime{};
0059 
0060     virtual QDateTime nextScheduledTime();
0061     virtual qint64 scheduleIntervalInSeconds();
0062 
0063     enum Status {GOOD, MEDIUM, BAD, NO_STATUS};
0064     Status backupStatus();
0065     static QString iconName(Status pStatus);
0066     QString absoluteExcludesFilePath();
0067 
0068 protected:
0069     void usrRead() override;
0070     int mPlanNumber;
0071 };
0072 
0073 #endif // BACKUPPLAN_H