summaryrefslogtreecommitdiff
path: root/plugins/StopSpamMod/src
diff options
context:
space:
mode:
authorVadim Dashevskiy <watcherhd@gmail.com>2013-01-19 08:40:02 +0000
committerVadim Dashevskiy <watcherhd@gmail.com>2013-01-19 08:40:02 +0000
commit9983ccb17775804f3985ed0d3c69852c7cad0348 (patch)
tree17b37447365df3bf48984b5f1afd846f4f77fba0 /plugins/StopSpamMod/src
parent66b9ccda8318b710b7856960577bb0861f9488c0 (diff)
- Another portion of _T replacement when it's not needed (from person)
git-svn-id: http://svn.miranda-ng.org/main/trunk@3160 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/StopSpamMod/src')
-rwxr-xr-xplugins/StopSpamMod/src/init.cpp377
-rwxr-xr-xplugins/StopSpamMod/src/options.cpp187
-rwxr-xr-xplugins/StopSpamMod/src/stopspam.cpp92
-rwxr-xr-xplugins/StopSpamMod/src/utilities.cpp77
4 files changed, 330 insertions, 403 deletions
diff --git a/plugins/StopSpamMod/src/init.cpp b/plugins/StopSpamMod/src/init.cpp
index 9a7e7abb24..2d1da2bf5d 100755
--- a/plugins/StopSpamMod/src/init.cpp
+++ b/plugins/StopSpamMod/src/init.cpp
@@ -1,190 +1,189 @@
-/* Copyright (C) Miklashevsky Roman, sss, elzor
-*
-* This program 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.
-*
-* This program 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 this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-
-#include "headers.h"
-
-
-
-BOOL gbDosServiceExist = 0;
-BOOL gbVarsServiceExist = 0;
-
-DWORD gbMaxQuestCount = 5;
-BOOL gbInfTalkProtection = 0;
-BOOL gbAddPermanent = 0;
-BOOL gbHandleAuthReq = 1;
-BOOL gbSpecialGroup = 0;
-BOOL gbHideContacts = 1;
-BOOL gbIgnoreContacts = 0;
-BOOL gbExclude = 1;
-BOOL gbDelExcluded = 0;
-BOOL gbDelAllTempory = 0;
-BOOL gbHistoryLog = 0;
-BOOL gbDosServiceIntegration = 0;
-BOOL gbCaseInsensitive = 0;
-BOOL gbRegexMatch = 0;
-BOOL gbInvisDisable = 0;
-BOOL gbIgnoreURL = 1;
-BOOL gbLogToFile=0;
-BOOL gbAutoAuth=0;
-BOOL gbAutoAddToServerList=0;
-BOOL gbAutoReqAuth=1;
-BOOL gbMathExpression = 0;
-
-HANDLE hStopSpamLogDirH=0;
-
-tstring gbSpammersGroup = _T("Spammers");
-tstring gbAutoAuthGroup = _T("NotSpammers");
-
-tstring gbQuestion;
-tstring gbAnswer;
-tstring gbCongratulation;
-std::wstring gbAuthRepl;
-extern char * pluginDescription;
-extern TCHAR const * defQuestion;
-extern int RemoveTmp(WPARAM,LPARAM);
-
-
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// returns plugin's extended information
-
-// {553811EE-DEB6-48b8-8902-A8A00C1FD679}
-#define MIID_STOPSPAM { 0x553811ee, 0xdeb6, 0x48b8, { 0x89, 0x2, 0xa8, 0xa0, 0xc, 0x1f, 0xd6, 0x79 } }
-
-PLUGININFOEX pluginInfoEx = {
- sizeof(PLUGININFOEX),
- pluginName" mod",
- PLUGIN_MAKE_VERSION(0, 0, 2, 0),
- pluginDescription,
- "Roman Miklashevsky, sss, Elzor",
- "sss123next@list.ru",
- "© 2004-2012 Roman Miklashevsky, A. Petkevich, Kosh&chka, sss, Elzor",
- "http://sss.chaoslab.ru/tracker/mim_plugs/",
- UNICODE_AWARE,
- MIID_STOPSPAM
-};
-
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
-{
- return &pluginInfoEx;
-}
-
-extern tstring DBGetContactSettingStringPAN(HANDLE hContact, char const * szModule, char const * szSetting, tstring errorValue);
-
-void InitVars()
-{
- gbDosServiceIntegration = DBGetContactSettingByte(NULL, pluginName, "DOSIntegration", 0);
- gbSpammersGroup = DBGetContactSettingStringPAN(NULL, pluginName, "SpammersGroup", _T("Spammers"));
- gbAnswer = DBGetContactSettingStringPAN(NULL, pluginName, "answer", _T("nospam"));
- gbCongratulation = DBGetContactSettingStringPAN(NULL, pluginName, "congratulation", _T("Congratulations! You just passed human/robot test. Now you can write me a message."));
- gbInfTalkProtection = DBGetContactSettingByte(NULL, pluginName, "infTalkProtection", 0);
- gbAddPermanent = DBGetContactSettingByte(NULL, pluginName, "addPermanent", 0);
- gbMaxQuestCount = DBGetContactSettingDword(NULL, pluginName, "maxQuestCount", 5);
- gbHandleAuthReq = DBGetContactSettingByte(NULL, pluginName, "handleAuthReq", 1);
- gbQuestion = DBGetContactSettingStringPAN(NULL, pluginName, "question", defQuestion);
- gbAnswer = DBGetContactSettingStringPAN(NULL, pluginName, "answer", _T("nospam"));
- gbCongratulation = DBGetContactSettingStringPAN(NULL, pluginName, "congratulation", _T("Congratulations! You just passed human/robot test. Now you can write me a message."));
- gbAuthRepl = DBGetContactSettingStringPAN(NULL, pluginName, "authrepl", _T("StopSpam: send a message and reply to a anti-spam bot question."));
- gbSpecialGroup = DBGetContactSettingByte(NULL, pluginName, "SpecialGroup", 0);
- gbHideContacts = DBGetContactSettingByte(NULL, pluginName, "HideContacts", 0);
- gbIgnoreContacts = DBGetContactSettingByte(NULL, pluginName, "IgnoreContacts", 0);
- gbExclude = DBGetContactSettingByte(NULL, pluginName, "ExcludeContacts", 1);
- gbDelExcluded = DBGetContactSettingByte(NULL, pluginName, "DelExcluded", 0);
- gbDelAllTempory = DBGetContactSettingByte(NULL, pluginName, "DelAllTempory", 0);
- gbCaseInsensitive = DBGetContactSettingByte(NULL, pluginName, "CaseInsensitive", 0);
- gbRegexMatch = DBGetContactSettingByte(NULL, pluginName, "RegexMatch", 0);
- gbInvisDisable = DBGetContactSettingByte(NULL, pluginName, "DisableInInvis", 0);
- gbIgnoreURL = DBGetContactSettingByte(NULL, pluginName, "IgnoreURL", 0);
- gbAutoAuthGroup = DBGetContactSettingStringPAN(NULL, pluginName, "AutoAuthGroup", _T("Not Spammers"));
- gbAutoAuth=DBGetContactSettingByte(NULL, pluginName, "AutoAuth", 0);
- gbAutoAddToServerList=DBGetContactSettingByte(NULL, pluginName, "AutoAddToServerList", 0);
- gbAutoReqAuth=DBGetContactSettingByte(NULL, pluginName, "AutoReqAuth", 0);
- gbLogToFile=DBGetContactSettingByte(NULL, pluginName, "LogSpamToFile", 0);
- gbHistoryLog = DBGetContactSettingByte(NULL, pluginName, "HistoryLog", 0);
- gbMathExpression = DBGetContactSettingByte(NULL, pluginName, "MathExpression", 0);
-
-}
-
-static int OnSystemModulesLoaded(WPARAM wParam,LPARAM lParam)
-{
-/* if (ServiceExists(MS_DOS_SERVICE))
- gbDosServiceExist = TRUE; */
- if (ServiceExists(MS_VARS_FORMATSTRING))
- gbVarsServiceExist = TRUE;
- InitVars();
- void CleanThread();
- if(gbDelAllTempory || gbDelExcluded)
- boost::thread *thr = new boost::thread(&CleanThread);
- // Folders plugin support
- if (ServiceExists(MS_FOLDERS_REGISTER_PATH))
- {
- hStopSpamLogDirH = (HANDLE) FoldersRegisterCustomPath("StopSpam", "StopSpam Logs",
- PROFILE_PATH "\\" CURRENT_PROFILE "\\StopSpamLog");
- }
- return 0;
-}
-
-HANDLE hEventFilter = 0, hOptInitialise = 0, hSettingChanged = 0;
-
-
-BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
-{
- /*if(DLL_PROCESS_ATTACH == fdwReason)
- hInst=hinstDLL;
- return TRUE;*/
- hInst = hinstDLL;
- return TRUE;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// returns plugin's interfaces information
-
-static const MUUID interfaces[] = { MIID_STOPSPAM, MIID_LAST };
-
-extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void)
-{
- return interfaces;
-}
-
-int hLangpack = 0;
-
-extern "C" int __declspec(dllexport) Load()
-{
- mir_getLP(&pluginInfoEx);
-
- CreateServiceFunction("/RemoveTmp", (MIRANDASERVICE)RemoveTmp);
- HookEvent(ME_SYSTEM_MODULESLOADED, OnSystemModulesLoaded);
-
+/* Copyright (C) Miklashevsky Roman, sss, elzor
+*
+* This program 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.
+*
+* This program 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 this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+
+#include "headers.h"
+
+
+
+BOOL gbDosServiceExist = 0;
+BOOL gbVarsServiceExist = 0;
+
+DWORD gbMaxQuestCount = 5;
+BOOL gbInfTalkProtection = 0;
+BOOL gbAddPermanent = 0;
+BOOL gbHandleAuthReq = 1;
+BOOL gbSpecialGroup = 0;
+BOOL gbHideContacts = 1;
+BOOL gbIgnoreContacts = 0;
+BOOL gbExclude = 1;
+BOOL gbDelExcluded = 0;
+BOOL gbDelAllTempory = 0;
+BOOL gbHistoryLog = 0;
+BOOL gbDosServiceIntegration = 0;
+BOOL gbCaseInsensitive = 0;
+BOOL gbRegexMatch = 0;
+BOOL gbInvisDisable = 0;
+BOOL gbIgnoreURL = 1;
+BOOL gbLogToFile=0;
+BOOL gbAutoAuth=0;
+BOOL gbAutoAddToServerList=0;
+BOOL gbAutoReqAuth=1;
+BOOL gbMathExpression = 0;
+
+HANDLE hStopSpamLogDirH=0;
+
+tstring gbSpammersGroup = _T("Spammers");
+tstring gbAutoAuthGroup = _T("NotSpammers");
+
+tstring gbQuestion;
+tstring gbAnswer;
+tstring gbCongratulation;
+std::wstring gbAuthRepl;
+extern char * pluginDescription;
+extern TCHAR const * defQuestion;
+extern int RemoveTmp(WPARAM,LPARAM);
+
+
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// returns plugin's extended information
+
+// {553811EE-DEB6-48b8-8902-A8A00C1FD679}
+#define MIID_STOPSPAM { 0x553811ee, 0xdeb6, 0x48b8, { 0x89, 0x2, 0xa8, 0xa0, 0xc, 0x1f, 0xd6, 0x79 } }
+
+PLUGININFOEX pluginInfoEx = {
+ sizeof(PLUGININFOEX),
+ pluginName" mod",
+ PLUGIN_MAKE_VERSION(0, 0, 2, 0),
+ pluginDescription,
+ "Roman Miklashevsky, sss, Elzor",
+ "sss123next@list.ru",
+ "© 2004-2012 Roman Miklashevsky, A. Petkevich, Kosh&chka, sss, Elzor",
+ "http://sss.chaoslab.ru/tracker/mim_plugs/",
+ UNICODE_AWARE,
+ MIID_STOPSPAM
+};
+
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
+{
+ return &pluginInfoEx;
+}
+
+extern tstring DBGetContactSettingStringPAN(HANDLE hContact, char const * szModule, char const * szSetting, tstring errorValue);
+
+void InitVars()
+{
+ gbDosServiceIntegration = db_get_b(NULL, pluginName, "DOSIntegration", 0);
+ gbSpammersGroup = DBGetContactSettingStringPAN(NULL, pluginName, "SpammersGroup", _T("Spammers"));
+ gbAnswer = DBGetContactSettingStringPAN(NULL, pluginName, "answer", _T("nospam"));
+ gbCongratulation = DBGetContactSettingStringPAN(NULL, pluginName, "congratulation", _T("Congratulations! You just passed human/robot test. Now you can write me a message."));
+ gbInfTalkProtection = db_get_b(NULL, pluginName, "infTalkProtection", 0);
+ gbAddPermanent = db_get_b(NULL, pluginName, "addPermanent", 0);
+ gbMaxQuestCount = db_get_dw(NULL, pluginName, "maxQuestCount", 5);
+ gbHandleAuthReq = db_get_b(NULL, pluginName, "handleAuthReq", 1);
+ gbQuestion = DBGetContactSettingStringPAN(NULL, pluginName, "question", defQuestion);
+ gbAnswer = DBGetContactSettingStringPAN(NULL, pluginName, "answer", _T("nospam"));
+ gbCongratulation = DBGetContactSettingStringPAN(NULL, pluginName, "congratulation", _T("Congratulations! You just passed human/robot test. Now you can write me a message."));
+ gbAuthRepl = DBGetContactSettingStringPAN(NULL, pluginName, "authrepl", _T("StopSpam: send a message and reply to a anti-spam bot question."));
+ gbSpecialGroup = db_get_b(NULL, pluginName, "SpecialGroup", 0);
+ gbHideContacts = db_get_b(NULL, pluginName, "HideContacts", 0);
+ gbIgnoreContacts = db_get_b(NULL, pluginName, "IgnoreContacts", 0);
+ gbExclude = db_get_b(NULL, pluginName, "ExcludeContacts", 1);
+ gbDelExcluded = db_get_b(NULL, pluginName, "DelExcluded", 0);
+ gbDelAllTempory = db_get_b(NULL, pluginName, "DelAllTempory", 0);
+ gbCaseInsensitive = db_get_b(NULL, pluginName, "CaseInsensitive", 0);
+ gbRegexMatch = db_get_b(NULL, pluginName, "RegexMatch", 0);
+ gbInvisDisable = db_get_b(NULL, pluginName, "DisableInInvis", 0);
+ gbIgnoreURL = db_get_b(NULL, pluginName, "IgnoreURL", 0);
+ gbAutoAuthGroup = DBGetContactSettingStringPAN(NULL, pluginName, "AutoAuthGroup", _T("Not Spammers"));
+ gbAutoAuth = db_get_b(NULL, pluginName, "AutoAuth", 0);
+ gbAutoAddToServerList = db_get_b(NULL, pluginName, "AutoAddToServerList", 0);
+ gbAutoReqAuth = db_get_b(NULL, pluginName, "AutoReqAuth", 0);
+ gbLogToFile = db_get_b(NULL, pluginName, "LogSpamToFile", 0);
+ gbHistoryLog = db_get_b(NULL, pluginName, "HistoryLog", 0);
+ gbMathExpression = db_get_b(NULL, pluginName, "MathExpression", 0);
+
+}
+
+static int OnSystemModulesLoaded(WPARAM wParam,LPARAM lParam)
+{
+/* if (ServiceExists(MS_DOS_SERVICE))
+ gbDosServiceExist = TRUE; */
+ if (ServiceExists(MS_VARS_FORMATSTRING))
+ gbVarsServiceExist = TRUE;
+ InitVars();
+ void CleanThread();
+ if(gbDelAllTempory || gbDelExcluded)
+ boost::thread *thr = new boost::thread(&CleanThread);
+ // Folders plugin support
+ if (ServiceExists(MS_FOLDERS_REGISTER_PATH))
+ {
+ hStopSpamLogDirH = (HANDLE) FoldersRegisterCustomPath("StopSpam", "StopSpam Logs", PROFILE_PATH "\\" CURRENT_PROFILE "\\StopSpamLog");
+ }
+ return 0;
+}
+
+HANDLE hEventFilter = 0, hOptInitialise = 0, hSettingChanged = 0;
+
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
+{
+ /*if(DLL_PROCESS_ATTACH == fdwReason)
+ hInst=hinstDLL;
+ return TRUE;*/
+ hInst = hinstDLL;
+ return TRUE;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// returns plugin's interfaces information
+
+static const MUUID interfaces[] = { MIID_STOPSPAM, MIID_LAST };
+
+extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void)
+{
+ return interfaces;
+}
+
+int hLangpack = 0;
+
+extern "C" int __declspec(dllexport) Load()
+{
+ mir_getLP(&pluginInfoEx);
+
+ CreateServiceFunction("/RemoveTmp", (MIRANDASERVICE)RemoveTmp);
+ HookEvent(ME_SYSTEM_MODULESLOADED, OnSystemModulesLoaded);
+
CLISTMENUITEM mi = { sizeof(mi) };
- mi.position=-0x7FFFFFFF;
- mi.flags=0;
- mi.hIcon=LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
- mi.pszName="Remove Temporary Contacts";
- mi.pszService="/RemoveTmp";
-
- Menu_AddMainMenuItem(&mi);
-
- miranda::EventHooker::HookAll();
- return 0;
-}
-
-extern "C" int __declspec(dllexport) Unload(void)
-{
- miranda::EventHooker::UnhookAll();
- return 0;
-}
+ mi.position=-0x7FFFFFFF;
+ mi.flags=0;
+ mi.hIcon=LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
+ mi.pszName=LPGEN("Remove Temporary Contacts");
+ mi.pszService="/RemoveTmp";
+
+ Menu_AddMainMenuItem(&mi);
+
+ miranda::EventHooker::HookAll();
+ return 0;
+}
+
+extern "C" int __declspec(dllexport) Unload(void)
+{
+ miranda::EventHooker::UnhookAll();
+ return 0;
+}
diff --git a/plugins/StopSpamMod/src/options.cpp b/plugins/StopSpamMod/src/options.cpp
index 5757f06fe7..7f03d86ed5 100755
--- a/plugins/StopSpamMod/src/options.cpp
+++ b/plugins/StopSpamMod/src/options.cpp
@@ -19,16 +19,15 @@
#define MIRANDA_VER 0x0800
#include "headers.h"
-char * pluginDescription = "No more spam! Robots can't go! Only human beings invited!\r\n\r\n"
+char * pluginDescription = LPGEN("No more spam! Robots can't go! Only human beings invited!\r\n\r\n"
"This plugin works pretty simple:\r\n"
"While messages from users on your contact list go as there is no any anti-spam software, "
"messages from unknown users are not delivered to you. "
"But also they are not ignored, this plugin replies with a simple question, "
"and if user gives the right answer plugin adds him to your contact list "
-"so that he can contact you.";
-TCHAR const * defQuestion =
-_T("Spammers made me to install small anti-spam system you are now speaking with.\r\n")
-_T("Please reply \"nospam\" without quotes and spaces if you want to contact me.");
+"so that he can contact you.");
+TCHAR const * defQuestion = TranslateT("Spammers made me to install small anti-spam system you are now speaking with.\r\n"
+"Please reply \"nospam\" without quotes and spaces if you want to contact me.");
INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -69,20 +68,13 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
case PSN_APPLY:
{
- DBWriteContactSettingDword(NULL, pluginName, "maxQuestCount", gbMaxQuestCount =
- GetDlgItemInt(hwnd, ID_MAXQUESTCOUNT, NULL, FALSE));
- DBWriteContactSettingByte(NULL, pluginName, "infTalkProtection", gbInfTalkProtection =
- BST_CHECKED == SendDlgItemMessage(hwnd, ID_INFTALKPROT, BM_GETCHECK, 0, 0));
- DBWriteContactSettingByte(NULL, pluginName, "addPermanent", gbAddPermanent =
- BST_CHECKED == SendDlgItemMessage(hwnd, ID_ADDPERMANENT, BM_GETCHECK, 0, 0));
- DBWriteContactSettingByte(NULL, pluginName, "handleAuthReq", gbHandleAuthReq =
- BST_CHECKED == SendDlgItemMessage(hwnd, ID_HANDLEAUTHREQ, BM_GETCHECK, 0, 0));
- DBWriteContactSettingByte(NULL, pluginName, "HideContacts", gbHideContacts =
- BST_CHECKED == SendDlgItemMessage(hwnd, ID_HIDECONTACTS, BM_GETCHECK, 0, 0));
- DBWriteContactSettingByte(NULL, pluginName, "IgnoreContacts", gbIgnoreContacts =
- BST_CHECKED == SendDlgItemMessage(hwnd, ID_IGNORESPAMMERS, BM_GETCHECK, 0, 0));
- DBWriteContactSettingByte(NULL, pluginName, "LogSpamToFile", gbLogToFile =
- BST_CHECKED == SendDlgItemMessage(hwnd, ID_LOGSPAMTOFILE, BM_GETCHECK, 0, 0));
+ db_set_dw(NULL, pluginName, "maxQuestCount", gbMaxQuestCount = GetDlgItemInt(hwnd, ID_MAXQUESTCOUNT, NULL, FALSE));
+ db_set_b(NULL, pluginName, "infTalkProtection", gbInfTalkProtection = BST_CHECKED == SendDlgItemMessage(hwnd, ID_INFTALKPROT, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "addPermanent", gbAddPermanent = BST_CHECKED == SendDlgItemMessage(hwnd, ID_ADDPERMANENT, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "handleAuthReq", gbHandleAuthReq = BST_CHECKED == SendDlgItemMessage(hwnd, ID_HANDLEAUTHREQ, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "HideContacts", gbHideContacts = BST_CHECKED == SendDlgItemMessage(hwnd, ID_HIDECONTACTS, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "IgnoreContacts", gbIgnoreContacts = BST_CHECKED == SendDlgItemMessage(hwnd, ID_IGNORESPAMMERS, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "LogSpamToFile", gbLogToFile = BST_CHECKED == SendDlgItemMessage(hwnd, ID_LOGSPAMTOFILE, BM_GETCHECK, 0, 0));
}
return TRUE;
}
@@ -123,10 +115,10 @@ INT_PTR CALLBACK MessagesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
break;
}
case ID_RESTOREDEFAULTS:
- SetDlgItemText(hwnd, ID_QUESTION, TranslateTS(defQuestion));
- SetDlgItemText(hwnd, ID_ANSWER, TranslateTS(_T("nospam")));
- SetDlgItemText(hwnd, ID_AUTHREPL, TranslateTS(_T("StopSpam: send a message and reply to a anti-spam bot question.")));
- SetDlgItemText(hwnd, ID_CONGRATULATION, TranslateTS(_T("Congratulations! You just passed human/robot test. Now you can write me a message.")));
+ SetDlgItemText(hwnd, ID_QUESTION, defQuestion);
+ SetDlgItemText(hwnd, ID_ANSWER, TranslateT("nospam"));
+ SetDlgItemText(hwnd, ID_AUTHREPL, TranslateT("StopSpam: send a message and reply to a anti-spam bot question."));
+ SetDlgItemText(hwnd, ID_CONGRATULATION, TranslateT("Congratulations! You just passed human/robot test. Now you can write me a message."));
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
return TRUE;
case IDC_VARS:
@@ -143,30 +135,25 @@ INT_PTR CALLBACK MessagesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
{
case PSN_APPLY:
{
- DBWriteContactSettingTString(NULL, pluginName, "question",
- GetDlgItemString(hwnd, ID_QUESTION).c_str());
+ db_set_ws(NULL, pluginName, "question", GetDlgItemString(hwnd, ID_QUESTION).c_str());
gbQuestion = DBGetContactSettingStringPAN(NULL, pluginName, "question", defQuestion);
- DBWriteContactSettingTString(NULL, pluginName, "answer",
- GetDlgItemString(hwnd, ID_ANSWER).c_str());
- gbAnswer = DBGetContactSettingStringPAN(NULL, pluginName, "answer", _T("nospam"));
- DBWriteContactSettingTString(NULL, pluginName, "authrepl",
- GetDlgItemString(hwnd, ID_AUTHREPL).c_str());
- gbAuthRepl = DBGetContactSettingStringPAN(NULL, pluginName, "authrepl", _T("StopSpam: send a message and reply to a anti-spam bot question."));
- DBWriteContactSettingTString(NULL, pluginName, "congratulation",
- GetDlgItemString(hwnd, ID_CONGRATULATION).c_str());
- gbCongratulation = DBGetContactSettingStringPAN(NULL, pluginName, "congratulation", _T("Congratulations! You just passed human/robot test. Now you can write me a message."));
+ db_set_ws(NULL, pluginName, "answer", GetDlgItemString(hwnd, ID_ANSWER).c_str());
+ gbAnswer = DBGetContactSettingStringPAN(NULL, pluginName, "answer", TranslateT("nospam"));
+ db_set_ws(NULL, pluginName, "authrepl", GetDlgItemString(hwnd, ID_AUTHREPL).c_str());
+ gbAuthRepl = DBGetContactSettingStringPAN(NULL, pluginName, "authrepl", TranslateT("StopSpam: send a message and reply to a anti-spam bot question."));
+ db_set_ws(NULL, pluginName, "congratulation", GetDlgItemString(hwnd, ID_CONGRATULATION).c_str());
+ gbCongratulation = DBGetContactSettingStringPAN(NULL, pluginName, "congratulation", TranslateT("Congratulations! You just passed human/robot test. Now you can write me a message."));
}
return TRUE;
}
}
- break;
+ break;
}
return FALSE;
}
INT_PTR CALLBACK ProtoDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
-
switch(msg)
{
case WM_INITDIALOG:
@@ -175,10 +162,8 @@ INT_PTR CALLBACK ProtoDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
int n;
PROTOACCOUNT **pppd;
if(!ProtoEnumAccounts(&n, &pppd))
- for(int i = 0; i < n; ++i)
- {
- SendDlgItemMessageA(hwnd, (ProtoInList(pppd[i]->szModuleName) ? ID_USEDPROTO : ID_ALLPROTO),
- LB_ADDSTRING, 0, (LPARAM)pppd[i]->szModuleName);
+ for (int i = 0; i < n; ++i) {
+ SendDlgItemMessageA(hwnd, (ProtoInList(pppd[i]->szModuleName) ? ID_USEDPROTO : ID_ALLPROTO), LB_ADDSTRING, 0, (LPARAM)pppd[i]->szModuleName);
}
}
return TRUE;
@@ -188,11 +173,9 @@ INT_PTR CALLBACK ProtoDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case ID_ADD:
{
WPARAM n = (WPARAM)SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_GETCURSEL, 0, 0);
- if(LB_ERR != n)
- {
+ if(LB_ERR != n) {
size_t len = SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_GETTEXTLEN, n, 0);
- if(LB_ERR != len)
- {
+ if(LB_ERR != len) {
TCHAR * buf = new TCHAR[len + 1];
SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_GETTEXT, n, (LPARAM)buf);
SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_ADDSTRING, 0, (LPARAM)buf);
@@ -205,11 +188,9 @@ INT_PTR CALLBACK ProtoDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case ID_REMOVE:
{
WPARAM n = (WPARAM)SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETCURSEL, 0, 0);
- if(LB_ERR != n)
- {
+ if(LB_ERR != n) {
size_t len = SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETTEXTLEN, n, 0);
- if(LB_ERR != len)
- {
+ if(LB_ERR != len) {
TCHAR * buf = new TCHAR[len + 1];
SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETTEXT, n, (LPARAM)buf);
SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_ADDSTRING, 0, (LPARAM)buf);
@@ -253,34 +234,30 @@ INT_PTR CALLBACK ProtoDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
LRESULT count = SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETCOUNT, 0, 0);
std::ostringstream out;
- for(int i = 0; i < count; ++i)
- {
+ for(int i = 0; i < count; ++i) {
size_t len = SendDlgItemMessageA(hwnd, ID_USEDPROTO, LB_GETTEXTLEN, i, 0);
- if(LB_ERR != len)
- {
+ if(LB_ERR != len) {
char * buf = new char[len + 1];
SendDlgItemMessageA(hwnd, ID_USEDPROTO, LB_GETTEXT, i, (LPARAM)buf);
out << buf << "\r\n";
delete []buf;
}
}
- DBWriteContactSettingString(NULL, pluginName, "protoList", out.str().c_str());
+ db_set_s(NULL, pluginName, "protoList", out.str().c_str());
}
return TRUE;
- }
+ }
}
- break;
+ break;
}
return FALSE;
}
INT_PTR CALLBACK AdvancedDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
-
switch(msg)
{
- case WM_INITDIALOG:
- {
+ case WM_INITDIALOG: {
TranslateDialogDefault(hwnd);
SendDlgItemMessage(hwnd, IDC_INVIS_DISABLE, BM_SETCHECK, gbInvisDisable ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage(hwnd, IDC_CASE_INSENSITIVE, BM_SETCHECK, gbCaseInsensitive ? BST_CHECKED : BST_UNCHECKED, 0);
@@ -302,12 +279,11 @@ INT_PTR CALLBACK AdvancedDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
SetDlgItemText(hwnd, IDC_AUTOADDGROUP, gbAutoAuthGroup.c_str());
}
return TRUE;
- case WM_COMMAND:{
+ case WM_COMMAND: {
switch (LOWORD(wParam))
{
- case IDC_MATH_DETAILS:
- {
- MessageBox(NULL, TranslateT("If math expression is turned on you can use following expression in message text:\nXX+XX-X/X*X\neach X will be replaced by one ruandom number and answer will be expression result\nMessage must contain only one expression without spaces"), _T("Info"), MB_OK);
+ case IDC_MATH_DETAILS: {
+ MessageBox(NULL, TranslateT("If math expression is turned on you can use following expression in message text:\nXX+XX-X/X*X\neach X will be replaced by one ruandom number and answer will be expression result\nMessage must contain only one expression without spaces"), TranslateT("Info"), MB_OK);
}
break;
case IDC_INVIS_DISABLE:
@@ -327,106 +303,82 @@ INT_PTR CALLBACK AdvancedDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
case IDC_HISTORY_LOG:
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
break;
-
}
- }
+ }
break;
- case WM_NOTIFY:
- {
+ case WM_NOTIFY: {
NMHDR* nmhdr = (NMHDR*)lParam;
switch (nmhdr->code)
{
- case PSN_APPLY:
- {
- DBWriteContactSettingByte(NULL, pluginName, "CaseInsensitive", gbCaseInsensitive =
- BST_CHECKED == SendDlgItemMessage(hwnd, IDC_CASE_INSENSITIVE, BM_GETCHECK, 0, 0));
- DBWriteContactSettingByte(NULL, pluginName, "DisableInInvis", gbInvisDisable =
- BST_CHECKED == SendDlgItemMessage(hwnd, IDC_INVIS_DISABLE, BM_GETCHECK, 0, 0));
- DBWriteContactSettingByte(NULL, pluginName, "DOSIntegration", gbDosServiceIntegration =
- BST_CHECKED == SendDlgItemMessage(hwnd, ID_DOS_INTEGRATION, BM_GETCHECK, 0, 0));
+ case PSN_APPLY: {
+ db_set_b(NULL, pluginName, "CaseInsensitive", gbCaseInsensitive = BST_CHECKED == SendDlgItemMessage(hwnd, IDC_CASE_INSENSITIVE, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "DisableInInvis", gbInvisDisable = BST_CHECKED == SendDlgItemMessage(hwnd, IDC_INVIS_DISABLE, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "DOSIntegration", gbDosServiceIntegration = BST_CHECKED == SendDlgItemMessage(hwnd, ID_DOS_INTEGRATION, BM_GETCHECK, 0, 0));
{
static tstring NewGroupName, CurrentGroupName;
NewGroupName = GetDlgItemString(hwnd, ID_SPECIALGROUPNAME);
CurrentGroupName = gbSpammersGroup = DBGetContactSettingStringPAN(NULL, pluginName, "SpammersGroup", _T("0"));
- if(wcscmp(CurrentGroupName.c_str(), NewGroupName.c_str()) != 0)
- {
+ if (wcscmp(CurrentGroupName.c_str(), NewGroupName.c_str()) != 0) {
int GroupNumber = 0;
BYTE GroupExist = 0;
TCHAR szValue[96] = {0};
char szNumber[32] = {0};
extern int CreateCListGroup(TCHAR* szGroupName);
strcpy(szNumber, "0");
- while(strcmp(DBGetContactSettingStringPAN_A(NULL, "CListGroups", szNumber, "0").c_str(), "0") != 0)
- {
+ while (strcmp(DBGetContactSettingStringPAN_A(NULL, "CListGroups", szNumber, "0").c_str(), "0") != 0) {
_itoa(GroupNumber, szNumber, 10);
wcscpy(szValue, DBGetContactSettingStringPAN(NULL, "CListGroups", szNumber, _T("0")).c_str());
- if(wcscmp(NewGroupName.c_str(), szValue + 1) == 0)
- {
+ if (wcscmp(NewGroupName.c_str(), szValue + 1) == 0) {
GroupExist = 1;
break;
}
GroupNumber++;
}
- DBWriteContactSettingTString(NULL,pluginName, "SpammersGroup", NewGroupName.c_str());
+ db_set_ws(NULL,pluginName, "SpammersGroup", NewGroupName.c_str());
gbSpammersGroup = DBGetContactSettingStringPAN(NULL,pluginName,"SpammersGroup", _T("Spammers"));
if(!GroupExist && gbSpecialGroup)
CreateCListGroup((TCHAR*)gbSpammersGroup.c_str());
}
}
- DBWriteContactSettingByte(NULL, pluginName, "SpecialGroup", gbSpecialGroup =
- BST_CHECKED == SendDlgItemMessage(hwnd, ID_SPECIALGROUP, BM_GETCHECK, 0, 0));
- DBWriteContactSettingByte(NULL, pluginName, "ExcludeContacts", gbExclude =
- BST_CHECKED == SendDlgItemMessage(hwnd, ID_EXCLUDE, BM_GETCHECK, 0, 0));
- DBWriteContactSettingByte(NULL, pluginName, "DelExcluded", gbDelExcluded =
- BST_CHECKED == SendDlgItemMessage(hwnd, ID_REMOVE_TMP, BM_GETCHECK, 0, 0));
- DBWriteContactSettingByte(NULL, pluginName, "DelAllTempory", gbDelAllTempory =
- BST_CHECKED == SendDlgItemMessage(hwnd, ID_REMOVE_TMP_ALL, BM_GETCHECK, 0, 0));
- DBWriteContactSettingByte(NULL, pluginName, "IgnoreURL", gbIgnoreURL =
- BST_CHECKED == SendDlgItemMessage(hwnd, ID_IGNOREURL, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "SpecialGroup", gbSpecialGroup = BST_CHECKED == SendDlgItemMessage(hwnd, ID_SPECIALGROUP, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "ExcludeContacts", gbExclude = BST_CHECKED == SendDlgItemMessage(hwnd, ID_EXCLUDE, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "DelExcluded", gbDelExcluded = BST_CHECKED == SendDlgItemMessage(hwnd, ID_REMOVE_TMP, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "DelAllTempory", gbDelAllTempory = BST_CHECKED == SendDlgItemMessage(hwnd, ID_REMOVE_TMP_ALL, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "IgnoreURL", gbIgnoreURL = BST_CHECKED == SendDlgItemMessage(hwnd, ID_IGNOREURL, BM_GETCHECK, 0, 0));
- DBWriteContactSettingByte(NULL, pluginName, "AutoAuth", gbAutoAuth =
- BST_CHECKED == SendDlgItemMessage(hwnd, IDC_AUTOAUTH, BM_GETCHECK, 0, 0));
- DBWriteContactSettingByte(NULL, pluginName, "AutoAddToServerList", gbAutoAddToServerList =
- BST_CHECKED == SendDlgItemMessage(hwnd, IDC_ADDTOSRVLST, BM_GETCHECK, 0, 0));
- DBWriteContactSettingByte(NULL, pluginName, "AutoReqAuth", gbAutoReqAuth =
- BST_CHECKED == SendDlgItemMessage(hwnd, IDC_REQAUTH, BM_GETCHECK, 0, 0));
- DBWriteContactSettingByte(NULL, pluginName, "RegexMatch", gbRegexMatch =
- BST_CHECKED == SendDlgItemMessage(hwnd, IDC_REGEX, BM_GETCHECK, 0, 0));
- DBWriteContactSettingByte(NULL, pluginName, "HistoryLog", gbHistoryLog =
- BST_CHECKED == SendDlgItemMessage(hwnd, IDC_HISTORY_LOG, BM_GETCHECK, 0, 0));
- DBWriteContactSettingByte(NULL, pluginName, "MathExpression", gbMathExpression =
- BST_CHECKED == SendDlgItemMessage(hwnd, IDC_MATH_QUESTION, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "AutoAuth", gbAutoAuth = BST_CHECKED == SendDlgItemMessage(hwnd, IDC_AUTOAUTH, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "AutoAddToServerList", gbAutoAddToServerList = BST_CHECKED == SendDlgItemMessage(hwnd, IDC_ADDTOSRVLST, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "AutoReqAuth", gbAutoReqAuth = BST_CHECKED == SendDlgItemMessage(hwnd, IDC_REQAUTH, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "RegexMatch", gbRegexMatch = BST_CHECKED == SendDlgItemMessage(hwnd, IDC_REGEX, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "HistoryLog", gbHistoryLog = BST_CHECKED == SendDlgItemMessage(hwnd, IDC_HISTORY_LOG, BM_GETCHECK, 0, 0));
+ db_set_b(NULL, pluginName, "MathExpression", gbMathExpression = BST_CHECKED == SendDlgItemMessage(hwnd, IDC_MATH_QUESTION, BM_GETCHECK, 0, 0));
{
static tstring NewAGroupName, CurrentAGroupName;
NewAGroupName = GetDlgItemString(hwnd, IDC_AUTOADDGROUP);
CurrentAGroupName = gbAutoAuthGroup = DBGetContactSettingStringPAN(NULL, pluginName, "AutoAuthGroup", _T("0"));
- if(wcscmp(CurrentAGroupName.c_str(), NewAGroupName.c_str()) != 0)
- {
+ if (wcscmp(CurrentAGroupName.c_str(), NewAGroupName.c_str()) != 0) {
int GroupNumber = 0;
BYTE GroupExist = 0;
TCHAR szValue[96] = {0};
char szNumber[32] = {0};
extern int CreateCListGroup(TCHAR* szGroupName);
strcpy(szNumber, "0");
- while(strcmp(DBGetContactSettingStringPAN_A(NULL, "CListGroups", szNumber, "0").c_str(), "0") != 0)
- {
+ while (strcmp(DBGetContactSettingStringPAN_A(NULL, "CListGroups", szNumber, "0").c_str(), "0") != 0) {
_itoa(GroupNumber, szNumber, 10);
wcscpy(szValue, DBGetContactSettingStringPAN(NULL, "CListGroups", szNumber, _T("0")).c_str());
- if(wcscmp(NewAGroupName.c_str(), szValue + 1) == 0)
- {
+ if (wcscmp(NewAGroupName.c_str(), szValue + 1) == 0) {
GroupExist = 1;
break;
}
GroupNumber++;
}
- DBWriteContactSettingTString(NULL,pluginName, "AutoAuthGroup", NewAGroupName.c_str());
+ db_set_ws(NULL,pluginName, "AutoAuthGroup", NewAGroupName.c_str());
gbAutoAuthGroup = DBGetContactSettingStringPAN(NULL,pluginName,"AutoAuthGroup", _T("Not Spammers"));
if(!GroupExist && gbAutoAddToServerList)
CreateCListGroup((TCHAR*)gbAutoAuthGroup.c_str());
}
}
-
}
return TRUE;
}
@@ -442,33 +394,32 @@ MIRANDA_HOOK_EVENT(ME_OPT_INITIALISE, w, l)
{
OPTIONSDIALOGPAGE odp = {0};
odp.cbSize = sizeof(odp);
- odp.ptszGroup = _T("Message Sessions");
- odp.ptszTitle = _T(pluginName);
+ odp.pszGroup = LPGEN("Message Sessions");
+ odp.pszTitle = LPGEN("StopSpam");
odp.position = -1;
odp.hInstance = hInst;
odp.flags = ODPF_TCHAR;
- odp.ptszTab = _T("Main");
+ odp.pszTab = LPGEN("Main");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_MAIN);
odp.pfnDlgProc = MainDlgProc;
Options_AddPage(w, &odp);
- odp.ptszTab = _T("Messages");
+ odp.pszTab = LPGEN("Messages");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_MESSAGES);
odp.pfnDlgProc = MessagesDlgProc;
Options_AddPage(w, &odp);
- odp.ptszTab = _T("Protocols");
+ odp.pszTab = LPGEN("Protocols");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_PROTO);
odp.pfnDlgProc = ProtoDlgProc;
Options_AddPage(w, &odp);
- odp.ptszTab = _T("Advanced");
+ odp.pszTab = LPGEN("Advanced");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_ADVANCED);
odp.pfnDlgProc = AdvancedDlgProc;
Options_AddPage(w, &odp);
return 0;
}
-
diff --git a/plugins/StopSpamMod/src/stopspam.cpp b/plugins/StopSpamMod/src/stopspam.cpp
index f8d9f205c7..4ac29df394 100755
--- a/plugins/StopSpamMod/src/stopspam.cpp
+++ b/plugins/StopSpamMod/src/stopspam.cpp
@@ -33,7 +33,7 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_ADDED, wParam, lParam)
DBEVENTINFO dbei = {0};
dbei.cbSize = sizeof(dbei);
dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0);
- if(-1 == dbei.cbBlob)
+ if(-1 == dbei.cbBlob)
return 0;
dbei.pBlob = new BYTE[dbei.cbBlob];
@@ -53,17 +53,17 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_ADDED, wParam, lParam)
HANDLE hcntct = DbGetAuthEventContact(&dbei);
// if request is from unknown or not marked Answered contact
- int a = DBGetContactSettingByte(hcntct, "CList", "NotOnList", 0);
- int b = !DBGetContactSettingByte(hcntct, pluginName, "Answered", 0);
+ int a = db_get_b(hcntct, "CList", "NotOnList", 0);
+ int b = !db_get_b(hcntct, pluginName, "Answered", 0);
- if(a && b)//
+ if(a && b)//
{
// ...send message
if(gbHideContacts)
- DBWriteContactSettingByte(hcntct, "CList", "Hidden", 1);
+ db_set_b(hcntct, "CList", "Hidden", 1);
if(gbSpecialGroup)
- DBWriteContactSettingTString(hcntct, "CList", "Group", gbSpammersGroup.c_str());
+ db_set_ws(hcntct, "CList", "Group", gbSpammersGroup.c_str());
BYTE msg = 1;
if(gbIgnoreURL){
TCHAR* EventText = ReqGetText(&dbei); //else return NULL
@@ -74,8 +74,8 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_ADDED, wParam, lParam)
{
if(CallProtoService(dbei.szModule, PS_GETSTATUS, 0, 0) == ID_STATUS_INVISIBLE)
msg = 0;
- else if(DBGetContactSettingWord(hContact,dbei.szModule,"ApparentMode",0) == ID_STATUS_OFFLINE)
- msg = 0; //is it useful ?
+ else if(db_get_w(hContact,dbei.szModule,"ApparentMode",0) == ID_STATUS_OFFLINE)
+ msg = 0; //is it useful ?
}
if(msg)
{
@@ -107,12 +107,12 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l)
}
//do not check excluded contact
- if(DBGetContactSettingByte(hContact, pluginName, "Answered", 0))
+ if(db_get_b(hContact, pluginName, "Answered", 0))
return 0;
- if(DBGetContactSettingByte(hContact, pluginName, "Excluded", 0))
+ if(db_get_b(hContact, pluginName, "Excluded", 0))
{
- if(!DBGetContactSettingByte(hContact, "CList", "NotOnList", 0))
- DBDeleteContactSetting(hContact, pluginName, "Excluded");
+ if(!db_get_b(hContact, "CList", "NotOnList", 0))
+ db_unset(hContact, pluginName, "Excluded");
return 0;
}
//we want block not only messages, i seen many types other eventtype flood
@@ -120,14 +120,14 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l)
// ...let the event go its way
return 0;
//mark contact which we trying to contact for exclude from check
- if((dbei->flags & DBEF_SENT) && DBGetContactSettingByte(hContact, "CList", "NotOnList", 0)
- && (!gbMaxQuestCount || DBGetContactSettingDword(hContact, pluginName, "QuestionCount", 0) < gbMaxQuestCount) && gbExclude)
+ if((dbei->flags & DBEF_SENT) && db_get_b(hContact, "CList", "NotOnList", 0)
+ && (!gbMaxQuestCount || db_get_dw(hContact, pluginName, "QuestionCount", 0) < gbMaxQuestCount) && gbExclude)
{
- DBWriteContactSettingByte(hContact, pluginName, "Excluded", 1);
+ db_set_b(hContact, pluginName, "Excluded", 1);
return 0;
}
// if message is from known or marked Answered contact
- if(!DBGetContactSettingByte(hContact, "CList", "NotOnList", 0))
+ if(!db_get_b(hContact, "CList", "NotOnList", 0))
// ...let the event go its way
return 0;
// if message is corrupted or empty it cannot be an answer.
@@ -157,7 +157,7 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l)
{
if(CallProtoService(dbei->szModule, PS_GETSTATUS, 0, 0) == ID_STATUS_INVISIBLE)
msg = 0;
- else if(DBGetContactSettingWord(hContact,dbei->szModule,"ApparentMode",0) == ID_STATUS_OFFLINE)
+ else if(db_get_w(hContact,dbei->szModule,"ApparentMode",0) == ID_STATUS_OFFLINE)
msg = 0; //is it useful ?
}
bool answered = false;
@@ -189,20 +189,20 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l)
boost::regex expr(check);
answered = boost::regex_search(msg.begin(), msg.end(), expr);
}
- }
+ }
if(answered)
{
// unhide contact
- DBDeleteContactSetting(hContact, "CList", "Hidden");
+ db_unset(hContact, "CList", "Hidden");
- DBDeleteContactSetting(hContact, pluginName, "MathAnswer");
+ db_unset(hContact, pluginName, "MathAnswer");
// mark contact as Answered
- DBWriteContactSettingByte(hContact, pluginName, "Answered", 1);
+ db_set_b(hContact, pluginName, "Answered", 1);
//add contact permanently
if(gbAddPermanent) //do not use this )
- DBDeleteContactSetting(hContact, "CList", "NotOnList");
+ db_unset(hContact, "CList", "NotOnList");
// send congratulation
if(msg)
@@ -211,13 +211,9 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l)
// for notICQ protocols or disable auto auth. reqwest
if((Stricmp(_T("ICQ"),prot.c_str()))||(!gbAutoReqAuth))
{
-#ifdef _UNICODE
char * buf=mir_utf8encodeW(variables_parse(gbCongratulation, hContact).c_str());
CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)buf);
mir_free(buf);
-#else
- CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)GetCongratulation().c_str());
-#endif
};
// Note: For ANSI can be not work
if(!Stricmp(_T("ICQ"),prot.c_str())){
@@ -227,9 +223,9 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l)
// add contact to server list and local group
if(gbAutoAddToServerList)
{
- DBWriteContactSettingTString(hContact, "CList", "Group", gbAutoAuthGroup.c_str());
+ db_set_ws(hContact, "CList", "Group", gbAutoAuthGroup.c_str());
CallProtoService(dbei->szModule, "/AddServerContact", w, 0);
- DBDeleteContactSetting(hContact, "CList", "NotOnList");
+ db_unset(hContact, "CList", "NotOnList");
};
// auto auth. reqwest with send congratulation
if(gbAutoReqAuth)
@@ -245,7 +241,7 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l)
if(msg)
{
if((!gbInfTalkProtection || tstring::npos==message.find(_T("StopSpam automatic message:\r\n")))
- && (!gbMaxQuestCount || DBGetContactSettingDword(hContact, pluginName, "QuestionCount", 0) < gbMaxQuestCount))
+ && (!gbMaxQuestCount || db_get_dw(hContact, pluginName, "QuestionCount", 0) < gbMaxQuestCount))
{
// send question
tstring q;
@@ -262,18 +258,12 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l)
{
std::string arg;
p2 = p1;
-#ifdef UNICODE
for(p1 = gbQuestion.find(_T("X"), p1); (p1 < gbQuestion.length()) && (gbQuestion[p1] == L'X'); ++p1)
-#else
- for(p1 = gbQuestion.find(_T("X"), p1); gbQuestion[p1] == 'X'; ++p1)
-#endif
arg += get_random_num(1);
-#ifdef UNICODE
+
tmp_question.replace(p2, arg.size(), toUTF16(arg));
-#else
- tmp_question.replace(p2, arg.size(), arg);
-#endif
args.push_back(atoi(arg.c_str()));
+
if((p1 < gbQuestion.length()) && (p1 != tstring::npos) && (expr_acts.find(gbQuestion[p1]) != tstring::npos))
actions.push_back(gbQuestion[p1]);
++p1;
@@ -317,23 +307,19 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l)
else
break;
}
- DBWriteContactSettingDword(hContact, pluginName, "MathAnswer", math_answer);
+ db_set_dw(hContact, pluginName, "MathAnswer", math_answer);
q += variables_parse(tmp_question, hContact);
}
else
q += variables_parse(gbQuestion, hContact);
-#ifdef _UNICODE
char * buf=mir_utf8encodeW(q.c_str());
CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)buf);
mir_free(buf);
-#else
- CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)q.c_str());
-#endif
// increment question count
- DWORD questCount = DBGetContactSettingDword(hContact, pluginName, "QuestionCount", 0);
- DBWriteContactSettingDword(hContact, pluginName, "QuestionCount", questCount + 1);
+ DWORD questCount = db_get_dw(hContact, pluginName, "QuestionCount", 0);
+ db_set_dw(hContact, pluginName, "QuestionCount", questCount + 1);
}
else
{
@@ -348,18 +334,18 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l)
} */
if(gbIgnoreContacts)
{
- DBWriteContactSettingDword(hContact, "Ignore", "Mask1", 0x0000007F);
+ db_set_dw(hContact, "Ignore", "Mask1", 0x0000007F);
}
}
}
if(gbHideContacts)
- DBWriteContactSettingByte(hContact, "CList", "Hidden", 1);
+ db_set_b(hContact, "CList", "Hidden", 1);
if(gbSpecialGroup)
- DBWriteContactSettingTString(hContact, "CList", "Group", gbSpammersGroup.c_str());
- DBWriteContactSettingByte(hContact, "CList", "NotOnList", 1);
+ db_set_ws(hContact, "CList", "Group", gbSpammersGroup.c_str());
+ db_set_b(hContact, "CList", "NotOnList", 1);
// save first message from contact
- if (DBGetContactSettingDword(hContact, pluginName, "QuestionCount", 0)<2){
+ if (db_get_dw(hContact, pluginName, "QuestionCount", 0)<2){
dbei->flags |= DBEF_READ;
CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)dbei);
};
@@ -368,7 +354,6 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l)
return 1;
}
-
MIRANDA_HOOK_EVENT(ME_DB_CONTACT_SETTINGCHANGED, w, l)
{
HANDLE hContact = (HANDLE)w;
@@ -381,12 +366,9 @@ MIRANDA_HOOK_EVENT(ME_DB_CONTACT_SETTINGCHANGED, w, l)
return 0;
if(!cws->value.type)
{
- DBDeleteContactSetting(hContact, pluginName, "Answered");
- DBDeleteContactSetting(hContact, pluginName, "QuestionCount");
+ db_unset(hContact, pluginName, "Answered");
+ db_unset(hContact, pluginName, "QuestionCount");
}
return 0;
}
-
-
-
diff --git a/plugins/StopSpamMod/src/utilities.cpp b/plugins/StopSpamMod/src/utilities.cpp
index e4c3813211..84eeaf79f0 100755
--- a/plugins/StopSpamMod/src/utilities.cpp
+++ b/plugins/StopSpamMod/src/utilities.cpp
@@ -22,7 +22,7 @@ tstring DBGetContactSettingStringPAN(HANDLE hContact, char const * szModule, cha
{
DBVARIANT dbv;
//if(DBGetContactSetting(hContact, szModule, szSetting, &dbv))
- if(DBGetContactSettingTString(hContact, szModule, szSetting, &dbv))
+ if(db_get_s(hContact, szModule, szSetting, &dbv))
return errorValue;
// if(DBVT_TCHAR == dbv.type )
errorValue = dbv.ptszVal;
@@ -34,7 +34,7 @@ std::string DBGetContactSettingStringPAN_A(HANDLE hContact, char const * szModul
{
DBVARIANT dbv;
//if(DBGetContactSetting(hContact, szModule, szSetting, &dbv))
- if(DBGetContactSettingString(hContact, szModule, szSetting, &dbv))
+ if(db_get_s(hContact, szModule, szSetting, &dbv))
return errorValue;
// if(DBVT_ASCIIZ == dbv.type )
errorValue = dbv.pszVal;
@@ -52,7 +52,7 @@ tstring &GetDlgItemString(HWND hwnd, int id)
s = buf;
delete []buf;
return s;
-}
+}
std::string &GetProtoList()
{
@@ -60,7 +60,6 @@ std::string &GetProtoList()
return s = DBGetContactSettingStringPAN_A(NULL, pluginName, "protoList", "ICQ\r\n");
}
-
bool ProtoInList(std::string proto)
{
return std::string::npos != GetProtoList().find(proto + "\r\n");
@@ -89,23 +88,23 @@ void DeleteCListGroupsByName(TCHAR* szGroupName)
TCHAR szValue[96] = {0};
char szNumber[32] = {0};
strcpy(szNumber, "0");
- BYTE ConfirmDelete=DBGetContactSettingByte(NULL, "CList", "ConfirmDelete", SETTING_CONFIRMDELETE_DEFAULT);
- if(ConfirmDelete)
- DBWriteContactSettingByte(NULL, "CList", "ConfirmDelete",0);
+ BYTE ConfirmDelete=db_get_b(NULL, "CList", "ConfirmDelete", SETTING_CONFIRMDELETE_DEFAULT);
+ if(ConfirmDelete)
+ db_set_b(NULL, "CList", "ConfirmDelete", 0);
while(strcmp(DBGetContactSettingStringPAN_A(NULL, "CListGroups", szNumber, "0").c_str(), "0") != 0)
{
wcscpy(szValue, DBGetContactSettingStringPAN(NULL, "CListGroups", szNumber, _T("0")).c_str());
if(wcscmp(szGroupName, szValue + 1) == 0)
- CallService(MS_CLIST_GROUPDELETE,(WPARAM)(HANDLE)GroupNumber+1,0); // bug or ??? @_@
+ CallService(MS_CLIST_GROUPDELETE, (WPARAM)(HANDLE)GroupNumber+1, 0); // bug or ??? @_@
GroupNumber++;
#if defined(_MSC_VER) && _MSC_VER >= 1300
_itoa_s(GroupNumber, szNumber, sizeof(szNumber), 10);
#else
_itoa(GroupNumber, szNumber, 10);
-#endif
+#endif
};
- if(ConfirmDelete)
- DBWriteContactSettingByte(NULL, "CList", "ConfirmDelete",ConfirmDelete);
+ if(ConfirmDelete)
+ db_set_b(NULL, "CList", "ConfirmDelete", ConfirmDelete);
}
/*
@@ -135,7 +134,7 @@ void RemoveExcludedUsers()
std::string proto=DBGetContactSettingStringPAN_A(plist->hContact,"Protocol","p","");
UINT status = CallProtoService(proto.c_str(), PS_GETSTATUS, 0, 0);
- if(status>= ID_STATUS_CONNECTING && status <= ID_STATUS_OFFLINE){
+ if(status>= ID_STATUS_CONNECTING && status <= ID_STATUS_OFFLINE){
LogSpamToFile(plist->hContact, _T("Mark for delete"));
DBWriteContactSettingByte(plist->hContact,"CList","Delete", 1);
}else{
@@ -161,7 +160,7 @@ void RemoveTemporaryUsers()
if(hContact)
{
do{
- if(DBGetContactSettingByte(hContact, "CList", "NotOnList", 0)||
+ if(DBGetContactSettingByte(hContact, "CList", "NotOnList", 0)||
(_T("Not In List")== DBGetContactSettingStringPAN(hContact,"CList","Group",_T("")))
)
{
@@ -186,7 +185,7 @@ void RemoveTemporaryUsers()
CallService(MS_DB_CONTACT_DELETE, (WPARAM)plist->hContact, 0);
};
- tmp = plist;
+ tmp = plist;
plist = plist->next;
delete tmp;
}
@@ -224,7 +223,7 @@ tstring variables_parse(tstring const &tstrFormat, HANDLE hContact){
// case-insensitive _tcscmp
//by nullbie as i remember...
-#define NEWTSTR_MALLOC(A) (A==NULL)?NULL:_tcscpy((TCHAR*)mir_alloc(sizeof(TCHAR)*(_tcslen(A)+1)),A)
+#define NEWTSTR_MALLOC(A) (A==NULL) ? NULL : _tcscpy((TCHAR*)mir_alloc(sizeof(TCHAR)*(_tcslen(A)+1)),A)
const int Stricmp(const TCHAR *str, const TCHAR *substr)
{
int i = 0;
@@ -239,20 +238,20 @@ const int Stricmp(const TCHAR *str, const TCHAR *substr)
mir_free(str_up);
mir_free(substr_up);
-
+
return i;
}
TCHAR* ReqGetText(DBEVENTINFO* dbei)
{
- if ( !dbei->pBlob )
+ if ( !dbei->pBlob )
return 0;
char * ptr=(char *)&dbei->pBlob[sizeof(DWORD)*2];
- int len=dbei->cbBlob-sizeof(DWORD)*2;
+ int len=dbei->cbBlob-sizeof(DWORD)*2;
int i=0;
-
- while(len&&(i<4))
+
+ while(len && (i<4))
{
if(!ptr[0]) i++;
ptr++;
@@ -272,7 +271,6 @@ TCHAR* ReqGetText(DBEVENTINFO* dbei)
return 0;
}
-
BOOL IsUrlContains(TCHAR * Str)
{
const int CountUrl=11;
@@ -289,11 +287,11 @@ BOOL IsUrlContains(TCHAR * Str)
_T(".su"),
_T(".ua"),
_T(".tv")
- };
+ };
- if(Str&&_tcslen(Str)>0) {
+ if(Str && _tcslen(Str)>0) {
TCHAR *StrLower = NEWTSTR_MALLOC(Str);
- CharLowerBuff(StrLower, lstrlen(StrLower));
+ CharLowerBuff(StrLower, lstrlen(StrLower));
for (int i=0; i<CountUrl; i++)
if(_tcsstr (StrLower, URL[i]))
{
@@ -332,7 +330,7 @@ tstring GetContactUid(HANDLE hContact, tstring Protocol)
#else
_itoa(ci.dVal,aUid,10);
-#endif
+#endif
OemToChar(aUid, dUid);
Uid=dUid;
break;
@@ -340,21 +338,19 @@ tstring GetContactUid(HANDLE hContact, tstring Protocol)
Uid=_T("");
break;
};
- }
+ }
mir_free(szProto);
return Uid;
}
-
void LogSpamToFile(HANDLE hContact, tstring message)
{
-
if (!gbLogToFile) return;
tstring LogStrW, LogTime, LogProtocol, LogContactId, LogContactName;
std::string filename;
std::fstream file;
-
+
UINT cbName=255;
char* pszName = (char *)mir_alloc(cbName);
extern HANDLE hStopSpamLogDirH;
@@ -372,15 +368,15 @@ void LogSpamToFile(HANDLE hContact, tstring message)
tm *TimeNow;
time(&time_now);
TimeNow = localtime(&time_now);
- LogTime=_wasctime( TimeNow );
+ LogTime=_wasctime( TimeNow );
// Time Log line
-
+
// Name, UID and Protocol Log line
LogProtocol=DBGetContactSettingStringPAN(hContact,"Protocol","p",_T(""));
LogContactName=(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, GCDNF_TCHAR);
LogContactId=(LogProtocol==_T(""))?_T(""):GetContactUid(hContact,LogProtocol);
// Name, UID and Protocol Log line
-
+
LogStrW=_T("[")+LogTime.substr(0,LogTime.length()-1)+_T("] ")+
LogContactId+_T(" - ")+
LogContactName+_T(" (")+
@@ -392,7 +388,6 @@ void LogSpamToFile(HANDLE hContact, tstring message)
mir_free(buf);
file.close();
-
}
boost::mutex clean_mutex;
@@ -412,14 +407,14 @@ void CleanProtocolTmpThread(std::string proto)
char *proto_tmp = GetContactProto(hContact);
if(proto_tmp)
if(!strcmp(proto.c_str(), proto_tmp))
- if(DBGetContactSettingByte(hContact, "CList", "NotOnList", 0)|| (_T("Not In List")== DBGetContactSettingStringPAN(hContact,"CList","Group",_T(""))))
+ if(db_get_b(hContact, "CList", "NotOnList", 0)|| (_T("Not In List")== DBGetContactSettingStringPAN(hContact,"CList","Group",_T(""))))
contacts.push_back(hContact);
}
boost::this_thread::sleep(boost::posix_time::seconds(5));
clean_mutex.lock();
std::list<HANDLE>::iterator end = contacts.end();
for(std::list<HANDLE>::iterator i = contacts.begin(); i != end; ++i)
- {
+ {
LogSpamToFile(*i, _T("Deleted"));
HistoryLogFunc(*i, "Deleted");
CallService(MS_DB_CONTACT_DELETE, (WPARAM)*i, 0);
@@ -432,7 +427,7 @@ void CleanProtocolExclThread(std::string proto)
while(true)
{
UINT status = CallProtoService(proto.c_str(), PS_GETSTATUS, 0, 0);
- if(status > ID_STATUS_OFFLINE)
+ if(status > ID_STATUS_OFFLINE)
break;
boost::this_thread::sleep(boost::posix_time::seconds(2));
}
@@ -442,14 +437,14 @@ void CleanProtocolExclThread(std::string proto)
char *proto_tmp = GetContactProto(hContact);
if(proto_tmp)
if(!strcmp(proto.c_str(), proto_tmp))
- if(DBGetContactSettingByte(hContact, "CList", "NotOnList", 0) && DBGetContactSettingByte(hContact, pluginName, "Excluded", 0))
+ if(db_get_b(hContact, "CList", "NotOnList", 0) && db_get_b(hContact, pluginName, "Excluded", 0))
contacts.push_back(hContact);
}
boost::this_thread::sleep(boost::posix_time::seconds(5));
clean_mutex.lock();
std::list<HANDLE>::iterator end = contacts.end();
for(std::list<HANDLE>::iterator i = contacts.begin(); i != end; ++i)
- {
+ {
LogSpamToFile(*i, _T("Deleted"));
HistoryLogFunc(*i, "Deleted");
CallService(MS_DB_CONTACT_DELETE, (WPARAM)*i, 0);
@@ -457,7 +452,6 @@ void CleanProtocolExclThread(std::string proto)
clean_mutex.unlock();
}
-
void CleanThread()
{
std::list<std::string> protocols;
@@ -478,6 +472,7 @@ void CleanThread()
boost::thread *thr = new boost::thread(boost::bind(&CleanProtocolExclThread, *i));
}
}
+
void HistoryLog(HANDLE hContact, char *data, int event_type, int flags)
{
DBEVENTINFO Event = {0};
@@ -490,6 +485,7 @@ void HistoryLog(HANDLE hContact, char *data, int event_type, int flags)
Event.pBlob = (PBYTE)_strdup(data);
CallService(MS_DB_EVENT_ADD, (WPARAM)(HANDLE)hContact,(LPARAM)&Event);
}
+
void HistoryLogFunc(HANDLE hContact, std::string message)
{
if(gbHistoryLog)
@@ -523,7 +519,6 @@ std::string toUTF8(std::string str)
return toUTF8(toUTF16(str));
}
-
std::wstring toUTF16(std::string str) //convert as much as possible
{
std::wstring ustr;
@@ -545,7 +540,7 @@ std::string get_random_num(int length)
std::string data;
boost::random_device rng;
boost::variate_generator<boost::random_device&, boost::uniform_int<>> gen(rng, boost::uniform_int<>(0, chars.length()-1));
- for(int i = 0; i < length; ++i)
+ for(int i = 0; i < length; ++i)
data += chars[gen()];
return data;
}