]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_swhois.cpp
Fixes to make this module scale much better. Dont connect on each query, keep open...
[user/henk/code/inspircd.git] / src / modules / m_swhois.cpp
index db5d60cd722046aa0fc84b6a3f79e6a7e2387f7d..630729e7080fa2ccf7422aeff247b9019ac90013 100644 (file)
@@ -28,18 +28,18 @@ class CommandSwhois : public Command
                TRANSLATE3(TR_NICK, TR_TEXT, TR_END);
        }
 
-       CmdResult Handle(const char* const* parameters, int pcnt, User* user)
+       CmdResult Handle(const std::vector<std::string> &parameters, User* user)
        {
                User* dest = ServerInstance->FindNick(parameters[0]);
                
                if (!dest)
                {
-                       user->WriteNumeric(401, "%s %s :No such nick/channel", user->nick, parameters[0]);
+                       user->WriteNumeric(401, "%s %s :No such nick/channel", user->nick, parameters[0].c_str());
                        return CMD_FAILURE;
                }
 
                std::string line;
-               for (int i = 1; i < pcnt; i++)
+               for (int i = 1; i < (int)parameters.size(); i++)
                {
                        if (i != 1)
                                line.append(" ");
@@ -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<std::string>* metadata = new std::deque<std::string>;
-               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())
@@ -206,19 +200,19 @@ class ModuleSWhois : public Module
                        std::string* text;
                        if (dest->GetExt("swhois", text))
                        {
-                               user->Shrink("swhois");
+                               dest->Shrink("swhois");
                                delete text;
-
-                               if (extdata.empty())
-                                       return; // XXX does the command parser even allow sending blank mdata? it needs to here! -- w00t
                        }
 
-                       text2 = new std::string(extdata);
+                       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* const* params, int pcnt, User *user, CmdResult result, const std::string &original_line)
+       virtual void OnPostCommand(const std::string &command, const std::vector<std::string> &params, User *user, CmdResult result, const std::string &original_line)
        {
                if ((command != "OPER") || (result != CMD_SUCCESS))
                        return;
@@ -262,13 +256,7 @@ class ModuleSWhois : public Module
                
                std::string *text = new std::string(swhois);
                user->Extend("swhois", text);
-               std::deque<std::string>* metadata = new std::deque<std::string>;
-               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()