]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_conn_umodes.cpp
httpd connection close fixes (these need to be backported to 1.1 at some point?)...
[user/henk/code/inspircd.git] / src / modules / m_conn_umodes.cpp
index 34e1fd34df15c591f1ff43fc8dd7898c6771e622..97a8b83406ad93500c0a539cdbbf6313d482a408 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
@@ -28,27 +28,25 @@ class ModuleModesOnConnect : public Module
        {
                
                Conf = new ConfigReader(ServerInstance);
+               Implementation eventlist[] = { I_OnPostConnect, I_OnRehash };
+               ServerInstance->Modules->Attach(eventlist, this, 2);
        }
 
-       void Implements(char* List)
-       {
-               List[I_OnPostConnect] = List[I_OnRehash] = 1;
-       }
 
        virtual void OnRehash(User* user, const std::string &parameter)
        {
-               DELETE(Conf);
+               delete Conf;
                Conf = new ConfigReader(ServerInstance);
        }
        
        virtual ~ModuleModesOnConnect()
        {
-               DELETE(Conf);
+               delete Conf;
        }
        
        virtual Version GetVersion()
        {
-               return Version(1,1,0,1,VF_VENDOR,API_VERSION);
+               return Version(1,2,0,1,VF_VENDOR,API_VERSION);
        }
        
        virtual void OnPostConnect(User* user)
@@ -65,32 +63,28 @@ class ModuleModesOnConnect : public Module
                                if (!ThisModes.empty())
                                {
                                        std::string buf;
-                                       stringstream ss(ThisModes);
+                                       std::stringstream ss(ThisModes);
 
-                                       vector<string> tokens;
+                                       std::vector<std::string> tokens;
 
                                        // split ThisUserModes into modes and mode params
                                        while (ss >> buf)
                                                tokens.push_back(buf);
 
-                                       int size = tokens.size() + 1;
-                                       const char** modes = new const char*[size];
-                                       modes[0] = user->nick;
-                                       modes[1] = tokens[0].c_str();
+                                       std::vector<std::string> modes;
+                                       modes.push_back(user->nick);
+                                       modes.push_back(tokens[0]);
 
                                        if (tokens.size() > 1)
                                        {
                                                // process mode params
-                                               int i = 2;
                                                for (unsigned int k = 1; k < tokens.size(); k++)
                                                {
-                                                       modes[i] = tokens[k].c_str();
-                                                       i++;
+                                                       modes.push_back(tokens[k]);
                                                }
                                        }
 
-                                       ServerInstance->Parser->CallHandler("MODE", modes, size, user);
-                                       delete [] modes;
+                                       ServerInstance->Parser->CallHandler("MODE", modes, user);
                                }
                                break;
                        }