#ifndef QAPTDOWNLOADDEB_H
#define QAPTDOWNLOADDEB_H

#include <QObject>
#include <QApt/Package>
#include <QApt/Config>
#include <QApt/DebFile>
#include <QApt/Backend>
#include <QApt/Transaction>
namespace QApt {
    class Backend;
    class Package;
    class Transaction;
    class DownloadProgress;
}

class QAptDownLoadDeb : public QObject
{
    Q_OBJECT
public:
    explicit QAptDownLoadDeb(QWidget *parent =nullptr);
    void initQaptBackend();
    void updateLabels();
    bool updateCache();
    bool startInstall(QString filePath,QString debName);
    bool startDownload(QString &packageName);
    bool startCheckVersion(QString &packageName );
    QString downloadStatusToString(QApt::DownloadStatus status);

public:
    bool checkPkgVersion(QString pkgName);
    QString getCurPkgVersion(QString pkgName);
    QString getLastestVersion(QString pkgName);
signals:
    void sigCurrentProgressValue(int value);
public slots:
    void onTransactionStatusChanged(QApt::TransactionStatus status);
    void onDownloadProgressChanged(QApt::DownloadProgress progress);
private:
    QApt::Backend *m_backend;
    QApt::Package *m_package;
    QApt::Group *m_group;
    QApt::DownloadProgress m_progress;
    QApt::Transaction *m_trans;
private:
    std::atomic_bool qaptInited{false};
};

#endif // QAPTDOWNLOADDEB_H
