From 6fe89c25874a40e9383dfaccb14f360971fe694b Mon Sep 17 00:00:00 2001 From: sss Date: Sat, 4 Apr 2009 11:13:52 +0000 Subject: git-svn-id: http://172.18.13.13/svn/mim_plugs@17 63852ff1-2cfd-40b9-8011-e561a9d89b1c --- stopspam_mod/branches/0.0.1.6/BUGS.txt | 1 + stopspam_mod/branches/0.0.1.6/Makefile | 12 + stopspam_mod/branches/0.0.1.6/eventhooker.cpp | 68 +++ stopspam_mod/branches/0.0.1.6/eventhooker.h | 60 +++ stopspam_mod/branches/0.0.1.6/globals.h | 20 + stopspam_mod/branches/0.0.1.6/headers.h | 23 ++ stopspam_mod/branches/0.0.1.6/init.cpp | 186 +++++++++ stopspam_mod/branches/0.0.1.6/options.cpp | 330 +++++++++++++++ stopspam_mod/branches/0.0.1.6/options.h | 1 + stopspam_mod/branches/0.0.1.6/resource.h | 46 +++ stopspam_mod/branches/0.0.1.6/stopspam.cpp | 255 ++++++++++++ stopspam_mod/branches/0.0.1.6/stopspam.h | 19 + stopspam_mod/branches/0.0.1.6/stopspam.rc | 211 ++++++++++ stopspam_mod/branches/0.0.1.6/stopspam_8.sln | 25 ++ stopspam_mod/branches/0.0.1.6/stopspam_8.vcproj | 404 ++++++++++++++++++ stopspam_mod/branches/0.0.1.6/stopspam_9.sln | 28 ++ stopspam_mod/branches/0.0.1.6/stopspam_9.vcproj | 525 ++++++++++++++++++++++++ stopspam_mod/branches/0.0.1.6/utilities.cpp | 94 +++++ stopspam_mod/branches/0.0.1.6/utilities.h | 6 + stopspam_mod/branches/0.0.1.6/version.h | 6 + 20 files changed, 2320 insertions(+) create mode 100644 stopspam_mod/branches/0.0.1.6/BUGS.txt create mode 100644 stopspam_mod/branches/0.0.1.6/Makefile create mode 100644 stopspam_mod/branches/0.0.1.6/eventhooker.cpp create mode 100644 stopspam_mod/branches/0.0.1.6/eventhooker.h create mode 100644 stopspam_mod/branches/0.0.1.6/globals.h create mode 100644 stopspam_mod/branches/0.0.1.6/headers.h create mode 100644 stopspam_mod/branches/0.0.1.6/init.cpp create mode 100644 stopspam_mod/branches/0.0.1.6/options.cpp create mode 100644 stopspam_mod/branches/0.0.1.6/options.h create mode 100644 stopspam_mod/branches/0.0.1.6/resource.h create mode 100644 stopspam_mod/branches/0.0.1.6/stopspam.cpp create mode 100644 stopspam_mod/branches/0.0.1.6/stopspam.h create mode 100644 stopspam_mod/branches/0.0.1.6/stopspam.rc create mode 100644 stopspam_mod/branches/0.0.1.6/stopspam_8.sln create mode 100644 stopspam_mod/branches/0.0.1.6/stopspam_8.vcproj create mode 100644 stopspam_mod/branches/0.0.1.6/stopspam_9.sln create mode 100644 stopspam_mod/branches/0.0.1.6/stopspam_9.vcproj create mode 100644 stopspam_mod/branches/0.0.1.6/utilities.cpp create mode 100644 stopspam_mod/branches/0.0.1.6/utilities.h create mode 100644 stopspam_mod/branches/0.0.1.6/version.h (limited to 'stopspam_mod/branches/0.0.1.6') diff --git a/stopspam_mod/branches/0.0.1.6/BUGS.txt b/stopspam_mod/branches/0.0.1.6/BUGS.txt new file mode 100644 index 0000000..d17bd4a --- /dev/null +++ b/stopspam_mod/branches/0.0.1.6/BUGS.txt @@ -0,0 +1 @@ +do not turn on this plugin on first login of your account, it can mark all your contacts as spammers. \ No newline at end of file diff --git a/stopspam_mod/branches/0.0.1.6/Makefile b/stopspam_mod/branches/0.0.1.6/Makefile new file mode 100644 index 0000000..fc08dd9 --- /dev/null +++ b/stopspam_mod/branches/0.0.1.6/Makefile @@ -0,0 +1,12 @@ +all: + i686-pc-mingw32-g++ -c -DBUILD_DLL *.cpp -I../../include -I/usr/i686-pc-mingw32/usr/include -I. -w -march=i686 -msse -O2 -pipe + i686-pc-mingw32-windres -i stopspam.rc -o resources.o + i686-pc-mingw32-gcc -shared -o stopspam.dll *.o -Wl,-O1,-s + upx -9 stopspam.dll + +clean: + rm *.o + +clean-all: + rm *.o *.dll + \ No newline at end of file diff --git a/stopspam_mod/branches/0.0.1.6/eventhooker.cpp b/stopspam_mod/branches/0.0.1.6/eventhooker.cpp new file mode 100644 index 0000000..f29e5b7 --- /dev/null +++ b/stopspam_mod/branches/0.0.1.6/eventhooker.cpp @@ -0,0 +1,68 @@ +/* eventhooker.cpp +* Copyright (C) Miklashevsky Roman +* +* 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 +#include "eventhooker.h" + +namespace miranda +{ + namespace + { + std::list eventHookerList; + } + + EventHooker::EventHooker(std::string name, MIRANDAHOOK fun) : name_(name), fun_(fun), handle_(0) + { + eventHookerList.push_back(this); + } + + EventHooker::~EventHooker() + { + eventHookerList.remove(this); + } + + void EventHooker::Hook() + { + handle_ = HookEvent(name_.c_str(), fun_); + } + + void EventHooker::Unhook() + { + if(handle_) + { + UnhookEvent(handle_); + handle_ = 0; + } + } + + void EventHooker::HookAll() + { + for(std::list::iterator it = eventHookerList.begin(); it != eventHookerList.end(); ++it) + { + (*it)->Hook(); + } + } + + void EventHooker::UnhookAll() + { + for(std::list::iterator it = eventHookerList.begin(); it != eventHookerList.end(); ++it) + { + (*it)->Unhook(); + } + } +} diff --git a/stopspam_mod/branches/0.0.1.6/eventhooker.h b/stopspam_mod/branches/0.0.1.6/eventhooker.h new file mode 100644 index 0000000..2174691 --- /dev/null +++ b/stopspam_mod/branches/0.0.1.6/eventhooker.h @@ -0,0 +1,60 @@ +/* eventhooker.h - Helper for hooking events in Miranda. +* Copyright (C) Miklashevsky Roman +* +* To hook event just write +* MIRANDA_HOOK_EVENT('name of the event', wParam, lParam) { 'your code' } +* Include following in your Load function +* miranda::EventHooker::HookAll(); +* And following in your Unload function +* miranda::EventHooker::UnhookAll(); +* That's all +* +* 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. +*/ + +#ifndef EVENTHOOKER_H_C8EAA58A_7C4D_45f7_A88E_0E41FE93754D +#define EVENTHOOKER_H_C8EAA58A_7C4D_45f7_A88E_0E41FE93754D + +#pragma warning( once : 4430 ) + +#include +#include +#include + +namespace miranda +{ + +#define MIRANDA_HOOK_EVENT(NAME, WPARAMNAME, LPARAMNAME) \ + NAME##_Handler(WPARAM,LPARAM);\ + miranda::EventHooker NAME##_Hooker(NAME, NAME##_Handler);\ + NAME##_Handler(WPARAM WPARAMNAME, LPARAM LPARAMNAME) + + struct EventHooker + { + EventHooker(std::string name, MIRANDAHOOK fun); + ~EventHooker(); + void Hook(); + void Unhook(); + static void HookAll(); + static void UnhookAll(); + private: + std::string name_; + MIRANDAHOOK fun_; + HANDLE handle_; + }; + +} + +#endif diff --git a/stopspam_mod/branches/0.0.1.6/globals.h b/stopspam_mod/branches/0.0.1.6/globals.h new file mode 100644 index 0000000..9ae64b3 --- /dev/null +++ b/stopspam_mod/branches/0.0.1.6/globals.h @@ -0,0 +1,20 @@ +#define pluginName "StopSpam" +/* +TCHAR const * defAnswer = _T("nospam"); +TCHAR const * defCongratulation = +_T("Congratulations! You just passed human/robot test. Now you can write me a message."); +char const * defProtoList = "ICQ\r\n"; +TCHAR const * infTalkProtPrefix = _T("StopSpam automatic message:\r\n"); +char const * answeredSetting = "Answered"; +char const * questCountSetting = "QuestionCount"; +TCHAR const * defAufrepl = _T("StopSpam: send a message and reply to a anti-spam bot question.");*/ + + +#ifdef _UNICODE +typedef std::wstring tstring; +#define PREF_TCHAR2 PREF_UTF +#else +typedef std::string tstring; +#define PREF_TCHAR2 0 +#endif //_UNICODE + diff --git a/stopspam_mod/branches/0.0.1.6/headers.h b/stopspam_mod/branches/0.0.1.6/headers.h new file mode 100644 index 0000000..088f622 --- /dev/null +++ b/stopspam_mod/branches/0.0.1.6/headers.h @@ -0,0 +1,23 @@ +#include +#include +#include +#include +#include +//#include +#include +#include +#include +#include +#include +#include +#include + +#include "globals.h" +#include "stopspam.h" +#include "options.h" +#include "eventhooker.h" +#include "version.h" +#include "resource.h" +#include "utilities.h" + +#include \ No newline at end of file diff --git a/stopspam_mod/branches/0.0.1.6/init.cpp b/stopspam_mod/branches/0.0.1.6/init.cpp new file mode 100644 index 0000000..fc32742 --- /dev/null +++ b/stopspam_mod/branches/0.0.1.6/init.cpp @@ -0,0 +1,186 @@ +#include "headers.h" + + + +BOOL gbDosServiceExist = 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 gbDosServiceIntegration = 0; +//BOOL gbDelNotInList = 0; +tstring gbSpammersGroup = _T("Spammers"); +tstring gbQuestion; +tstring gbAnswer; +tstring gbCongratulation; +std::string gbAuthRepl; +extern char * pluginDescription; +extern TCHAR const * defQuestion; + +struct MM_INTERFACE mmi; + +UTF8_INTERFACE utfi; + + + +///////////////////////////////////////////////////////////////////////////////////////// +// 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), + 0, + PLUGIN_MAKE_VERSION(0, 0, 1, 6), + pluginDescription, + "Roman Miklashevsky", + "sss123next@list.ru", + "© 2004-2009 Roman Miklashevsky, A. Petkevich, Kosh&chka, sss", + "http://sss.chaoslab.ru:81/tracker/mim_plugs/", + UNICODE_AWARE, + 0, + MIID_STOPSPAM +}; + + +char *date() +{ + static char d[11]; + char *tmp = __DATE__, m[4], mn[3] = "01"; + m[0]=tmp[0]; + m[1]=tmp[1]; + m[2]=tmp[2]; + if(strstr(m,"Jan")) + strcpy(mn,"01"); + else if(strstr(m,"Feb")) + strcpy(mn,"02"); + else if(strstr(m,"Mar")) + strcpy(mn,"03"); + else if(strstr(m,"Apr")) + strcpy(mn,"04"); + else if(strstr(m,"May")) + strcpy(mn,"05"); + else if(strstr(m,"Jun")) + strcpy(mn,"06"); + else if(strstr(m,"Jul")) + strcpy(mn,"07"); + else if(strstr(m,"Aug")) + strcpy(mn,"08"); + else if(strstr(m,"Sep")) + strcpy(mn,"09"); + else if(strstr(m,"Oct")) + strcpy(mn,"10"); + else if(strstr(m,"Nov")) + strcpy(mn,"11"); + else if(strstr(m,"Dec")) + strcpy(mn,"12"); + d[0]=tmp[7]; + d[1]=tmp[8]; + d[2]=tmp[9]; + d[3]=tmp[10]; + d[4]='.'; + d[5]=mn[0]; + d[6]=mn[1]; + d[7]='.'; + d[8]=tmp[4]; + d[9]=tmp[5]; + return d; +} + + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + if ( mirandaVersion < PLUGIN_MAKE_VERSION( 0, 7, 0, 0 )) + return NULL; + { + static char plugname[52]; + strcpy(plugname, pluginName" mod ["); + strcat(plugname, date()); + strcat(plugname, " "); + strcat(plugname, __TIME__); + strcat(plugname, "]"); + pluginInfoEx.shortName = plugname; + } + + return &pluginInfoEx; +} + + +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_A(NULL, pluginName, "authrepl", "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); +// gbDelNotInList = DBGetContactSettingByte(NULL, pluginName, "DelNotInList", 0); +} + +static int OnSystemModulesLoaded(WPARAM wParam,LPARAM lParam) +{ + if (ServiceExists(MS_DOS_SERVICE)) + gbDosServiceExist = TRUE; + InitVars(); + if(gbDelExcluded) + RemoveExcludedUsers(); + return 0; +} + +PLUGINLINK *pluginLink; +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; +} + +extern "C" int __declspec(dllexport) Load(PLUGINLINK *link) +{ + pluginLink = link; + mir_getMMI(&mmi); + mir_getUTFI(&utfi); + HookEvent(ME_SYSTEM_MODULESLOADED, OnSystemModulesLoaded); + + miranda::EventHooker::HookAll(); + return 0; +} + +extern "C" int __declspec(dllexport) Unload(void) +{ + miranda::EventHooker::UnhookAll(); + return 0; +} \ No newline at end of file diff --git a/stopspam_mod/branches/0.0.1.6/options.cpp b/stopspam_mod/branches/0.0.1.6/options.cpp new file mode 100644 index 0000000..9983444 --- /dev/null +++ b/stopspam_mod/branches/0.0.1.6/options.cpp @@ -0,0 +1,330 @@ +#define MIRANDA_VER 0x0800 +#include "headers.h" + +char * pluginDescription = "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."); + + +INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + + switch(msg) + { + case WM_INITDIALOG: + { + SetDlgItemTextA(hwnd, ID_DESCRIPTION, pluginDescription); + TranslateDialogDefault(hwnd); + SetDlgItemInt(hwnd, ID_MAXQUESTCOUNT, gbMaxQuestCount, FALSE); + SendDlgItemMessage(hwnd, ID_INFTALKPROT, BM_SETCHECK, gbInfTalkProtection ? BST_CHECKED : BST_UNCHECKED, 0); + SendDlgItemMessage(hwnd, ID_ADDPERMANENT, BM_SETCHECK, gbAddPermanent ? BST_CHECKED : BST_UNCHECKED, 0); + SendDlgItemMessage(hwnd, ID_HANDLEAUTHREQ, BM_SETCHECK, gbHandleAuthReq ? BST_CHECKED : BST_UNCHECKED, 0); + gbDosServiceExist?EnableWindow(GetDlgItem(hwnd, ID_DOS_INTEGRATION),1):EnableWindow(GetDlgItem(hwnd, ID_DOS_INTEGRATION),0); + SendDlgItemMessage(hwnd, ID_DOS_INTEGRATION, BM_SETCHECK, gbDosServiceIntegration ? BST_CHECKED : BST_UNCHECKED, 0); + SetDlgItemText(hwnd, ID_SPECIALGROUPNAME, gbSpammersGroup.c_str()); + SendDlgItemMessage(hwnd, ID_SPECIALGROUP, BM_SETCHECK, gbSpecialGroup ? BST_CHECKED : BST_UNCHECKED, 0); + SendDlgItemMessage(hwnd, ID_HIDECONTACTS, BM_SETCHECK, gbHideContacts ? BST_CHECKED : BST_UNCHECKED, 0); + SendDlgItemMessage(hwnd, ID_IGNORESPAMMERS, BM_SETCHECK, gbIgnoreContacts ? BST_CHECKED : BST_UNCHECKED, 0); + SendDlgItemMessage(hwnd, ID_EXCLUDE, BM_SETCHECK, gbExclude ? BST_CHECKED : BST_UNCHECKED, 0); + SendDlgItemMessage(hwnd, ID_REMOVE_TMP, BM_SETCHECK, gbDelExcluded ? BST_CHECKED : BST_UNCHECKED, 0); +// SendDlgItemMessage(hwnd, ID_DEL_NO_IN_LIST, BM_SETCHECK, gbDelNotInList ? BST_CHECKED : BST_UNCHECKED, 0); + } + return TRUE; + case WM_COMMAND:{ + switch (LOWORD(wParam)) + { + case ID_MAXQUESTCOUNT: + { + if (EN_CHANGE != HIWORD(wParam) || (HWND)lParam != GetFocus()) + return FALSE; + break; + } + } + SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); + } + break; + case WM_NOTIFY: + { + NMHDR* nmhdr = (NMHDR*)lParam; + switch (nmhdr->code) + { + 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, "DOSIntegration", gbDosServiceIntegration = + BST_CHECKED == SendDlgItemMessage(hwnd, ID_DOS_INTEGRATION, BM_GETCHECK, 0, 0)); +/* DBWriteContactSettingByte(NULL, pluginName, "DelNotInList", gbDelNotInList = + BST_CHECKED == SendDlgItemMessage(hwnd, ID_DEL_NO_IN_LIST, 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) + { + 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) + { +#if defined(_MSC_VER) && _MSC_VER >= 1300 + _itoa_s(GroupNumber, szNumber, sizeof(szNumber), 10); +#else + _itoa(GroupNumber, szNumber, 10); + +#endif + wcscpy(szValue, DBGetContactSettingStringPAN(NULL, "CListGroups", szNumber, _T("0")).c_str()); + if(wcscmp(NewGroupName.c_str(), szValue + 1) == 0) + { + GroupExist = 1; + break; + } + GroupNumber++; + } + DBWriteContactSettingTString(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, "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, "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)); + + } + return TRUE; + } + } + break; + } + return FALSE; +} + +INT_PTR CALLBACK MessagesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + + switch(msg) + { + case WM_INITDIALOG: + { + TranslateDialogDefault(hwnd); + SetDlgItemText(hwnd, ID_QUESTION, gbQuestion.c_str()); + SetDlgItemText(hwnd, ID_ANSWER, gbAnswer.c_str()); + SetDlgItemText(hwnd, ID_CONGRATULATION, gbCongratulation.c_str()); + SetDlgItemTextA(hwnd, ID_AUTHREPL, gbAuthRepl.c_str()); + } + return TRUE; + case WM_COMMAND: + { + switch(LOWORD(wParam)) + { + case ID_QUESTION: + case ID_ANSWER: + case ID_AUTHREPL: + case ID_CONGRATULATION: + { + if (EN_CHANGE != HIWORD(wParam) || (HWND)lParam != GetFocus()) + return FALSE; + 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."))); + SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); + return TRUE; + } + SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); + } + break; + case WM_NOTIFY: + { + NMHDR* nmhdr = (NMHDR*)lParam; + switch (nmhdr->code) + { + case PSN_APPLY: + { + DBWriteContactSettingTString(NULL, pluginName, "question", + GetDlgItemString(hwnd, ID_QUESTION).c_str()); + 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_A(NULL, pluginName, "authrepl", "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.")); + } + return TRUE; + } + } + break; + } + return FALSE; +} + +INT_PTR CALLBACK ProtoDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + + switch(msg) + { + case WM_INITDIALOG: + { + TranslateDialogDefault(hwnd); + int n; + PROTOCOLDESCRIPTOR** pppd; + if(!CallService(MS_PROTO_ENUMPROTOCOLS, (LPARAM)&n, (WPARAM)&pppd)) + for(int i = 0; i < n; ++i) + { + SendDlgItemMessageA(hwnd, (ProtoInList(pppd[i]->szName) ? ID_USEDPROTO : ID_ALLPROTO), + LB_ADDSTRING, 0, (LPARAM)pppd[i]->szName); + } + } + return TRUE; + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case ID_ADD: + { + WPARAM n = (WPARAM)SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_GETCURSEL, 0, 0); + if(LB_ERR != n) + { + size_t len = SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_GETTEXTLEN, n, 0); + 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); + delete []buf; + SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_DELETESTRING, n, 0); + } + } + } + break; + case ID_REMOVE: + { + WPARAM n = (WPARAM)SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETCURSEL, 0, 0); + if(LB_ERR != n) + { + size_t len = SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETTEXTLEN, n, 0); + 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); + delete []buf; + SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_DELETESTRING, n, 0); + } + } + } + break; + case ID_ADDALL: + for(;;) + { + LRESULT count = SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_GETCOUNT, 0, 0); + if(!count || LB_ERR == count) + break; + SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_SETCURSEL, 0, 0); + SendMessage(hwnd, WM_COMMAND, ID_ADD, 0); + } + break; + case ID_REMOVEALL: + for(;;) + { + LRESULT count = SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETCOUNT, 0, 0); + if(!count || LB_ERR == count) + break; + SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_SETCURSEL, 0, 0); + SendMessage(hwnd, WM_COMMAND, ID_REMOVE, 0); + } + break; + default: + return FALSE; + } + SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); + return TRUE; + case WM_NOTIFY: + { + NMHDR* nmhdr = (NMHDR*)lParam; + switch (nmhdr->code) + { + case PSN_APPLY: + { + LRESULT count = SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETCOUNT, 0, 0); + std::ostringstream out; + for(int i = 0; i < count; ++i) + { + size_t len = SendDlgItemMessageA(hwnd, ID_USEDPROTO, LB_GETTEXTLEN, i, 0); + 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()); + } + return TRUE; + } + } + break; + } + return FALSE; +} + +HINSTANCE hInst; +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.position = -1; + odp.hInstance = hInst; + odp.flags = ODPF_TCHAR; + + odp.ptszTab = _T("Main"); + odp.pszTemplate = MAKEINTRESOURCEA(IDD_MAIN); + odp.pfnDlgProc = MainDlgProc; + CallService(MS_OPT_ADDPAGE, w, (LPARAM)&odp); + + + odp.ptszTab = _T("Messages"); + odp.pszTemplate = MAKEINTRESOURCEA(IDD_MESSAGES); + odp.pfnDlgProc = MessagesDlgProc; + CallService(MS_OPT_ADDPAGE, w, (LPARAM)&odp); + + odp.ptszTab = _T("Protocols"); + odp.pszTemplate = MAKEINTRESOURCEA(IDD_PROTO); + odp.pfnDlgProc = ProtoDlgProc; + CallService(MS_OPT_ADDPAGE, w, (LPARAM)&odp); + + return 0; +} + diff --git a/stopspam_mod/branches/0.0.1.6/options.h b/stopspam_mod/branches/0.0.1.6/options.h new file mode 100644 index 0000000..e32791e --- /dev/null +++ b/stopspam_mod/branches/0.0.1.6/options.h @@ -0,0 +1 @@ +extern HINSTANCE hInst; \ No newline at end of file diff --git a/stopspam_mod/branches/0.0.1.6/resource.h b/stopspam_mod/branches/0.0.1.6/resource.h new file mode 100644 index 0000000..4e5950e --- /dev/null +++ b/stopspam_mod/branches/0.0.1.6/resource.h @@ -0,0 +1,46 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by stopspam.rc +// +#define IDD_MESSAGES 101 +#define IDD_MAIN 103 +#define ID_DESCRIPTION 1001 +#define ID_QUESTION 1002 +#define ID_ANSWER 1003 +#define ID_CONGRATULATION 1004 +#define ID_RESTOREDEFAULTS 1005 +#define ID_ADD 1005 +#define ID_ANSWER2 1007 +#define ID_AUTHREPL 1007 +#define ID_ALLPROTO 1008 +#define IDD_PROTO 1008 +#define ID_MAXQUESTCOUNT 1008 +#define ID_REMOVE 1009 +#define ID_SPECIALGROUPNAME 1009 +#define ID_USEDPROTO 1010 +#define ID_REMOVEALL 1011 +#define ID_ADDALL 1012 +#define ID_INFTALKPROT 1013 +#define ID_ADDPERMANENT 1014 +#define ID_ADDPERMANENT2 1015 +#define ID_HANDLEAUTHREQ 1015 +#define ID_DOS_INTEGRATION 1016 +#define ID_SPECIALGROUP 1017 +#define ID_HIDECONTACTS 1018 +#define ID_IGNORESPAMMERS 1019 +#define ID_REMOVE_TMP 1020 +#define ID_REMOVE_TMP2 1021 +#define ID_EXCLUDE 1021 +#define ID_ADDPERMANENT3 1022 +#define ID_DEL_NO_IN_LIST 1022 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 104 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1017 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/stopspam_mod/branches/0.0.1.6/stopspam.cpp b/stopspam_mod/branches/0.0.1.6/stopspam.cpp new file mode 100644 index 0000000..e162837 --- /dev/null +++ b/stopspam_mod/branches/0.0.1.6/stopspam.cpp @@ -0,0 +1,255 @@ +#include "headers.h" + +MIRANDA_HOOK_EVENT(ME_DB_CONTACT_ADDED, w, l) +{ + return 0; +} + + +MIRANDA_HOOK_EVENT(ME_DB_EVENT_ADDED, wParam, lParam) +{ + HANDLE hContact = (HANDLE)wParam; + HANDLE hDbEvent = (HANDLE)lParam; + + DBEVENTINFO dbei = {0}; + dbei.cbSize = sizeof(dbei); + dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0); + if(-1 == dbei.cbBlob) + return 0; + + dbei.pBlob = new BYTE[dbei.cbBlob]; + CallService(MS_DB_EVENT_GET, lParam, (LPARAM)&dbei); + + // if event is in protocol that is not despammed + if(!ProtoInList(dbei.szModule)) { + delete dbei.pBlob; + return 0; + } + + // event is an auth request + if(gbHandleAuthReq) + { + if(!(dbei.flags & DBEF_SENT) && !(dbei.flags & DBEF_READ) && dbei.eventType == EVENTTYPE_AUTHREQUEST) + { + HANDLE hcntct; + hcntct=*((PHANDLE)(dbei.pBlob+sizeof(DWORD))); + + /*char text[100]; + sprintf(text, "%d, %d, \r\n%d, %d", + (int)hcntct, + (int)hDbEvent, + DBGetContactSettingByte(hContact, pluginName, answeredSetting, 0), + DBGetContactSettingByte(hContact, "CList", "NotOnList", 0)); + + int a = MessageBox( 0, text, "Авторизация",MB_OK|MB_ICONQUESTION );*/ + + + // if request is from unknown or not marked Answered contact + + int a = DBGetContactSettingByte(hcntct, "CList", "NotOnList", 0); + int b = !DBGetContactSettingByte(hcntct, pluginName, "Answered", 0); + + if(a && b)// + { + // ...send message + /*MessageBox( 0, "...send message", "yappp...",MB_OK|MB_ICONQUESTION );*/ + std::string allowService = dbei.szModule; + allowService += PS_AUTHDENY; + + if(gbHideContacts) + DBWriteContactSettingByte(hcntct, "CList", "Hidden", 1); + if(gbSpecialGroup) + DBWriteContactSettingTString(hcntct, "CList", "Group", gbSpammersGroup.c_str()); + + int a = CallService(allowService.c_str(), (WPARAM)hDbEvent, (LPARAM)gbAuthRepl.c_str()); + + //CallProtoService(dbei.szModule,PS_AUTHDENY,(WPARAM)hDbEvent,(LPARAM)GetAuthRepl().c_str()); + delete dbei.pBlob; + return 1; + } + } + } + delete dbei.pBlob; + return 0; +} + +MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l) +{ + HANDLE hContact = (HANDLE)w; + DBEVENTINFO * dbei = (DBEVENTINFO*)l; + + + // if event is in protocol that is not despammed + if(!ProtoInList(dbei->szModule)) + { + // ...let the event go its way + return 0; + } + //do not check excluded contact + +/* if(DBGetContactSettingWord(hContact, dbei->szModule, "ServerId", 0)) + { + DBDeleteContactSetting(hContact, "CList", "NotOnList"); + return 0; + }*/ + +/* if(gbDelNotInList) + if(DBGetContactSettingStringPAN_A((HANDLE)w, "CList", "Group", "") == "Not In List") + { + CallService(MS_DB_CONTACT_DELETE, (WPARAM)w, 0); + return 1; + } +*/ + if(DBGetContactSettingByte(hContact, pluginName, "Answered", 0)) + return 0; + if(DBGetContactSettingByte(hContact, pluginName, "Excluded", 0)) + { + if(!DBGetContactSettingByte(hContact, "CList", "NotOnList", 0)) + DBDeleteContactSetting(hContact, pluginName, "Excluded"); + return 0; + } + // if event is not a message, or if the message has been read or sent... +/* if((dbei->flags & DBEF_READ) || (dbei->eventType != EVENTTYPE_MESSAGE) || (dbei->eventType != EVENTTYPE_FILE) || (dbei->eventType != EVENTTYPE_URL) || (dbei->eventType != EVENTTYPE_CONTACTS)) + // ...let the event go its way + return 0; */ + //we want block not only messages, i seen many types other eventtype flood + if(dbei->flags & DBEF_READ) + // ...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) + { + DBWriteContactSettingByte(hContact, pluginName, "Excluded", 1); + return 0; + } + // if message is from known or marked Answered contact + if(!DBGetContactSettingByte(hContact, "CList", "NotOnList", 0)) + // ...let the event go its way + return 0; + // if message is corrupted or empty it cannot be an answer. + if(!dbei->cbBlob || !dbei->pBlob) + // reject processing of the event + return 1; + + tstring message; + + if(dbei->flags & DBEF_UTF){ + WCHAR* msg_u; + char* msg_a = mir_strdup(( char* )dbei->pBlob ); + mir_utf8decode( msg_a, &msg_u ); +#ifdef _UNICODE + message = msg_u; +#else + message = mir_u2a(msg_u); +#endif + } + else{ +#ifdef _UNICODE + message = mir_a2u((char*)(dbei->pBlob)); +#else + message = (char*)(dbei->pBlob); +#endif + } + + // if message contains right answer... + +// if( tstring::npos!=message.find(gbAnswer) ) + if(!wcscmp(message.c_str(), gbAnswer.c_str())) + { + // unhide contact + DBDeleteContactSetting(hContact, "CList", "Hidden"); + + // mark contact as Answered + DBWriteContactSettingByte(hContact, pluginName, "Answered", 1); + + //add contact permanently + if(gbAddPermanent) //do not use this ) + DBDeleteContactSetting(hContact, "CList", "NotOnList"); + + // send congratulation +#ifdef _UNICODE + char * buf=mir_utf8encodeW(gbCongratulation.c_str()); + CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)buf); + mir_free(buf); +#else + CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)GetCongratulation().c_str()); +#endif + + // process the event + return 0; + } + + // if message message does not contain infintite talk protection prefix + // and question count for this contact is less then maximum + if( (!gbInfTalkProtection || tstring::npos==message.find(_T("StopSpam automatic message:\r\n"))) + && (!gbMaxQuestCount || DBGetContactSettingDword(hContact, pluginName, "QuestionCount", 0) < gbMaxQuestCount) ) + { + // send question + tstring q = _T("StopSpam automatic message:\r\n") + gbQuestion; + +#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); + + } + else + { + if (gbDosServiceExist) + { + if(gbDosServiceIntegration) + { + int i; + i = rand()%255*13; + CallService(MS_DOS_SERVICE, (WPARAM)hContact, (LPARAM)i); + } + } + if(gbIgnoreContacts) + { + DBWriteContactSettingDword(hContact, "Ignore", "Mask1", 0x0000007F); + } + } + if(gbHideContacts) + DBWriteContactSettingByte(hContact, "CList", "Hidden", 1); + if(gbSpecialGroup) + DBWriteContactSettingTString(hContact, "CList", "Group", gbSpammersGroup.c_str()); + DBWriteContactSettingByte(hContact, "CList", "NotOnList", 1); + + // save message from contact + dbei->flags |= DBEF_READ; + CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)dbei); + + // reject processing of the event + return 1; +} + + +MIRANDA_HOOK_EVENT(ME_DB_CONTACT_SETTINGCHANGED, w, l) +{ + HANDLE hContact = (HANDLE)w; + DBCONTACTWRITESETTING * cws = (DBCONTACTWRITESETTING*)l; + + // if CList/NotOnList is being deleted then remove answeredSetting + if(strcmp(cws->szModule, "CList")) + return 0; + if(strcmp(cws->szSetting, "NotOnList")) + return 0; + if(!cws->value.type) + { + DBDeleteContactSetting(hContact, pluginName, "Answered"); + DBDeleteContactSetting(hContact, pluginName, "QuestionCount"); + } + + return 0; +} + + + diff --git a/stopspam_mod/branches/0.0.1.6/stopspam.h b/stopspam_mod/branches/0.0.1.6/stopspam.h new file mode 100644 index 0000000..10088bb --- /dev/null +++ b/stopspam_mod/branches/0.0.1.6/stopspam.h @@ -0,0 +1,19 @@ + +extern BOOL gbDosServiceExist; +extern DWORD gbMaxQuestCount; +extern BOOL gbInfTalkProtection; +extern BOOL gbAddPermanent; +extern BOOL gbHandleAuthReq; +extern BOOL gbSpecialGroup; +extern BOOL gbHideContacts; +extern BOOL gbIgnoreContacts; +extern BOOL gbExclude; +extern BOOL gbDelExcluded; +extern BOOL gbDosServiceIntegration; +extern BOOL gbDelNotInList; +extern tstring gbSpammersGroup; +extern tstring gbQuestion; +extern tstring gbAnswer; +extern tstring gbCongratulation; +extern std::string gbAuthRepl; + diff --git a/stopspam_mod/branches/0.0.1.6/stopspam.rc b/stopspam_mod/branches/0.0.1.6/stopspam.rc new file mode 100644 index 0000000..b38c2d4 --- /dev/null +++ b/stopspam_mod/branches/0.0.1.6/stopspam.rc @@ -0,0 +1,211 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Russian resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) +#ifdef _WIN32 +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT +#pragma code_page(1251) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_MESSAGES DIALOGEX 0, 0, 302, 225 +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_POPUP | WS_SYSMENU +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + LTEXT "Question: (Ctrl-Enter for carriage return)",IDC_STATIC,0,5,156,8 + EDITTEXT ID_QUESTION,0,17,300,57,ES_MULTILINE | ES_AUTOVSCROLL | WS_VSCROLL + PUSHBUTTON "Restore defaults",ID_RESTOREDEFAULTS,234,208,66,14,NOT WS_TABSTOP + LTEXT "Answer:",IDC_STATIC,0,82,270,8 + EDITTEXT ID_ANSWER,0,94,300,14,ES_AUTOHSCROLL + LTEXT "Congratulation:",IDC_STATIC,0,112,270,8 + EDITTEXT ID_CONGRATULATION,0,125,300,48,ES_MULTILINE | ES_AUTOVSCROLL | WS_VSCROLL + LTEXT "Auth. request reply:",IDC_STATIC,0,174,270,8 + EDITTEXT ID_AUTHREPL,0,187,300,14,ES_AUTOHSCROLL +END + +IDD_PROTO DIALOGEX 0, 0, 230, 173 +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_SYSMENU +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + LTEXT "Installed protocols:",IDC_STATIC,6,8,84,8 + LISTBOX ID_ALLPROTO,6,20,84,138,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON ">>>>",ID_ADDALL,96,26,36,14 + PUSHBUTTON ">>",ID_ADD,96,44,36,14 + PUSHBUTTON "<<",ID_REMOVE,96,62,36,14 + PUSHBUTTON "<<<<",ID_REMOVEALL,96,80,36,14 + LTEXT "Despammed protocols:",IDC_STATIC,138,8,85,8 + LISTBOX ID_USEDPROTO,138,20,84,138,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP +END + +IDD_MAIN DIALOGEX 0, 0, 309, 219 +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_SYSMENU +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + EDITTEXT ID_DESCRIPTION,12,7,290,82,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_TABSTOP + LTEXT "Do not send more than ",IDC_STATIC,11,89,87,12,SS_CENTERIMAGE + EDITTEXT ID_MAXQUESTCOUNT,107,89,30,12,ES_AUTOHSCROLL | ES_NUMBER + LTEXT " questions to one contact (0 - for no limit)",IDC_STATIC,144,89,155,12,SS_CENTERIMAGE + CONTROL "Enable StopSpam-StopSpam infinite talk protection",ID_INFTALKPROT, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,122,270,10 + CONTROL "Add contact permanently",ID_ADDPERMANENT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,134,270,8 + CONTROL "Enable auth. requests blocking",ID_HANDLEAUTHREQ,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,146,270,8 + CONTROL "Enable integration with DOS plugin",ID_DOS_INTEGRATION, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,199,270,8 + CONTROL "Add contacts to specified group:",ID_SPECIALGROUP, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,111,134,10 + EDITTEXT ID_SPECIALGROUPNAME,152,110,53,12,ES_AUTOHSCROLL + CONTROL "Hide unanswered contacts and spammers from contact list",ID_HIDECONTACTS, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,156,279,10 + CONTROL "Ignore spammers (do not write messages to history)",ID_IGNORESPAMMERS, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,167,268,10 + CONTROL "Remove Excluded contacts after restart",ID_REMOVE_TMP, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,188,270,8 + CONTROL "Exclude contacts which we sending something from spam check",ID_EXCLUDE, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,178,270,8 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_MESSAGES, DIALOG + BEGIN + RIGHTMARGIN, 300 + TOPMARGIN, 7 + BOTTOMMARGIN, 222 + END + + IDD_PROTO, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 223 + TOPMARGIN, 7 + BOTTOMMARGIN, 166 + END + + IDD_MAIN, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 302 + TOPMARGIN, 7 + BOTTOMMARGIN, 212 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 0,0,1,0 + PRODUCTVERSION 0,0,1,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "Comments", "Licensed under the terms of the GNU General Public License" + VALUE "CompanyName", " " + VALUE "FileDescription", "StopSpam plugin for Miranda IM" + VALUE "FileVersion", "0.0.1.6 alpha build #0" + VALUE "InternalName", "stopspam" + VALUE "LegalCopyright", "Copyright © 2000-2009 Miranda IM Project. This software is released under the terms of the GNU General Public License." + VALUE "OriginalFilename", "stopspam.dll" + VALUE "ProductName", "StopSpam" + VALUE "ProductVersion", "0.0.1.6 alpha build #0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END + +#endif // Russian resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/stopspam_mod/branches/0.0.1.6/stopspam_8.sln b/stopspam_mod/branches/0.0.1.6/stopspam_8.sln new file mode 100644 index 0000000..b7014bb --- /dev/null +++ b/stopspam_mod/branches/0.0.1.6/stopspam_8.sln @@ -0,0 +1,25 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stopspam", "stopspam_8.vcproj", "{3E6CEC79-5E93-4607-B10E-498586ECF6A6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug Unicode|Win32 = Debug Unicode|Win32 + Debug|Win32 = Debug|Win32 + Release Unicode|Win32 = Release Unicode|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3E6CEC79-5E93-4607-B10E-498586ECF6A6}.Debug Unicode|Win32.ActiveCfg = Debug Unicode|Win32 + {3E6CEC79-5E93-4607-B10E-498586ECF6A6}.Debug Unicode|Win32.Build.0 = Debug Unicode|Win32 + {3E6CEC79-5E93-4607-B10E-498586ECF6A6}.Debug|Win32.ActiveCfg = Debug|Win32 + {3E6CEC79-5E93-4607-B10E-498586ECF6A6}.Debug|Win32.Build.0 = Debug|Win32 + {3E6CEC79-5E93-4607-B10E-498586ECF6A6}.Release Unicode|Win32.ActiveCfg = Release Unicode|Win32 + {3E6CEC79-5E93-4607-B10E-498586ECF6A6}.Release Unicode|Win32.Build.0 = Release Unicode|Win32 + {3E6CEC79-5E93-4607-B10E-498586ECF6A6}.Release|Win32.ActiveCfg = Release|Win32 + {3E6CEC79-5E93-4607-B10E-498586ECF6A6}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/stopspam_mod/branches/0.0.1.6/stopspam_8.vcproj b/stopspam_mod/branches/0.0.1.6/stopspam_8.vcproj new file mode 100644 index 0000000..2bc6d66 --- /dev/null +++ b/stopspam_mod/branches/0.0.1.6/stopspam_8.vcproj @@ -0,0 +1,404 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/stopspam_mod/branches/0.0.1.6/stopspam_9.sln b/stopspam_mod/branches/0.0.1.6/stopspam_9.sln new file mode 100644 index 0000000..db623ad --- /dev/null +++ b/stopspam_mod/branches/0.0.1.6/stopspam_9.sln @@ -0,0 +1,28 @@ +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stopspam", "stopspam_9.vcproj", "{3E6CEC79-5E93-4607-B10E-498586ECF6A6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug Unicode|Win32 = Debug Unicode|Win32 + Debug|Win32 = Debug|Win32 + Release Unicode (static)|Win32 = Release Unicode (static)|Win32 + Release Unicode|Win32 = Release Unicode|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3E6CEC79-5E93-4607-B10E-498586ECF6A6}.Debug Unicode|Win32.ActiveCfg = Debug Unicode|Win32 + {3E6CEC79-5E93-4607-B10E-498586ECF6A6}.Debug Unicode|Win32.Build.0 = Debug Unicode|Win32 + {3E6CEC79-5E93-4607-B10E-498586ECF6A6}.Debug|Win32.ActiveCfg = Debug|Win32 + {3E6CEC79-5E93-4607-B10E-498586ECF6A6}.Debug|Win32.Build.0 = Debug|Win32 + {3E6CEC79-5E93-4607-B10E-498586ECF6A6}.Release Unicode (static)|Win32.ActiveCfg = Release Unicode (static)|Win32 + {3E6CEC79-5E93-4607-B10E-498586ECF6A6}.Release Unicode (static)|Win32.Build.0 = Release Unicode (static)|Win32 + {3E6CEC79-5E93-4607-B10E-498586ECF6A6}.Release Unicode|Win32.ActiveCfg = Release Unicode|Win32 + {3E6CEC79-5E93-4607-B10E-498586ECF6A6}.Release Unicode|Win32.Build.0 = Release Unicode|Win32 + {3E6CEC79-5E93-4607-B10E-498586ECF6A6}.Release|Win32.ActiveCfg = Release|Win32 + {3E6CEC79-5E93-4607-B10E-498586ECF6A6}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/stopspam_mod/branches/0.0.1.6/stopspam_9.vcproj b/stopspam_mod/branches/0.0.1.6/stopspam_9.vcproj new file mode 100644 index 0000000..5d81d03 --- /dev/null +++ b/stopspam_mod/branches/0.0.1.6/stopspam_9.vcproj @@ -0,0 +1,525 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/stopspam_mod/branches/0.0.1.6/utilities.cpp b/stopspam_mod/branches/0.0.1.6/utilities.cpp new file mode 100644 index 0000000..f2b35b3 --- /dev/null +++ b/stopspam_mod/branches/0.0.1.6/utilities.cpp @@ -0,0 +1,94 @@ +#include "headers.h" + +tstring DBGetContactSettingStringPAN(HANDLE hContact, char const * szModule, char const * szSetting, tstring errorValue) +{ + DBVARIANT dbv; + //if(DBGetContactSetting(hContact, szModule, szSetting, &dbv)) + if(DBGetContactSettingTString(hContact, szModule, szSetting, &dbv)) + return errorValue; +// if(DBVT_TCHAR == dbv.type ) + errorValue = dbv.ptszVal; + DBFreeVariant(&dbv); + return errorValue; +} + +std::string DBGetContactSettingStringPAN_A(HANDLE hContact, char const * szModule, char const * szSetting, std::string errorValue) +{ + DBVARIANT dbv; + //if(DBGetContactSetting(hContact, szModule, szSetting, &dbv)) + if(DBGetContactSettingString(hContact, szModule, szSetting, &dbv)) + return errorValue; +// if(DBVT_ASCIIZ == dbv.type ) + errorValue = dbv.pszVal; + DBFreeVariant(&dbv); + return errorValue; +} + +tstring &GetDlgItemString(HWND hwnd, int id) +{ + HWND h = GetDlgItem(hwnd, id); + int len = GetWindowTextLength(h); + TCHAR * buf = new TCHAR[len + 1]; + GetWindowText(h, buf, len + 1); + static tstring s; + s = buf; + delete []buf; + return s; +} + +std::string &GetProtoList() +{ + static std::string s; + return s = DBGetContactSettingStringPAN_A(NULL, pluginName, "protoList", "ICQ\r\n"); +} + + +bool ProtoInList(std::string proto) +{ + return std::string::npos != GetProtoList().find(proto + "\r\n"); +} + +int CreateCListGroup(TCHAR* szGroupName) +{ + int hGroup; + CLIST_INTERFACE *clint = NULL; + + if (ServiceExists(MS_CLIST_RETRIEVE_INTERFACE)) + clint = (CLIST_INTERFACE*)CallService(MS_CLIST_RETRIEVE_INTERFACE, 0, 0); + + hGroup = CallService(MS_CLIST_GROUPCREATE, 0, 0); + + TCHAR* usTmp = szGroupName; + + clint->pfnRenameGroup(hGroup, usTmp); + + return hGroup; +} + + +void RemoveExcludedUsers() +{ + HANDLE hContact; + HANDLE ToRemove[4096]; + int i = 0; + int a = 0; + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + if(hContact) + { + do + { + if(DBGetContactSettingByte(hContact, "CList", "NotOnList", 0) && DBGetContactSettingByte(hContact, pluginName, "Excluded", 0)) + { + ToRemove[i] = hContact; + i++; + } + } + while(hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact, 0)); + ToRemove[i] = INVALID_HANDLE_VALUE; + while(ToRemove[a] != INVALID_HANDLE_VALUE) + { + CallService(MS_DB_CONTACT_DELETE, (WPARAM)ToRemove[a], 0); + a++; + } + } +} diff --git a/stopspam_mod/branches/0.0.1.6/utilities.h b/stopspam_mod/branches/0.0.1.6/utilities.h new file mode 100644 index 0000000..efe8a59 --- /dev/null +++ b/stopspam_mod/branches/0.0.1.6/utilities.h @@ -0,0 +1,6 @@ +tstring DBGetContactSettingStringPAN(HANDLE hContact, char const * szModule, char const * szSetting, tstring errorValue); +std::string DBGetContactSettingStringPAN_A(HANDLE hContact, char const * szModule, char const * szSetting, std::string errorValue); +tstring &GetDlgItemString(HWND hwnd, int id); +std::string &GetProtoList(); +bool ProtoInList(std::string proto); +void RemoveExcludedUsers(); \ No newline at end of file diff --git a/stopspam_mod/branches/0.0.1.6/version.h b/stopspam_mod/branches/0.0.1.6/version.h new file mode 100644 index 0000000..9f7c792 --- /dev/null +++ b/stopspam_mod/branches/0.0.1.6/version.h @@ -0,0 +1,6 @@ +#ifndef VERSION_H_CAA3B062_9BEE_40e6_A9F9_20BBF467731B +#define VERSION_H_CAA3B062_9BEE_40e6_A9F9_20BBF467731B + +#define SUBWCREV (0) + +#endif -- cgit v1.2.3