#include "datasetting.h"
#include "src/po/translation.h"

#include <pwd.h>
#include <unistd.h>

#include <QDate>
#include <QDebug>
#include <QDir>

DataSetting::DataSetting(QObject *parent) :
    QObject(parent),
    m_iSpeed(0),
    m_SBurnFormat(QString("ISO9660")),
    m_bClean(false),
    m_bCloseSession(false),
    m_bCreateISO(false),
    m_bOpen(false),
    m_bVerficationData(false)
{
    struct passwd *pwd;
    QDir dir;

    pwd = ::getpwuid(::getuid());

    m_oPreparer = _("KylinSoft");
    m_oPublisher = QString::fromUtf8(pwd->pw_name);
    //m_oVolumnID = QDate::currentDate().toString("yyyy-MM-dd"); //V10上使用日期作为卷标
    m_oVolumnID = _("KylinBurner");
    m_oCopyright = _("Kylinsoft © %1 All rights.").arg(QDate::currentDate().toString("yyyy"));
    dir.setPath(QDir::homePath() + "/.cache/KylinBurner/");
    if (!dir.exists())
        dir.mkpath(dir.absolutePath());
    m_oTemporaryPth = dir.absolutePath();
    //qDebug()<<"new DataSetting(m_SBurnFormat==["<<m_SBurnFormat<<"])";
}

DataSetting::DataSetting(DataSetting &other, QObject *parent)
{
    parent = other.parent();
    m_iSpeed = other.getSpeed();
    m_bClean = other.getClean();
    m_bCreateISO = other.getCreateISO();
    m_bCloseSession = other.getCloseSession();
    m_bVerficationData = other.getVerficationData();
    m_bOpen = other.getOpen();
    m_oPreparer = other.getPreparer();
    m_oPublisher = other.getPublisher();
    m_oVolumnID = other.getVolumnID();
    m_oCopyright = other.getCopyright();
    m_oTemporaryPth = other.getTempPath();
    m_SBurnFormat = other.getBurnFormat();
}

void DataSetting::load()
{
    //qDebug()<<"DataSetting::load() speed("<<m_iSpeed<<")";
    //qDebug()<<"DataSetting::load() burnFormat("<<m_SBurnFormat<<")";
    speed(m_iSpeed);
    clean(m_bClean);
    createISO(m_bCreateISO);
    closeSession(m_bCloseSession);
    open(m_bOpen);
    preparer(m_oPreparer);
    publisher(m_oPublisher);
    //volumnID(m_oVolumnID);
    copyright(m_oCopyright);
    tempPath(m_oTemporaryPth);
    burnFormat(m_SBurnFormat);
}

DataSetting::~DataSetting()
{}
