]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/coremods/core_whois.cpp
Add the override keyword in places that it is missing.
[user/henk/code/inspircd.git] / src / coremods / core_whois.cpp
index 703ebbed39a579b667dc5b33cc3f6cb0a997ba9b..1dd087e12415009ccd01ba5dbb3f42d8c361d3dd 100644 (file)
@@ -33,20 +33,16 @@ class WhoisContextImpl : public Whois::Context
        }
 
        using Whois::Context::SendLine;
-       void SendLine(unsigned int numeric, const std::string& text) CXX11_OVERRIDE;
+       void SendLine(Numeric::Numeric& numeric) CXX11_OVERRIDE;
 };
 
-void WhoisContextImpl::SendLine(unsigned int numeric, const std::string& text)
+void WhoisContextImpl::SendLine(Numeric::Numeric& numeric)
 {
-       std::string copy_text = target->nick;
-       copy_text.push_back(' ');
-       copy_text.append(text);
-
        ModResult MOD_RESULT;
-       FIRST_MOD_RESULT_CUSTOM(lineevprov, Whois::LineEventListener, OnWhoisLine, MOD_RESULT, (*this, numeric, copy_text));
+       FIRST_MOD_RESULT_CUSTOM(lineevprov, Whois::LineEventListener, OnWhoisLine, MOD_RESULT, (*this, numeric));
 
        if (MOD_RESULT != MOD_RES_DENY)
-               source->WriteNumeric(numeric, copy_text);
+               source->WriteNumeric(numeric);
 }
 
 /** Handle /WHOIS.
@@ -59,7 +55,7 @@ class CommandWhois : public SplitCommand
        Events::ModuleEventProvider evprov;
        Events::ModuleEventProvider lineevprov;
 
-       void DoWhois(LocalUser* user, User* dest, unsigned long signon, unsigned long idle);
+       void DoWhois(LocalUser* user, User* dest, time_t signon, unsigned long idle);
        void SendChanList(WhoisContextImpl& whois);
 
  public:
@@ -82,8 +78,8 @@ class CommandWhois : public SplitCommand
         * @param user The user issuing the command
         * @return A value from CmdResult to indicate command success or failure.
         */
-       CmdResult HandleLocal(const std::vector<std::string>& parameters, LocalUser* user);
-       CmdResult HandleRemote(const std::vector<std::string>& parameters, RemoteUser* target);
+       CmdResult HandleLocal(const std::vector<std::string>& parameters, LocalUser* user) CXX11_OVERRIDE;
+       CmdResult HandleRemote(const std::vector<std::string>& parameters, RemoteUser* target) CXX11_OVERRIDE;
 };
 
 class WhoisNumericSink
@@ -95,9 +91,9 @@ class WhoisNumericSink
        {
        }
 
-       void operator()(unsigned int numeric, const std::string& text) const
+       void operator()(Numeric::Numeric& numeric) const
        {
-               whois.SendLine(numeric, text);
+               whois.SendLine(numeric);
        }
 };
 
@@ -105,8 +101,9 @@ class WhoisChanListNumericBuilder : public Numeric::GenericBuilder<' ', false, W
 {
  public:
        WhoisChanListNumericBuilder(WhoisContextImpl& whois)
-               : GenericBuilder<' ', false, WhoisNumericSink>(WhoisNumericSink(whois), 319, true, whois.GetSource()->nick.size() + whois.GetTarget()->nick.size() + 1)
+               : Numeric::GenericBuilder<' ', false, WhoisNumericSink>(WhoisNumericSink(whois), 319, false, whois.GetSource()->nick.size() + whois.GetTarget()->nick.size() + 1)
        {
+               GetNumeric().push(whois.GetTarget()->nick).push(std::string());
        }
 };
 
@@ -150,7 +147,7 @@ class WhoisChanList
        {
                num.Flush();
                if (!spynum.IsEmpty())
-                       whois.SendLine(336, ":is on private/secret channels:");
+                       whois.SendLine(336, "is on private/secret channels:");
                spynum.Flush();
        }
 };
@@ -176,49 +173,49 @@ void CommandWhois::SendChanList(WhoisContextImpl& whois)
        chanlist.Flush(whois);
 }
 
-void CommandWhois::DoWhois(LocalUser* user, User* dest, unsigned long signon, unsigned long idle)
+void CommandWhois::DoWhois(LocalUser* user, User* dest, time_t signon, unsigned long idle)
 {
        WhoisContextImpl whois(user, dest, lineevprov);
 
-       whois.SendLine(311, "%s %s * :%s", dest->ident.c_str(), dest->dhost.c_str(), dest->fullname.c_str());
+       whois.SendLine(311, dest->ident, dest->GetDisplayedHost(), '*', dest->fullname);
        if (whois.IsSelfWhois() || user->HasPrivPermission("users/auspex"))
        {
-               whois.SendLine(378, ":is connecting from %s@%s %s", dest->ident.c_str(), dest->host.c_str(), dest->GetIPString().c_str());
+               whois.SendLine(378, InspIRCd::Format("is connecting from %s@%s %s", dest->ident.c_str(), dest->GetRealHost().c_str(), dest->GetIPString().c_str()));
        }
 
        SendChanList(whois);
 
        if (!whois.IsSelfWhois() && !ServerInstance->Config->HideWhoisServer.empty() && !user->HasPrivPermission("servers/auspex"))
        {
-               whois.SendLine(312, "%s :%s", ServerInstance->Config->HideWhoisServer.c_str(), ServerInstance->Config->Network.c_str());
+               whois.SendLine(312, ServerInstance->Config->HideWhoisServer, ServerInstance->Config->Network);
        }
        else
        {
-               whois.SendLine(312, "%s :%s", dest->server->GetName().c_str(), dest->server->GetDesc().c_str());
+               whois.SendLine(312, dest->server->GetName(), dest->server->GetDesc());
        }
 
        if (dest->IsAway())
        {
-               whois.SendLine(301, ":%s", dest->awaymsg.c_str());
+               whois.SendLine(301, dest->awaymsg);
        }
 
        if (dest->IsOper())
        {
                if (ServerInstance->Config->GenericOper)
-                       whois.SendLine(313, ":is an IRC operator");
+                       whois.SendLine(313, "is an IRC operator");
                else
-                       whois.SendLine(313, ":is %s %s on %s", (strchr("AEIOUaeiou",dest->oper->name[0]) ? "an" : "a"),dest->oper->name.c_str(), ServerInstance->Config->Network.c_str());
+                       whois.SendLine(313, InspIRCd::Format("is %s %s on %s", (strchr("AEIOUaeiou",dest->oper->name[0]) ? "an" : "a"), dest->oper->name.c_str(), ServerInstance->Config->Network.c_str()));
        }
 
        if (whois.IsSelfWhois() || user->HasPrivPermission("users/auspex"))
        {
                if (dest->IsModeSet(snomaskmode))
                {
-                       whois.SendLine(379, ":is using modes +%s %s", dest->FormatModes(), snomaskmode->GetUserParameter(dest).c_str());
+                       whois.SendLine(379, InspIRCd::Format("is using modes %s %s", dest->GetModeLetters().c_str(), snomaskmode->GetUserParameter(dest).c_str()));
                }
                else
                {
-                       whois.SendLine(379, ":is using modes +%s", dest->FormatModes());
+                       whois.SendLine(379, InspIRCd::Format("is using modes %s", dest->GetModeLetters().c_str()));
                }
        }
 
@@ -230,10 +227,10 @@ void CommandWhois::DoWhois(LocalUser* user, User* dest, unsigned long signon, un
         */
        if ((idle) || (signon))
        {
-               whois.SendLine(317, "%lu %lu :seconds idle, signon time", idle, signon);
+               whois.SendLine(317, idle, signon, "seconds idle, signon time");
        }
 
-       whois.SendLine(318, ":End of /WHOIS list.");
+       whois.SendLine(318, "End of /WHOIS list.");
 }
 
 CmdResult CommandWhois::HandleRemote(const std::vector<std::string>& parameters, RemoteUser* target)
@@ -250,7 +247,7 @@ CmdResult CommandWhois::HandleRemote(const std::vector<std::string>& parameters,
        if (!localuser)
                return CMD_FAILURE;
 
-       unsigned long idle = ConvToInt(parameters.back());
+       unsigned long idle = ConvToNum<unsigned long>(parameters.back());
        DoWhois(localuser, target, target->signon, idle);
 
        return CMD_SUCCESS;
@@ -259,8 +256,9 @@ CmdResult CommandWhois::HandleRemote(const std::vector<std::string>& parameters,
 CmdResult CommandWhois::HandleLocal(const std::vector<std::string>& parameters, LocalUser* user)
 {
        User *dest;
-       int userindex = 0;
-       unsigned long idle = 0, signon = 0;
+       unsigned int userindex = 0;
+       unsigned long idle = 0;
+       time_t signon = 0;
 
        if (CommandParser::LoopCall(user, this, parameters, 0))
                return CMD_SUCCESS;
@@ -296,8 +294,8 @@ CmdResult CommandWhois::HandleLocal(const std::vector<std::string>& parameters,
        else
        {
                /* no such nick/channel */
-               user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", !parameters[userindex].empty() ? parameters[userindex].c_str() : "*");
-               user->WriteNumeric(RPL_ENDOFWHOIS, "%s :End of /WHOIS list.", !parameters[userindex].empty() ? parameters[userindex].c_str() : "*");
+               user->WriteNumeric(Numerics::NoSuchNick(!parameters[userindex].empty() ? parameters[userindex] : "*"));
+               user->WriteNumeric(RPL_ENDOFWHOIS, (!parameters[userindex].empty() ? parameters[userindex] : "*"), "End of /WHOIS list.");
                return CMD_FAILURE;
        }