]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_hostchange.cpp
To be more specific, specify rpath() macro here
[user/henk/code/inspircd.git] / src / modules / m_hostchange.cpp
index de485b2c03e9c456917ab460ee3f3c4ea952d80c..473a35d124e9e8a4a5347267d5bd56b241c6595f 100644 (file)
@@ -2,20 +2,15 @@
  *       | 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 "users.h"
 #include "channels.h"
@@ -24,6 +19,8 @@ using namespace std;
 
 /* $ModDesc: Provides masking of user hostnames in a different way to m_cloaking */
 
+/** Holds information on a host set by m_hostchange
+ */
 class Host : public classbase
 {
  public:
@@ -37,18 +34,17 @@ class ModuleHostChange : public Module
 {
  private:
 
-       Server *Srv;
+       
        ConfigReader *Conf;
        hostchanges_t hostchanges;
        std::string MySuffix;
         
  public:
-       ModuleHostChange(Server* Me)
+       ModuleHostChange(InspIRCd* Me)
                : Module::Module(Me)
        {
-               Srv = Me;
-               Conf = new ConfigReader;
-               OnRehash("");
+               Conf = new ConfigReader(ServerInstance);
+               OnRehash(NULL,"");
        }
        
        virtual ~ModuleHostChange()
@@ -58,7 +54,7 @@ class ModuleHostChange : public Module
 
        Priority Prioritize()
        {
-               return (Priority)Srv->PriorityAfter("m_cloaking.so");
+               return (Priority)ServerInstance->PriorityAfter("m_cloaking.so");
        }
 
        void Implements(char* List)
@@ -66,10 +62,10 @@ class ModuleHostChange : public Module
                List[I_OnRehash] = List[I_OnUserConnect] = 1;
        }
 
-       virtual void OnRehash(const std::string &parameter)
+       virtual void OnRehash(userrec* user, const std::string &parameter)
        {
                DELETE(Conf);
-               Conf = new ConfigReader;
+               Conf = new ConfigReader(ServerInstance);
                MySuffix = Conf->ReadValue("host","suffix",0);
                for (hostchanges_t::iterator i = hostchanges.begin(); i != hostchanges.end(); i++)
                {
@@ -92,14 +88,14 @@ class ModuleHostChange : public Module
        {
                // returns the version number of the module to be
                // listed in /MODULES
-               return Version(1,0,0,1,VF_VENDOR);
+               return Version(1,1,0,1,VF_VENDOR,API_VERSION);
        }
        
        virtual void OnUserConnect(userrec* user)
        {
                for (hostchanges_t::iterator i = hostchanges.begin(); i != hostchanges.end(); i++)
                {
-                       if (Srv->MatchText(std::string(user->ident)+"@"+std::string(user->host),i->first))
+                       if (ServerInstance->MatchText(std::string(user->ident)+"@"+std::string(user->host),i->first))
                        {
                                Host* h = (Host*)i->second;
                                // host of new user matches a hostchange tag's mask
@@ -133,8 +129,9 @@ class ModuleHostChange : public Module
                                }
                                if (newhost != "")
                                {
-                                       Srv->SendServ(user->fd,"NOTICE "+std::string(user->nick)+" :Setting your virtual host: " + newhost);
-                                       Srv->ChangeHost(user,newhost);
+                                       user->WriteServ("NOTICE "+std::string(user->nick)+" :Setting your virtual host: " + newhost);
+                                       if (!user->ChangeDisplayedHost(newhost.c_str()))
+                                               user->WriteServ("NOTICE "+std::string(user->nick)+" :Could not set your virtual host: " + newhost);
                                        return;
                                }
                        }
@@ -155,7 +152,7 @@ class ModuleHostChangeFactory : public ModuleFactory
        {
        }
        
-       virtual Module * CreateModule(Server* Me)
+       virtual Module * CreateModule(InspIRCd* Me)
        {
                return new ModuleHostChange(Me);
        }