]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_inviteexception.cpp
Annotations
[user/henk/code/inspircd.git] / src / modules / m_inviteexception.cpp
index d5cb15ea5c0f5aec347ccf4d8a433e84046d6256..bcb2d7d6d03e01d0c6b2f8055d2334c014b74925 100644 (file)
@@ -5,7 +5,7 @@
 #include "channels.h"
 #include "modules.h"
 #include "mode.h"
-#include "helperfuncs.h"
+
 #include "u_listmode.h"
 
 /* $ModDesc: Provides support for the +I channel mode */
  * ignoring if +i is set on the channel
  */
 
+class InspIRCd* ServerInstance;
+
+/** Handles channel mode +I
+ */
 class InviteException : public ListModeBase
 {
  public:
-       InviteException(Server* serv) : ListModeBase(serv, 'I', "End of Channel Invite Exception List", "346", "347") { }
+       InviteException(InspIRCd* Instance) : ListModeBase(Instance, 'I', "End of Channel Invite Exception List", "346", "347", true) { }
 };
 
 class ModuleInviteException : public Module
 {
        InviteException* ie;
-       Server* Srv;
-
 public:
-       ModuleInviteException(Server* serv) : Module(serv)
+       ModuleInviteException(InspIRCd* Me) : Module(Me)
        {
-               ie = new InviteException(serv);
-               Srv = serv;
+               ie = new InviteException(ServerInstance);
+               ServerInstance->AddMode(ie, 'I');
        }
        
        virtual void Implements(char* List)
@@ -46,20 +48,19 @@ public:
        virtual void On005Numeric(std::string &output)
        {
                output.append(" INVEX=I");
-               InsertMode(output, "I", 1);
        }
         
        virtual int OnCheckInvite(userrec* user, chanrec* chan)
        {
                if(chan != NULL)
                {
-                       modelist* list = (modelist*)chan->GetExt(ie->GetInfoKey());
-                       Srv->Log(DEBUG, std::string(user->nick)+" is trying to join "+std::string(chan->name)+", checking for invite exceptions");
+                       modelist* list;
+                       chan->GetExt(ie->GetInfoKey(), list);
                        if (list)
                        {
                                for (modelist::iterator it = list->begin(); it != list->end(); it++)
                                {
-                                       if(Srv->MatchText(user->GetFullRealHost(), it->mask) || Srv->MatchText(user->GetFullHost(), it->mask))
+                                       if(match(user->GetFullRealHost(), it->mask.c_str()) || match(user->GetFullHost(), it->mask.c_str()))
                                        {
                                                // They match an entry on the list, so let them in.
                                                return 1;
@@ -94,7 +95,13 @@ public:
                
        virtual Version GetVersion()
        {
-               return Version(1, 0, 0, 3, VF_VENDOR | VF_STATIC);
+               return Version(1, 0, 0, 3, VF_VENDOR | VF_COMMON);
+       }
+
+       ~ModuleInviteException()
+       {
+               ServerInstance->Modes->DelMode(ie);
+               DELETE(ie);
        }
 };
 
@@ -110,9 +117,9 @@ class ModuleInviteExceptionFactory : public ModuleFactory
        {
        }
        
-       virtual Module * CreateModule(Server* serv)
+       virtual Module * CreateModule(InspIRCd* Me)
        {
-               return new ModuleInviteException(serv);
+               return new ModuleInviteException(Me);
        }
        
 };