summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2013-09-02 13:17:24 +0200
committerattilamolnar <attilamolnar@hush.com>2013-09-13 12:15:44 +0200
commit02220d48eec4dd3507b582031de639c9d7835ec8 (patch)
treef74a09b5096b754b3484c3a03ee4d0fa91270c09
parent58d7827bb1bd3d90f38a1c199f6f41ae9f24885c (diff)
Split ProtocolInterface::SendMetaData() into multiple functions
-rw-r--r--include/protocol.h19
-rw-r--r--src/modules/m_spanningtree/main.cpp4
-rw-r--r--src/modules/m_spanningtree/protocolinterface.cpp21
-rw-r--r--src/modules/m_spanningtree/protocolinterface.h4
4 files changed, 33 insertions, 15 deletions
diff --git a/include/protocol.h b/include/protocol.h
index e474dd095..bffc4a5e9 100644
--- a/include/protocol.h
+++ b/include/protocol.h
@@ -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.
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 6e992c02d..f92c09b88 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -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();
diff --git a/src/modules/m_spanningtree/protocolinterface.cpp b/src/modules/m_spanningtree/protocolinterface.cpp
index 013dfac1b..cc015ff4a 100644
--- a/src/modules/m_spanningtree/protocolinterface.cpp
+++ b/src/modules/m_spanningtree/protocolinterface.cpp
@@ -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)
diff --git a/src/modules/m_spanningtree/protocolinterface.h b/src/modules/m_spanningtree/protocolinterface.h
index b48e45425..4ba7a54d4 100644
--- a/src/modules/m_spanningtree/protocolinterface.h
+++ b/src/modules/m_spanningtree/protocolinterface.h
@@ -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);