From a991e99b78a5f3c1fbd42e9b6cc4bfc7b30e83b6 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 16 Nov 2017 22:26:08 +0300 Subject: TranslateT for global data is a very bad idea --- plugins/StopSpamPlus/src/events.cpp | 5 +++-- plugins/StopSpamPlus/src/options.cpp | 6 +++--- plugins/StopSpamPlus/src/stdafx.h | 6 ++---- 3 files changed, 8 insertions(+), 9 deletions(-) (limited to 'plugins') diff --git a/plugins/StopSpamPlus/src/events.cpp b/plugins/StopSpamPlus/src/events.cpp index 2810d8d68d..6b5c95a53c 100644 --- a/plugins/StopSpamPlus/src/events.cpp +++ b/plugins/StopSpamPlus/src/events.cpp @@ -132,11 +132,12 @@ int OnDbEventFilterAdd(WPARAM w, LPARAM l) // if message message does not contain infintite talk protection prefix // and question count for this contact is less then maximum - if ((!plSets->InfTalkProtection.Get() || tstring::npos == message.find(infTalkProtPrefix)) + const wchar_t *pwszPrefix = TranslateT("StopSpam automatic message:\r\n"); + if ((!plSets->InfTalkProtection.Get() || tstring::npos == message.find(pwszPrefix)) && (!plSets->MaxQuestCount.Get() || db_get_dw(hContact, pluginName, questCountSetting, 0) < plSets->MaxQuestCount.Get())) { // send question - tstring q = infTalkProtPrefix + variables_parse((tstring)(plSets->Question), hContact); + tstring q = pwszPrefix + variables_parse((tstring)(plSets->Question), hContact); char * buf = mir_utf8encodeW(q.c_str()); diff --git a/plugins/StopSpamPlus/src/options.cpp b/plugins/StopSpamPlus/src/options.cpp index 5f70f6a8d6..af9f587e4c 100644 --- a/plugins/StopSpamPlus/src/options.cpp +++ b/plugins/StopSpamPlus/src/options.cpp @@ -1,7 +1,7 @@ #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"); +const wchar_t pluginDescription[] = LPGENW("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."); + char const *answeredSetting = "Answered"; char const *questCountSetting = "QuestionCount"; @@ -9,7 +9,7 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: - SetDlgItemText(hwnd, ID_DESCRIPTION, pluginDescription); + SetDlgItemText(hwnd, ID_DESCRIPTION, TranslateW(pluginDescription)); TranslateDialogDefault(hwnd); SetDlgItemInt(hwnd, ID_MAXQUESTCOUNT, plSets->MaxQuestCount.Get(), FALSE); CheckDlgButton(hwnd, ID_INFTALKPROT, plSets->InfTalkProtection.Get() ? BST_CHECKED : BST_UNCHECKED); diff --git a/plugins/StopSpamPlus/src/stdafx.h b/plugins/StopSpamPlus/src/stdafx.h index fa52b8e615..4b25fba17b 100644 --- a/plugins/StopSpamPlus/src/stdafx.h +++ b/plugins/StopSpamPlus/src/stdafx.h @@ -31,10 +31,8 @@ typedef std::wstring tstring; #define pluginName LPGEN("StopSpam") -extern wchar_t * pluginDescription; -extern wchar_t const * infTalkProtPrefix; -extern char const * answeredSetting; -extern char const * questCountSetting; +extern char const *answeredSetting; +extern char const *questCountSetting; extern HINSTANCE hInst; //options -- cgit v1.2.3