#ifndef PROCESSCOPYDISKDL_H
#define PROCESSCOPYDISKDL_H

#include "src/frame/auditlog.h"
#include <QObject>
#include <QIcon>
#include <QProcess>

class AuditLog;
class DataCDROM;
class QGSettings;

class ProcessCopyDiskDL : public QObject
{
    Q_OBJECT
public:
    ProcessCopyDiskDL(void *, void *, QObject *parent = nullptr);
    ~ProcessCopyDiskDL();
    void execProcess();

private:
    bool binIsExist();
    void init(void *, void *);
    void progressUIInit();              //进度条界面设置
    void connectInit();
    void auditLogInit();                //审计日志
    void auditLogWrite();
    void setCommandParameter();         //设置命令
    bool prepareIsoPath();
    void readIso();
    void writeIso();

private Q_SLOTS:
    void slotsRemoveDisc(QString);      // 有光驱被拔出
    void slotsExit();
    void slotsCancel();

    void slotsOutput();
    void slotsErrorGetIso();
    void slotsErrorBurnImage();
    void slotsFinishedGetIso(int,QProcess::ExitStatus);
    void slotsFinishedBurnImage(int,QProcess::ExitStatus);

    void slotsProcessBarGetIso();

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:
    AuditLog        m_oBurnDataDLLog;
    DataCDROM      *m_oDestCDROM;
    DataCDROM      *cloneSourceCDROM;
    DataCDROM      *cloneDestCDROM;

    QString         m_oProcessName;
    QString         m_oSrcDeviceBlock;
    QString         m_oDesDeviceBlock;

    QProcess       *m_oProcessGetIso;
    QProcess       *m_oProcessBurnImage;
    QStringList     m_oArgumentsGetIso;
    QStringList     m_oArgumentsBurnImage;

    bool            m_bCancel;
    bool            m_bBurnSuccess;     // 刻录最终是否成功
    QString         m_lastErrorMsg;     // 刻录命令返回信息中的错误信息
    QString         m_oIsoPath;
    int             m_iProgress;
    QString         m_cmdStr;           // 刻录命令字符
    QIcon           m_oIcon;

    AuditLog        m_copyDiskLog;
    QGSettings     *m_auditBurner;
    QString         m_auditLogPath;
    bool            m_isSpecialMachine;

    QTimer         *m_oGetIsoTimer;


};

#endif // PROCESSCOPYDISKDL_H
