]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_conn_umodes.cpp
A ton more clear() and empty() stuff thats been lingering on the long term todo for...
[user/henk/code/inspircd.git] / src / modules / m_conn_umodes.cpp
index 04f6e3bafefc0cb7056da26f955caa24bb09eb40..f1cc8bc6b863a814c0c137dbc9f364a687b8bd92 100644 (file)
@@ -2,25 +2,18 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
- *                       E-mail:
- *                <brain@chatspike.net>
- *               <Craig@chatspike.net>
- *     
- * Written by Craig Edwards, Craig McLure, and others.
+ *  InspIRCd: (C) 2002-2007 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.
  *
  * ---------------------------------------------------
  */
 
-using namespace std;
-
-#include <stdio.h>
-#include <vector>
+#include "inspircd.h"
 #include "users.h"
 #include "channels.h"
-#include "inspircd.h"
 #include "modules.h"
 #include "wildcard.h"
 
@@ -34,7 +27,7 @@ class ModuleModesOnConnect : public Module
 
  public:
        ModuleModesOnConnect(InspIRCd* Me)
-               : Module::Module(Me)
+               : Module(Me)
        {
                
                Conf = new ConfigReader(ServerInstance);
@@ -45,7 +38,7 @@ class ModuleModesOnConnect : public Module
                List[I_OnPostConnect] = List[I_OnRehash] = 1;
        }
 
-       virtual void OnRehash(const std::string &parameter)
+       virtual void OnRehash(userrec* user, const std::string &parameter)
        {
                DELETE(Conf);
                Conf = new ConfigReader(ServerInstance);
@@ -58,7 +51,7 @@ class ModuleModesOnConnect : public Module
        
        virtual Version GetVersion()
        {
-               return Version(1,0,0,1,VF_VENDOR,API_VERSION);
+               return Version(1,1,0,1,VF_VENDOR,API_VERSION);
        }
        
        virtual void OnPostConnect(userrec* user)
@@ -66,15 +59,13 @@ class ModuleModesOnConnect : public Module
                if (!IS_LOCAL(user))
                        return;
 
-               ServerInstance->Log(DEBUG,"Post connect for mode setting");
                for (int j = 0; j < Conf->Enumerate("connect"); j++)
                {
                        std::string hostn = Conf->ReadValue("connect","allow",j);
                        if ((match(user->GetIPString(),hostn.c_str(),true)) || (match(user->host,hostn.c_str())))
                        {
-                               ServerInstance->Log(DEBUG,"Found matching connect block '%s'",hostn.c_str());
                                std::string ThisModes = Conf->ReadValue("connect","modes",j);
-                               if (ThisModes != "")
+                               if (!ThisModes.empty())
                                {
                                        std::string buf;
                                        stringstream ss(ThisModes);
@@ -86,7 +77,7 @@ class ModuleModesOnConnect : public Module
                                                tokens.push_back(buf);
 
                                        int size = tokens.size() + 1;
-                                       const char* modes[size];
+                                       const char** modes = new const char*[size];
                                        modes[0] = user->nick;
                                        modes[1] = tokens[0].c_str();
 
@@ -101,7 +92,8 @@ class ModuleModesOnConnect : public Module
                                                }
                                        }
 
-                                       ServerInstance->SendMode(modes, size, user);
+                                       ServerInstance->Parser->CallHandler("MODE", modes, size, user);
+                                       delete [] modes;
                                }
                                break;
                        }
@@ -130,7 +122,7 @@ class ModuleModesOnConnectFactory : public ModuleFactory
 };
 
 
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
 {
        return new ModuleModesOnConnectFactory;
 }