]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Split ProtocolInterface::SendMetaData() into multiple functions
authorattilamolnar <attilamolnar@hush.com>
Mon, 2 Sep 2013 11:17:24 +0000 (13:17 +0200)
committerattilamolnar <attilamolnar@hush.com>
Fri, 13 Sep 2013 10:15:44 +0000 (12:15 +0200)
include/protocol.h
src/modules/m_spanningtree/main.cpp
src/modules/m_spanningtree/protocolinterface.cpp
src/modules/m_spanningtree/protocolinterface.h

index e474dd0951069827fe806d81ebeeff3dc36981a3..bffc4a5e91edc24c073bb0924f7ca977e0dbaa52 100644 (file)
@@ -53,12 +53,25 @@ class CoreExport ProtocolInterface
         */
        virtual bool SendEncapsulatedData(const parameterlist &encap) { return false; }
 
-       /** Send metadata for an object to other linked servers.
-        * @param target The object to send metadata for.
+       /** Send metadata for a channel to other linked servers.
+        * @param chan The channel to send metadata for
         * @param key The 'key' of the data, e.g. "swhois" for swhois desc on a user
         * @param data The string representation of the data
         */
-       virtual void SendMetaData(Extensible* target, const std::string &key, const std::string &data) { }
+       virtual void SendMetaData(Channel* chan, const std::string& key, const std::string& data) { }
+
+       /** Send metadata for a user to other linked servers.
+        * @param user The user to send metadata for
+        * @param key The 'key' of the data, e.g. "swhois" for swhois desc on a user
+        * @param data The string representation of the data
+        */
+       virtual void SendMetaData(User* user, const std::string& key, const std::string& data) { }
+
+       /** Send metadata related to the server to other linked servers.
+        * @param key The 'key' of the data
+        * @param data The string representation of the data
+        */
+       virtual void SendMetaData(const std::string& key, const std::string& data) { }
 
        /** Send a topic change for a channel
         * @param channel The channel to change the topic for.
index 6e992c02d583bd1af8a0256199f57bbf51d30c7d..f92c09b888d678242fdebf9b64a95dbdaa9acfb4 100644 (file)
@@ -646,14 +646,14 @@ void ModuleSpanningTree::OnLoadModule(Module* mod)
                data.push_back('=');
                data.append(v.link_data);
        }
-       ServerInstance->PI->SendMetaData(NULL, "modules", data);
+       ServerInstance->PI->SendMetaData("modules", data);
 }
 
 void ModuleSpanningTree::OnUnloadModule(Module* mod)
 {
        if (!Utils)
                return;
-       ServerInstance->PI->SendMetaData(NULL, "modules", "-" + mod->ModuleSourceFile);
+       ServerInstance->PI->SendMetaData("modules", "-" + mod->ModuleSourceFile);
 
        // Close all connections which use an IO hook provided by this module
        const TreeServer::ChildServers& list = Utils->TreeRoot->GetChildren();
index 013dfac1b2405a35c28b4b1876139e50a6640e44..cc015ff4a81de3242e11e63d5f2b70eda91c80f7 100644 (file)
@@ -56,16 +56,19 @@ bool SpanningTreeProtocolInterface::SendEncapsulatedData(const parameterlist &en
        return params.Unicast(encap[0]);
 }
 
-void SpanningTreeProtocolInterface::SendMetaData(Extensible* target, const std::string &key, const std::string &data)
+void SpanningTreeProtocolInterface::SendMetaData(User* u, const std::string& key, const std::string& data)
 {
-       User* u = dynamic_cast<User*>(target);
-       Channel* c = dynamic_cast<Channel*>(target);
-       if (u)
-               CommandMetadata::Builder(u, key, data).Broadcast();
-       else if (c)
-               CommandMetadata::Builder(c, key, data).Broadcast();
-       else
-               CommandMetadata::Builder(key, data).Broadcast();
+       CommandMetadata::Builder(u, key, data).Broadcast();
+}
+
+void SpanningTreeProtocolInterface::SendMetaData(Channel* c, const std::string& key, const std::string& data)
+{
+       CommandMetadata::Builder(c, key, data).Broadcast();
+}
+
+void SpanningTreeProtocolInterface::SendMetaData(const std::string& key, const std::string& data)
+{
+       CommandMetadata::Builder(key, data).Broadcast();
 }
 
 void SpanningTreeProtocolInterface::SendTopic(Channel* channel, std::string &topic)
index b48e4542580dae79ccfb87e033805e0f41de8f7e..4ba7a54d4eec6a6a26848169cfdfba7bcc6c7b46 100644 (file)
@@ -23,7 +23,9 @@ class SpanningTreeProtocolInterface : public ProtocolInterface
 {
  public:
        bool SendEncapsulatedData(const parameterlist &encap);
-       void SendMetaData(Extensible* target, const std::string &key, const std::string &data);
+       void SendMetaData(User* user, const std::string& key, const std::string& data) CXX11_OVERRIDE;
+       void SendMetaData(Channel* chan, const std::string& key, const std::string& data) CXX11_OVERRIDE;
+       void SendMetaData(const std::string& key, const std::string& data) CXX11_OVERRIDE;
        void SendTopic(Channel* channel, std::string &topic);
        void SendMode(User* source, User* usertarget, Channel* chantarget, const parameterlist& modedata, const std::vector<TranslateType>& types);
        void SendSNONotice(const std::string &snomask, const std::string &text);