
/*
 * See the files COPYING and README for copyright information and how to reach 
 * the author.
 *
 *  $Id: setup.c,v 1.3 2004/12/02 15:02:52 lordjaxom Exp $
 */

#include "setup.h"
#include "common.h"
#include "i18n.h"
#include <vdr/menuitems.h>
#include <vdr/videodir.h>

int DVDSIZE = 4332;

cBurnSetup BurnSetup;

const char *Script = NULL;
const char *Datadir = NULL;
const char *DVDdev = NULL;
const char *ISOdir = NULL;

cBurnSetup::cBurnSetup(void)
{
    CleanupLimit = 3;
    CreateArchiveMarks = 0;
    DiskType = (int)dtDVD;
    if (DVDdev == NULL) {
        StoreMode = smCreateISO;
    } else if (ISOdir == NULL) {
        StoreMode = smBurnISO;
    } else {
        StoreMode = smCreateBurn;
    }
    ChaptersMode = cm10Mins;
    HidePathInfo = 1;
    RenderRecordingIndex = 0;
    UseIso2UTF = 1;
    VerifyAfterBurn = 0;
}

bool cBurnSetup::SetupParse(const char *Name, const char *Value)
{
    if (strcmp(Name, "CreateArchiveMarks") == 0) {
        CreateArchiveMarks = atoi(Value);
    } else if (strcmp(Name, "CleanupLimit") == 0) {
        CleanupLimit = atoi(Value);
    } else if (strcmp(Name, "DiskType") == 0) {
        DiskType = atoi(Value);
    } else if (strcmp(Name, "StoreMode") == 0) {
        StoreMode = atoi(Value);
        if (DVDdev == NULL &&
                (StoreMode == smBurnISO || StoreMode == smCreateBurn))
        {
            StoreMode = smCreateISO;
        }
        if (ISOdir == NULL &&
                (StoreMode == smBurnISO || StoreMode == smCreateISO))
        {
            StoreMode = smCreateBurn;
        }
    } else if (strcmp(Name, "ChaptersMode") == 0) {
        ChaptersMode = atoi(Value);
    } else if (strcmp(Name, "DVDSize") == 0) {
        DVDSIZE = atoi(Value);
    } else if (strcmp(Name, "HidePathInfo") == 0) {
        HidePathInfo = atoi(Value);
    } else if (strcmp(Name, "RenderRecordingIndex") == 0) {
        RenderRecordingIndex = atoi(Value);
    } else if (strcmp(Name, "UseIso2UTF") == 0) {
        UseIso2UTF = atoi(Value);
    } else if (strcmp(Name, "VerifyAfterBurn") == 0) {
        VerifyAfterBurn = atoi(Value);
    } else {
        return false;
    }
    return true;
}

cBurnMenuSetupPage::cBurnMenuSetupPage(void)
{
    mData = BurnSetup;

    Add(new cMenuEditBoolItem(tr("Convert texts to UTF-8"),
            &mData.UseIso2UTF));
    Add(new cMenuEditBoolItem(tr("Create archive marks"),
            &mData.CreateArchiveMarks));
    Add(new cMenuEditIntItem(tr("DVD size"), &DVDSIZE, 0, 10000));
    Add(new cMenuEditBoolItem(tr("Hide path info"), &mData.HidePathInfo));
    Add(new cMenuEditBoolItem(tr("Number recordings in DVD menu"),
            &mData.RenderRecordingIndex));
    Add(new cMenuEditBoolItem(tr("Verify after burn"),
            &mData.VerifyAfterBurn));
    Add(new cMenuEditIntItem(tr("Start cleanup after # jobs"),
            &mData.CleanupLimit, 0, 10));
}

cBurnMenuSetupPage::~cBurnMenuSetupPage()
{
}

void cBurnMenuSetupPage::Store(void)
{
    SetupStore("CreateArchiveMarks", mData.CreateArchiveMarks);
    SetupStore("DiskType", mData.DiskType);
    SetupStore("StoreMode", mData.StoreMode);
    SetupStore("ChaptersMode", mData.ChaptersMode);
    SetupStore("DVDSize", DVDSIZE);
    SetupStore("HidePathInfo", mData.HidePathInfo);
    SetupStore("RenderRecordingIndex", mData.RenderRecordingIndex);
    SetupStore("UseIso2UTF", mData.UseIso2UTF);
    SetupStore("VerifyAfterBurn", mData.VerifyAfterBurn);
    BurnSetup = mData;
}
