]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_conn_umodes.cpp
Remote server PRIVMSG/NOTICE to nickname support
[user/henk/code/inspircd.git] / src / modules / m_conn_umodes.cpp
index 1973820cdf7fc9b94400ed67cd510f48f5b59ef8..15fe8c3f2ef4802b9e03694f78f9057741d63e5c 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 <stdio.h>
-#include <vector>
-#include "users.h"
-#include "channels.h"
 #include "inspircd.h"
-#include "modules.h"
 #include "wildcard.h"
 
 /* $ModDesc: Sets (and unsets) modes on users when they connect */
@@ -33,30 +28,28 @@ 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(userrec* user, const std::string &parameter)
+       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(userrec* user)
+       virtual void OnPostConnect(User* user)
        {
                if (!IS_LOCAL(user))
                        return;
@@ -67,12 +60,12 @@ class ModuleModesOnConnect : public Module
                        if ((match(user->GetIPString(),hostn.c_str(),true)) || (match(user->host,hostn.c_str())))
                        {
                                std::string ThisModes = Conf->ReadValue("connect","modes",j);
-                               if (ThisModes != "")
+                               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)
@@ -95,7 +88,7 @@ class ModuleModesOnConnect : public Module
                                        }
 
                                        ServerInstance->Parser->CallHandler("MODE", modes, size, user);
-                    delete [] modes;
+                                       delete [] modes;
                                }
                                break;
                        }
@@ -103,29 +96,4 @@ class ModuleModesOnConnect : public Module
        }
 };
 
-// stuff down here is the module-factory stuff. For basic modules you can ignore this.
-
-class ModuleModesOnConnectFactory : public ModuleFactory
-{
- public:
-       ModuleModesOnConnectFactory()
-       {
-       }
-       
-       ~ModuleModesOnConnectFactory()
-       {
-       }
-       
-       virtual Module * CreateModule(InspIRCd* Me)
-       {
-               return new ModuleModesOnConnect(Me);
-       }
-       
-};
-
-
-extern "C" DllExport void * init_module( void )
-{
-       return new ModuleModesOnConnectFactory;
-}
-
+MODULE_INIT(ModuleModesOnConnect)