summaryrefslogtreecommitdiff
path: root/plugins/StopSpamPlus/src/settings.cpp
blob: 05a9007d0cd26219bc0d41019fb8e1183041d5f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "headers.h"

//reading from database-------------
tstring db_usage::DBGetPluginSetting(std::string const &name, tstring const &defValue)
{
	DBVARIANT dbv;
	if(DBGetContactSettingTString(NULL, pluginName, name.c_str(), &dbv))
		return defValue;
	tstring value = dbv.ptszVal;
	DBFreeVariant(&dbv);
	return value;
}


std::string db_usage::DBGetPluginSetting(std::string const &name, std::string const &defValue)
{
	DBVARIANT dbv;
	if(DBGetContactSettingString(NULL, pluginName, name.c_str(), &dbv))
		return defValue;
	std::string value = dbv.pszVal;
	DBFreeVariant(&dbv);
	return value;
}


bool db_usage::DBGetPluginSetting(std::string const &name, bool const &defValue)
{
	return(0 != DBGetContactSettingByte(NULL, pluginName, name.c_str(), defValue?1:0));
}

DWORD db_usage::DBGetPluginSetting(std::string const &name, DWORD const &defValue)
{
	return DBGetContactSettingDword(NULL, pluginName, name.c_str(), defValue);
}

//writting to database--------------
void db_usage::DBSetPluginSetting(std::string const &name, tstring const &value)
{
	DBWriteContactSettingTString(NULL, pluginName, name.c_str(), value.c_str());
}


void db_usage::DBSetPluginSetting(std::string const &name, std::string const &value)
{
	DBWriteContactSettingString(NULL, pluginName, name.c_str(), value.c_str());
}


void db_usage::DBSetPluginSetting(std::string const &name, bool const &value)
{
	DBWriteContactSettingByte(NULL, pluginName, name.c_str(), value?1:0);
}

void db_usage::DBSetPluginSetting(std::string const &name, DWORD const &value)
{
	DBWriteContactSettingDword(NULL, pluginName, name.c_str(),value);
}

Settings *plSets;