1 #ifndef JOB_H 2 #define JOB_H 3 4 #include "backuptask.h" 5 #include "persistentmodel/archive.h" 6 7 #include <QFileSystemWatcher> 8 #include <QObject> 9 #include <QUrl> 10 11 #define JOB_NAME_PREFIX QLatin1String("Job_") 12 13 class Job; 14 typedef QSharedPointer<Job> JobPtr; 15 16 Q_DECLARE_METATYPE(JobPtr) 17 18 typedef enum { Disabled, Daily, Weekly, Monthly } JobSchedule; 19 20 /*! 21 * \ingroup persistent 22 * \brief The Job stores metadata about a user's scheduled job. 23 */ 24 class Job : public QObject, public PersistentObject 25 { 26 Q_OBJECT 27 28 public: 29 //! Constructor. 30 explicit Job(QObject *parent = nullptr); 31 ~Job(); 32 33 //! Returns JOB_NAME_PREFIX + job name. 34 QString archivePrefix(); 35 36 //! Checks that each file listed in the Job exists. 37 bool validateUrls(); 38 39 //! Installs a watcher to notify us if any files or 40 //! directories in this Job are changed. 41 void installWatcher(); 42 //! Removes the filesystem watcher. 43 void removeWatcher(); 44 45 //! \name Getter/setter methods 46 //! @{ 47 QString name() const; 48 void setName(const QString &name); 49 50 QList<QUrl> urls() const; 51 void setUrls(const QList<QUrl> &urls); 52 53 QList<ArchivePtr> archives() const; 54 void setArchives(const QList<ArchivePtr> &archives); 55 56 JobSchedule optionScheduledEnabled() const; 57 void setOptionScheduledEnabled(JobSchedule schedule); 58 59 bool optionPreservePaths() const; 60 void setOptionPreservePaths(bool optionPreservePaths); 61 62 bool optionTraverseMount() const; 63 void setOptionTraverseMount(bool optionTraverseMount); 64 65 bool optionFollowSymLinks() const; 66 void setOptionFollowSymLinks(bool optionFollowSymLinks); 67 68 int optionSkipFilesSize() const; 69 void setOptionSkipFilesSize(const int &optionSkipFilesSize); 70 71 bool optionSkipFiles() const; 72 void setOptionSkipFiles(bool optionSkipFiles); 73 74 QString optionSkipFilesPatterns() const; 75 void setOptionSkipFilesPatterns(const QString &optionSkipFilesPatterns); 76 77 bool optionSkipNoDump() const; 78 void setOptionSkipNoDump(bool optionSkipNoDump); 79 80 bool settingShowHidden() const; 81 void setSettingShowHidden(bool settingShowHidden); 82 83 bool settingShowSystem() const; 84 void setSettingShowSystem(bool settingShowSystem); 85 86 bool settingHideSymlinks() const; 87 void setSettingHideSymlinks(bool settingHideSymlinks); 88 //! @} 89 90 //! Create a backupTask() which may be passed to TaskManager::backupNow(). 91 BackupTaskPtr createBackupTask(); 92 93 // From PersistentObject 94 //! Saves this object to the PersistentStore; creating or 95 //! updating as appropriate. 96 void save(); 97 //! Loads this object from the PersistentStore. The object's 98 //! \c _name must already be set. 99 void load(); 100 //! Deletes this object from the PersistentStore. The object's 101 //! \c _name must already be set. 102 void purge(); 103 //! Returns whether an object with this key exists in the PersistentStore. 104 bool doesKeyExist(QString key); 105 106 signals: 107 //! The list of archives belonging to this backup has changed. 108 void changed(); 109 //! This Job was deleted. 110 void purged(); 111 //! Notifies that the list of archives belonging to this Job 112 //! needs to be refreshed. 113 void loadArchives(); 114 //! A file or directory (which is being watched) has changed. 115 void fsEvent(); 116 117 private: 118 QString _name; 119 QList<QUrl> _urls; 120 QList<ArchivePtr> _archives; 121 QFileSystemWatcher _fsWatcher; 122 int _optionScheduledEnabled; 123 bool _optionPreservePaths; 124 bool _optionTraverseMount; 125 bool _optionFollowSymLinks; 126 int _optionSkipFilesSize; 127 bool _optionSkipFiles; 128 QString _optionSkipFilesPatterns; 129 bool _optionSkipNoDump; 130 bool _settingShowHidden; 131 bool _settingShowSystem; 132 bool _settingHideSymlinks; 133 }; 134 135 #endif // JOB_H 136