summaryrefslogtreecommitdiff
path: root/plugins/StopSpamMod
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/StopSpamMod')
-rwxr-xr-xplugins/StopSpamMod/src/eventhooker.cpp67
-rwxr-xr-xplugins/StopSpamMod/src/eventhooker.h46
-rwxr-xr-xplugins/StopSpamMod/src/init.cpp8
-rwxr-xr-xplugins/StopSpamMod/src/options.cpp3
-rwxr-xr-xplugins/StopSpamMod/src/stdafx.h6
-rwxr-xr-xplugins/StopSpamMod/src/stopspam.cpp6
6 files changed, 15 insertions, 121 deletions
diff --git a/plugins/StopSpamMod/src/eventhooker.cpp b/plugins/StopSpamMod/src/eventhooker.cpp
deleted file mode 100755
index d9b9296bfe..0000000000
--- a/plugins/StopSpamMod/src/eventhooker.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/* eventhooker.cpp
-* Copyright (C) Miklashevsky Roman, sss, elzor
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "stdafx.h"
-
-namespace miranda
-{
- namespace
- {
- std::list<EventHooker*> eventHookerList;
- }
-
- EventHooker::EventHooker(std::string name, MIRANDAHOOK fun) : name_(name), fun_(fun), handle_(0)
- {
- eventHookerList.push_back(this);
- }
-
- EventHooker::~EventHooker()
- {
- eventHookerList.remove(this);
- }
-
- void EventHooker::Hook()
- {
- handle_ = HookEvent(name_.c_str(), fun_);
- }
-
- void EventHooker::Unhook()
- {
- if(handle_)
- {
- UnhookEvent(handle_);
- handle_ = 0;
- }
- }
-
- void EventHooker::HookAll()
- {
- for(std::list<EventHooker*>::iterator it = eventHookerList.begin(); it != eventHookerList.end(); ++it)
- {
- (*it)->Hook();
- }
- }
-
- void EventHooker::UnhookAll()
- {
- for(std::list<EventHooker*>::iterator it = eventHookerList.begin(); it != eventHookerList.end(); ++it)
- {
- (*it)->Unhook();
- }
- }
-}
diff --git a/plugins/StopSpamMod/src/eventhooker.h b/plugins/StopSpamMod/src/eventhooker.h
deleted file mode 100755
index 4a5ef3b9fc..0000000000
--- a/plugins/StopSpamMod/src/eventhooker.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* eventhooker.h - Helper for hooking events in Miranda.
-* Copyright (C) Miklashevsky Roman, sss, elzor
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#ifndef EVENTHOOKER_H_C8EAA58A_7C4D_45f7_A88E_0E41FE93754D
-#define EVENTHOOKER_H_C8EAA58A_7C4D_45f7_A88E_0E41FE93754D
-
-namespace miranda
-{
-
-#define MIRANDA_HOOK_EVENT(NAME, WPARAMNAME, LPARAMNAME) \
- int NAME##_Handler(WPARAM,LPARAM);\
- miranda::EventHooker NAME##_Hooker(NAME, NAME##_Handler);\
- int NAME##_Handler(WPARAM WPARAMNAME, LPARAM LPARAMNAME)
-
- struct EventHooker
- {
- EventHooker(std::string name, MIRANDAHOOK fun);
- ~EventHooker();
- void Hook();
- void Unhook();
- static void HookAll();
- static void UnhookAll();
- private:
- std::string name_;
- MIRANDAHOOK fun_;
- HANDLE handle_;
- };
-
-}
-
-#endif
diff --git a/plugins/StopSpamMod/src/init.cpp b/plugins/StopSpamMod/src/init.cpp
index 29f753168f..aeac374fd9 100755
--- a/plugins/StopSpamMod/src/init.cpp
+++ b/plugins/StopSpamMod/src/init.cpp
@@ -17,6 +17,8 @@
#include "stdafx.h"
+HINSTANCE hInst;
+
BOOL gbDosServiceExist = 0;
BOOL gbVarsServiceExist = 0;
@@ -145,6 +147,10 @@ extern "C" int __declspec(dllexport) Load()
CreateServiceFunction("/RemoveTmp", (MIRANDASERVICE)RemoveTmp);
HookEvent(ME_SYSTEM_MODULESLOADED, OnSystemModulesLoaded);
+ HookEvent(ME_DB_EVENT_ADDED, OnDbEventAdded);
+ HookEvent(ME_DB_EVENT_FILTER_ADD, OnDbEventFilterAdd);
+ HookEvent(ME_DB_CONTACT_SETTINGCHANGED, OnDbContactSettingChanged);
+ HookEvent(ME_OPT_INITIALISE, OnOptInit);
CMenuItem mi;
SET_UID(mi, 0x60ce7660, 0x5a5, 0x4234, 0x99, 0xb6, 0x55, 0x21, 0xed, 0xa0, 0xb8, 0x32);
@@ -155,12 +161,10 @@ extern "C" int __declspec(dllexport) Load()
Menu_AddMainMenuItem(&mi);
- miranda::EventHooker::HookAll();
return 0;
}
extern "C" int __declspec(dllexport) Unload(void)
{
- miranda::EventHooker::UnhookAll();
return 0;
}
diff --git a/plugins/StopSpamMod/src/options.cpp b/plugins/StopSpamMod/src/options.cpp
index ba5fd494cb..cfb15f66c3 100755
--- a/plugins/StopSpamMod/src/options.cpp
+++ b/plugins/StopSpamMod/src/options.cpp
@@ -312,8 +312,7 @@ INT_PTR CALLBACK AdvancedDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
return FALSE;
}
-HINSTANCE hInst;
-MIRANDA_HOOK_EVENT(ME_OPT_INITIALISE, w, l)
+int OnOptInit(WPARAM w, LPARAM l)
{
UNREFERENCED_PARAMETER(l);
diff --git a/plugins/StopSpamMod/src/stdafx.h b/plugins/StopSpamMod/src/stdafx.h
index 378384ff09..9f5b3612ee 100755
--- a/plugins/StopSpamMod/src/stdafx.h
+++ b/plugins/StopSpamMod/src/stdafx.h
@@ -27,7 +27,6 @@ using namespace std;
#include "globals.h"
#include "stopspam.h"
-#include "eventhooker.h"
#include "version.h"
#include "resource.h"
#include "utilities.h"
@@ -35,3 +34,8 @@ using namespace std;
extern HINSTANCE hInst;
extern HANDLE hStopSpamLogDirH;
+
+int OnDbContactSettingChanged(WPARAM w, LPARAM l);
+int OnDbEventFilterAdd(WPARAM w, LPARAM l);
+int OnDbEventAdded(WPARAM hContact, LPARAM hDbEvent);
+int OnOptInit(WPARAM w, LPARAM l); \ No newline at end of file
diff --git a/plugins/StopSpamMod/src/stopspam.cpp b/plugins/StopSpamMod/src/stopspam.cpp
index a2571810f9..d4823b49af 100755
--- a/plugins/StopSpamMod/src/stopspam.cpp
+++ b/plugins/StopSpamMod/src/stopspam.cpp
@@ -17,7 +17,7 @@
#include "stdafx.h"
-MIRANDA_HOOK_EVENT(ME_DB_EVENT_ADDED, hContact, hDbEvent)
+int OnDbEventAdded(WPARAM hContact, LPARAM hDbEvent)
{
DBEVENTINFO dbei = {};
dbei.cbBlob = db_event_getBlobSize(hDbEvent);
@@ -70,7 +70,7 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_ADDED, hContact, hDbEvent)
return 0;
}
-MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l)
+int OnDbEventFilterAdd(WPARAM w, LPARAM l)
{
MCONTACT hContact = (MCONTACT)w;
if (!l) //fix potential DEP crash
@@ -297,7 +297,7 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l)
return 1;
}
-MIRANDA_HOOK_EVENT(ME_DB_CONTACT_SETTINGCHANGED, w, l)
+int OnDbContactSettingChanged(WPARAM w, LPARAM l)
{
MCONTACT hContact = (MCONTACT)w;
DBCONTACTWRITESETTING * cws = (DBCONTACTWRITESETTING*)l;