From 3c8009b4950a670618c3ee476f21f67a9468fdb2 Mon Sep 17 00:00:00 2001 From: Daniel Vassdal Date: Thu, 13 Feb 2014 09:29:39 -0800 Subject: sasl.h, m_sasl.cpp: Add RemoveSession(), DeleteSessions(), and have active sessions closed when a Mechanism is unloaded --- include/modules/sasl.h | 56 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 22 deletions(-) (limited to 'include/modules/sasl.h') diff --git a/include/modules/sasl.h b/include/modules/sasl.h index 836c26d19..f997ead76 100644 --- a/include/modules/sasl.h +++ b/include/modules/sasl.h @@ -18,6 +18,29 @@ namespace SASL }; class Mechanism; + struct Session; + + class Service : public ::Service + { + public: + Service(Module *o) : ::Service(o, "SASL::Service", "sasl") { } + + virtual void ProcessMessage(const Message &) = 0; + + virtual Anope::string GetAgent() = 0; + + virtual Session* GetSession(const Anope::string &uid) = 0; + + virtual void SendMessage(SASL::Session *session, const Anope::string &type, const Anope::string &data) = 0; + + virtual void Succeed(Session *, NickCore *) = 0; + virtual void Fail(Session *) = 0; + virtual void SendMechs(Session *) = 0; + virtual void DeleteSessions(Mechanism *, bool = false) = 0; + virtual void RemoveSession(Session *) = 0; + }; + + static ServiceReference sasl("SASL::Service", "sasl"); struct Session { @@ -26,11 +49,15 @@ namespace SASL Reference mech; Session(Mechanism *m, const Anope::string &u) : created(Anope::CurTime), uid(u), mech(m) { } - virtual ~Session() { } + virtual ~Session() + { + if (sasl) + sasl->RemoveSession(this); + } }; /* PLAIN, EXTERNAL, etc */ - class Mechanism : public Service + class Mechanism : public ::Service { public: Mechanism(Module *o, const Anope::string &sname) : Service(o, "SASL::Mechanism", sname) { } @@ -38,26 +65,11 @@ namespace SASL virtual Session* CreateSession(const Anope::string &uid) { return new Session(this, uid); } virtual void ProcessMessage(Session *session, const Message &) = 0; - }; - - class Service : public ::Service - { - public: - Service(Module *o) : ::Service(o, "SASL::Service", "sasl") { } - - virtual void ProcessMessage(const Message &) = 0; - - virtual Anope::string GetAgent() = 0; - virtual Session* GetSession(const Anope::string &uid) = 0; - - virtual void SendMessage(SASL::Session *session, const Anope::string &type, const Anope::string &data) = 0; - - virtual void Succeed(Session *, NickCore *) = 0; - virtual void Fail(Session *) = 0; - virtual void SendMechs(Session *) = 0; + virtual ~Mechanism() + { + if (sasl) + sasl->DeleteSessions(this, true); + } }; } - -static ServiceReference sasl("SASL::Service", "sasl"); - -- cgit