summaryrefslogtreecommitdiff
path: root/include/modules
diff options
context:
space:
mode:
Diffstat (limited to 'include/modules')
-rw-r--r--include/modules/account.h27
-rw-r--r--include/modules/cap.h21
-rw-r--r--include/modules/httpd.h29
-rw-r--r--include/modules/sasl.h12
-rw-r--r--include/modules/spanningtree.h29
5 files changed, 80 insertions, 38 deletions
diff --git a/include/modules/account.h b/include/modules/account.h
index c00b044e4..0368127a6 100644
--- a/include/modules/account.h
+++ b/include/modules/account.h
@@ -22,16 +22,7 @@
#include <map>
#include <string>
-class AccountEvent : public Event
-{
- public:
- User* const user;
- const std::string account;
- AccountEvent(Module* me, User* u, const std::string& name)
- : Event(me, "account_login"), user(u), account(name)
- {
- }
-};
+#include "event.h"
typedef StringExtItem AccountExtItem;
@@ -39,3 +30,19 @@ inline AccountExtItem* GetAccountExtItem()
{
return static_cast<AccountExtItem*>(ServerInstance->Extensions.GetItem("accountname"));
}
+
+class AccountEventListener : public Events::ModuleEventListener
+{
+ public:
+ AccountEventListener(Module* mod)
+ : ModuleEventListener(mod, "event/account")
+ {
+ }
+
+ /** Called when a user logs in or logs out
+ * @param user User logging in or out
+ * @param newaccount New account name of the user or empty string if the user
+ * logged out
+ */
+ virtual void OnAccountChange(User* user, const std::string& newaccount) = 0;
+};
diff --git a/include/modules/cap.h b/include/modules/cap.h
index cc1cb8d8c..7aa60cd21 100644
--- a/include/modules/cap.h
+++ b/include/modules/cap.h
@@ -20,7 +20,9 @@
#pragma once
-class CapEvent : public Event
+#include "event.h"
+
+class CapEvent
{
public:
enum CapEventType
@@ -35,23 +37,27 @@ class CapEvent : public Event
std::vector<std::string> wanted;
std::vector<std::string> ack;
User* user;
- CapEvent(Module* sender, User* u, CapEventType capevtype) : Event(sender, "cap_request"), type(capevtype), user(u) {}
+ CapEvent(Module* sender, User* u, CapEventType capevtype) : type(capevtype), user(u) {}
};
-class GenericCap
+class GenericCap : public Events::ModuleEventListener
{
+ bool active;
+
public:
LocalIntExt ext;
const std::string cap;
GenericCap(Module* parent, const std::string& Cap)
- : ext("cap_" + Cap, ExtensionItem::EXT_USER, parent)
+ : Events::ModuleEventListener(parent, "event/cap")
+ , active(true)
+ , ext("cap_" + Cap, ExtensionItem::EXT_USER, parent)
, cap(Cap)
{
}
- void HandleEvent(Event& ev)
+ void OnCapEvent(CapEvent& ev) CXX11_OVERRIDE
{
- if (ev.id != "cap_request")
+ if (!active)
return;
CapEvent *data = static_cast<CapEvent*>(&ev);
@@ -87,4 +93,7 @@ class GenericCap
ext.set(data->user, 0);
}
}
+
+ void SetActive(bool newstate) { active = newstate; }
+ bool IsActive() const { return active; }
};
diff --git a/include/modules/httpd.h b/include/modules/httpd.h
index 86234d53f..b4b88bed5 100644
--- a/include/modules/httpd.h
+++ b/include/modules/httpd.h
@@ -24,6 +24,7 @@
#pragma once
#include "base.h"
+#include "event.h"
#include <string>
#include <sstream>
@@ -107,7 +108,7 @@ class HttpServerSocket;
/** This class represents a HTTP request.
*/
-class HTTPRequest : public Event
+class HTTPRequest
{
protected:
std::string type;
@@ -134,9 +135,9 @@ class HTTPRequest : public Event
* @param ip The IP address making the web request.
* @param pdata The post data (content after headers) received with the request, up to Content-Length in size
*/
- HTTPRequest(Module* me, const std::string &eventid, const std::string &request_type, const std::string &uri,
+ HTTPRequest(const std::string& request_type, const std::string& uri,
HTTPHeaders* hdr, HttpServerSocket* socket, const std::string &ip, const std::string &pdata)
- : Event(me, eventid), type(request_type), document(uri), ipaddr(ip), postdata(pdata), headers(hdr), sock(socket)
+ : type(request_type), document(uri), ipaddr(ip), postdata(pdata), headers(hdr), sock(socket)
{
}
@@ -237,3 +238,25 @@ class HTTPdAPI : public dynamic_reference<HTTPdAPIBase>
{
}
};
+
+class HTTPACLEventListener : public Events::ModuleEventListener
+{
+ public:
+ HTTPACLEventListener(Module* mod)
+ : ModuleEventListener(mod, "event/http-acl")
+ {
+ }
+
+ virtual ModResult OnHTTPACLCheck(HTTPRequest& req) = 0;
+};
+
+class HTTPRequestEventListener : public Events::ModuleEventListener
+{
+ public:
+ HTTPRequestEventListener(Module* mod)
+ : ModuleEventListener(mod, "event/http-request")
+ {
+ }
+
+ virtual ModResult OnHTTPRequest(HTTPRequest& req) = 0;
+};
diff --git a/include/modules/sasl.h b/include/modules/sasl.h
index 321711a68..0a7b19a70 100644
--- a/include/modules/sasl.h
+++ b/include/modules/sasl.h
@@ -19,13 +19,15 @@
#pragma once
-class SASLFallback : public Event
+#include "event.h"
+
+class SASLEventListener : public Events::ModuleEventListener
{
public:
- const parameterlist& params;
- SASLFallback(Module* me, const parameterlist& p)
- : Event(me, "sasl_fallback"), params(p)
+ SASLEventListener(Module* mod)
+ : ModuleEventListener(mod, "event/sasl")
{
- Send();
}
+
+ virtual void OnSASLAuth(const parameterlist& params) = 0;
};
diff --git a/include/modules/spanningtree.h b/include/modules/spanningtree.h
index 99f4f9fc4..e71cdf9d0 100644
--- a/include/modules/spanningtree.h
+++ b/include/modules/spanningtree.h
@@ -19,22 +19,23 @@
#pragma once
-struct AddServerEvent : public Event
-{
- const std::string servername;
- AddServerEvent(Module* me, const std::string& name)
- : Event(me, "new_server"), servername(name)
- {
- Send();
- }
-};
+#include "event.h"
-struct DelServerEvent : public Event
+class SpanningTreeEventListener : public Events::ModuleEventListener
{
- const std::string servername;
- DelServerEvent(Module* me, const std::string& name)
- : Event(me, "lost_server"), servername(name)
+ public:
+ SpanningTreeEventListener(Module* mod)
+ : ModuleEventListener(mod, "event/spanningtree")
{
- Send();
}
+
+ /** Fired when a server finishes burst
+ * @param server Server that recently linked and finished burst
+ */
+ virtual void OnServerLink(const Server* server) { }
+
+ /** Fired when a server splits
+ * @param server Server that split
+ */
+ virtual void OnServerSplit(const Server* server) { }
};