/*
 * setup.c
 */

#include "setup.h"
#include "mpa-frame.h"


/* default setup values: */
struct setup_values SetupValues = {
	1,  /* receiving mode on start is 'on' */
        5,  /* max. receivers */
        50, /* min. free space (in mb) */
	3,  /* default view 'by date' */
        1,  /* pause postprocessing if osd is opened */
        8,  /* max. tracks in postprocessing queue */
        1,  /* fade in mode */
        9,  /* fade in seconds */
        2,  /* fade out mode */
        12, /* fade out seconds */
        0,  /* audio codec */
        2,  /* number of audio codecs */
        9   /* bitrate */
};

char *audio_codecs[] = { "original", "mp3" };
const char *fade_types[] = { "off", "linear", "exponential" };
const char *_bit_rates[] = { "0", "32000", "48000", "56000", "64000", "80000",
        "96000", "112000", "128000", "160000", "192000", "224000", "256000",
        "320000", "384000", "0" };

#define VIEWS 4

const char *views[] = { "all", "by artist", "by channel", "by date" };

/* --- cAudiorecorderSetup -------------------------------------------------- */

cAudiorecorderSetup::cAudiorecorderSetup(void)
:cMenuSetupPage()
{
        setupvalues = SetupValues;
        
	Add(new cOsdItem("--- Receiver: ---", osUnknown, false));
        Add(new cMenuEditBoolItem("Receiving mode on start",
                        &setupvalues.start_type, "off", "on"));
        Add(new cMenuEditIntItem("Max. number of receivers",
                        &setupvalues.max_receivers, 0, 12));
        Add(new cMenuEditIntItem("Min. free disc space (in mb)",
                        &setupvalues.min_free_space, 50, 999999));
        
	Add(new cOsdItem("--- Browser: ---", osUnknown, false));
        Add(new cMenuEditStraItem("Default view", &setupvalues.default_view,
                        VIEWS, views));
        
	Add(new cOsdItem("--- Postprocessing: ---", osUnknown, false));
        Add(new cMenuEditBoolItem("Pause if osd is opened",
                        &setupvalues.pause));
        Add(new cMenuEditIntItem("Max. tracks in queue",
                        &setupvalues.max_postproc, 1, 20));
        Add(new cMenuEditStraItem("Fade in mode", &setupvalues.fade_in_mode,
                        3, fade_types));
        Add(new cMenuEditIntItem("Fade in seconds", &setupvalues.fade_in,
                        0, 20));
        Add(new cMenuEditStraItem("Fade out mode", &setupvalues.fade_out_mode,
                        3, fade_types));
        Add(new cMenuEditIntItem("Fade out seconds", &setupvalues.fade_out,
                        0, 20));
        Add(new cMenuEditStraItem("Audio codec", &setupvalues.audio_codec,
                        setupvalues.num_audio_codecs, audio_codecs));
        Add(new cMenuEditStraItem("Bitrate (if audio codec isn't <original>)",
                        &setupvalues.bit_rate, 14, &_bit_rates[1]));
}


void cAudiorecorderSetup::Store(void)
{
        SetupValues = setupvalues;
        
        SetupStore("default_view", SetupValues.default_view);
        SetupStore("start_type", SetupValues.start_type);
        SetupStore("max_receivers", SetupValues.max_receivers);
        SetupStore("min_free_space", SetupValues.min_free_space);
        SetupStore("pause", SetupValues.pause);
        SetupStore("max_postproc", SetupValues.max_postproc);
        SetupStore("fade_in_mode", SetupValues.fade_in_mode);
        SetupStore("fade_in", SetupValues.fade_in);
        SetupStore("fade_out_mode", SetupValues.fade_out_mode);
        SetupStore("fade_out", SetupValues.fade_out);
        SetupStore("audio_codec", audio_codecs[SetupValues.audio_codec]);
        SetupStore("bit_rate", SetupValues.bit_rate);
}
