summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey (Elzor) Bolhovskoy <elzor@foobar2000.ru>2010-04-08 19:46:22 +0600
committerSergey (Elzor) Bolhovskoy <elzor@foobar2000.ru>2010-04-08 19:46:22 +0600
commitc0245a95c2bbe2e83a5514e6652ce483a70122ee (patch)
tree1957eaacd6c0b825dd17759e35514f519b84d8ca
parentb63effd23d033036b6b07c16680d26636289ab53 (diff)
Add more options for ICQ protocol, auto remove useless messages from contact
-rw-r--r--init.cpp13
-rw-r--r--options.cpp60
-rw-r--r--resource.h9
-rw-r--r--stopspam.cpp41
-rw-r--r--stopspam.h4
-rw-r--r--stopspam.rc14
-rw-r--r--stopspam_9.vcproj4
-rw-r--r--utilities.cpp3
8 files changed, 126 insertions, 22 deletions
diff --git a/init.cpp b/init.cpp
index a2d3c99..d597eb2 100644
--- a/init.cpp
+++ b/init.cpp
@@ -18,8 +18,15 @@ BOOL gbDosServiceIntegration = 0;
BOOL gbCaseInsensitive = 0;
BOOL gbInvisDisable = 0;
BOOL gbIgnoreURL = 1;
+
+BOOL gbAutoAuth=0;
+BOOL gbAutoAddToServerList=0;
+BOOL gbAutoReqAuth=1;
+
//BOOL gbDelNotInList = 0;
tstring gbSpammersGroup = _T("Spammers");
+tstring gbAutoAuthGroup = _T("NotSpammers");
+
tstring gbQuestion;
tstring gbAnswer;
tstring gbCongratulation;
@@ -144,6 +151,12 @@ void InitVars()
gbCaseInsensitive = DBGetContactSettingByte(NULL, pluginName, "CaseInsensitive", 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);
+
+
// gbDelNotInList = DBGetContactSettingByte(NULL, pluginName, "DelNotInList", 0);
}
diff --git a/options.cpp b/options.cpp
index fabee4d..1a7c694 100644
--- a/options.cpp
+++ b/options.cpp
@@ -269,13 +269,27 @@ INT_PTR CALLBACK AdvancedDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
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_IGNOREURL, BM_SETCHECK, gbIgnoreURL ? BST_CHECKED : BST_UNCHECKED, 0);
+ SendDlgItemMessage(hwnd, IDC_AUTOAUTH, BM_SETCHECK, gbAutoAuth ? BST_CHECKED : BST_UNCHECKED, 0);
+ SendDlgItemMessage(hwnd, IDC_ADDTOSRVLST, BM_SETCHECK, gbAutoAddToServerList ? BST_CHECKED : BST_UNCHECKED, 0);
+ SendDlgItemMessage(hwnd, IDC_REQAUTH, BM_SETCHECK, gbAutoReqAuth ? BST_CHECKED : BST_UNCHECKED, 0);
+ SetDlgItemText(hwnd, IDC_AUTOADDGROUP, gbAutoAuthGroup.c_str());
}
return TRUE;
case WM_COMMAND:{
switch (LOWORD(wParam))
{
- case IDC_INVIS_DISABLE: case IDC_CASE_INSENSITIVE: case ID_DOS_INTEGRATION:
- case ID_SPECIALGROUPNAME: case ID_SPECIALGROUP: case ID_EXCLUDE: case ID_REMOVE_TMP: case ID_IGNOREURL:
+ case IDC_INVIS_DISABLE:
+ case IDC_CASE_INSENSITIVE:
+ case ID_DOS_INTEGRATION:
+ case ID_SPECIALGROUPNAME:
+ case ID_SPECIALGROUP:
+ case ID_EXCLUDE:
+ case ID_REMOVE_TMP:
+ case ID_IGNOREURL:
+ case IDC_AUTOAUTH:
+ case IDC_ADDTOSRVLST:
+ case IDC_REQAUTH:
+ case IDC_AUTOADDGROUP:
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
break;
@@ -337,6 +351,48 @@ INT_PTR CALLBACK AdvancedDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
BST_CHECKED == SendDlgItemMessage(hwnd, ID_REMOVE_TMP, BM_GETCHECK, 0, 0));
DBWriteContactSettingByte(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));
+ {
+ 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)
+ {
+ 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(NewAGroupName.c_str(), szValue + 1) == 0)
+ {
+ GroupExist = 1;
+ break;
+ }
+ GroupNumber++;
+ }
+ DBWriteContactSettingTString(NULL,pluginName, "AutoAuthGroup", NewAGroupName.c_str());
+ gbAutoAuthGroup = DBGetContactSettingStringPAN(NULL,pluginName,"AutoAuthGroup", _T("Not Spammers"));
+ if(!GroupExist && gbAutoAddToServerList)
+ CreateCListGroup((TCHAR*)gbAutoAuthGroup.c_str());
+ }
+ }
+
}
return TRUE;
}
diff --git a/resource.h b/resource.h
index ed4a257..2f534f0 100644
--- a/resource.h
+++ b/resource.h
@@ -40,7 +40,12 @@
#define ID_EXCLUDE 1021
#define ID_ADDPERMANENT3 1022
#define ID_DEL_NO_IN_LIST 1022
-#define ID_IGNOREURL 1023
+#define IDC_ADDTOSRVLST 1022
+#define ID_IGNOREURL 1023
+#define IDC_EDIT1 1024
+#define IDC_AUTOADDGROUP 1024
+#define IDC_AUTOAUTH 1025
+#define IDC_REQAUTH 1026
// Next default values for new objects
//
@@ -48,7 +53,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 104
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1021
+#define _APS_NEXT_CONTROL_VALUE 1027
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/stopspam.cpp b/stopspam.cpp
index 8ae8d47..ede14a6 100644
--- a/stopspam.cpp
+++ b/stopspam.cpp
@@ -81,7 +81,6 @@ 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))
@@ -164,16 +163,35 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l)
// send congratulation
if(msg)
{
+ tstring prot=DBGetContactSettingStringPAN(NULL,dbei->szModule,"AM_BaseProto", _T(""));
+ // 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);
+ 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());
+ CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)GetCongratulation().c_str());
#endif
+ };
+ // Note: For ANSI can be not work
+ if(!Stricmp(_T("ICQ"),prot.c_str())){
+ // grand auth.
+ if(gbAutoAuth)
+ CallProtoService(dbei->szModule, "/GrantAuth", w, 0);
+ // add contact to server list and local group
+ if(gbAutoAddToServerList)
+ {
+ DBWriteContactSettingTString(hContact, "CList", "Group", gbAutoAuthGroup.c_str());
+ CallProtoService(dbei->szModule, "/AddServerContact", w, 0);
+ DBDeleteContactSetting(hContact, "CList", "NotOnList");
+ };
+ // auto auth. reqwest with send congratulation
+ if(gbAutoReqAuth)
+ CallContactService(hContact,PSS_AUTHREQUEST,0, (LPARAM)variables_parse(gbCongratulation, hContact).c_str());
+ }
}
-
- // process the event
return 0;
}
@@ -225,10 +243,11 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l)
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);
-
+ // save first message from contact
+ if (DBGetContactSettingDword(hContact, pluginName, "QuestionCount", 0)<2){
+ dbei->flags |= DBEF_READ;
+ CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)dbei);
+ };
// reject processing of the event
return 1;
}
diff --git a/stopspam.h b/stopspam.h
index ea7a963..fdd4092 100644
--- a/stopspam.h
+++ b/stopspam.h
@@ -20,4 +20,8 @@ extern tstring gbQuestion;
extern tstring gbAnswer;
extern tstring gbCongratulation;
extern std::wstring gbAuthRepl;
+extern BOOL gbAutoAuth;
+extern BOOL gbAutoAddToServerList;
+extern BOOL gbAutoReqAuth;
+extern tstring gbAutoAuthGroup;
diff --git a/stopspam.rc b/stopspam.rc
index b572c38..42879d9 100644
--- a/stopspam.rc
+++ b/stopspam.rc
@@ -13,7 +13,7 @@
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
-// Russian resources
+// русский resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
#ifdef _WIN32
@@ -92,6 +92,12 @@ BEGIN
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,16,196,10
EDITTEXT ID_SPECIALGROUPNAME,217,15,79,12,ES_AUTOHSCROLL
CONTROL "Ignore URL in messages",ID_IGNOREURL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,88,287,10
+ CONTROL "Add contact to server list",IDC_ADDTOSRVLST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,114,187,10
+ EDITTEXT IDC_AUTOADDGROUP,210,112,76,14,ES_AUTOHSCROLL
+ GROUPBOX "After congratulation (ICQ only)",IDC_STATIC,15,103,278,51
+ CONTROL "Automatically grant authorization",IDC_AUTOAUTH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,126,263,10
+ CONTROL "Request authorization from contacts which pass stopspam test",IDC_REQAUTH,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,138,267,10
END
@@ -178,12 +184,12 @@ BEGIN
END
END
-#endif // Russian resources
+#endif // русский resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
-// English (U.S.) resources
+// английский (США) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
@@ -216,7 +222,7 @@ END
#endif // APSTUDIO_INVOKED
-#endif // English (U.S.) resources
+#endif // английский (США) resources
/////////////////////////////////////////////////////////////////////////////
diff --git a/stopspam_9.vcproj b/stopspam_9.vcproj
index f4492d0..f749670 100644
--- a/stopspam_9.vcproj
+++ b/stopspam_9.vcproj
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="9,00"
+ Version="9.00"
Name="stopspam"
ProjectGUID="{3E6CEC79-5E93-4607-B10E-498586ECF6A6}"
RootNamespace="stopspam"
@@ -386,7 +386,7 @@
InlineFunctionExpansion="1"
FavorSizeOrSpeed="2"
OmitFramePointers="true"
- AdditionalIncludeDirectories=""
+ AdditionalIncludeDirectories="..\..\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;STOPSPAM_EXPORTS;_CRT_SECURE_NO_DEPRECATE"
StringPooling="true"
RuntimeLibrary="0"
diff --git a/utilities.cpp b/utilities.cpp
index d935cae..4d3b3cf 100644
--- a/utilities.cpp
+++ b/utilities.cpp
@@ -146,7 +146,7 @@ tstring variables_parse(tstring const &tstrFormat, HANDLE hContact){
// case-insensitive _tcsstr
//by nullbie as i remember...
-#define NEWTSTR_MALLOC(A) (A==NULL)?NULL:_tcscpy((TCHAR*)malloc(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;
@@ -163,3 +163,4 @@ const int Stricmp(const TCHAR *str, const TCHAR *substr)
return i;
}
+