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

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

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

bool DataSetting::m_bVerficationData = false;

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_isShowBeforBurn(true)
{
    struct passwd *pwd;
    QDir dir;

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

    m_oPreparer = _("KylinSoft");
    m_oPublisher = QString::fromUtf8(pwd->pw_name);

    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();

}

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();
    m_isShowBeforBurn = other.getIsShowBeforBurn();
}

void DataSetting::load()
{
    speed(m_iSpeed);
    clean(m_bClean);
    createISO(m_bCreateISO);
    closeSession(m_bCloseSession);
    open(m_bOpen);
    preparer(m_oPreparer);
    publisher(m_oPublisher);

    copyright(m_oCopyright);
    tempPath(m_oTemporaryPth);
    burnFormat(m_SBurnFormat);
    IsShowBeforBurn(m_isShowBeforBurn);
}

DataSetting::~DataSetting()
{}
