X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_swhois.cpp;h=c6f26384a6b797626bc7aae116b0edfe6c2db001;hb=89fc6ca9c66198fe54cce19d59279cd454fc1bd0;hp=25a860ae42bc8e62912630cabee9167d95d610c1;hpb=449bbb6e04f73685341fc22acb4b579794bd56ac;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_swhois.cpp b/src/modules/m_swhois.cpp index 25a860ae4..c6f26384a 100644 --- a/src/modules/m_swhois.cpp +++ b/src/modules/m_swhois.cpp @@ -28,13 +28,13 @@ class CommandSwhois : public Command TRANSLATE3(TR_NICK, TR_TEXT, TR_END); } - CmdResult Handle(const char** parameters, int pcnt, User* user) + CmdResult Handle(const char* const* parameters, int pcnt, User* user) { User* dest = ServerInstance->FindNick(parameters[0]); if (!dest) { - user->WriteServ("401 %s %s :No such nick/channel", user->nick, parameters[0]); + user->WriteNumeric(401, "%s %s :No such nick/channel", user->nick, parameters[0]); return CMD_FAILURE; } @@ -75,13 +75,7 @@ class CommandSwhois : public Command * Sorry w00t i know this was your fix, but i got bored and wanted to clear down the tracker :) * -- Brain */ - std::deque* metadata = new std::deque; - metadata->push_back(dest->nick); - metadata->push_back("swhois"); // The metadata id - metadata->push_back(*text); // The value to send - Event event((char*)metadata,(Module*)this,"send_metadata"); - event.Send(ServerInstance); - delete metadata; + ServerInstance->PI->SendMetaData(dest, TYPE_USER, "swhois", *text); // If it's an empty swhois, unset it (not ideal, but ok) if (text->empty()) @@ -133,6 +127,7 @@ class ModuleSWhois : public Module ServerInstance->SendWhoisLine(user, dest, 320, "%s %s :%s",user->nick,dest->nick,swhois->c_str()); } } + /* Dont block anything */ return 0; } @@ -200,17 +195,24 @@ class ModuleSWhois : public Module if ((target_type == TYPE_USER) && (extname == "swhois")) { User* dest = (User*)target; - // if they dont already have an swhois field, accept the remote server's + + // if they already have an swhois field, trash it and replace it with the remote one. std::string* text; - if (!dest->GetExt("swhois", text)) + if (dest->GetExt("swhois", text)) { - std::string* text2 = new std::string(extdata); - dest->Extend("swhois",text2); + dest->Shrink("swhois"); + delete text; } + + if (extdata.empty()) + return; // XXX does the command parser even allow sending blank mdata? it needs to here! -- w00t + + text = new std::string(extdata); + dest->Extend("swhois", text); } } - virtual void OnPostCommand(const std::string &command, const char **params, int pcnt, User *user, CmdResult result, const std::string &original_line) + virtual void OnPostCommand(const std::string &command, const char* const* params, int pcnt, User *user, CmdResult result, const std::string &original_line) { if ((command != "OPER") || (result != CMD_SUCCESS)) return; @@ -254,13 +256,7 @@ class ModuleSWhois : public Module std::string *text = new std::string(swhois); user->Extend("swhois", text); - std::deque* metadata = new std::deque; - metadata->push_back(user->nick); - metadata->push_back("swhois"); // The metadata id - metadata->push_back(*text); // The value to send - Event event((char*)metadata,(Module*)this,"send_metadata"); - event.Send(ServerInstance); - delete metadata; + ServerInstance->PI->SendMetaData(user, TYPE_USER, "swhois", *text); } virtual ~ModuleSWhois() @@ -270,7 +266,7 @@ class ModuleSWhois : 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); } };