diff options
author | Gluzskiy Alexandr <sss123next@list.ru> | 2009-09-30 21:35:51 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss123next@list.ru> | 2009-09-30 21:35:51 +0300 |
commit | 4d4bd94c0e34e2eaedc9d12926f14ccde8e0b69c (patch) | |
tree | 2d7d1d0d5958ff64e6f563f6336408e5c2ad80ce | |
parent | c506453b8518a9bd7622756f24e24323ad97e375 (diff) |
variables support for stopspam (ported from stopspam from koshechka)
-rw-r--r-- | stopspam_mod/trunk/eventhooker.h | 4 | ||||
-rw-r--r-- | stopspam_mod/trunk/headers.h | 3 | ||||
-rw-r--r-- | stopspam_mod/trunk/init.cpp | 8 | ||||
-rw-r--r-- | stopspam_mod/trunk/options.cpp | 4 | ||||
-rw-r--r-- | stopspam_mod/trunk/stopspam.cpp | 8 | ||||
-rw-r--r-- | stopspam_mod/trunk/stopspam.h | 2 | ||||
-rw-r--r-- | stopspam_mod/trunk/stopspam.rc | 4 | ||||
-rw-r--r-- | stopspam_mod/trunk/utilities.cpp | 21 | ||||
-rw-r--r-- | stopspam_mod/trunk/utilities.h | 3 |
9 files changed, 41 insertions, 16 deletions
diff --git a/stopspam_mod/trunk/eventhooker.h b/stopspam_mod/trunk/eventhooker.h index 2174691..b1ca2ab 100644 --- a/stopspam_mod/trunk/eventhooker.h +++ b/stopspam_mod/trunk/eventhooker.h @@ -37,9 +37,9 @@ namespace miranda {
#define MIRANDA_HOOK_EVENT(NAME, WPARAMNAME, LPARAMNAME) \
- NAME##_Handler(WPARAM,LPARAM);\
+ int NAME##_Handler(WPARAM,LPARAM);\
miranda::EventHooker NAME##_Hooker(NAME, NAME##_Handler);\
- NAME##_Handler(WPARAM WPARAMNAME, LPARAM LPARAMNAME)
+ int NAME##_Handler(WPARAM WPARAMNAME, LPARAM LPARAMNAME)
struct EventHooker
{
diff --git a/stopspam_mod/trunk/headers.h b/stopspam_mod/trunk/headers.h index f41fc97..db718df 100644 --- a/stopspam_mod/trunk/headers.h +++ b/stopspam_mod/trunk/headers.h @@ -12,6 +12,9 @@ #include <m_langpack.h>
#include <m_clistint.h>
#include <m_skin.h>
+#define VARIABLES_NOHELPER
+#include <m_variables.h>
+
#include "globals.h"
#include "stopspam.h"
diff --git a/stopspam_mod/trunk/init.cpp b/stopspam_mod/trunk/init.cpp index f762872..166ac15 100644 --- a/stopspam_mod/trunk/init.cpp +++ b/stopspam_mod/trunk/init.cpp @@ -19,7 +19,7 @@ tstring gbSpammersGroup = _T("Spammers"); tstring gbQuestion;
tstring gbAnswer;
tstring gbCongratulation;
-std::string gbAuthRepl;
+std::wstring gbAuthRepl;
extern char * pluginDescription;
extern TCHAR const * defQuestion;
extern int RemoveTmp(WPARAM,LPARAM);
@@ -39,7 +39,7 @@ UTF8_INTERFACE utfi; PLUGININFOEX pluginInfoEx = {
sizeof(PLUGININFOEX),
0,
- PLUGIN_MAKE_VERSION(0, 0, 1, 6),
+ PLUGIN_MAKE_VERSION(0, 0, 1, 7),
pluginDescription,
"Roman Miklashevsky",
"sss123next@list.ru",
@@ -101,7 +101,7 @@ char *date() extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
{
- if ( mirandaVersion < PLUGIN_MAKE_VERSION( 0, 7, 0, 0 ))
+ if ( mirandaVersion < PLUGIN_MAKE_VERSION( 0, 7, 0, 1 ))
return NULL;
{
static char plugname[52];
@@ -130,7 +130,7 @@ void InitVars() 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.");
+ 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);
diff --git a/stopspam_mod/trunk/options.cpp b/stopspam_mod/trunk/options.cpp index 9983444..52fd4d5 100644 --- a/stopspam_mod/trunk/options.cpp +++ b/stopspam_mod/trunk/options.cpp @@ -134,7 +134,7 @@ INT_PTR CALLBACK MessagesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar 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());
+ SetDlgItemText(hwnd, ID_AUTHREPL, gbAuthRepl.c_str());
}
return TRUE;
case WM_COMMAND:
@@ -175,7 +175,7 @@ INT_PTR CALLBACK MessagesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar 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.");
+ 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."));
diff --git a/stopspam_mod/trunk/stopspam.cpp b/stopspam_mod/trunk/stopspam.cpp index e162837..005d67c 100644 --- a/stopspam_mod/trunk/stopspam.cpp +++ b/stopspam_mod/trunk/stopspam.cpp @@ -61,7 +61,7 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_ADDED, wParam, lParam) if(gbSpecialGroup)
DBWriteContactSettingTString(hcntct, "CList", "Group", gbSpammersGroup.c_str());
- int a = CallService(allowService.c_str(), (WPARAM)hDbEvent, (LPARAM)gbAuthRepl.c_str());
+ int a = CallService(allowService.c_str(), (WPARAM)hDbEvent, (LPARAM)(variables_parse(gbAuthRepl, hcntct).c_str()));
//CallProtoService(dbei.szModule,PS_AUTHDENY,(WPARAM)hDbEvent,(LPARAM)GetAuthRepl().c_str());
delete dbei.pBlob;
@@ -155,7 +155,7 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l) // if message contains right answer...
// if( tstring::npos!=message.find(gbAnswer) )
- if(!wcscmp(message.c_str(), gbAnswer.c_str()))
+ if(!wcscmp(message.c_str(), (variables_parse(gbAnswer, hContact).c_str())))
{
// unhide contact
DBDeleteContactSetting(hContact, "CList", "Hidden");
@@ -169,7 +169,7 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l) // send congratulation
#ifdef _UNICODE
- char * buf=mir_utf8encodeW(gbCongratulation.c_str());
+ char * buf=mir_utf8encodeW(variables_parse(gbCongratulation, hContact).c_str());
CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)buf);
mir_free(buf);
#else
@@ -186,7 +186,7 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l) && (!gbMaxQuestCount || DBGetContactSettingDword(hContact, pluginName, "QuestionCount", 0) < gbMaxQuestCount) )
{
// send question
- tstring q = _T("StopSpam automatic message:\r\n") + gbQuestion;
+ tstring q = _T("StopSpam automatic message:\r\n") + variables_parse(gbQuestion, hContact);
#ifdef _UNICODE
char * buf=mir_utf8encodeW(q.c_str());
diff --git a/stopspam_mod/trunk/stopspam.h b/stopspam_mod/trunk/stopspam.h index 10088bb..738ec15 100644 --- a/stopspam_mod/trunk/stopspam.h +++ b/stopspam_mod/trunk/stopspam.h @@ -15,5 +15,5 @@ extern tstring gbSpammersGroup; extern tstring gbQuestion;
extern tstring gbAnswer;
extern tstring gbCongratulation;
-extern std::string gbAuthRepl;
+extern std::wstring gbAuthRepl;
diff --git a/stopspam_mod/trunk/stopspam.rc b/stopspam_mod/trunk/stopspam.rc index b38c2d4..14ec700 100644 --- a/stopspam_mod/trunk/stopspam.rc +++ b/stopspam_mod/trunk/stopspam.rc @@ -142,12 +142,12 @@ 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 "FileVersion", "0.0.1.7 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"
+ VALUE "ProductVersion", "0.0.1.7 alpha build #0"
END
END
BLOCK "VarFileInfo"
diff --git a/stopspam_mod/trunk/utilities.cpp b/stopspam_mod/trunk/utilities.cpp index 655ba24..bf00574 100644 --- a/stopspam_mod/trunk/utilities.cpp +++ b/stopspam_mod/trunk/utilities.cpp @@ -122,3 +122,24 @@ int RemoveTmp(WPARAM,LPARAM) RemoveTemporaryUsers();
return 0;
}
+tstring variables_parse(tstring const &tstrFormat, HANDLE hContact){
+ if (ServiceExists(MS_VARS_FORMATSTRING)) {
+ FORMATINFO fi;
+ TCHAR *tszParsed;
+ tstring tstrResult;
+
+ ZeroMemory(&fi, sizeof(fi));
+ fi.cbSize = sizeof(fi);
+ fi.tszFormat = _tcsdup(tstrFormat.c_str());
+ fi.hContact = hContact;
+ fi.flags |= FIF_TCHAR;
+ tszParsed = (TCHAR *)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
+ free(fi.tszFormat);
+ if (tszParsed) {
+ tstrResult = tszParsed;
+ CallService(MS_VARS_FREEMEMORY, (WPARAM)tszParsed, 0);
+ return tstrResult;
+ }
+ }
+ return tstrFormat;
+}
\ No newline at end of file diff --git a/stopspam_mod/trunk/utilities.h b/stopspam_mod/trunk/utilities.h index efe8a59..1b5f719 100644 --- a/stopspam_mod/trunk/utilities.h +++ b/stopspam_mod/trunk/utilities.h @@ -3,4 +3,5 @@ std::string DBGetContactSettingStringPAN_A(HANDLE hContact, char const * szModul tstring &GetDlgItemString(HWND hwnd, int id);
std::string &GetProtoList();
bool ProtoInList(std::string proto);
-void RemoveExcludedUsers();
\ No newline at end of file +void RemoveExcludedUsers();
+tstring variables_parse(tstring const &tstrFormat, HANDLE hContact);
\ No newline at end of file |