]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_swhois.cpp
and a little tweak to remote MOTD too.
[user/henk/code/inspircd.git] / src / modules / m_swhois.cpp
index f1a089dd0535f4a8a80d7fec362b5e5326b20e42..0c538d88b8b54e1dcf290d1206763dd164dbe6c3 100644 (file)
  * ---------------------------------------------------
  */
 
+#include "inspircd.h"
 #include "users.h"
 #include "channels.h"
 #include "modules.h"
-#include "inspircd.h"
 
 /* $ModDesc: Provides the SWHOIS command which allows setting of arbitary WHOIS lines */
 
@@ -81,7 +81,7 @@ class ModuleSWhois : public Module
        ConfigReader* Conf;
        
  public:
-       ModuleSWhois(InspIRCd* Me) : Module::Module(Me)
+       ModuleSWhois(InspIRCd* Me) : Module(Me)
        {
                
                Conf = new ConfigReader(ServerInstance);
@@ -89,7 +89,7 @@ class ModuleSWhois : public Module
                ServerInstance->AddCommand(mycommand);
        }
 
-       void OnRehash(const std::string &parameter)
+       void OnRehash(userrec* user, const std::string &parameter)
        {
                DELETE(Conf);
                Conf = new ConfigReader(ServerInstance);
@@ -123,9 +123,8 @@ class ModuleSWhois : public Module
        // this method is called. We should use the ProtoSendMetaData function after we've
        // corrected decided how the data should look, to send the metadata on its way if
        // it is ours.
-       virtual void OnSyncUserMetaData(userrec* user, Module* proto, void* opaque, const std::string &extname)
+       virtual void OnSyncUserMetaData(userrec* user, Module* proto, void* opaque, const std::string &extname, bool displayable)
        {
-               ServerInstance->Log(DEBUG,"Sync user metadata type '%s'", extname.c_str());
                // check if the linking module wants to know about OUR metadata
                if (extname == "swhois")
                {
@@ -138,15 +137,11 @@ class ModuleSWhois : public Module
                                // sees fit, and send it on its way. We dont need or want to know how.
                                proto->ProtoSendMetaData(opaque,TYPE_USER,user,extname,*swhois);
                        }
-                       else
-                       {
-                               ServerInstance->Log(DEBUG,"User has a null swhois string!");
-                       }
                }
        }
 
        // when a user quits, tidy up their metadata
-       virtual void OnUserQuit(userrec* user, const std::string &message)
+       virtual void OnUserQuit(userrec* user, const std::string &message, const std::string &oper_message)
        {
                std::string* swhois;
                user->GetExt("swhois", swhois);
@@ -185,7 +180,6 @@ class ModuleSWhois : public Module
                // check if its our metadata key, and its associated with a user
                if ((target_type == TYPE_USER) && (extname == "swhois"))
                {
-                       ServerInstance->Log(DEBUG,"Extend with swhois");
                        userrec* dest = (userrec*)target;
                        // if they dont already have an swhois field, accept the remote server's
                        std::string* text;
@@ -193,7 +187,6 @@ class ModuleSWhois : public Module
                        {
                                std::string* text = new std::string(extdata);
                                dest->Extend("swhois",text);
-                               ServerInstance->Log(DEBUG,"extended: %s %s", dest->nick, text->c_str());
                        }
                }
        }
@@ -242,8 +235,15 @@ 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;
        }
-       
+
        virtual ~ModuleSWhois()
        {
                DELETE(Conf);
@@ -275,7 +275,7 @@ class ModuleSWhoisFactory : public ModuleFactory
 };
 
 
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
 {
        return new ModuleSWhoisFactory;
 }