]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_svshold.cpp
m_spanningtree Remove SpanningTreeUtilities* fields and parameters
[user/henk/code/inspircd.git] / src / modules / m_svshold.cpp
index d2269839d94bf95d74cade0a14a750e6c396395e..fc1eb5381a84505395b2c9954f190cc75f027178 100644 (file)
 #include "inspircd.h"
 #include "xline.h"
 
-/* $ModDesc: Implements SVSHOLD. Like Q:Lines, but can only be added/removed by Services. */
-
 /** Holds a SVSHold item
  */
 class SVSHold : public XLine
 {
 public:
-       irc::string nickname;
+       std::string nickname;
 
-       SVSHold(time_t s_time, long d, std::string src, std::string re, std::string nick)
+       SVSHold(time_t s_time, long d, const std::string& src, const std::string& re, const std::string& nick)
                : XLine(s_time, d, src, re, "SVSHOLD")
        {
-               this->nickname = nick.c_str();
-       }
-
-       ~SVSHold()
-       {
+               this->nickname = nick;
        }
 
        bool Matches(User *u)
@@ -51,20 +45,12 @@ public:
 
        bool Matches(const std::string &s)
        {
-               if (nickname == s)
-                       return true;
-               return false;
-       }
-
-       void DisplayExpiry()
-       {
-               ServerInstance->SNO->WriteToSnoMask('x',"Removing expired SVSHOLD %s (set by %s %ld seconds ago)",
-                       this->nickname.c_str(), this->source.c_str(), (long int)(ServerInstance->Time() - this->set_time));
+               return InspIRCd::Match(s, nickname);
        }
 
-       const char* Displayable()
+       const std::string& Displayable()
        {
-               return nickname.c_str();
+               return nickname;
        }
 };
 
@@ -96,7 +82,6 @@ class CommandSvshold : public Command
        CommandSvshold(Module* Creator) : Command(Creator, "SVSHOLD", 1)
        {
                flags_needed = 'o'; this->syntax = "<nickname> [<duration> :<reason>]";
-               TRANSLATE4(TR_TEXT, TR_TEXT, TR_TEXT, TR_END);
        }
 
        CmdResult Handle(const std::vector<std::string> &parameters, User *user)
@@ -118,7 +103,7 @@ class CommandSvshold : public Command
                        }
                        else
                        {
-                               user->WriteServ("NOTICE %s :*** SVSHOLD %s not found in list, try /stats S.",user->nick.c_str(),parameters[0].c_str());
+                               user->WriteNotice("*** SVSHOLD " + parameters[0] + " not found in list, try /stats S.");
                        }
                }
                else
@@ -126,8 +111,7 @@ class CommandSvshold : public Command
                        if (parameters.size() < 3)
                                return CMD_FAILURE;
 
-                       // Adding - XXX todo make this respect <insane> tag perhaps..
-                       long duration = ServerInstance->Duration(parameters[1]);
+                       unsigned long duration = InspIRCd::Duration(parameters[1]);
                        SVSHold* r = new SVSHold(ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), parameters[0].c_str());
 
                        if (ServerInstance->XLines->AddLine(r, user))
@@ -170,15 +154,13 @@ class ModuleSVSHold : public Module
        {
        }
 
-       void init()
+       void init() CXX11_OVERRIDE
        {
                ServerInstance->XLines->RegisterFactory(&s);
                ServerInstance->Modules->AddService(cmd);
-               Implementation eventlist[] = { I_OnUserPreNick, I_OnStats };
-               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
        }
 
-       virtual ModResult OnStats(char symbol, User* user, string_list &out)
+       ModResult OnStats(char symbol, User* user, string_list &out) CXX11_OVERRIDE
        {
                if(symbol != 'S')
                        return MOD_RES_PASSTHRU;
@@ -187,7 +169,7 @@ class ModuleSVSHold : public Module
                return MOD_RES_DENY;
        }
 
-       virtual ModResult OnUserPreNick(User *user, const std::string &newnick)
+       ModResult OnUserPreNick(User *user, const std::string &newnick) CXX11_OVERRIDE
        {
                XLine *rl = ServerInstance->XLines->MatchesLine("SVSHOLD", newnick);
 
@@ -200,13 +182,13 @@ class ModuleSVSHold : public Module
                return MOD_RES_PASSTHRU;
        }
 
-       virtual ~ModuleSVSHold()
+       ~ModuleSVSHold()
        {
                ServerInstance->XLines->DelAll("SVSHOLD");
                ServerInstance->XLines->UnregisterFactory(&s);
        }
 
-       virtual Version GetVersion()
+       Version GetVersion() CXX11_OVERRIDE
        {
                return Version("Implements SVSHOLD. Like Q:Lines, but can only be added/removed by Services.", VF_COMMON | VF_VENDOR);
        }