
/*
 * config.c: A plugin for the Video Disk Recorder
 *
 * See the README file for copyright information and how to reach the author.
 *
 * $Id$
 */

#include <vdr/eit.h>
#include <vdr/osd.h>
#include <vdr/menuitems.h>

#include "config.h"
#include "i18n.h"

cDVDSelectSetup DVDSelectSetup;

// --- cDVDSelectSetup -----------------------------------------------------------

cDVDSelectSetup::cDVDSelectSetup(void)
{
    strcpy(NameDevice, "/dev/dummy");
    strcpy(NameOrgDevice, "/dev/dvd");
    strcpy(ImageDir, "/video/dvd");
    strcpy(DVDOutputDir, "/video/dvd");
    strcpy(DVDReadScript, "/usr/local/bin/dvdselect_readdvd.sh");
    strcpy(DVDWriteScript, "/usr/local/bin/dvdselect_writedvd.sh");
}

bool cDVDSelectSetup::SetupParse(const char *Name, const char *Value)
{
  // Parse your own setup parameters and store their values.
  if (!strcasecmp(Name, "NameDevice"))               strn0cpy(NameDevice, Value, MaxFileName);
  else if (!strcasecmp(Name, "NameOrgDevice"))       strn0cpy(NameOrgDevice, Value, MaxFileName);
  else if (!strcasecmp(Name, "ImageDir"))            strn0cpy(ImageDir, Value , MaxFileName);
  else if (!strcasecmp(Name, "DVDOutputDir"))        strn0cpy(DVDOutputDir, Value , MaxFileName);
  else if (!strcasecmp(Name, "DVDReadScript"))              strn0cpy(DVDReadScript, Value , MaxFileName);
  else if (!strcasecmp(Name, "DVDWriteScript"))              strn0cpy(DVDWriteScript, Value , MaxFileName);
  else
    return false;
  return true;
}

// --- cMenuSetupDVD --------------------------------------------------------

cMenuSetupDVDSelect::cMenuSetupDVDSelect(void)
{
  data = DVDSelectSetup;
  SetSection(tr("DVD"));

  Add(new cMenuEditStrItem( tr("dvddevice"),
        data.NameDevice,
        MaxFileName,
        tr(" abcdefghijklmnopqrstuvwxyz0123456789-./")
      ));
  Add(new cMenuEditStrItem( tr("dvdorgdevice"),
        data.NameOrgDevice,
        MaxFileName,
        tr(" abcdefghijklmnopqrstuvwxyz0123456789-./")
      ));
  Add(new cMenuEditStrItem( tr("imagedir"),
        data.ImageDir,
        MaxFileName,
        tr(" abcdefghijklmnopqrstuvwxyz0123456789-./")
      ));
  Add(new cMenuEditStrItem( tr("DVDOutputDir"),
        data.DVDOutputDir,
        MaxFileName,
        tr(" abcdefghijklmnopqrstuvwxyz0123456789-./")
      ));
  Add(new cMenuEditStrItem( tr("dvdreadscript"),
        data.DVDReadScript,
        MaxFileName,
        tr(" abcdefghijklmnopqrstuvwxyz0123456789-./")
      ));
  Add(new cMenuEditStrItem( tr("dvdwritescript"),
        data.DVDWriteScript,
        MaxFileName,
        tr(" abcdefghijklmnopqrstuvwxyz0123456789-./")
      ));
}

void cMenuSetupDVDSelect::Store(void)
{
  DVDSelectSetup = data;
  SetupStore( "NameDevice", data.NameDevice);
  SetupStore( "NameOrgDevice", data.NameOrgDevice);
  SetupStore( "ImageDir",   data.ImageDir );
  SetupStore( "DVDReadScript",   data.DVDReadScript );
  SetupStore( "DVDWriteScript",   data.DVDWriteScript );
}
