/*
   SPDX-FileCopyrightText: 2023-2026 Laurent Montel <montel@kde.org>

   SPDX-License-Identifier: LGPL-2.0-or-later
*/

#pragma once

#include "libruqolawidgets_private_export.h"
#include <QThread>

class KZip;
class KArchiveDirectory;
class LIBRUQOLAWIDGETS_TESTS_EXPORT ImportAccountJob : public QThread
{
    Q_OBJECT
public:
    explicit ImportAccountJob(const QString &fileName, QObject *parent = nullptr);
    ~ImportAccountJob() override;

protected:
    void run() override;

Q_SIGNALS:
    void importFailed(const QString &str);
    void importDone();
    void importInfo(const QString &msg);

private:
    LIBRUQOLAWIDGETS_NO_EXPORT void importAccount(QString accountName);
    LIBRUQOLAWIDGETS_NO_EXPORT void finishImportAccounts();
    LIBRUQOLAWIDGETS_NO_EXPORT void importAccounts();
    LIBRUQOLAWIDGETS_NO_EXPORT void copyDatabase(const KArchiveDirectory *databaseDirectory,
                                                 const QString &accountName,
                                                 const QString &databasePath,
                                                 const QString &subfolder,
                                                 const QString &dest,
                                                 bool renameFiles);

    [[nodiscard]] LIBRUQOLAWIDGETS_NO_EXPORT QString verifyExistingAccount(QString accountName) const;
    QStringList mAccountInfos;
    KZip *const mArchive;
    int mAccountIndex = 0;
};
