File indexing completed on 2024-12-22 04:45:57

0001 /*
0002    SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 #include "importexportdata/importexportutils.h"
0009 #include "libruqolawidgets_private_export.h"
0010 
0011 #include <QThread>
0012 class KZip;
0013 class LIBRUQOLAWIDGETS_TESTS_EXPORT ExportAccountJob : public QThread
0014 {
0015     Q_OBJECT
0016 public:
0017     explicit ExportAccountJob(const QString &fileName, QObject *parent = nullptr);
0018     ~ExportAccountJob() override;
0019 
0020     [[nodiscard]] QVector<ImportExportUtils::AccountImportExportInfo> listAccounts() const;
0021     void setListAccounts(const QVector<ImportExportUtils::AccountImportExportInfo> &newListAccounts);
0022 
0023     [[nodiscard]] bool canStart() const;
0024 
0025 protected:
0026     void run() override;
0027 
0028 Q_SIGNALS:
0029     void exportDone();
0030     void exportFailed(const QString &errorMsg);
0031     void exportInfo(const QString &msg);
0032 
0033     void exportCacheData(const ImportExportUtils::AccountImportExportInfo &info);
0034     void exportLogsData(const ImportExportUtils::AccountImportExportInfo &info);
0035 
0036 private:
0037     LIBRUQOLAWIDGETS_NO_EXPORT void storeDirectory(const QString &subDirectory, const QString &subfolderPath);
0038     LIBRUQOLAWIDGETS_NO_EXPORT void exportAccount(const ImportExportUtils::AccountImportExportInfo &info);
0039     LIBRUQOLAWIDGETS_NO_EXPORT void exportConfig(const ImportExportUtils::AccountImportExportInfo &info);
0040     LIBRUQOLAWIDGETS_NO_EXPORT void exportCache(const ImportExportUtils::AccountImportExportInfo &info);
0041     LIBRUQOLAWIDGETS_NO_EXPORT void exportLogs(const ImportExportUtils::AccountImportExportInfo &info);
0042     LIBRUQOLAWIDGETS_NO_EXPORT void exportDatabase(const ImportExportUtils::AccountImportExportInfo &info);
0043     LIBRUQOLAWIDGETS_NO_EXPORT void finishExportAccount();
0044     LIBRUQOLAWIDGETS_NO_EXPORT void exportAccount();
0045     QVector<ImportExportUtils::AccountImportExportInfo> mListAccounts;
0046     int mAccountIndex = 0;
0047     QStringList mAccountNames;
0048     KZip *const mArchive;
0049 };