summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-11-16 21:58:06 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-11-16 21:58:06 +0300
commit52592007b35811a902ead1d9999a558880178e10 (patch)
tree7e0e9e72a2d4f0244efbe524479170bb00d33875
parent67aa28cc9441ad4aca94a1ecbfe97f5b497061b2 (diff)
fixes #1034 (StopSpam: wrong codepage)
-rw-r--r--plugins/StopSpamPlus/src/options.cpp123
-rw-r--r--plugins/StopSpamPlus/src/settings.h39
-rw-r--r--plugins/StopSpamPlus/src/stdafx.h1
-rw-r--r--plugins/StopSpamPlus/src/utils.cpp18
-rw-r--r--plugins/StopSpamPlus/src/version.h14
5 files changed, 85 insertions, 110 deletions
diff --git a/plugins/StopSpamPlus/src/options.cpp b/plugins/StopSpamPlus/src/options.cpp
index 2fcf6eeb47..5f70f6a8d6 100644
--- a/plugins/StopSpamPlus/src/options.cpp
+++ b/plugins/StopSpamPlus/src/options.cpp
@@ -1,17 +1,14 @@
#include "stdafx.h"
-wchar_t * pluginDescription = TranslateT("No more spam! Robots can't go! Only human beings invited!\r\n\r\nThis plugin works pretty simple:\r\nWhile 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.");
-wchar_t const * infTalkProtPrefix = TranslateT("StopSpam automatic message:\r\n");
-char const * answeredSetting = "Answered";
-char const * questCountSetting = "QuestionCount";
+wchar_t *pluginDescription = TranslateT("No more spam! Robots can't go! Only human beings invited!\r\n\r\nThis plugin works pretty simple:\r\nWhile 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.");
+wchar_t const *infTalkProtPrefix = TranslateT("StopSpam automatic message:\r\n");
+char const *answeredSetting = "Answered";
+char const *questCountSetting = "QuestionCount";
INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
-
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
- {
SetDlgItemText(hwnd, ID_DESCRIPTION, pluginDescription);
TranslateDialogDefault(hwnd);
SetDlgItemInt(hwnd, ID_MAXQUESTCOUNT, plSets->MaxQuestCount.Get(), FALSE);
@@ -21,32 +18,25 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
CheckDlgButton(hwnd, ID_NOTCASESENS, plSets->AnswNotCaseSens.Get() ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwnd, ID_REMOVE_TMP_ALL, plSets->RemTmpAll.Get() ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwnd, ID_HISTORY_LOG, plSets->HistLog.Get() ? BST_CHECKED : BST_UNCHECKED);
- }
- return TRUE;
- case WM_COMMAND:{
- switch (LOWORD(wParam))
- {
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
case ID_MAXQUESTCOUNT:
- {
if (EN_CHANGE != HIWORD(wParam) || (HWND)lParam != GetFocus())
return FALSE;
break;
- }
+
case ID_DESCRIPTION:
- {
return FALSE;
}
- }
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- }
- break;
+ break;
+
case WM_NOTIFY:
- {
NMHDR* nmhdr = (NMHDR*)lParam;
- switch (nmhdr->code)
- {
+ switch (nmhdr->code) {
case PSN_APPLY:
- {
plSets->MaxQuestCount = GetDlgItemInt(hwnd, ID_MAXQUESTCOUNT, nullptr, FALSE);
plSets->InfTalkProtection = (BST_CHECKED == IsDlgButtonChecked(hwnd, ID_INFTALKPROT));
plSets->AddPermanent = (BST_CHECKED == IsDlgButtonChecked(hwnd, ID_ADDPERMANENT));
@@ -54,11 +44,9 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
plSets->AnswNotCaseSens = (BST_CHECKED == IsDlgButtonChecked(hwnd, ID_NOTCASESENS));
plSets->RemTmpAll = (BST_CHECKED == IsDlgButtonChecked(hwnd, ID_REMOVE_TMP_ALL));
plSets->HistLog = (BST_CHECKED == IsDlgButtonChecked(hwnd, ID_HISTORY_LOG));
+ return TRUE;
}
- return TRUE;
- }
- }
- break;
+ break;
}
return FALSE;
}
@@ -66,10 +54,8 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
INT_PTR CALLBACK MessagesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
- {
TranslateDialogDefault(hwnd);
SetDlgItemString(hwnd, ID_QUESTION, plSets->Question.Get());
SetDlgItemString(hwnd, ID_ANSWER, plSets->Answer.Get());
@@ -78,54 +64,51 @@ INT_PTR CALLBACK MessagesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
SetDlgItemString(hwnd, ID_DIVIDER, plSets->AnswSplitString.Get());
variables_skin_helpbutton(hwnd, IDC_VARS);
ServiceExists(MS_VARS_FORMATSTRING) ? EnableWindow(GetDlgItem(hwnd, IDC_VARS), 1) : EnableWindow(GetDlgItem(hwnd, IDC_VARS), 0);
- }
- return TRUE;
+ return TRUE;
+
case WM_COMMAND:
- {
- switch (LOWORD(wParam))
- {
- case ID_QUESTION:
- case ID_ANSWER:
- case ID_AUTHREPL:
- case ID_CONGRATULATION:
- case ID_DIVIDER:
{
- if (EN_CHANGE != HIWORD(wParam) || (HWND)lParam != GetFocus())
- return FALSE;
- break;
- }
- case ID_RESTOREDEFAULTS:
- SetDlgItemString(hwnd, ID_QUESTION, plSets->Question.GetDefault());
- SetDlgItemString(hwnd, ID_ANSWER, plSets->Answer.GetDefault());
- SetDlgItemString(hwnd, ID_CONGRATULATION, plSets->Congratulation.GetDefault());
- SetDlgItemString(hwnd, ID_AUTHREPL, plSets->AuthRepl.GetDefault());
- SetDlgItemString(hwnd, ID_DIVIDER, plSets->AnswSplitString.GetDefault());
+ switch (LOWORD(wParam)) {
+ case ID_QUESTION:
+ case ID_ANSWER:
+ case ID_AUTHREPL:
+ case ID_CONGRATULATION:
+ case ID_DIVIDER:
+ if (EN_CHANGE != HIWORD(wParam) || (HWND)lParam != GetFocus())
+ return FALSE;
+ break;
+
+ case ID_RESTOREDEFAULTS:
+ SetDlgItemString(hwnd, ID_QUESTION, plSets->Question.GetDefault());
+ SetDlgItemString(hwnd, ID_ANSWER, plSets->Answer.GetDefault());
+ SetDlgItemString(hwnd, ID_CONGRATULATION, plSets->Congratulation.GetDefault());
+ SetDlgItemString(hwnd, ID_AUTHREPL, plSets->AuthRepl.GetDefault());
+ SetDlgItemString(hwnd, ID_DIVIDER, plSets->AnswSplitString.GetDefault());
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ return TRUE;
+
+ case IDC_VARS:
+ variables_showhelp(hwnd, msg, VHF_FULLDLG | VHF_SETLASTSUBJECT, nullptr, nullptr);
+ return TRUE;
+ }
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- return TRUE;
- case IDC_VARS:
- variables_showhelp(hwnd, msg, VHF_FULLDLG | VHF_SETLASTSUBJECT, nullptr, nullptr);
- return TRUE;
}
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- }
- break;
+ break;
+
case WM_NOTIFY:
- {
NMHDR* nmhdr = (NMHDR*)lParam;
- switch (nmhdr->code)
- {
+ switch (nmhdr->code) {
case PSN_APPLY:
- {
- plSets->Question = GetDlgItemString(hwnd, ID_QUESTION);
- plSets->Answer = GetDlgItemString(hwnd, ID_ANSWER);
- plSets->AuthRepl = GetDlgItemString(hwnd, ID_AUTHREPL);
- plSets->Congratulation = GetDlgItemString(hwnd, ID_CONGRATULATION);
- plSets->AnswSplitString = GetDlgItemString(hwnd, ID_DIVIDER);
- }
- return TRUE;
+ {
+ plSets->Question = GetDlgItemString(hwnd, ID_QUESTION);
+ plSets->Answer = GetDlgItemString(hwnd, ID_ANSWER);
+ plSets->AuthRepl = GetDlgItemString(hwnd, ID_AUTHREPL);
+ plSets->Congratulation = GetDlgItemString(hwnd, ID_CONGRATULATION);
+ plSets->AnswSplitString = GetDlgItemString(hwnd, ID_DIVIDER);
+ }
+ return TRUE;
}
- }
- break;
+ break;
}
return FALSE;
}
diff --git a/plugins/StopSpamPlus/src/settings.h b/plugins/StopSpamPlus/src/settings.h
index 8c364569b2..e1f7d00d02 100644
--- a/plugins/StopSpamPlus/src/settings.h
+++ b/plugins/StopSpamPlus/src/settings.h
@@ -61,28 +61,27 @@ public:
db_setting<bool> RemTmpAll;
db_setting<bool> HistLog;
- Settings():Question("Question",TranslateW(L"Spammers made me to install small anti-spam system you are now speaking with. "
- L"Please reply \"nospam\" without quotes and spaces if you want to contact me.\r\n"
- L"Внимание! Антиспам защита. Ответьте \"nospam\" без кавычек и пробелов, если хотите связаться со мной."))
- ,AuthRepl("AuthReply",TranslateW(L"StopSpam: send a message and reply to a anti-spam bot question.\r\n"
- L"Антиспам: отправьте сообщение и ответьте на вопрос антиспам системы."))
- ,Answer("Answer",L"nospam")
- ,Congratulation("Congratulation",TranslateW(L"Congratulations! You just passed human/robot test. Now you can write me a message.\r\n"
- L"Поздравляю! Вы прошли антиспам проверку. Теперь вы можете писать мне."))
- ,DisabledProtoList("DisabledProtoList","MetaContacts RSSNews")
- ,InfTalkProtection("InfTalkProtection", 1)
- ,AddPermanent("AddPermanent", 0)
- ,HandleAuthReq("HandleAuthReq", 0)
- ,MaxQuestCount("MaxQuestCount", 2)
- ,AnswNotCaseSens("AnswNotCaseSens", 1)
- ,AnswSplitString("AnswSplitString",L"|")
- ,RemTmpAll("RemTmpAll", 1)
- ,HistLog("HistLog", 0)
+ Settings():
+ Question("Question", TranslateW(L"Spammers made me to install small anti-spam system you are now speaking with. "
+ L"Please reply \"nospam\" without quotes and spaces if you want to contact me.")),
+ AuthRepl("AuthReply", TranslateW(L"StopSpam: send a message and reply to a anti-spam bot question.")),
+ Answer("Answer", L"nospam"),
+ Congratulation("Congratulation", TranslateW(L"Congratulations! You just passed human/robot test. Now you can write me a message.")),
+ DisabledProtoList("DisabledProtoList", "MetaContacts RSSNews"),
+ InfTalkProtection("InfTalkProtection", 1),
+ AddPermanent("AddPermanent", 0),
+ HandleAuthReq("HandleAuthReq", 0),
+ MaxQuestCount("MaxQuestCount", 2),
+ AnswNotCaseSens("AnswNotCaseSens", 1),
+ AnswSplitString("AnswSplitString", L"|"),
+ RemTmpAll("RemTmpAll", 1),
+ HistLog("HistLog", 0)
{
- const std::string& str = DisabledProtoList.Get();
- if ( !str.empty() && *(str.rbegin()) != ' ' )
- DisabledProtoList=DisabledProtoList.Get()+' ';
+ const std::string &str = DisabledProtoList.Get();
+ if (!str.empty() && *(str.rbegin()) != ' ')
+ DisabledProtoList = DisabledProtoList.Get() + ' ';
}
+
bool ProtoDisabled(std::string proto)
{
return std::string::npos != DisabledProtoList.Get().find(proto + " ");
diff --git a/plugins/StopSpamPlus/src/stdafx.h b/plugins/StopSpamPlus/src/stdafx.h
index 44c3d49d29..fa52b8e615 100644
--- a/plugins/StopSpamPlus/src/stdafx.h
+++ b/plugins/StopSpamPlus/src/stdafx.h
@@ -43,7 +43,6 @@ INT_PTR CALLBACK MessagesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
INT_PTR CALLBACK ProtoDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
//utils
-void SetDlgItemString(HWND hwndDlg, UINT idItem, std::string const &str);
void SetDlgItemString(HWND hwndDlg, UINT idItem, std::wstring const &str);
tstring &GetDlgItemString(HWND hwnd, int id);
bool IsExistMyMessage(MCONTACT hContact);
diff --git a/plugins/StopSpamPlus/src/utils.cpp b/plugins/StopSpamPlus/src/utils.cpp
index 562ac2a570..b542d91469 100644
--- a/plugins/StopSpamPlus/src/utils.cpp
+++ b/plugins/StopSpamPlus/src/utils.cpp
@@ -31,21 +31,15 @@ bool IsExistMyMessage(MCONTACT hContact)
return false;
}
-void SetDlgItemString(HWND hwndDlg, UINT idItem, std::string const &str)
-{
- SetDlgItemTextA(hwndDlg, idItem, str.c_str());
-}
-
void SetDlgItemString(HWND hwndDlg, UINT idItem, std::wstring const &str)
{
SetDlgItemTextW(hwndDlg, idItem, str.c_str());
}
-tstring variables_parse(tstring const &tstrFormat, MCONTACT hContact){
+tstring variables_parse(tstring const &tstrFormat, MCONTACT hContact)
+{
if (ServiceExists(MS_VARS_FORMATSTRING)) {
FORMATINFO fi;
- tstring tstrResult;
-
memset(&fi, 0, sizeof(fi));
fi.cbSize = sizeof(fi);
fi.tszFormat = wcsdup(tstrFormat.c_str());
@@ -54,7 +48,7 @@ tstring variables_parse(tstring const &tstrFormat, MCONTACT hContact){
wchar_t *tszParsed = (wchar_t *)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
free(fi.tszFormat);
if (tszParsed) {
- tstrResult = tszParsed;
+ tstring tstrResult = tszParsed;
mir_free(tszParsed);
return tstrResult;
}
@@ -69,6 +63,6 @@ tstring trim(const tstring &tstr, const tstring& trimChars)
if ((tstring::npos == s) || (tstring::npos == e))
return L"";
- else
- return tstr.substr(s, e - s + 1);
-} \ No newline at end of file
+
+ return tstr.substr(s, e - s + 1);
+}
diff --git a/plugins/StopSpamPlus/src/version.h b/plugins/StopSpamPlus/src/version.h
index f9ea518181..920c757277 100644
--- a/plugins/StopSpamPlus/src/version.h
+++ b/plugins/StopSpamPlus/src/version.h
@@ -1,14 +1,14 @@
-#define __MAJOR_VERSION 0
-#define __MINOR_VERSION 0
+#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 0
#define __RELEASE_NUM 1
-#define __BUILD_NUM 4
+#define __BUILD_NUM 5
#include <stdver.h>
#define __PLUGIN_NAME "StopSpam+"
#define __FILENAME "StopSpam.dll"
-#define __DESCRIPTION "Anti-spam plugin for Miranda NG."
-#define __AUTHOR "Roman Miklashevsky, A. Petkevich, Kosh&chka, persei"
+#define __DESCRIPTION "Anti-spam plugin for Miranda NG."
+#define __AUTHOR "Roman Miklashevsky, A. Petkevich, Kosh&chka, persei"
#define __AUTHOREMAIL "koshechka@miranda.im"
-#define __AUTHORWEB "https://miranda-ng.org/p/StopSpam/"
-#define __COPYRIGHT "© 2004-2010 Roman Miklashevsky, A. Petkevich, Kosh&chka, persei"
+#define __AUTHORWEB "https://miranda-ng.org/p/StopSpam/"
+#define __COPYRIGHT "© 2004-2010 Roman Miklashevsky, A. Petkevich, Kosh&chka, persei"