/*
 * cdda_conf.c: The configuration parameter storage
 *
 * See the README file for copyright information and how to reach the author.
 *
 * $Id: cdda_conf.c,v 1.1.1.4 2005/06/27 13:34:02 cm Exp $
 */

#include <stdlib.h>
#include <string.h>
#include "cdda_conf.h"

// --- cConfiguration ---------------------------------------------------------
cCddaConfiguration::cCddaConfiguration() {
  p_device = p_cddbDirectory = NULL;
  skipSeconds = 10;
  skipBackMargin = 10;
  audioOnly = menuEntry = true;
  autoReplay = false;
  cddbCache = false;
  cddbPriority = cpNoCdText;
  strncpy(cddbServerFqdn, "freedb.freedb.org", 33);
  cddbServerPort = 8880;
  infoView = ivAll;
}

cCddaConfiguration::~cCddaConfiguration() {
  free(p_device);
}

const char *cCddaConfiguration::SetDevice(const char *name) {
  if (NULL != name)
    free(p_device);

  return p_device = strdup(name);
}

const char *cCddaConfiguration::SetCddbDir(const char *dir) {
  if (NULL != dir)
    free(p_cddbDirectory);

  return p_cddbDirectory = strdup(dir);
}

int cCddaConfiguration::SetSkipSeconds(int seconds) {
  return skipSeconds = seconds;
}

int cCddaConfiguration::SetSkipBackMargin(int seconds) {
  return skipBackMargin= seconds;
}

bool cCddaConfiguration::SetAudioOnly(bool on) {
  return audioOnly = on;
}

bool cCddaConfiguration::SetMenuEntry(bool on) {
  return menuEntry = on;
}

bool cCddaConfiguration::SetAutoReplay(bool on) {
  return autoReplay = on;
}

eCddbPriority cCddaConfiguration::SetCddbPriority(eCddbPriority priority) {
  return cddbPriority = priority;
}

const char *cCddaConfiguration::SetCddbServerFqdn(const char *fqdn) {
  return strncpy(cddbServerFqdn, fqdn, 33);
}

int cCddaConfiguration::SetCddbServerPort(unsigned int port) {
  return cddbServerPort = port;
}

bool cCddaConfiguration::SetCddbCache(bool on) {
  return cddbCache = on;
}

eDisplayInformationView cCddaConfiguration::SetDisplayInfoView(eDisplayInformationView view) {
  return infoView = view;
}
