From a02bbd978031df7352f850cdfa568d9e7887e855 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 23 Jul 2018 18:02:52 +0300 Subject: fixes #1479 (StopSpam should update default phrases if langpack changed) --- plugins/StopSpamPlus/src/events.cpp | 4 ++-- plugins/StopSpamPlus/src/options.cpp | 14 +++++++++++--- plugins/StopSpamPlus/src/settings.cpp | 24 +++++++++++++++++++++--- plugins/StopSpamPlus/src/settings.h | 4 ++++ plugins/StopSpamPlus/src/version.h | 2 +- 5 files changed, 39 insertions(+), 9 deletions(-) (limited to 'plugins/StopSpamPlus') diff --git a/plugins/StopSpamPlus/src/events.cpp b/plugins/StopSpamPlus/src/events.cpp index 2c2a077b65..b56e108d9b 100644 --- a/plugins/StopSpamPlus/src/events.cpp +++ b/plugins/StopSpamPlus/src/events.cpp @@ -121,7 +121,7 @@ int OnDbEventFilterAdd(WPARAM w, LPARAM l) // send congratulation - char * buf = mir_utf8encodeW(variables_parse(g_sets.Congratulation, hContact).c_str()); + char * buf = mir_utf8encodeW(variables_parse(g_sets.getCongrats(), hContact).c_str()); ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)buf); mir_free(buf); @@ -137,7 +137,7 @@ int OnDbEventFilterAdd(WPARAM w, LPARAM l) const wchar_t *pwszPrefix = TranslateT("StopSpam automatic message:\r\n"); if ((!g_sets.InfTalkProtection || tstring::npos == message.find(pwszPrefix)) && (!g_sets.MaxQuestCount || db_get_dw(hContact, MODULENAME, questCountSetting, 0) < g_sets.MaxQuestCount)) { // send question - tstring q = pwszPrefix + variables_parse(g_sets.Question, hContact); + tstring q = pwszPrefix + variables_parse(g_sets.getQuestion(), hContact); char * buf = mir_utf8encodeW(q.c_str()); diff --git a/plugins/StopSpamPlus/src/options.cpp b/plugins/StopSpamPlus/src/options.cpp index 0773c23f4e..2bdc37c4b7 100644 --- a/plugins/StopSpamPlus/src/options.cpp +++ b/plugins/StopSpamPlus/src/options.cpp @@ -68,6 +68,10 @@ public: { variables_skin_helpbutton(m_hwnd, IDC_VARS); btnHelp.Enable(ServiceExists(MS_VARS_FORMATSTRING)); + + edtQuestion.SetText(g_sets.getQuestion()); + edtCongrat.SetText(g_sets.getCongrats()); + edtReply.SetText(g_sets.getReply()); return true; } @@ -78,9 +82,13 @@ public: void onRestore(CCtrlButton*) { - edtQuestion.SetText(g_sets.Question.Default()); - edtAnswer.SetText(g_sets.Answer.Default()); - edtCongrat.SetText(g_sets.Congratulation.Default()); + g_plugin.delSetting(g_sets.Answer.GetDBSettingName()); + g_plugin.delSetting(g_sets.Question.GetDBSettingName()); + g_plugin.delSetting(g_sets.Congratulation.GetDBSettingName()); + + edtQuestion.SetText(g_sets.getQuestion()); + edtAnswer.SetText(g_sets.Answer); + edtCongrat.SetText(g_sets.getCongrats()); edtReply.SetText(g_sets.AuthRepl.Default()); edtDivider.SetText(g_sets.AnswSplitString.Default()); diff --git a/plugins/StopSpamPlus/src/settings.cpp b/plugins/StopSpamPlus/src/settings.cpp index 0e133956d4..01d11c7570 100644 --- a/plugins/StopSpamPlus/src/settings.cpp +++ b/plugins/StopSpamPlus/src/settings.cpp @@ -5,10 +5,10 @@ Settings g_sets; ///////////////////////////////////////////////////////////////////////////////////////// Settings::Settings() : - Question(MODULENAME, "Question", TranslateW(L"Spammers made me to install small anti-spam system you are now speaking with. Please reply \"nospam\" without quotes and spaces if you want to contact me.")), - AuthRepl(MODULENAME, "AuthReply", TranslateW(L"StopSpam: send a message and reply to an anti-spam bot question.")), + Question(MODULENAME, "Question"), + AuthRepl(MODULENAME, "AuthReply"), Answer(MODULENAME, "Answer", L"nospam"), - Congratulation(MODULENAME, "Congratulation", TranslateW(L"Congratulations! You just passed human/robot test. Now you can write me a message.")), + Congratulation(MODULENAME, "Congratulation"), DisabledProtoList(MODULENAME, "DisabledProtoList", "MetaContacts RSSNews"), InfTalkProtection(MODULENAME, "InfTalkProtection", 1), AddPermanent(MODULENAME, "AddPermanent", 0), @@ -20,3 +20,21 @@ Settings::Settings() : HistLog(MODULENAME, "HistLog", 0) { } + +const wchar_t* Settings::getQuestion() +{ + const wchar_t *res = Question; + return (res != nullptr) ? res : TranslateW(L"Spammers made me to install small anti-spam system you are now speaking with. Please reply \"nospam\" without quotes and spaces if you want to contact me."); +} + +const wchar_t* Settings::getReply() +{ + const wchar_t *res = AuthRepl; + return (res != nullptr) ? res : TranslateW(L"StopSpam: send a message and reply to an anti-spam bot question."); +} + +const wchar_t* Settings::getCongrats() +{ + const wchar_t *res = Congratulation; + return (res != nullptr) ? res : TranslateW(L"Congratulations! You just passed human/robot test. Now you can write me a message."); +} diff --git a/plugins/StopSpamPlus/src/settings.h b/plugins/StopSpamPlus/src/settings.h index 683d7cb0c7..7d3e3218cb 100644 --- a/plugins/StopSpamPlus/src/settings.h +++ b/plugins/StopSpamPlus/src/settings.h @@ -9,6 +9,10 @@ struct Settings CMOption DisabledProtoList; CMOption MaxQuestCount; + const wchar_t* getQuestion(); + const wchar_t* getReply(); + const wchar_t* getCongrats(); + bool ProtoDisabled(const char *proto) { std::string temp(proto); temp += ' '; diff --git a/plugins/StopSpamPlus/src/version.h b/plugins/StopSpamPlus/src/version.h index 3349b2f3d2..3ce9c45789 100644 --- a/plugins/StopSpamPlus/src/version.h +++ b/plugins/StopSpamPlus/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 1 #define __RELEASE_NUM 0 -#define __BUILD_NUM 1 +#define __BUILD_NUM 2 #include -- cgit v1.2.3