]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Add m_cap.* stuff, unfinished. Thanks for the initial advice nenolod :)
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 18 Mar 2008 20:18:16 +0000 (20:18 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 18 Mar 2008 20:18:16 +0000 (20:18 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9120 e03df62e-2008-0410-955e-edbf42e46eb7

src/modules/m_cap.cpp [new file with mode: 0644]
src/modules/m_cap.h [new file with mode: 0644]

diff --git a/src/modules/m_cap.cpp b/src/modules/m_cap.cpp
new file mode 100644 (file)
index 0000000..0a36a9b
--- /dev/null
@@ -0,0 +1,108 @@
+/*       +------------------------------------+
+ *       | Inspire Internet Relay Chat Daemon |
+ *       +------------------------------------+
+ *
+ *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
+ * This program is free but copyrighted software; see
+ *            the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+#include "inspircd.h"
+#include "m_cap.h"
+
+/* $ModDesc: Provides a pointless /dalinfo command, demo module */
+
+/*
+ *          std::string type;
+ *                   std::vector<std::string> parameters;
+ *                            User* user;
+ *                                     Module* creator;
+ */
+
+/** Handle /CAP
+ */
+class CommandCAP : public Command
+{
+       Module* Creator;
+ public:
+       /* Command 'dalinfo', takes no parameters and needs no special modes */
+       CommandCAP (InspIRCd* Instance, Module* mod) : Command(Instance,"CAP", 0, 1, true), Creator(mod)
+       {
+               this->source = "m_cap.so";
+       }
+
+       CmdResult Handle (const char* const* parameters, int pcnt, User *user)
+       {
+               irc::string subcommand = parameters[0];
+               if (subcommand == "REQ")
+               {
+                       CapData Data;
+                       Data.type = parameters[1];
+                       Data.user = user;
+                       Data.creator = this->Creator;
+                       Data.parameter = (pcnt > 1 ? parameters[1] : "");
+
+                       user->Extend("CAP_REGHOLD");
+                       Event event((char*) &Data, (Module*)this->Creator, "cap_req");
+                       event.Send(this->ServerInstance);
+               }
+               else if (subcommand == "END")
+               {
+                       user->Shrink("CAP_REGHOLD");
+               }
+               else if (subcommand == "LS")
+               {
+                       CapData Data;
+                       user->Extend("CAP_REGHOLD");
+                       Data.type = "LS";
+                       Data.user = user;
+                       Data.creator = this->Creator;
+                       Data.parameter.clear();
+
+                       Event event((char*) &Data, (Module*)this->Creator, "cap_ls");
+                       event.Send(this->ServerInstance);
+               }
+               return CMD_FAILURE;
+       }
+};
+
+class ModuleCAP : public Module
+{
+       CommandCAP* newcommand;
+ public:
+       ModuleCAP(InspIRCd* Me)
+               : Module(Me)
+       {
+               // Create a new command
+               newcommand = new CommandCAP(ServerInstance, this);
+               ServerInstance->AddCommand(newcommand);
+
+               Implementation eventlist[] = { I_OnCheckReady, I_OnCleanup, I_OnUserDisconnect, I_OnRequest };
+               ServerInstance->Modules->Attach(eventlist, this, 5);
+       }
+
+       virtual bool OnCheckReady(User* user)
+       {
+               /* Users in CAP state get held until CAP END */
+               if (user->GetExt("CAP_REGHOLD"))
+                       return true;
+
+               return false;
+       }
+
+       virtual ~ModuleCAP()
+       {
+       }
+
+       virtual Version GetVersion()
+       {
+               return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
+       }
+};
+
+MODULE_INIT(ModuleCAP)
+
diff --git a/src/modules/m_cap.h b/src/modules/m_cap.h
new file mode 100644 (file)
index 0000000..1495289
--- /dev/null
@@ -0,0 +1,29 @@
+/*       +------------------------------------+
+ *       | Inspire Internet Relay Chat Daemon |
+ *       +------------------------------------+
+ *
+ *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
+ * This program is free but copyrighted software; see
+ *            the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+#ifndef __CAP_H__
+#define __CAP_H__
+
+#include <map>
+#include <string>
+
+class CapData
+{
+ public:
+       irc::string type;
+       irc::string parameter;
+       User* user;
+       Module* creator;
+};
+
+#endif