From 9a2481ebf1109adc4b626414108d92674793cd5d Mon Sep 17 00:00:00 2001 From: brain Date: Tue, 18 Mar 2008 23:32:58 +0000 Subject: Add support for CAP to this via multi-prefix. NOTE, the OnNamesList for this and others want refactoring, because theyre craq. Ask me sometime about the new way we have in mind for this. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9125 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_namesx.cpp | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/src/modules/m_namesx.cpp b/src/modules/m_namesx.cpp index 83541417b..a1ae48b70 100644 --- a/src/modules/m_namesx.cpp +++ b/src/modules/m_namesx.cpp @@ -12,6 +12,7 @@ */ #include "inspircd.h" +#include "m_cap.h" static const char* dummy = "ON"; @@ -24,8 +25,8 @@ class ModuleNamesX : public Module ModuleNamesX(InspIRCd* Me) : Module(Me) { - Implementation eventlist[] = { I_OnSyncUserMetaData, I_OnPreCommand, I_OnUserList, I_On005Numeric }; - ServerInstance->Modules->Attach(eventlist, this, 4); + Implementation eventlist[] = { I_OnSyncUserMetaData, I_OnPreCommand, I_OnUserList, I_On005Numeric, I_OnEvent }; + ServerInstance->Modules->Attach(eventlist, this, 5); } @@ -117,6 +118,44 @@ class ModuleNamesX : public Module } return 0; } + + virtual void OnEvent(Event *ev) + { + if (ev->GetEventID() == "cap_req") + { + CapData *data = (CapData *) ev->GetData(); + + std::vector::iterator it; + if ((it = std::find(data->wanted.begin(), data->wanted.end(), "multi-prefix")) != data->wanted.end()) + { + // we can handle this, so ACK it, and remove it from the wanted list + data->wanted.erase(it); + data->ack.push_back(*it); + data->user->Extend("NAMESX",dummy); + } + } + + if (ev->GetEventID() == "cap_ls") + { + CapData *data = (CapData *) ev->GetData(); + data->wanted.push_back("multi-prefix"); + } + + if (ev->GetEventID() == "cap_list") + { + CapData *data = (CapData *) ev->GetData(); + + if (data->user->GetExt("NAMESX")) + data->ack.push_back("multi-prefix"); + } + + if (ev->GetEventID() == "cap_clear") + { + CapData *data = (CapData *) ev->GetData(); + data->ack.push_back("-multi-prefix"); + data->user->Shrink("NAMESX"); + } + } }; MODULE_INIT(ModuleNamesX) -- cgit v1.2.3