File indexing completed on 2024-04-14 15:50:49

0001 /**
0002  * SPDX-FileCopyrightText: (C) 2003 by Sébastien Laoût <slaout@linux62.org>
0003  * SPDX-License-Identifier: GPL-2.0-or-later
0004  */
0005 
0006 #ifndef BACKUP_H
0007 #define BACKUP_H
0008 
0009 #include <QDialog>
0010 
0011 #include <QtCore/QThread>
0012 
0013 class QApplication;
0014 class QLabel;
0015 
0016 #include "basket_export.h"
0017 
0018 /**
0019  * @author Sébastien Laoût
0020  */
0021 class BackupDialog : public QDialog
0022 {
0023     Q_OBJECT
0024 public:
0025     explicit BackupDialog(QWidget *parent = nullptr, const char *name = nullptr);
0026     ~BackupDialog() override;
0027 private Q_SLOTS:
0028     void moveToAnotherFolder();
0029     void useAnotherExistingFolder();
0030     void backup();
0031     void restore();
0032     void populateLastBackup();
0033 
0034 private:
0035     QLabel *m_lastBackup;
0036 };
0037 
0038 /**
0039  * @author Sébastien Laoût <slaout@linux62.org>
0040  */
0041 class BASKET_EXPORT Backup
0042 {
0043 public:
0044     static void figureOutBinaryPath(const char *argv0, QApplication &app);
0045     static void setFolderAndRestart(const QString &folder, const QString &message);
0046     static QString newSafetyFolder();
0047 
0048 private:
0049     static QString binaryPath;
0050 };
0051 
0052 class BackupThread : public QThread
0053 {
0054 public:
0055     BackupThread(const QString &tarFile, const QString &folderToBackup);
0056 
0057 protected:
0058     void run() override;
0059 
0060 private:
0061     QString m_tarFile;
0062     QString m_folderToBackup;
0063 };
0064 
0065 class RestoreThread : public QThread
0066 {
0067 public:
0068     RestoreThread(const QString &tarFile, const QString &destFolder);
0069     inline bool success()
0070     {
0071         return m_success;
0072     }
0073 
0074 protected:
0075     void run() override;
0076 
0077 private:
0078     QString m_tarFile;
0079     QString m_destFolder;
0080     bool m_success;
0081 };
0082 
0083 #endif // BACKUP_H