#include "audio.hpp"

#include "global_options.hpp"
#include "gettext.hpp"

using std::vector;
using std::string;

Audio::AudioOpts::AudioOpts() 
{
  // header
  header = gettext("Audio Options");

  // values

  // reload
  vector<string> none;
  reload_p = new Option(false, gettext("reload"), "reload", 0, none, none);
  val.push_back(reload_p);

  // sorting order
  val.push_back(go->dir_order);

  vector<string> repeat_values;

  repeat_values.push_back(gettext("no")); 
  repeat_values.push_back(gettext("yes"));

  vector<string> english_repeat_values;

  english_repeat_values.push_back("no"); 
  english_repeat_values.push_back("yes");

  repeat_p = new Option(false, gettext("repeat"), "repeat", 0, repeat_values, english_repeat_values);
  val.push_back(repeat_p);

  vector<string> shutdown_values;

  shutdown_values.push_back(gettext("no")); 
  shutdown_values.push_back(gettext("yes"));

  vector<string> english_shutdown_values;

  english_shutdown_values.push_back("no"); 
  english_shutdown_values.push_back("yes");

  shutdown_p = new Option(false, gettext("shutdown on finish"), "autoshutdown", 0, shutdown_values, english_shutdown_values);
  val.push_back(shutdown_p);

  vector<string> shuffle_values;

  shuffle_values.push_back(gettext("off"));
  shuffle_values.push_back(gettext("real random"));
  shuffle_values.push_back(gettext("winamp random"));
#ifdef use_imms
  shuffle_values.push_back(gettext("intelligent"));
#endif

  vector<string> english_shuffle_values;
  
  english_shuffle_values.push_back("off");
  english_shuffle_values.push_back("real random");
  english_shuffle_values.push_back("winamp random");
#ifdef use_imms
  english_shuffle_values.push_back("intelligent");
#endif
  
  shuffle_p = new Option(false, gettext("shuffle"), "shuffle", 0, shuffle_values, english_shuffle_values);
  val.push_back(shuffle_p);

#ifdef music_radio
  vector<string> bitrate_values;

  bitrate_values.push_back("0");
  bitrate_values.push_back("24");
  bitrate_values.push_back("48");
  bitrate_values.push_back("64");
  bitrate_values.push_back("96");
  bitrate_values.push_back("128");
  bitrate_values.push_back("192");
  bitrate_values.push_back("256");

  vector<string> english_bitrate_values;

  english_bitrate_values.push_back("0");
  english_bitrate_values.push_back("24");
  english_bitrate_values.push_back("48");
  english_bitrate_values.push_back("64");
  english_bitrate_values.push_back("96");
  english_bitrate_values.push_back("128");
  english_bitrate_values.push_back("192");
  english_bitrate_values.push_back("256");

  bitrate_p = new Option(false, gettext("minimum bitrate"), "bitrate", 0, bitrate_values, english_bitrate_values);
  val.push_back(bitrate_p);
#else
  vector<string> bitrate_values;
  bitrate_values.push_back(gettext("n/a"));

  vector<string> english_bitrate_values;
  english_bitrate_values.push_back("n/a");

  bitrate_p = new Option(false, gettext("minimum bitrate"), "bitrate", 0, bitrate_values, english_bitrate_values);
  val.push_back(bitrate_p);
#endif

#ifdef use_imms
  if (conf->p_idle_time() != 0) {
    vector<string> extract_meta_values;

    extract_meta_values.push_back(gettext("no")); 
    extract_meta_values.push_back(gettext("yes"));

    vector<string> english_extract_meta_values;

    english_extract_meta_values.push_back("no"); 
    english_extract_meta_values.push_back("yes");

    extract_meta_p = new Option(false, gettext("bg metadata extraction"), "bg metadata extraction", 0, extract_meta_values, english_extract_meta_values);
    val.push_back(extract_meta_p);
  }
#endif
}

Audio::AudioOpts::~AudioOpts()
{
  delete reload_p;
  delete repeat_p;
  delete shutdown_p;
  delete shuffle_p;
#ifdef use_imms
  if (conf->p_idle_time() != 0) {
    delete extract_meta_p;
  }
#endif
}

void Audio::AudioOpts::read_dirs()
{ 
  Audio *audio = Audio::get_instance(); 
  audio->read_dirs(); 
  audio->reset();
}
