]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_noctcp.cpp
Header update: 2007 -> 2008
[user/henk/code/inspircd.git] / src / modules / m_noctcp.cpp
index 029a950651e51127a1ba0c6ae39e5d8e0030895d..9124ffa639f1aa7f3bb912d627b8405ffef9163c 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
  * See: http://www.inspircd.org/wiki/index.php/Credits
  *
  * This program is free but copyrighted software; see
  * ---------------------------------------------------
  */
 
-#include "users.h"
-#include "channels.h"
-#include "modules.h"
 #include "inspircd.h"
 
 /* $ModDesc: Provides support for unreal-style channel mode +c */
 
-
-
 class NoCTCP : public ModeHandler
 {
  public:
        NoCTCP(InspIRCd* Instance) : ModeHandler(Instance, 'C', 0, 0, false, MODETYPE_CHANNEL, false) { }
 
-       ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
+       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
        {
                if (adding)
                {
@@ -56,29 +51,27 @@ class ModuleNoCTCP : public Module
  public:
  
        ModuleNoCTCP(InspIRCd* Me)
-               : Module::Module(Me)
+               : Module(Me)
        {
                
                nc = new NoCTCP(ServerInstance);
-               if (!ServerInstance->AddMode(nc, 'C'))
+               if (!ServerInstance->AddMode(nc))
                        throw ModuleException("Could not add new modes!");
+               Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice };
+               ServerInstance->Modules->Attach(eventlist, this, 2);
        }
 
-       void Implements(char* List)
-       {
-               List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
-       }
 
-       virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
+       virtual int OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
        {
                return OnUserPreNotice(user,dest,target_type,text,status,exempt_list);
        }
        
-       virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
+       virtual int OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
        {
                if ((target_type == TYPE_CHANNEL) && (IS_LOCAL(user)))
                {
-                       chanrec* c = (chanrec*)dest;
+                       Channel* c = (Channel*)dest;
                        if (c->IsModeSet('C'))
                        {
                                if ((text.length()) && (text[0] == '\1'))
@@ -97,7 +90,7 @@ class ModuleNoCTCP : public Module
        virtual ~ModuleNoCTCP()
        {
                ServerInstance->Modes->DelMode(nc);
-               DELETE(nc);
+               delete nc;
        }
 
        virtual Version GetVersion()
@@ -106,28 +99,4 @@ class ModuleNoCTCP : public Module
        }
 };
 
-
-class ModuleNoCTCPFactory : public ModuleFactory
-{
- public:
-       ModuleNoCTCPFactory()
-       {
-       }
-       
-       ~ModuleNoCTCPFactory()
-       {
-       }
-       
-       virtual Module * CreateModule(InspIRCd* Me)
-       {
-               return new ModuleNoCTCP(Me);
-       }
-       
-};
-
-
-extern "C" void * init_module( void )
-{
-       return new ModuleNoCTCPFactory;
-}
-
+MODULE_INIT(ModuleNoCTCP)