]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_customtitle.cpp
Fix for bug #415, affects only trunk (wish i'd known this before i started!)
[user/henk/code/inspircd.git] / src / modules / m_customtitle.cpp
index 011ec19745b26fd6a7673047e163089327a67393..73f2cda87dfc2766045a80ed50ad813121685a66 100644 (file)
@@ -12,9 +12,6 @@
  */
 
 #include "inspircd.h"
-#include "users.h"
-#include "channels.h"
-#include "modules.h"
 #include "wildcard.h"
 
 /* $ModDesc: Provides the TITLE command which allows setting of CUSTOM WHOIS TITLE line */
@@ -29,6 +26,7 @@ class cmd_title : public command_t
        {
                this->source = "m_customtitle.so";
                syntax = "<user> <password>";
+               TRANSLATE3(TR_NICK, TR_TEXT, TR_END);
        }
 
 bool OneOfMatches(const char* host, const char* ip, const char* hostlist)
@@ -47,6 +45,9 @@ bool OneOfMatches(const char* host, const char* ip, const char* hostlist)
 
        CmdResult Handle(const char** parameters, int pcnt, userrec* user)
        {
+               if (!IS_LOCAL(user))
+                       return CMD_LOCALONLY;
+       
                char TheHost[MAXBUF];
                char TheIP[MAXBUF];
 
@@ -70,12 +71,20 @@ bool OneOfMatches(const char* host, const char* ip, const char* hostlist)
                                if (text)
                                {
                                        user->Shrink("ctitle");
-                                       DELETE(text);
+                                       delete text;
                                }
 
                                text = new std::string(title);
                                user->Extend("ctitle", text);
 
+                               std::deque<std::string>* metadata = new std::deque<std::string>;
+                               metadata->push_back(user->nick);
+                               metadata->push_back("ctitle");      // The metadata id
+                               metadata->push_back(*text);     // The value to send
+                               Event event((char*)metadata,(Module*)this,"send_metadata");
+                               event.Send(ServerInstance);
+                               delete metadata;
+                                                                                       
                                if (!vhost.empty())
                                        user->ChangeDisplayedHost(vhost.c_str());
 
@@ -164,7 +173,7 @@ class ModuleCustomTitle : public Module
                if (ctitle)
                {
                        user->Shrink("ctitle");
-                       DELETE(ctitle);
+                       delete ctitle;
                }
        }
 
@@ -179,7 +188,7 @@ class ModuleCustomTitle : public Module
                        if (ctitle)
                        {
                                user->Shrink("ctitle");
-                               DELETE(ctitle);
+                               delete ctitle;
                        }
                }
        }
@@ -213,7 +222,7 @@ class ModuleCustomTitle : public Module
        
        virtual Version GetVersion()
        {
-               return Version(1,1,0,0,VF_VENDOR,API_VERSION);
+               return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
        }
 };