diff options
author | Vadim Dashevskiy <watcherhd@gmail.com> | 2012-05-15 10:38:20 +0000 |
---|---|---|
committer | Vadim Dashevskiy <watcherhd@gmail.com> | 2012-05-15 10:38:20 +0000 |
commit | 48540940b6c28bb4378abfeb500ec45a625b37b6 (patch) | |
tree | 2ef294c0763e802f91d868bdef4229b6868527de /plugins/StopSpamPlus/src/settings.h | |
parent | 5c350913f011e119127baeb32a6aedeb4f0d33bc (diff) |
initial commit
git-svn-id: http://svn.miranda-ng.org/main/trunk@2 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/StopSpamPlus/src/settings.h')
-rw-r--r-- | plugins/StopSpamPlus/src/settings.h | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/plugins/StopSpamPlus/src/settings.h b/plugins/StopSpamPlus/src/settings.h new file mode 100644 index 0000000000..5fe2b43a39 --- /dev/null +++ b/plugins/StopSpamPlus/src/settings.h @@ -0,0 +1,100 @@ +#pragma once
+
+#include "../headers.h"
+
+class db_usage
+{
+public:
+ //reading from database
+ static tstring DBGetPluginSetting(std::string const &name, tstring const &defValue);
+#ifdef _UNICODE
+ static std::string DBGetPluginSetting(std::string const &name, std::string const &defValue);
+#endif
+ static bool DBGetPluginSetting(std::string const &name, bool const &defValue);
+ static DWORD DBGetPluginSetting(std::string const &name, DWORD const &defValue);
+ //writting to database
+ static void DBSetPluginSetting(std::string const &name, tstring const &value);
+#ifdef _UNICODE
+ static void DBSetPluginSetting(std::string const &name, std::string const &value);
+#endif
+ static void DBSetPluginSetting(std::string const &name, bool const &value);
+ static void DBSetPluginSetting(std::string const &name, DWORD const &value);
+
+};
+
+template <typename T>
+class db_setting
+{
+ std::string m_name;
+ T m_defValue;
+ T m_value;
+public:
+ db_setting(std::string const &name, T const &defValue):m_name(name),m_defValue(defValue)
+ {
+ m_value=db_usage::DBGetPluginSetting(m_name, m_defValue);
+ }
+ const T & GetDefault()const{return m_defValue;}
+ void Set(T const &value)
+ {
+ m_value=value;
+ db_usage::DBSetPluginSetting(m_name, m_value);
+ }
+ const T & Get()const{return m_value;}
+ db_setting<T>& operator=(T const &value)
+ {
+ m_value=value;
+ db_usage::DBSetPluginSetting(m_name, m_value);
+ return *this;
+ }
+ operator T(){return m_value;}
+ void SetResident(BOOL bResident){
+ CallService(MS_DB_SETSETTINGRESIDENT, bResident, (LPARAM)(pluginName m_name.c_str()));
+ }
+};
+
+class Settings
+{
+public:
+ db_setting<tstring> Question;
+ db_setting<tstring> AuthRepl;
+ db_setting<tstring> Answer;
+ db_setting<tstring> Congratulation;
+ db_setting<std::string> DisabledProtoList;
+ db_setting<bool> InfTalkProtection;
+ db_setting<bool> AddPermanent;
+ db_setting<DWORD> MaxQuestCount;
+ db_setting<bool> HandleAuthReq;
+ db_setting<bool> AnswNotCaseSens;
+ db_setting<tstring> AnswSplitString;
+ db_setting<bool> RemTmpAll;
+ db_setting<bool> HistLog;
+
+ Settings():Question("Question",TranslateTS(_T("Spammers made me to install small anti-spam system you are now speaking with. ")
+ _T("Please reply \"nospam\" without quotes and spaces if you want to contact me.\r\n")
+ _T("Внимание! Антиспам защита. Ответьте \"nospam\" без кавычек и пробелов, если хотите связаться со мной.")))
+ ,AuthRepl("AuthReply",TranslateTS(_T("StopSpam: send a message and reply to a anti-spam bot question.\r\n")
+ _T("Антиспам: отправьте сообщение и ответьте на вопрос антиспам системы.")))
+ ,Answer("Answer",TranslateT("nospam"))
+ ,Congratulation("Congratulation",TranslateTS(_T("Congratulations! You just passed human/robot test. Now you can write me a message.\r\n")
+ _T("Поздравляю! Вы прошли антиспам проверку. Теперь вы можете писать мне.")))
+ ,DisabledProtoList("DisabledProtoList","MetaContacts RSSNews")
+ ,InfTalkProtection("InfTalkProtection", 1)
+ ,AddPermanent("AddPermanent", 0)
+ ,HandleAuthReq("HandleAuthReq", 0)
+ ,MaxQuestCount("MaxQuestCount", 2)
+ ,AnswNotCaseSens("AnswNotCaseSens", 1)
+ ,AnswSplitString("AnswSplitString",_T("|"))
+ ,RemTmpAll("RemTmpAll", 1)
+ ,HistLog("HistLog", 0)
+ {
+ const std::string& str = DisabledProtoList.Get();
+ if ( !str.empty() && *(str.rbegin()) != ' ' )
+ DisabledProtoList=DisabledProtoList.Get()+' ';
+ }
+ bool ProtoDisabled(std::string proto)
+ {
+ return std::string::npos != DisabledProtoList.Get().find(proto + " ");
+ }
+};
+
+extern Settings *plSets;
|