]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_dccallow.cpp
Header update: 2007 -> 2008
[user/henk/code/inspircd.git] / src / modules / m_dccallow.cpp
index 7ddce8ab09f9f0a5e8af22e2d2a1c224156f800a..7ac1bc73756389c97a0b063cb4955fc5aab82126 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
@@ -37,24 +37,24 @@ class DCCAllow
        DCCAllow(const std::string &nick, const std::string &hm, const time_t so, const long ln) : nickname(nick), hostmask(hm), set_on(so), length(ln) { }
 };
 
-typedef std::vector<userrec *> userlist;
+typedef std::vector<User *> userlist;
 userlist ul;
 typedef std::vector<DCCAllow> dccallowlist;
 dccallowlist* dl;
 typedef std::vector<BannedFileList> bannedfilelist;
 bannedfilelist bfl;
 
-class cmd_dccallow : public Command
+class CommandDccallow : public Command
 {
  public:
-       cmd_dccallow(InspIRCd* Me) : Command(Me, "DCCALLOW", 0, 0)
+       CommandDccallow(InspIRCd* Me) : Command(Me, "DCCALLOW", 0, 0)
        {
                this->source = "m_dccallow.so";
                syntax = "{[+|-]<nick> <time>|HELP|LIST}";
                /* XXX we need to fix this so it can work with translation stuff (i.e. move +- into a seperate param */
        }
 
-       CmdResult Handle(const char **parameters, int pcnt, userrec *user)
+       CmdResult Handle(const char **parameters, int pcnt, User *user)
        {
                /* syntax: DCCALLOW [+|-]<nick> (<time>) */
                if (!pcnt)
@@ -85,7 +85,7 @@ class cmd_dccallow : public Command
                        }
                        
                        std::string nick = parameters[0] + 1;
-                       userrec *target = ServerInstance->FindNick(nick);
+                       User *target = ServerInstance->FindNick(nick);
        
                        if (target)
                        {
@@ -118,7 +118,7 @@ class cmd_dccallow : public Command
                                                // remove from userlist
                                                for (userlist::iterator j = ul.begin(); j != ul.end(); ++j)
                                                {
-                                                       userrec* u = (userrec*)(*j);
+                                                       User* u = (User*)(*j);
                                                        if (u == user)
                                                        {
                                                                ul.erase(j);
@@ -200,7 +200,7 @@ class cmd_dccallow : public Command
                return CMD_FAILURE;
        }
 
-       void DisplayHelp(userrec* user)
+       void DisplayHelp(User* user)
        {
                user->WriteServ("998 %s :DCCALLOW [<+|->nick [time]] [list] [help]", user->nick);
                user->WriteServ("998 %s :You may allow DCCs from specific users by specifying a", user->nick);
@@ -224,7 +224,7 @@ class cmd_dccallow : public Command
                user->WriteServ("999 %s :End of DCCALLOW HELP", user->nick);
        }
        
-       void DisplayDCCAllowList(userrec* user)
+       void DisplayDCCAllowList(User* user)
        {
                 // display current DCCALLOW list
                user->WriteServ("990 %s :Users on your DCCALLOW list:", user->nick);
@@ -245,30 +245,28 @@ class cmd_dccallow : public Command
        
 class ModuleDCCAllow : public Module
 {
-       cmd_dccallow* mycommand;
+       CommandDccallow* mycommand;
  public:
 
        ModuleDCCAllow(InspIRCd* Me)
                : Module(Me)
        {
                Conf = new ConfigReader(ServerInstance);
-               mycommand = new cmd_dccallow(ServerInstance);
+               mycommand = new CommandDccallow(ServerInstance);
                ServerInstance->AddCommand(mycommand);
                ReadFileConf();
+               Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserQuit, I_OnUserPreNick, I_OnRehash };
+               ServerInstance->Modules->Attach(eventlist, this, 5);
        }
 
-       void Implements(char* List)
-       {
-               List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = List[I_OnUserQuit] = List[I_OnUserPreNick] = List[I_OnRehash] = 1;
-       }
 
-       virtual void OnRehash(userrec* user, const std::string &parameter)
+       virtual void OnRehash(User* user, const std::string &parameter)
        {
                delete Conf;
                Conf = new ConfigReader(ServerInstance);
        }
 
-       virtual void OnUserQuit(userrec* user, const std::string &reason, const std::string &oper_message)
+       virtual void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message)
        {
                dccallowlist* dl;
        
@@ -287,25 +285,25 @@ class ModuleDCCAllow : public Module
        }
 
 
-       virtual int OnUserPreNick(userrec* user, const std::string &newnick)
+       virtual int OnUserPreNick(User* user, const std::string &newnick)
        {
                RemoveNick(user);
                return 0;
        }
 
-       virtual int OnUserPreMessage(userrec* user, void* dest, int target_type, std::string &text, char status, CUList &exempt_list)
+       virtual int OnUserPreMessage(User* user, void* dest, int target_type, std::string &text, char status, CUList &exempt_list)
        {
                return OnUserPreNotice(user, dest, target_type, text, status, exempt_list);
        }
 
-       virtual int OnUserPreNotice(userrec* user, void* dest, int target_type, std::string &text, char status, CUList &exempt_list)
+       virtual int OnUserPreNotice(User* user, void* dest, int target_type, std::string &text, char status, CUList &exempt_list)
        {
                if (!IS_LOCAL(user))
                        return 0;
 
                if (target_type == TYPE_USER)
                {
-                       userrec* u = (userrec*)dest;
+                       User* u = (User*)dest;
 
                        /* Always allow a user to dcc themselves (although... why?) */
                        if (user == u)
@@ -384,7 +382,7 @@ class ModuleDCCAllow : public Module
        {
                for (userlist::iterator iter = ul.begin(); iter != ul.end(); ++iter)
                {
-                       userrec* u = (userrec*)(*iter);
+                       User* u = (User*)(*iter);
                        u->GetExt("dccallow_list", dl);
        
                        if (dl)
@@ -413,12 +411,12 @@ class ModuleDCCAllow : public Module
                }
        }
        
-       void RemoveNick(userrec* user)
+       void RemoveNick(User* user)
        {
                /* Iterate through all DCCALLOW lists and remove user */
                for (userlist::iterator iter = ul.begin(); iter != ul.end(); ++iter)
                {
-                       userrec *u = (userrec*)(*iter);
+                       User *u = (User*)(*iter);
                        u->GetExt("dccallow_list", dl);
        
                        if (dl)
@@ -445,12 +443,12 @@ class ModuleDCCAllow : public Module
                }
        }
 
-       void RemoveFromUserlist(userrec *user)
+       void RemoveFromUserlist(User *user)
        {
                // remove user from userlist
                for (userlist::iterator j = ul.begin(); j != ul.end(); ++j)
                {
-                       userrec* u = (userrec*)(*j);
+                       User* u = (User*)(*j);
                        if (u == user)
                        {
                                ul.erase(j);