#ifndef PROCESSBURNDATADL_H
#define PROCESSBURNDATADL_H

#include "src/frame/auditlog.h"

#include <QObject>
#include <QIcon>
#include <QProcess>

class DataCDROM;
class QProcess;
class QTimer;
class DataDirectory;
class QGSettings;

class ProcessBurnDataDL : public QObject
{
    Q_OBJECT

public:
    ProcessBurnDataDL(void *, void *, QObject *parent = nullptr);
    ~ProcessBurnDataDL();
private:
    bool binIsExist();
    void init();
    void progressUIInit();              //进度条界面设置
    void connectInit();
    void auditLogInit();                //审计日志
    void auditLogWrite();
    void verficationDataInit(bool);     //校验数据
    void setCommandParameter();         //设置命令

    void prepareFile();
    void execProcess();
    void emptyDiscBurn();
    void appendBurn();

private Q_SLOTS:
    void slotsRemoveDisc(QString);      // 有光驱被拔出
    void slotsCopy(QString, QString);
    void slotsProcessBarDVD(); // 使DVD盘进度条按计时器时间走，不卡在关盘操作上
    void slotsExit();
    void slotsCancel();

    void slotsOutput();
    void slotsError();
    void slotsFinished(int,QProcess::ExitStatus);

Q_SIGNALS:
    // progress
    void title(QString);
    void setRange(int, int);
    void setValue(int, QIcon icon = QIcon(), QString str = QString());
    void addValue(int, QIcon icon = QIcon(), QString str = QString());
    void cancel(bool);
    // tip
    void success(QString); void fail(QString);
    void eject();

private:
    int             m_iCopied;
    int             m_iProgress;
    int             m_icountBurn;
    qreal           m_fSpeed;
    bool            m_bAppendBurn;
    bool            m_bVerficationData;
    bool            m_bGreateThan2GB;          // 是否有需刻录的新文件>2G
    bool            m_oFlag;
    bool            m_bCancel;          // 用户是否取消
    bool            m_bBurnSuccess;     // 刻录最终是否成功
    bool            m_bBurnLogError;    // 刻录命令返回信息中是否有被认为刻录失败的描述
    bool            m_isSpecialMachine;

    void           *m_oCDROM;
    void           *m_oRoot;
    void           *m_ocopy;

    AuditLog        m_oBurnDataDLLog;


    unsigned long   m_oSize;
    unsigned long   m_oNewSize;           // 需刻录内容的容量
    unsigned long   m_ototal;
    unsigned int    m_u32Icon;          // 第N张加载图标
    DataDirectory  *m_root;
    DataCDROM      *cloneCDROM;

    QProcess       *m_oProcess;         // 刻录进程
    QTimer         *m_oProgressBarTimer_DVD;
    QString         m_oProcessName;     // 刻录命令的名字
    QStringList     m_oArguments;       // 刻录命令的参数
    QIcon           m_oIcon;            // 加载图标
    QString         m_lastErrorMsg;     // 刻录命令返回信息中的错误信息
    QString         m_cmdStr;           // 刻录命令字符

    QGSettings     *auditburner;
    QString         auditlogpath;
    QString         m_oDeviceBlock;
    QString         m_oGrowisofs;
    QString         m_odestination;
    QString         m_oTempPath;        // 写光盘前数据存储的临时目录

};

#endif // PROCESSBURNDATADL_H
