#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif

#include <stdio.h>
#include <malloc.h>
#include <string.h>

#include <getopt.h>
#include <stdlib.h>
#include <vdr/interface.h>
#include <vdr/plugin.h>
#include <unistd.h>
#include "menu.h"
#include "config.h"
#include "cProjektEinstellen.h"
#include "cMenuAufnahmeAuswahl.h"

// --- cProjektEinstellen ------------------------------------------------------------
cProjektEinstellen::cProjektEinstellen(char* myBeschreibung) : cOsdMenu(myBeschreibung, 12, 6)
{
  init();
  zeigeEintraege();
  SetHelp();
}

cProjektEinstellen::~cProjektEinstellen(){
}

void cProjektEinstellen::init(){
  //cVdrconvertSetup data;
  //INIT Anfang
  //TODO Projekttyp-Abhaengigkeit einbauen

  //Allgemeines
  strcpy(VDRROOT,VdrconvertSetup.VDRROOT);
  strcpy(DESTDIR,VdrconvertSetup.DESTDIR);
  strcpy(CONVERT_JOBS,VdrconvertSetup.CONVERT_JOBS);
  strcpy(VDRSYNC,VdrconvertSetup.VDRSYNC);
  strcpy(TCMPLEX,VdrconvertSetup.TCMPLEX);
  strcpy(TCMPLEX_PANTELTJE,VdrconvertSetup.TCMPLEX_PANTELTJE);
  strcpy(DVBMPLEX,VdrconvertSetup.DVBMPLEX);
  strcpy(MPLEX,VdrconvertSetup.MPLEX);
  strcpy(MKISOFS,VdrconvertSetup.MKISOFS);
  strcpy(MENCODER,VdrconvertSetup.MENCODER);
  strcpy(LAME,VdrconvertSetup.LAME);
  strcpy(DVDAUTHOR,VdrconvertSetup.DVDAUTHOR);
  strcpy(TOSVCD,VdrconvertSetup.TOSVCD);
  strcpy(TEMPDIR,VdrconvertSetup.TEMPDIR);
  strcpy(LOGDIR,VdrconvertSetup.LOGDIR);
  strcpy(SVDRPSEND,VdrconvertSetup.SVDRPSEND);
  strcpy(PARQ,VdrconvertSetup.PARQ);
  strcpy(COMPRESS,VdrconvertSetup.COMPRESS);
  DEBUG=VdrconvertSetup.DEBUG;
  PRIO=VdrconvertSetup.PRIO;
  SLEEP_TIME=VdrconvertSetup.SLEEP_TIME;
  CONV_TITLEDATE=VdrconvertSetup.CONV_TITLEDATE;

  //DVD-Variablen
  strcpy(DVD_DESTDIR,VdrconvertSetup.DVD_DESTDIR);
  strcpy(DVDTCMPLEXOPTS,VdrconvertSetup.DVDTCMPLEXOPTS);
  strcpy(DVD_DVBMPLEXOPTS,VdrconvertSetup.DVD_DVBMPLEXOPTS);
  strcpy(DVDALLOWEDWIDTH,VdrconvertSetup.DVDALLOWEDWIDTH);
  strcpy(DVDTRANSCODEOPTS,VdrconvertSetup.DVDTRANSCODEOPTS);
  strcpy(PPMTOY4M_OPTIONS,VdrconvertSetup.PPMTOY4M_OPTIONS);
  strcpy(DVDTRANSCODEBITRATE,VdrconvertSetup.DVDTRANSCODEBITRATE);
  strcpy(DVDAUTHORUSERCHAP,VdrconvertSetup.DVDAUTHORUSERCHAP);
  strcpy(DVDUSESTREAMS,VdrconvertSetup.DVDUSESTREAMS);
  DVDREMOVEAUTHORDIR=VdrconvertSetup.DVDREMOVEAUTHORDIR;
  DVDSIZE=VdrconvertSetup.DVDSIZE;
  CDSIZE=VdrconvertSetup.CDSIZE;
  strcpy(DVDNORM,VdrconvertSetup.DVDNORM);
  strcpy(DVDMAINSILENCEFILE,VdrconvertSetup.DVDMAINSILENCEFILE);
  strcpy(DVDSUBSILENCEFILE,VdrconvertSetup.DVDSUBSILENCEFILE);
  strcpy(DVDTEXTPLAYMOVIE,VdrconvertSetup.DVDTEXTPLAYMOVIE);
  strcpy(DVDTEXTMENU,VdrconvertSetup.DVDTEXTMENU);
  strcpy(DVDMAINMENUEPOSTACTION,VdrconvertSetup.DVDMAINMENUEPOSTACTION);
  strcpy(DVDMENUEPOSTACTION,VdrconvertSetup.DVDMENUEPOSTACTION);
  strcpy(DVDBUTTONCOLOR,VdrconvertSetup.DVDBUTTONCOLOR);
  strcpy(DVDSUBBUTTONCOLOR,DVDBUTTONCOLOR);
  strcpy(DVDHIBUTTON2COLOR_MENU,VdrconvertSetup.DVDHIBUTTON2COLOR_MENU);
  strcpy(DVDHIBUTTONCOLOR_MENU,VdrconvertSetup.DVDHIBUTTONCOLOR_MENU);
  strcpy(DVDHIBUTTONCOLOR_SUBMENU,DVDHIBUTTONCOLOR_MENU);
  strcpy(DVDHIBUTTON2COLOR_SUBMENU,DVDHIBUTTON2COLOR_MENU);
  strcpy(DVDFILE_MAINBACKGROUND_COLOR,VdrconvertSetup.DVDFILE_MAINBACKGROUND_COLOR);
  strcpy(DVDFILE_SUBBACKGROUND_COLOR,DVDFILE_MAINBACKGROUND_COLOR);
  strcpy(DVDTEXTCOLOR_MENU,VdrconvertSetup.DVDTEXTCOLOR_MENU);
  strcpy(DVDTEXTCOLOR_SUBMENU,DVDTEXTCOLOR_MENU);
  DVDMENU_SHADOW=VdrconvertSetup.DVDMENU_SHADOW;
  strcpy(DVDMAINCOLSFG,VdrconvertSetup.DVDMAINCOLSFG);
  strcpy(DVDMAINCOLSBG,VdrconvertSetup.DVDMAINCOLSBG);
  strcpy(DVDSUBCOLSFG,DVDMAINCOLSFG);
  strcpy(DVDSUBCOLSBG,DVDMAINCOLSBG);
  DVDMAINMENUETIMEOUT=VdrconvertSetup.DVDMAINMENUETIMEOUT;
  DVDMENUETIMEOUT=VdrconvertSetup.DVDMENUETIMEOUT;

  //MP3-Variablen
  strcpy(MP3_DESTDIR,VdrconvertSetup.MP3_DESTDIR);
  strcpy(MP3_OPTS,VdrconvertSetup.MP3_OPTS);
  MP3_SPLIT=VdrconvertSetup.MP3_SPLIT;
  strcpy(MPLAYERMP3SOURCE,VdrconvertSetup.MPLAYERMP3SOURCE);
  strcpy(MP3_TITLEDATE,VdrconvertSetup.MP3_TITLEDATE);
  MP3_USE_MPG123=VdrconvertSetup.MP3_USE_MPG123;
  strcpy(MP3USESTREAMS,VdrconvertSetup.MP3USESTREAMS);

}

void cProjektEinstellen::zeigeEintraege(){

  char *datei;
  asprintf(&datei,"%s.setup",VdrconvertSetup.gibDateiname(VdrconvertSetup.aktProjekttyp));
  FILE *fi = fopen (datei, "r");
  char *s;
  
  
  //INIT Ende

  if (fi!=NULL){
#if VDRVERSNUM >= 10318
        cReadLine r;
    while ((s = r.Read(fi)) != NULL) {
#else
    while ((s=readline(fi))!=NULL){
#endif    
      char *p = strchr(s, '=');
      if (p) {
	*p = 0;
	char *Name  = compactspace(s);
	char *Value = compactspace(p + 1);
  //Allgemeines
	if (!strcasecmp(Name, "VDRROOT")) {  strn0cpy(VDRROOT, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DESTDIR")) {  strn0cpy(DESTDIR, Value, MaxFileName);
	} else if (!strcasecmp(Name, "CONVERT_JOBS")) {  strn0cpy(CONVERT_JOBS, Value, MaxFileName);
	} else if (!strcasecmp(Name, "VDRSYNC")) {  strn0cpy(VDRSYNC, Value, MaxFileName);
	} else if (!strcasecmp(Name, "TCMPLEX")) {  strn0cpy(TCMPLEX, Value, MaxFileName);
	} else if (!strcasecmp(Name, "TCMPLEX_PANTELTJE")) {  strn0cpy(TCMPLEX_PANTELTJE, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVBMPLEX")) {  strn0cpy(DVBMPLEX, Value, MaxFileName);
	} else if (!strcasecmp(Name, "MPLEX")) {  strn0cpy(MPLEX, Value, MaxFileName);
	} else if (!strcasecmp(Name, "MKISOFS")) {  strn0cpy(MKISOFS, Value, MaxFileName);
	} else if (!strcasecmp(Name, "MENCODER")) {  strn0cpy(MENCODER, Value, MaxFileName);
	} else if (!strcasecmp(Name, "LAME")) {  strn0cpy(LAME, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDAUTHOR")) {  strn0cpy(DVDAUTHOR, Value, MaxFileName);
	} else if (!strcasecmp(Name, "TOSVCD")) {  strn0cpy(TOSVCD, Value, MaxFileName);
	} else if (!strcasecmp(Name, "TEMPDIR")) {  strn0cpy(TEMPDIR, Value, MaxFileName);
	} else if (!strcasecmp(Name, "LOGDIR")) {  strn0cpy(LOGDIR, Value, MaxFileName);
	} else if (!strcasecmp(Name, "SVDRPSEND")) {  strn0cpy(SVDRPSEND, Value, MaxFileName);
	} else if (!strcasecmp(Name, "PARQ")) {  strn0cpy(PARQ, Value, MaxFileName);
	} else if (!strcasecmp(Name, "COMPRESS")) {  strn0cpy(COMPRESS, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DEBUG")) { DEBUG=atoi(Value);
	} else if (!strcasecmp(Name, "PRIO")) {  PRIO=atoi(Value);
	} else if (!strcasecmp(Name, "SLEEP_TIME")) {  SLEEP_TIME=atoi(Value);
	} else if (!strcasecmp(Name, "CONV_TITLEDATE")) {  CONV_TITLEDATE=atoi(Value);
	//DVD-Parameter
	} else if (!strcasecmp(Name, "DVD_DESTDIR")) {  strn0cpy(DVD_DESTDIR, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDTCMPLEXOPTS")) {  strn0cpy(DVDTCMPLEXOPTS, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVD_DVBMPLEXOPTS")) {  strn0cpy(DVD_DVBMPLEXOPTS, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDALLOWEDWIDTH")) {  strn0cpy(DVDALLOWEDWIDTH, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDTRANSCODEOPTS")) {  strn0cpy(DVDTRANSCODEOPTS, Value, MaxFileName);
	} else if (!strcasecmp(Name, "PPMTOY4M_OPTIONS")) {  strn0cpy(PPMTOY4M_OPTIONS, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDTRANSCODEBITRATE")) {  strn0cpy(DVDTRANSCODEBITRATE, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDAUTHORUSERCHAP")) {  strn0cpy(DVDAUTHORUSERCHAP, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDUSESTREAMS")) {  strn0cpy(DVDUSESTREAMS, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDREMOVEAUTHORDIR")) {  DVDREMOVEAUTHORDIR=atoi(Value);
	} else if (!strcasecmp(Name, "DVDSIZE")) {  DVDSIZE=atoi(Value);
	} else if (!strcasecmp(Name, "CDSIZE")) {  CDSIZE=atoi(Value);
	} else if (!strcasecmp(Name, "DVDNORM")) {  strn0cpy(DVDNORM, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDMAINSILENCEFILE")) {  strn0cpy(DVDMAINSILENCEFILE, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDSUBSILENCEFILE")) {  strn0cpy(DVDSUBSILENCEFILE, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDTEXTPLAYMOVIE")) {  strn0cpy(DVDTEXTPLAYMOVIE, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDTEXTMENU")) {  strn0cpy(DVDTEXTMENU, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDMAINMENUEPOSTACTION")) {  strn0cpy(DVDMAINMENUEPOSTACTION, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDMENUEPOSTACTION")) {  strn0cpy(DVDMENUEPOSTACTION, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDBUTTONCOLOR")) {  strn0cpy(DVDBUTTONCOLOR, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDSUBBUTTONCOLOR")) {  strn0cpy(DVDSUBBUTTONCOLOR, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDHIBUTTON2COLOR_MENU")) {  strn0cpy(DVDHIBUTTON2COLOR_MENU, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDHIBUTTONCOLOR_MENU")) {  strn0cpy(DVDHIBUTTONCOLOR_MENU, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDHIBUTTONCOLOR_SUBMENU")) {  strn0cpy(DVDHIBUTTONCOLOR_SUBMENU, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDHIBUTTON2COLOR_SUBMENU")) {  strn0cpy(DVDHIBUTTON2COLOR_SUBMENU, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDFILE_MAINBACKGROUND_COLOR")) {  strn0cpy(DVDFILE_MAINBACKGROUND_COLOR, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDFILE_SUBBACKGROUND_COLOR")) {  strn0cpy(DVDFILE_SUBBACKGROUND_COLOR, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDTEXTCOLOR_MENU")) {  strn0cpy(DVDTEXTCOLOR_MENU, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDTEXTCOLOR_SUBMENU")) {  strn0cpy(DVDTEXTCOLOR_SUBMENU, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDMENU_SHADOW")) {  DVDMENU_SHADOW=atoi(Value);
	} else if (!strcasecmp(Name, "DVDMAINCOLSFG")) {  strn0cpy(DVDMAINCOLSFG, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDMAINCOLSBG")) {  strn0cpy(DVDMAINCOLSBG, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDSUBCOLSFG")) {  strn0cpy(DVDSUBCOLSFG, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDSUBCOLSBG")) {  strn0cpy(DVDSUBCOLSBG, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDMAINMENUETIMEOUT")) {  DVDMAINMENUETIMEOUT=atoi(Value);
	} else if (!strcasecmp(Name, "DVDMENUETIMEOUT")) {  DVDMENUETIMEOUT=atoi(Value);
	//MP3-Variablen
	} else if (!strcasecmp(Name, "MP3_DESTDIR")) { strn0cpy(MP3_DESTDIR ,Value, MaxFileName);
	} else if (!strcasecmp(Name, "MP3_OPTS")) { strn0cpy(MP3_OPTS ,Value, MaxFileName);
	} else if (!strcasecmp(Name, "MP3_SPLIT")) { MP3_SPLIT=atoi(Value);
	} else if (!strcasecmp(Name, "MPLAYERMP3SOURCE")) { strn0cpy(MPLAYERMP3SOURCE ,Value, MaxFileName);
	} else if (!strcasecmp(Name, "MP3_TITLEDATE")) { strn0cpy(MP3_TITLEDATE ,Value, MaxFileName);
	} else if (!strcasecmp(Name, "MP3_USE_MPG123")) { MP3_USE_MPG123=atoi(Value);
	} else if (!strcasecmp(Name, "MP3USESTREAMS")) { strn0cpy(MP3USESTREAMS ,Value, MaxFileName);
	}//else if
      }//if
    }//while
  }else{//if
    FILE *fi = fopen (datei, "w");//Datei anlegen
    //TODO Fehlerabfrage
    fclose(fi);
  }//else
  
  anzeigen();

  //Display();
  free(datei);
}


void cProjektEinstellen::anzeigen(){
  Clear();

  //Allgemeine-Variablen
  if (false){//DEBUG
  Add(new cMenuEditStrItem( tr("VDRROOT"),
	VDRROOT,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));
    Add(new cMenuEditStrItem( tr("DESTDIR"),
	DESTDIR,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));
    Add(new cMenuEditStrItem( tr("CONVERT_JOBS"),
	CONVERT_JOBS,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));
    Add(new cMenuEditStrItem( tr("VDRSYNC"),
	VDRSYNC,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));
    Add(new cMenuEditStrItem( tr("TCMPLEX"),
	TCMPLEX,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));
    Add(new cMenuEditStrItem( tr("TCMPLEX_PANTELTJE"),
	TCMPLEX_PANTELTJE,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));
    Add(new cMenuEditStrItem( tr("DVBMPLEX"),
	DVBMPLEX,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));
    Add(new cMenuEditStrItem( tr("MPLEX"),
	MPLEX,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));
    Add(new cMenuEditStrItem( tr("MKISOFS"),
	MKISOFS,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));
    Add(new cMenuEditStrItem( tr("MENCODER"),
	MENCODER,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));
    Add(new cMenuEditStrItem( tr("LAME"),
	LAME,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));
    Add(new cMenuEditStrItem( tr("DVDAUTHOR"),
	DVDAUTHOR,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));
    Add(new cMenuEditStrItem( tr("TOSVCD"),
	TOSVCD,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));
    Add(new cMenuEditStrItem( tr("LOGDIR"),
	LOGDIR,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));
    Add(new cMenuEditStrItem( tr("SVDRPSEND"),
	SVDRPSEND,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));
    Add(new cMenuEditStrItem( tr("PARQ"),
	PARQ,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));
    Add(new cMenuEditStrItem( tr("COMPRESS"),
	COMPRESS,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));
    Add(new cMenuEditIntItem( tr("PRIO"),
        &PRIO,
	-15,
        15
      ));
    Add(new cMenuEditIntItem( tr("SLEEP_TIME"),
        &SLEEP_TIME,
	1,
        60
      ));
    Add(new cMenuEditIntItem( tr("CONV_TITLEDATE"),
        &CONV_TITLEDATE,
	0,
        60
      ));
  Add(new cMenuEditBoolItem( tr("DEBUG"),
        &DEBUG
      ));
  }
  if (VdrconvertSetup.aktProjekttyp==1){//DVD
  //DVD-Variablen
      Add(new cMenuEditStrItem( tr("DVD_DESTDIR"),
	DVD_DESTDIR,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("DVDTCMPLEXOPTS"),
	DVDTCMPLEXOPTS,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("DVD_DVBMPLEXOPTS"),
	DVD_DVBMPLEXOPTS,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("DVDALLOWEDWIDTH"),
	DVDALLOWEDWIDTH,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("DVDTRANSCODEOPTS"),
	DVDTRANSCODEOPTS,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("PPMTOY4M_OPTIONS"),
	PPMTOY4M_OPTIONS,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("DVDTRANSCODEBITRATE"),
	DVDTRANSCODEBITRATE,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("DVDAUTHORUSERCHAP"),
	DVDAUTHORUSERCHAP,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("DVDUSESTREAMS"),
	DVDUSESTREAMS,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditBoolItem( tr("DVDREMOVEAUTHORDIR"),
	&DVDREMOVEAUTHORDIR
      ));

      Add(new cMenuEditIntItem( tr("DVDSIZE"),
	&DVDSIZE,
	0,
        60
      ));

      Add(new cMenuEditIntItem( tr("CDSIZE"),
	&CDSIZE,
	0,
        60
      ));

      Add(new cMenuEditStrItem( tr("DVDNORM"),
	DVDNORM,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("DVDMAINSILENCEFILE"),
	DVDMAINSILENCEFILE,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("DVDSUBSILENCEFILE"),
	DVDSUBSILENCEFILE,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("DVDTEXTPLAYMOVIE"),
	DVDTEXTPLAYMOVIE,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("DVDTEXTMENU"),
	DVDTEXTMENU,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("DVDMAINMENUEPOSTACTION"),
	DVDMAINMENUEPOSTACTION,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("DVDMENUEPOSTACTION"),
	DVDMENUEPOSTACTION,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("DVDBUTTONCOLOR"),
	DVDBUTTONCOLOR,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("DVDSUBBUTTONCOLOR"),
	DVDSUBBUTTONCOLOR,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("DVDHIBUTTON2COLOR_MENU"),
	DVDHIBUTTON2COLOR_MENU,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("DVDHIBUTTONCOLOR_MENU"),
	DVDHIBUTTONCOLOR_MENU,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("DVDHIBUTTONCOLOR_SUBMENU"),
	DVDHIBUTTONCOLOR_SUBMENU,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("DVDHIBUTTON2COLOR_SUBMENU"),
	DVDHIBUTTON2COLOR_SUBMENU,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("DVDFILE_MAINBACKGROUND_COLOR"),
	DVDFILE_MAINBACKGROUND_COLOR,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("DVDFILE_SUBBACKGROUND_COLOR"),
	DVDFILE_SUBBACKGROUND_COLOR,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("DVDTEXTCOLOR_MENU"),
	DVDTEXTCOLOR_MENU,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("DVDTEXTCOLOR_SUBMENU"),
	DVDTEXTCOLOR_SUBMENU,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditIntItem( tr("DVDMENU_SHADOW"),
	&DVDMENU_SHADOW,
	0,
        60
      ));

      Add(new cMenuEditStrItem( tr("DVDMAINCOLSFG"),
	DVDMAINCOLSFG,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("DVDMAINCOLSBG"),
	DVDMAINCOLSBG,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("DVDSUBCOLSFG"),
	DVDSUBCOLSFG,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("DVDSUBCOLSBG"),
	DVDSUBCOLSBG,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditIntItem( tr("DVDMAINMENUETIMEOUT"),
	&DVDMAINMENUETIMEOUT,
	0,
        60
      ));

      Add(new cMenuEditIntItem( tr("DVDMENUETIMEOUT"),
	&DVDMENUETIMEOUT,
	0,
        60
      ));
  }else  if (VdrconvertSetup.aktProjekttyp==3){//MP3
      Add(new cMenuEditStrItem( tr("MP3_DESTDIR"),
	MP3_DESTDIR,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("MP3_OPTS"),
	MP3_OPTS,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditBoolItem( tr("MP3_SPLIT"),
        &MP3_SPLIT
      ));

      Add(new cMenuEditStrItem( tr("MPLAYERMP3SOURCE"),
	MPLAYERMP3SOURCE,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("MP3_TITLEDATE"),
	MP3_TITLEDATE,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));

      Add(new cMenuEditStrItem( tr("MP3USESTREAMS"),
	MP3USESTREAMS,
        MaxFileName,
        tr("abcdefghijklmnopqrstuvwxyz0123456789 -./#")
      ));
  }
 
  Display();
}

void cProjektEinstellen::speichern(){
  char *datei;
  asprintf(&datei,"%s.setup",VdrconvertSetup.gibDateiname(VdrconvertSetup.aktProjekttyp));
  FILE *fi = fopen (datei, "w");

  //Allgemeines
  fprintf(fi,"VDRROOT=%s\n",VDRROOT);
  fprintf(fi,"DESTDIR=%s\n",DESTDIR);
  fprintf(fi,"CONVERT_JOBS=%s\n",CONVERT_JOBS);
  fprintf(fi,"VDRSYNC=%s\n",VDRSYNC);
  fprintf(fi,"TCMPLEX=%s\n",TCMPLEX);
  fprintf(fi,"TCMPLEX_PANTELTJE=%s\n",TCMPLEX_PANTELTJE);
  fprintf(fi,"DVBMPLEX=%s\n",DVBMPLEX);
  fprintf(fi,"MPLEX=%s\n",MPLEX);
  fprintf(fi,"MKISOFS=%s\n",MKISOFS);
  fprintf(fi,"MENCODER=%s\n",MENCODER);
  fprintf(fi,"LAME=%s\n",LAME);
  fprintf(fi,"DVDAUTHOR=%s\n",DVDAUTHOR);
  fprintf(fi,"TOSVCD=%s\n",TOSVCD);
  fprintf(fi,"TEMPDIR=%s\n",TEMPDIR);
  fprintf(fi,"LOGDIR=%s\n",LOGDIR);
  fprintf(fi,"SVDRPSEND=%s\n",SVDRPSEND);
  fprintf(fi,"PARQ=%s\n",PARQ);
  fprintf(fi,"COMPRESS=%s\n",COMPRESS);
  fprintf(fi,"DEBUG=%d\n",DEBUG);
  fprintf(fi,"PRIO=%d\n",PRIO);
  fprintf(fi,"SLEEP_TIME=%d\n",SLEEP_TIME);
  fprintf(fi,"CONV_TITLEDATE=%d\n",CONV_TITLEDATE);

  //DVD-Variablen
  fprintf(fi,"DVD_DESTDIR=%s\n",DVD_DESTDIR );
  /*
  fprintf(fi,"DVDTCMPLEXOPTS=%s\n",DVDTCMPLEXOPTS );
  fprintf(fi,"DVD_DVBMPLEXOPTS=%s\n",DVD_DVBMPLEXOPTS);
  fprintf(fi,"DVDALLOWEDWIDTH=%s\n",DVDALLOWEDWIDTH );
  fprintf(fi,"DVDTRANSCODEOPTS=%s\n",DVDTRANSCODEOPTS );
  fprintf(fi,"PPMTOY4M_OPTIONS=%s\n",PPMTOY4M_OPTIONS );
  fprintf(fi,"DVDTRANSCODEBITRATE=%s\n",DVDTRANSCODEBITRATE );
  fprintf(fi,"DVDAUTHORUSERCHAP=%s\n",DVDAUTHORUSERCHAP );
  fprintf(fi,"DVDUSESTREAMS=%s\n",DVDUSESTREAMS );
  fprintf(fi,"DVDREMOVEAUTHORDIR=%d\n",DVDREMOVEAUTHORDIR );
  fprintf(fi,"DVDSIZE=%d\n",DVDSIZE );
  fprintf(fi,"CDSIZE=%d\n",CDSIZE );
  fprintf(fi,"DVDNORM=%s\n",DVDNORM );
  fprintf(fi,"DVDMAINSILENCEFILE=%s\n",DVDMAINSILENCEFILE );
  fprintf(fi,"DVDSUBSILENCEFILE=%s\n",DVDSUBSILENCEFILE );
  fprintf(fi,"DVDTEXTPLAYMOVIE=%s\n",DVDTEXTPLAYMOVIE );
  fprintf(fi,"DVDTEXTMENU=%s\n",DVDTEXTMENU );
  fprintf(fi,"DVDMAINMENUEPOSTACTION=%s\n",DVDMAINMENUEPOSTACTION );
  fprintf(fi,"DVDMENUEPOSTACTION=%s\n",DVDMENUEPOSTACTION );
  fprintf(fi,"DVDBUTTONCOLOR=%s\n",DVDBUTTONCOLOR );
  fprintf(fi,"DVDSUBBUTTONCOLOR=%s\n",DVDSUBBUTTONCOLOR );
  fprintf(fi,"DVDHIBUTTON2COLOR_MENU=%s\n",DVDHIBUTTON2COLOR_MENU );
  fprintf(fi,"DVDHIBUTTONCOLOR_MENU=%s\n",DVDHIBUTTONCOLOR_MENU );
  fprintf(fi,"DVDHIBUTTONCOLOR_SUBMENU=%s\n",DVDHIBUTTONCOLOR_SUBMENU );
  fprintf(fi,"DVDHIBUTTON2COLOR_SUBMENU=%s\n",DVDHIBUTTON2COLOR_SUBMENU );
  fprintf(fi,"DVDFILE_MAINBACKGROUND_COLOR=%s\n",DVDFILE_MAINBACKGROUND_COLOR );
  fprintf(fi,"DVDFILE_SUBBACKGROUND_COLOR=%s\n",DVDFILE_SUBBACKGROUND_COLOR );
  fprintf(fi,"DVDTEXTCOLOR_MENU=%s\n",DVDTEXTCOLOR_MENU );
  fprintf(fi,"DVDTEXTCOLOR_SUBMENU=%s\n",DVDTEXTCOLOR_SUBMENU );
  fprintf(fi,"DVDMENU_SHADOW=%s\n",DVDMENU_SHADOW );
  fprintf(fi,"DVDMAINCOLSFG=%s\n",DVDMAINCOLSFG );
  fprintf(fi,"DVDMAINCOLSBG=%s\n",DVDMAINCOLSBG );
  fprintf(fi,"DVDSUBCOLSFG=%s\n",DVDSUBCOLSFG );
  fprintf(fi,"DVDSUBCOLSBG=%s\n",DVDSUBCOLSBG );
  fprintf(fi,"DVDMAINMENUETIMEOUT=%d\n",DVDMAINMENUETIMEOUT );
  fprintf(fi,"DVDMENUETIMEOUT=%d\n",DVDMENUETIMEOUT );
  */

  fclose(fi);
}

eOSState cProjektEinstellen::ProcessKey(eKeys Key){

  int setup_graphik_old = setupGraphik;
  eOSState state = cOsdMenu::ProcessKey(Key);

  if (state == osUnknown) {
    switch (Key) {
    case kOk:
      speichern();
      state = osBack;
      break;
    default:
      break;
    }//switch
  }//if


  if (Key != kNone && (setupGraphik != setup_graphik_old))
    anzeigen();
  //  if (Key != kNone)

  return state;
}

void cProjektEinstellen::SetHelp() {
  cOsdMenu::SetHelp(NULL);
}
