diff options
author | George Hazan <ghazan@miranda.im> | 2018-11-13 20:23:17 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-11-13 20:23:17 +0300 |
commit | 54e2d0c216f73e368eeb96dc43f8de233f1a6027 (patch) | |
tree | 76ff7d1bc46bc8ed7f455124e598432908f9115c | |
parent | b81af5bb151e516e40742a71922ed031e26832af (diff) |
StopSpam -> g_plugin
-rw-r--r-- | plugins/StopSpamPlus/src/events.cpp | 21 | ||||
-rw-r--r-- | plugins/StopSpamPlus/src/services.cpp | 2 | ||||
-rw-r--r-- | plugins/StopSpamPlus/src/stdafx.h | 5 | ||||
-rw-r--r-- | plugins/StopSpamPlus/src/utils.cpp | 4 |
4 files changed, 15 insertions, 17 deletions
diff --git a/plugins/StopSpamPlus/src/events.cpp b/plugins/StopSpamPlus/src/events.cpp index e5875f9407..ad96474d80 100644 --- a/plugins/StopSpamPlus/src/events.cpp +++ b/plugins/StopSpamPlus/src/events.cpp @@ -1,8 +1,5 @@ #include "stdafx.h"
-char const *answeredSetting = "Answered";
-char const *questCountSetting = "QuestionCount";
-
int OnDbEventAdded(WPARAM, LPARAM lParam)
{
MEVENT hDbEvent = (MEVENT)lParam;
@@ -26,7 +23,7 @@ int OnDbEventAdded(WPARAM, LPARAM lParam) // if request is from unknown or not marked Answered contact
//and if I don't sent message to this contact
- if (db_get_b(hcntct, "CList", "NotOnList", 0) && !db_get_b(hcntct, MODULENAME, answeredSetting, 0) && !IsExistMyMessage(hcntct)) {
+ if (db_get_b(hcntct, "CList", "NotOnList", 0) && !g_plugin.getByte(hcntct, DB_KEY_ANSWERED) && !IsExistMyMessage(hcntct)) {
if (!g_sets.HandleAuthReq) {
char *buf = mir_utf8encodeW(variables_parse(g_sets.getReply(), hcntct).c_str());
ProtoChainSend(hcntct, PSS_MESSAGE, 0, (LPARAM)buf);
@@ -64,7 +61,7 @@ int OnDbEventFilterAdd(WPARAM w, LPARAM l) return 0;
// if message is from known or marked Answered contact
- if (db_get_b(hContact, MODULENAME, answeredSetting, 0))
+ if (g_plugin.getByte(hContact, DB_KEY_ANSWERED))
// ...let the event go its way
return 0;
@@ -111,7 +108,7 @@ int OnDbEventFilterAdd(WPARAM w, LPARAM l) db_unset(hContact, "CList", "Hidden");
// mark contact as Answered
- db_set_b(hContact, MODULENAME, answeredSetting, 1);
+ g_plugin.setByte(hContact, DB_KEY_ANSWERED, 1);
//add contact permanently
if (g_sets.AddPermanent)
@@ -133,7 +130,7 @@ 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
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)) {
+ if ((!g_sets.InfTalkProtection || tstring::npos == message.find(pwszPrefix)) && (!g_sets.MaxQuestCount || g_plugin.getDword(hContact, DB_KEY_QUESTCOUNT) < g_sets.MaxQuestCount)) {
// send question
tstring q = pwszPrefix + variables_parse(g_sets.getQuestion(), hContact);
@@ -144,8 +141,8 @@ int OnDbEventFilterAdd(WPARAM w, LPARAM l) // increment question count
- DWORD questCount = db_get_dw(hContact, MODULENAME, questCountSetting, 0);
- db_set_dw(hContact, MODULENAME, questCountSetting, questCount + 1);
+ DWORD questCount = g_plugin.getDword(hContact, DB_KEY_QUESTCOUNT);
+ g_plugin.setDword(hContact, DB_KEY_QUESTCOUNT, questCount + 1);
}
// hide contact from contact list
@@ -164,15 +161,15 @@ int OnDbContactSettingchanged(WPARAM hContact, LPARAM l) {
DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)l;
- // if CList/NotOnList is being deleted then remove answeredSetting
+ // if CList/NotOnList is being deleted then remove DB_KEY_ANSWERED
if (strcmp(cws->szModule, "CList"))
return 0;
if (strcmp(cws->szSetting, "NotOnList"))
return 0;
if (!cws->value.type) {
- db_unset(hContact, MODULENAME, answeredSetting);
- db_unset(hContact, MODULENAME, questCountSetting);
+ g_plugin.delSetting(hContact, DB_KEY_ANSWERED);
+ g_plugin.delSetting(hContact, DB_KEY_QUESTCOUNT);
}
return 0;
diff --git a/plugins/StopSpamPlus/src/services.cpp b/plugins/StopSpamPlus/src/services.cpp index 053461b9ae..0c640fee6a 100644 --- a/plugins/StopSpamPlus/src/services.cpp +++ b/plugins/StopSpamPlus/src/services.cpp @@ -9,7 +9,7 @@ INT_PTR IsContactPassed(WPARAM hContact, LPARAM /*lParam*/) if (!g_sets.ProtoDisabled(szProto))
return CS_PASSED;
- if (db_get_b(hContact, MODULENAME, answeredSetting, 0))
+ if (g_plugin.getByte(hContact, DB_KEY_ANSWERED))
return CS_PASSED;
if (!db_get_b(hContact, "CList", "NotOnList", 0) && db_get_w(hContact, szProto, "SrvGroupId", -1) != 1)
diff --git a/plugins/StopSpamPlus/src/stdafx.h b/plugins/StopSpamPlus/src/stdafx.h index 6545486713..c3b187c5dc 100644 --- a/plugins/StopSpamPlus/src/stdafx.h +++ b/plugins/StopSpamPlus/src/stdafx.h @@ -31,6 +31,9 @@ typedef std::wstring tstring; #define MODULENAME LPGEN("StopSpam")
+#define DB_KEY_ANSWERED "Answered"
+#define DB_KEY_QUESTCOUNT "QuestionCount"
+
struct CMPlugin : public PLUGIN<CMPlugin>
{
CMPlugin();
@@ -38,8 +41,6 @@ struct CMPlugin : public PLUGIN<CMPlugin> int Load() override;
};
-extern char const *answeredSetting;
-
// utils
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 6fb2233318..e01f73802e 100644 --- a/plugins/StopSpamPlus/src/utils.cpp +++ b/plugins/StopSpamPlus/src/utils.cpp @@ -1,6 +1,6 @@ #include "stdafx.h"
-tstring &GetDlgItemString(HWND hwnd, int id)
+tstring& GetDlgItemString(HWND hwnd, int id)
{
HWND h = GetDlgItem(hwnd, id);
int len = GetWindowTextLength(h);
@@ -22,7 +22,7 @@ bool IsExistMyMessage(MCONTACT hContact) if (dbei.flags & DBEF_SENT){
// mark contact as Answered
- db_set_b(hContact, MODULENAME, answeredSetting, 1);
+ g_plugin.setByte(hContact, DB_KEY_ANSWERED, 1);
// ...let the event go its way
return true;
}
|