summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-03-18 23:32:58 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-03-18 23:32:58 +0000
commit9a2481ebf1109adc4b626414108d92674793cd5d (patch)
tree17f60028bf51e84a4cbc9213ad99843a4145ee6c /src
parent93425ec211be8185fa9a428dcb24bc8b8121f917 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_namesx.cpp43
1 files 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<std::string>::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)