summaryrefslogtreecommitdiff
path: root/modules/extra
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2014-04-20 14:35:14 -0400
committerAdam <Adam@anope.org>2014-04-20 14:35:14 -0400
commit26ac315192e0d8a04d50e910697ab794eedf0cc1 (patch)
treeb9916f14fe35ce5c4de95c4194ca4ea0cb30812f /modules/extra
parent0b6476f06ff9ce06545c421143c7d7163c750aa5 (diff)
New event system
Diffstat (limited to 'modules/extra')
-rw-r--r--modules/extra/m_ldap.cpp2
-rw-r--r--modules/extra/m_ldap_authentication.cpp23
-rw-r--r--modules/extra/m_ldap_oper.cpp9
-rw-r--r--modules/extra/m_mysql.cpp5
-rw-r--r--modules/extra/m_sasl_dh-aes.cpp6
-rw-r--r--modules/extra/m_sasl_dh-blowfish.cpp6
-rw-r--r--modules/extra/m_sql_authentication.cpp7
-rw-r--r--modules/extra/m_sql_log.cpp2
-rw-r--r--modules/extra/m_sql_oper.cpp4
-rw-r--r--modules/extra/m_sqlite.cpp1
-rw-r--r--modules/extra/m_ssl_gnutls.cpp6
-rw-r--r--modules/extra/m_ssl_openssl.cpp5
-rw-r--r--modules/extra/stats/cs_fantasy_top.cpp2
-rw-r--r--modules/extra/stats/m_chanstats.cpp4
14 files changed, 60 insertions, 22 deletions
diff --git a/modules/extra/m_ldap.cpp b/modules/extra/m_ldap.cpp
index eb5589032..1615d855c 100644
--- a/modules/extra/m_ldap.cpp
+++ b/modules/extra/m_ldap.cpp
@@ -444,11 +444,13 @@ class LDAPService : public LDAPProvider, public Thread, public Condition
};
class ModuleLDAP : public Module, public Pipe
+ , public EventHook<Event::ModuleUnload>
{
std::map<Anope::string, LDAPService *> LDAPServices;
public:
ModuleLDAP(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR)
+ , EventHook<Event::ModuleUnload>("OnModuleUnload")
{
me = this;
diff --git a/modules/extra/m_ldap_authentication.cpp b/modules/extra/m_ldap_authentication.cpp
index 1a4feb232..abd5cc33c 100644
--- a/modules/extra/m_ldap_authentication.cpp
+++ b/modules/extra/m_ldap_authentication.cpp
@@ -1,5 +1,6 @@
#include "module.h"
#include "modules/ldap.h"
+#include "modules/nickserv.h"
static Module *me;
@@ -104,7 +105,7 @@ class IdentifyInterface : public LDAPInterface
{
na = new NickAlias(ii->req->GetAccount(), new NickCore(ii->req->GetAccount()));
na->last_realname = ii->user ? ii->user->realname : ii->req->GetAccount();
- FOREACH_MOD(OnNickRegister, (ii->user, na));
+ NickServ::Event::OnNickRegister(&NickServ::Event::NickRegister::OnNickRegister, ii->user, na);
BotInfo *NickServ = Config->GetClient("NickServ");
if (ii->user && NickServ)
ii->user->SendMessage(NickServ, _("Your account \002%s\002 has been successfully created."), na->nick.c_str());
@@ -202,6 +203,10 @@ class OnRegisterInterface : public LDAPInterface
};
class NSIdentifyLDAP : public Module
+ , public EventHook<Event::PreCommand>
+ , public EventHook<Event::CheckAuthentication>
+ , public EventHook<Event::NickIdentify>
+ , public EventHook<NickServ::Event::NickRegister>
{
ServiceReference<LDAPProvider> ldap;
IdentifyInterface iinterface;
@@ -214,14 +219,20 @@ class NSIdentifyLDAP : public Module
Anope::string disable_register_reason;
Anope::string disable_email_reason;
public:
- NSIdentifyLDAP(const Anope::string &modname, const Anope::string &creator) :
- Module(modname, creator, EXTRA | VENDOR), ldap("LDAPProvider", "ldap/main"), iinterface(this), oninterface(this), orinterface(this),
- dn(this, "m_ldap_authentication_dn")
+
+ NSIdentifyLDAP(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR)
+ , EventHook<Event::PreCommand>("OnPreCommand", EventHook<Event::PreCommand>::Priority::FIRST)
+ , EventHook<Event::CheckAuthentication>("OnCheckAuthentication", EventHook<Event::CheckAuthentication>::Priority::FIRST)
+ , EventHook<Event::NickIdentify>("OnNickIdentify", EventHook<Event::NickIdentify>::Priority::FIRST)
+ , EventHook<NickServ::Event::NickRegister>("OnNickRegister", EventHook<NickServ::Event::NickRegister>::Priority::FIRST)
+ , ldap("LDAPProvider", "ldap/main")
+ , iinterface(this)
+ , oninterface(this)
+ , orinterface(this)
+ , dn(this, "m_ldap_authentication_dn")
{
me = this;
-
- ModuleManager::SetPriority(this, PRIORITY_FIRST);
}
void OnReload(Configuration::Conf *config) override
diff --git a/modules/extra/m_ldap_oper.cpp b/modules/extra/m_ldap_oper.cpp
index e265bfd9d..7c6db48f5 100644
--- a/modules/extra/m_ldap_oper.cpp
+++ b/modules/extra/m_ldap_oper.cpp
@@ -76,6 +76,8 @@ class IdentifyInterface : public LDAPInterface
};
class LDAPOper : public Module
+ , public EventHook<Event::NickIdentify>
+ , public EventHook<Event::DelCore>
{
ServiceReference<LDAPProvider> ldap;
IdentifyInterface iinterface;
@@ -85,8 +87,11 @@ class LDAPOper : public Module
Anope::string basedn;
Anope::string filter;
public:
- LDAPOper(const Anope::string &modname, const Anope::string &creator) :
- Module(modname, creator, EXTRA | VENDOR), ldap("LDAPProvider", "ldap/main"), iinterface(this)
+ LDAPOper(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR)
+ , EventHook<Event::NickIdentify>("OnNickIdentify")
+ , EventHook<Event::DelCore>("OnDelCore")
+ , ldap("LDAPProvider", "ldap/main")
+ , iinterface(this)
{
}
diff --git a/modules/extra/m_mysql.cpp b/modules/extra/m_mysql.cpp
index 808cdd264..d0db90195 100644
--- a/modules/extra/m_mysql.cpp
+++ b/modules/extra/m_mysql.cpp
@@ -153,7 +153,9 @@ class DispatcherThread : public Thread, public Condition
class ModuleSQL;
static ModuleSQL *me;
-class ModuleSQL : public Module, public Pipe
+class ModuleSQL : public Module
+ , public Pipe
+ , public EventHook<Event::ModuleUnload>
{
/* SQL connections */
std::map<Anope::string, MySQLService *> MySQLServices;
@@ -166,6 +168,7 @@ class ModuleSQL : public Module, public Pipe
DispatcherThread *DThread;
ModuleSQL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR)
+ , EventHook<Event::ModuleUnload>("OnModuleUnload")
{
me = this;
diff --git a/modules/extra/m_sasl_dh-aes.cpp b/modules/extra/m_sasl_dh-aes.cpp
index 0a73f7788..f3294bfc1 100644
--- a/modules/extra/m_sasl_dh-aes.cpp
+++ b/modules/extra/m_sasl_dh-aes.cpp
@@ -160,7 +160,7 @@ class DHAES : public Mechanism
return Err(sess, pubkey);
SASL::IdentifyRequest* req = new SASL::IdentifyRequest(this->owner, m.source, username, password);
- FOREACH_MOD(OnCheckAuthentication, (NULL, req));
+ Event::OnCheckAuthentication(&Event::CheckAuthentication::OnCheckAuthentication, nullptr, req);
req->Dispatch();
BN_free(pubkey);
@@ -174,8 +174,8 @@ class ModuleSASLDHAES : public Module
DHAES dhaes;
public:
- ModuleSASLDHAES(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR | EXTRA),
- dhaes(this)
+ ModuleSASLDHAES(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR | EXTRA)
+ , dhaes(this)
{
}
};
diff --git a/modules/extra/m_sasl_dh-blowfish.cpp b/modules/extra/m_sasl_dh-blowfish.cpp
index b310c1089..b32e8855e 100644
--- a/modules/extra/m_sasl_dh-blowfish.cpp
+++ b/modules/extra/m_sasl_dh-blowfish.cpp
@@ -170,7 +170,7 @@ class DHBS : public Mechanism
return Err(sess, pubkey);
SASL::IdentifyRequest* req = new SASL::IdentifyRequest(this->owner, m.source, username, password);
- FOREACH_MOD(OnCheckAuthentication, (NULL, req));
+ Event::OnCheckAuthentication(&Event::CheckAuthentication::OnCheckAuthentication, nullptr, req);
req->Dispatch();
BN_free(pubkey);
@@ -184,8 +184,8 @@ class ModuleSASLDHBS : public Module
DHBS dhbs;
public:
- ModuleSASLDHBS(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR | EXTRA),
- dhbs(this)
+ ModuleSASLDHBS(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR | EXTRA)
+ , dhbs(this)
{
}
};
diff --git a/modules/extra/m_sql_authentication.cpp b/modules/extra/m_sql_authentication.cpp
index b3c0fd6b7..65f0f2800 100644
--- a/modules/extra/m_sql_authentication.cpp
+++ b/modules/extra/m_sql_authentication.cpp
@@ -1,5 +1,6 @@
#include "module.h"
#include "modules/sql.h"
+#include "modules/nickserv.h"
static Module *me;
@@ -42,7 +43,7 @@ class SQLAuthenticationResult : public SQL::Interface
if (na == NULL)
{
na = new NickAlias(req->GetAccount(), new NickCore(req->GetAccount()));
- FOREACH_MOD(OnNickRegister, (user, na));
+ NickServ::Event::OnNickRegister(&NickServ::Event::NickRegister::OnNickRegister, user, na);
if (user && NickServ)
user->SendMessage(NickServ, _("Your account \002%s\002 has been successfully created."), na->nick.c_str());
}
@@ -66,6 +67,8 @@ class SQLAuthenticationResult : public SQL::Interface
};
class ModuleSQLAuthentication : public Module
+ , public EventHook<Event::PreCommand>
+ , public EventHook<Event::CheckAuthentication>
{
Anope::string engine;
Anope::string query;
@@ -75,6 +78,8 @@ class ModuleSQLAuthentication : public Module
public:
ModuleSQLAuthentication(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR)
+ , EventHook<Event::PreCommand>("OnPreCommand")
+ , EventHook<Event::CheckAuthentication>("OnCheckAuthentication")
{
me = this;
diff --git a/modules/extra/m_sql_log.cpp b/modules/extra/m_sql_log.cpp
index 475ff1253..496ecb5e6 100644
--- a/modules/extra/m_sql_log.cpp
+++ b/modules/extra/m_sql_log.cpp
@@ -11,12 +11,14 @@
#include "modules/sql.h"
class SQLLog : public Module
+ , public EventHook<Event::LogMessage>
{
std::set<Anope::string> inited;
Anope::string table;
public:
SQLLog(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR | EXTRA)
+ , EventHook<Event::LogMessage>("OnLogMessage")
{
}
diff --git a/modules/extra/m_sql_oper.cpp b/modules/extra/m_sql_oper.cpp
index 01d1fa174..90fab856a 100644
--- a/modules/extra/m_sql_oper.cpp
+++ b/modules/extra/m_sql_oper.cpp
@@ -90,6 +90,7 @@ class SQLOperResult : public SQL::Interface
};
class ModuleSQLOper : public Module
+ , public EventHook<Event::NickIdentify>
{
Anope::string engine;
Anope::string query;
@@ -97,7 +98,8 @@ class ModuleSQLOper : public Module
ServiceReference<SQL::Provider> SQL;
public:
- ModuleSQLOper(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR)
+ ModuleSQLOper(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR),
+ EventHook<Event::NickIdentify>("OnNickIdentify")
{
}
diff --git a/modules/extra/m_sqlite.cpp b/modules/extra/m_sqlite.cpp
index 1e9fdad7b..c0f503141 100644
--- a/modules/extra/m_sqlite.cpp
+++ b/modules/extra/m_sqlite.cpp
@@ -63,6 +63,7 @@ class ModuleSQLite : public Module
{
/* SQL connections */
std::map<Anope::string, SQLiteService *> SQLiteServices;
+
public:
ModuleSQLite(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR)
{
diff --git a/modules/extra/m_ssl_gnutls.cpp b/modules/extra/m_ssl_gnutls.cpp
index 8ad6ee684..492536c5c 100644
--- a/modules/extra/m_ssl_gnutls.cpp
+++ b/modules/extra/m_ssl_gnutls.cpp
@@ -293,6 +293,7 @@ namespace GnuTLS
}
class GnuTLSModule : public Module
+ , public EventHook<Event::PreServerConnect>
{
GnuTLS::Init libinit;
@@ -300,7 +301,10 @@ class GnuTLSModule : public Module
GnuTLS::X509CertCredentials *cred;
MySSLService service;
- GnuTLSModule(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), cred(NULL), service(this, "ssl")
+ GnuTLSModule(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR)
+ , EventHook<Event::PreServerConnect>("OnPreServerConnect")
+ , cred(NULL)
+ , service(this, "ssl")
{
me = this;
this->SetPermanent(true);
diff --git a/modules/extra/m_ssl_openssl.cpp b/modules/extra/m_ssl_openssl.cpp
index 4e35c0dbf..3344f1d28 100644
--- a/modules/extra/m_ssl_openssl.cpp
+++ b/modules/extra/m_ssl_openssl.cpp
@@ -81,13 +81,16 @@ class SSLSocketIO : public SocketIO
class SSLModule;
static SSLModule *me;
class SSLModule : public Module
+ , public EventHook<Event::PreServerConnect>
{
Anope::string certfile, keyfile;
public:
MySSLService service;
- SSLModule(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), service(this, "ssl")
+ SSLModule(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR)
+ , EventHook<Event::PreServerConnect>("OnPreServerConnect")
+ , service(this, "ssl")
{
me = this;
diff --git a/modules/extra/stats/cs_fantasy_top.cpp b/modules/extra/stats/cs_fantasy_top.cpp
index 7f4092fe2..540a4f3d9 100644
--- a/modules/extra/stats/cs_fantasy_top.cpp
+++ b/modules/extra/stats/cs_fantasy_top.cpp
@@ -151,7 +151,7 @@ class CSTop : public Module
{
source.Reply(_("%2lu \002%-16s\002 letters: %s, words: %s, lines: %s, smileys: %s, actions: %s"),
i+1, res.Get(i, "nick").c_str(), res.Get(i, "letters").c_str(),
- res.Get(i, "words").c_str(), res.Get(i, "line").c_str(),
+ res.Get(i, "words").c_str(), res.Get(i, "line").c_str(),
res.Get(i, "smileys").c_str(), res.Get(i, "actions").c_str());
}
}
diff --git a/modules/extra/stats/m_chanstats.cpp b/modules/extra/stats/m_chanstats.cpp
index a1674bce3..e80c3e456 100644
--- a/modules/extra/stats/m_chanstats.cpp
+++ b/modules/extra/stats/m_chanstats.cpp
@@ -20,7 +20,7 @@ class CommandCSSetChanstats : public Command
}
EventReturn MOD_RESULT;
- FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1]));
+ MOD_RESULT = Event::OnSetChannelOption(&Event::SetChannelOption::OnSetChannelOption, source, this, ci, params[1]);
if (MOD_RESULT == EVENT_STOP)
return;
@@ -73,7 +73,7 @@ class CommandNSSetChanstats : public Command
}
EventReturn MOD_RESULT;
- FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, na->nc, param));
+ MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, na->nc, param);
if (MOD_RESULT == EVENT_STOP)
return;