]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_dccallow.cpp
Make User:: nick/ident/dhost/fullname and some other things std::string instead of...
[user/henk/code/inspircd.git] / src / modules / m_dccallow.cpp
index 1322d334434c315a8cb105d1f0bda38e3fc696df..abcad9de92333f65b3b79843f9c33b3a1e90e83c 100644 (file)
 
 static ConfigReader *Conf;
 
-class BannedFileList
+class BannedFileList : public classbase
 {
  public:
        std::string filemask;
        std::string action;
 };
 
-class DCCAllow
+class DCCAllow : public classbase
 {
  public:
        std::string nickname;
@@ -54,29 +54,29 @@ class CommandDccallow : public Command
                /* XXX we need to fix this so it can work with translation stuff (i.e. move +- into a seperate param */
        }
 
-       CmdResult Handle(const char* const* parameters, int pcnt, User *user)
+       CmdResult Handle(const std::vector<std::string> &parameters, User *user)
        {
                /* syntax: DCCALLOW [+|-]<nick> (<time>) */
-               if (!pcnt)
+               if (!parameters.size())
                {
                        // display current DCCALLOW list
                        DisplayDCCAllowList(user);
                        return CMD_FAILURE;
                }
-               else if (pcnt > 0)
+               else if (parameters.size() > 0)
                {
-                       char action = *parameters[0];
+                       char action = *parameters[0].c_str();
                
                        // if they didn't specify an action, this is probably a command
                        if (action != '+' && action != '-')
                        {
-                               if (!strcasecmp(parameters[0], "LIST"))
+                               if (!strcasecmp(parameters[0].c_str(), "LIST"))
                                {
                                        // list current DCCALLOW list
                                        DisplayDCCAllowList(user);
                                        return CMD_FAILURE;
                                } 
-                               else if (!strcasecmp(parameters[0], "HELP"))
+                               else if (!strcasecmp(parameters[0].c_str(), "HELP"))
                                {
                                        // display help
                                        DisplayHelp(user);
@@ -84,7 +84,7 @@ class CommandDccallow : public Command
                                }
                        }
                        
-                       std::string nick = parameters[0] + 1;
+                       std::string nick = parameters[0].substr(1);
                        User *target = ServerInstance->FindNick(nick);
        
                        if (target)
@@ -150,11 +150,11 @@ class CommandDccallow : public Command
                                        std::string default_length = Conf->ReadValue("dccallow", "length", 0);
                
                                        long length;
-                                       if (pcnt < 2)
+                                       if (parameters.size() < 2)
                                        {
                                                length = ServerInstance->Duration(default_length);
                                        } 
-                                       else if (!atoi(parameters[1]))
+                                       else if (!atoi(parameters[1].c_str()))
                                        {
                                                length = 0;
                                        }
@@ -172,7 +172,7 @@ class CommandDccallow : public Command
                        
                                        if (length > 0)
                                        {
-                                               user->WriteNumeric(993, "%s %s :Added %s to DCCALLOW list for %d seconds", user->nick, user->nick, target->nick, length);
+                                               user->WriteNumeric(993, "%s %s :Added %s to DCCALLOW list for %ld seconds", user->nick, user->nick, target->nick, length);
                                        }
                                        else
                                        {
@@ -379,7 +379,7 @@ class ModuleDCCAllow : public Module
                                        dccallowlist::iterator iter2 = dl->begin();
                                        while (iter2 != dl->end())
                                        {
-                                               if ((iter2->set_on + iter2->length) <= ServerInstance->Time())
+                                               if (iter2->length != 0 && (iter2->set_on + iter2->length) <= ServerInstance->Time())
                                                {
                                                        u->WriteNumeric(997, "%s %s :DCCALLOW entry for %s has expired", u->nick, u->nick, iter2->nickname.c_str());
                                                        iter2 = dl->erase(iter2);
@@ -463,7 +463,7 @@ class ModuleDCCAllow : public Module
 
        virtual Version GetVersion()
        {
-               return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
+               return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
        }
 };