From 78d71d2cad6f243c6ff31d41380b8c5b58407de5 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Thu, 17 May 2012 17:37:22 +0000 Subject: added some plugins git-svn-id: http://svn.miranda-ng.org/main/trunk@20 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Boltun/config.cpp | 159 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 plugins/Boltun/config.cpp (limited to 'plugins/Boltun/config.cpp') diff --git a/plugins/Boltun/config.cpp b/plugins/Boltun/config.cpp new file mode 100644 index 0000000000..a59fc89d56 --- /dev/null +++ b/plugins/Boltun/config.cpp @@ -0,0 +1,159 @@ +//*********************************************************** +// Copyright © 2003-2008 Alexander S. Kiselev, Valentin Pavlyuchenko +// +// This file is part of Boltun. +// +// Boltun is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 2 of the License, or +// (at your option) any later version. +// +// Boltun is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Boltun. If not, see . +// +//*********************************************************** + +#include "config.h" + +#include +#include +#include + +#include "newpluginapi.h" +#include "m_database.h" +#include "m_langpack.h" +#include "boltun.h" + +//Database keys +#define DB_EVERYBODY "Everybody" +#define DB_NOT_IN_LIST "NotInList" +#define DB_AUTOAWAY "AutoAway" +#define DB_WARN "Warn" +#define DB_MARK_READ "MarkRead" +#define DB_WAIT_TIME "WaitTime" +#define DB_THINK_TIME "ThinkTime" +#define DB_PAUSE_DEPENDS "PauseDepends" +#define DB_PAUSE_RANDOM "PauseRandom" +#define DB_WARN_TEXT "WarnText" +#define DB_MIND_FILE_NAME "MindFileName" +#define DB_ENGINE_SILENT "SilentEngine" +#define DB_ENGINE_LOWERCASE "MakeLowerCase" +#define DB_ENGINE_UNDERSTAND_ALWAYS "UnderstandAlways" + +inline TCHAR* GetString(char* key, const TCHAR* def) +{ + DBVARIANT dbv; + TCHAR* val; + if(!DBGetContactSettingTString(NULL, BOLTUN_KEY, key, &dbv)) + { + size_t len = wcslen(dbv.ptszVal) + 1; + val = new TCHAR[len]; + _tcscpy_s(val, len, dbv.ptszVal); + DBFreeVariant(&dbv); + } + else + { + size_t len = wcslen(def) + 1; + val = new TCHAR[len]; + _tcscpy_s(val, len, def); + } + return val; +} + +inline const TCHAR* SetString(char* key, const TCHAR* value) +{ + size_t len = _tcslen(value) + 1; + TCHAR* val = new TCHAR[len]; + _tcscpy_s(val, len, value); + DBWriteContactSettingTString(NULL, BOLTUN_KEY, key, val); + return val; +} + +#define BUILDETTERS(x, str, def) \ + const bool BoltunConfig::Get##x() { \ + return DBGetContactSettingDword(NULL, BOLTUN_KEY, str, def) != 0; } \ + const bool BoltunConfig::Set##x(const bool value) { \ + DBWriteContactSettingDword(NULL, BOLTUN_KEY, str, value); \ + return value; } + +#define BUILDINTETTERS(x, str, def) \ + const int BoltunConfig::Get##x() { \ + return DBGetContactSettingDword(NULL, BOLTUN_KEY, str, def); } \ + const int BoltunConfig::Set##x(const int value) { \ + DBWriteContactSettingDword(NULL, BOLTUN_KEY, str, value); \ + return value; } + +#define BUILDSTRETTERS(x, str, def) \ + const TCHAR* BoltunConfig::Get##x() { \ + return GetString(str, def); } \ + const TCHAR* BoltunConfig::Set##x(const TCHAR* value) { \ + return SetString(str, value); } + +#define BUILDINIT(x) \ + x(&BoltunConfig::Get##x, &BoltunConfig::Set##x) + +BUILDETTERS(TalkWithNotInList, DB_NOT_IN_LIST, false); +BUILDETTERS(TalkWithEverybody, DB_EVERYBODY, false); +BUILDETTERS(TalkWarnContacts, DB_WARN, false); +BUILDETTERS(TalkEveryoneWhileAway, DB_AUTOAWAY, false); +BUILDETTERS(MarkAsRead, DB_MARK_READ, true); +BUILDINTETTERS(AnswerPauseTime, DB_WAIT_TIME, 2); +BUILDINTETTERS(AnswerThinkTime, DB_THINK_TIME, 4); +BUILDETTERS(PauseDepends, DB_PAUSE_DEPENDS, TRUE); +BUILDETTERS(PauseRandom, DB_PAUSE_RANDOM, TRUE); +BUILDSTRETTERS(WarnText, DB_WARN_TEXT, TranslateTS(DEFAULT_WARN_TEXT)); +BUILDSTRETTERS(MindFileName, DB_MIND_FILE_NAME, DEFAULT_MIND_FILE); +BUILDETTERS(EngineStaySilent, DB_ENGINE_SILENT, FALSE); +BUILDETTERS(EngineMakeLowerCase, DB_ENGINE_LOWERCASE, FALSE); +BUILDETTERS(EngineUnderstandAlways, DB_ENGINE_UNDERSTAND_ALWAYS, FALSE); + +BoltunConfig::BoltunConfig() + :BUILDINIT(TalkWithEverybody), + BUILDINIT(TalkWithNotInList), + BUILDINIT(TalkWarnContacts), + BUILDINIT(TalkEveryoneWhileAway), + BUILDINIT(MarkAsRead), + BUILDINIT(AnswerPauseTime), + BUILDINIT(AnswerThinkTime), + BUILDINIT(PauseDepends), + BUILDINIT(PauseRandom), + BUILDINIT(WarnText), + BUILDINIT(MindFileName), + BUILDINIT(EngineStaySilent), + BUILDINIT(EngineMakeLowerCase), + BUILDINIT(EngineUnderstandAlways) +{ + TalkWithEverybody.SetOwner(this); + TalkWithNotInList.SetOwner(this); + TalkWarnContacts.SetOwner(this); + TalkEveryoneWhileAway.SetOwner(this); + MarkAsRead.SetOwner(this); + AnswerPauseTime.SetOwner(this); + AnswerThinkTime.SetOwner(this); + PauseDepends.SetOwner(this); + PauseRandom.SetOwner(this); + WarnText.SetOwner(this); + MindFileName.SetOwner(this); + EngineStaySilent.SetOwner(this); + EngineMakeLowerCase.SetOwner(this); + EngineUnderstandAlways.SetOwner(this); +} + +BoltunConfig::~BoltunConfig() +{ +} + +class _BoltunConfigInit +{ +public: + BoltunConfig cfg; +}; + +_BoltunConfigInit inst; + +BoltunConfig &Config = inst.cfg; \ No newline at end of file -- cgit v1.2.3