}
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.
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:
* @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
{
}
- void operator()(unsigned int numeric, const std::string& text) const
+ void operator()(Numeric::Numeric& numeric) const
{
- whois.SendLine(numeric, text);
+ whois.SendLine(numeric);
}
};
{
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());
}
};
{
num.Flush();
if (!spynum.IsEmpty())
- whois.SendLine(336, ":is on private/secret channels:");
+ whois.SendLine(336, "is on private/secret channels:");
spynum.Flush();
}
};
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()));
}
}
*/
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)
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;
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;
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;
}