/*
 * hattrick.c: A plugin for the Video Disk Recorder
 *
 * See the README file for copyright information and how to reach the author.
 *
 * Author: Matthias Feistel <hitman_47@users.sourceforge.net>, (C) 2007
 *
 * Copyright: See COPYING file that comes with this distribution
 */

#include <stdlib.h>
#include <string>
#include "settings.h"
#include "config.h"
#include <vdr/interface.h>  //SETUP


// --- NewStrDup ---------------------------------------------------------------

char *NewStrDup(const char *string)
{
  if (NULL == string)
    return NULL;

  int n = strlen(string);
  char *p = new char[n + 1];
  strncpy(p, string, n);
  p[n] = 0x00;

  return p;
}

// --- NewStrNDup --------------------------------------------------------------

char *NewStrNDup(const char *string, int i)
{
  if (NULL == string)
    return NULL;

  int n = strnlen(string, i);
  char *p = new char[n + 1];
  strncpy(p, string, n);
  p[n] = 0x00;

  return p;
}

// --- cConfiguration ---------------------------------------------------------
cSettings::cSettings()
{
////  strncpy(m_Recommendedurl, "http://www.hattrick.org/", 511);	
  strncpy(m_Recommendedurl, "", 511);	
  strncpy(m_Cookie, "", 4095);
  strncpy(m_Username, "", 511);
  strncpy(m_Securitycode, "", 511);
  m_IsFavour_ownteam = true;
  m_IsDebugmode = false;
  m_IsTimer = false;
////  m_TeamContainer.clear();
}

cSettings::~cSettings()
{}

cSettings *cSettings::gpo_config = NULL;

cSettings& cSettings::GetInstance(void)
{
  if (NULL == gpo_config)
    gpo_config = new cSettings();

  return *gpo_config;
}

cTimerThread *cSettings::SetTimer(cTimerThread *timer)
{
  return m_Timer = timer;
}
const char *cSettings::SetCookie(const char *cookie)
{
  return strncpy(m_Cookie, cookie, 4096);
}
const char *cSettings::SetRecommendedurl(const char *recommendedurl)
{
  return strncpy(m_Recommendedurl, recommendedurl, 512);
}

const char *cSettings::SetUsername(const char *username)
{
  return strncpy(m_Username, username, 512);
}

const char *cSettings::SetSecuritycode(const char *securitycode)
{
  return strncpy(m_Securitycode, securitycode, 512);
}

bool cSettings::SetIsDebugmode(bool on)
{
  return m_IsDebugmode = on;
}

bool cSettings::SetIsFavour_ownteam(bool on)
{
  return m_IsFavour_ownteam = on;
}

bool cSettings::SetIsTimer(bool on)
{
  return m_IsTimer = on;
}

void cSettings::SetTeamContainer( std::map<long, cTeamData> TeamContainer )
{
  m_TeamContainer = TeamContainer;
}

std::map<long, cTeamData> cSettings::GetTeamContainer( )
{
  return m_TeamContainer;
}

void cSettings::SetFavouriteList( std::list<std::string> FavouriteList )
{
  m_FavouriteList = FavouriteList;
}

std::list<std::string> cSettings::GetFavouriteList( )
{
  return m_FavouriteList;
}
