diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-09-02 00:45:37 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-09-02 00:45:37 +0000 |
commit | f25c4b7a2263f5f3ce9bb41ba56b43c0d3a6d124 (patch) | |
tree | 43fba09e698269cd4c22c68be7ecb4a5875f55f3 /src/modules/m_spanningtree | |
parent | 6e85701ecb09604f2c87010683638ec0446cc515 (diff) |
MetaData rework
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11607 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_spanningtree')
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 40 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.h | 3 | ||||
-rw-r--r-- | src/modules/m_spanningtree/metadata.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_spanningtree/netburst.cpp | 15 | ||||
-rw-r--r-- | src/modules/m_spanningtree/protocolinterface.cpp | 26 | ||||
-rw-r--r-- | src/modules/m_spanningtree/protocolinterface.h | 2 |
6 files changed, 38 insertions, 54 deletions
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index c402b145a..2ecbd8a88 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -899,26 +899,28 @@ void ModuleSpanningTree::ProtoSendMode(void* opaque, TargetTypeFlags target_type } } -void ModuleSpanningTree::ProtoSendMetaData(void* opaque, TargetTypeFlags target_type, void* target, const std::string &extname, const std::string &extdata) -{ - TreeSocket* s = (TreeSocket*)opaque; - if (target) - { - if (target_type == TYPE_USER) - { - User* u = (User*)target; - s->WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" METADATA "+u->uuid+" "+extname+" :"+extdata); - } - else if (target_type == TYPE_CHANNEL) - { - Channel* c = (Channel*)target; - s->WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" METADATA "+c->name+" "+extname+" :"+extdata); - } - } - if (target_type == TYPE_OTHER) - { +void ModuleSpanningTree::ProtoSendMetaData(void* opaque, Extensible* target, const std::string &extname, const std::string &extdata) +{ + TreeSocket* s = static_cast<TreeSocket*>(opaque); + User* u = dynamic_cast<User*>(target); + Channel* c = dynamic_cast<Channel*>(target); + if (u) + s->WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" METADATA "+u->uuid+" "+extname+" :"+extdata); + else if (c) + s->WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" METADATA "+c->name+" "+extname+" :"+extdata); + else if (!target) s->WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" METADATA * "+extname+" :"+extdata); - } +} + +std::string ModuleSpanningTree::ProtoTranslate(Extensible* item) +{ + User* u = dynamic_cast<User*>(item); + Channel* c = dynamic_cast<Channel*>(item); + if (u) + return u->uuid; + if (c) + return c->name; + return "*"; } void ModuleSpanningTree::OnEvent(Event* event) diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index 15d59701d..54524c720 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -185,7 +185,8 @@ class ModuleSpanningTree : public Module virtual int OnStats(char statschar, User* user, string_list &results); virtual int OnSetAway(User* user, const std::string &awaymsg); virtual void ProtoSendMode(void* opaque, TargetTypeFlags target_type, void* target, const std::vector<std::string> &modeline, const std::vector<TranslateType> &translate); - virtual void ProtoSendMetaData(void* opaque, TargetTypeFlags target_type, void* target, const std::string &extname, const std::string &extdata); + virtual void ProtoSendMetaData(void* opaque, Extensible* target, const std::string &extname, const std::string &extdata); + virtual std::string ProtoTranslate(Extensible* item); virtual void OnEvent(Event* event); virtual void OnLoadModule(Module* mod,const std::string &name); virtual void OnUnloadModule(Module* mod,const std::string &name); diff --git a/src/modules/m_spanningtree/metadata.cpp b/src/modules/m_spanningtree/metadata.cpp index eece14b0c..f012568f9 100644 --- a/src/modules/m_spanningtree/metadata.cpp +++ b/src/modules/m_spanningtree/metadata.cpp @@ -32,14 +32,14 @@ bool TreeSocket::MetaData(const std::string &prefix, parameterlist ¶ms) { if (params[0] == "*") { - FOREACH_MOD_I(this->ServerInstance,I_OnDecodeMetaData,OnDecodeMetaData(TYPE_OTHER,NULL,params[1],params[2])); + FOREACH_MOD_I(this->ServerInstance,I_OnDecodeMetaData,OnDecodeMetaData(NULL,params[1],params[2])); } else if (*(params[0].c_str()) == '#') { Channel* c = this->ServerInstance->FindChan(params[0]); if (c) { - FOREACH_MOD_I(this->ServerInstance,I_OnDecodeMetaData,OnDecodeMetaData(TYPE_CHANNEL,c,params[1],params[2])); + FOREACH_MOD_I(this->ServerInstance,I_OnDecodeMetaData,OnDecodeMetaData(c,params[1],params[2])); } } else if (*(params[0].c_str()) != '#') @@ -47,7 +47,7 @@ bool TreeSocket::MetaData(const std::string &prefix, parameterlist ¶ms) User* u = this->ServerInstance->FindNick(params[0]); if (u) { - FOREACH_MOD_I(this->ServerInstance,I_OnDecodeMetaData,OnDecodeMetaData(TYPE_USER,u,params[1],params[2])); + FOREACH_MOD_I(this->ServerInstance,I_OnDecodeMetaData,OnDecodeMetaData(u,params[1],params[2])); } } } diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index 1601cd6e6..eda627e3f 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -46,7 +46,7 @@ void TreeSocket::DoBurst(TreeServer* s) /* Send everything else (channel modes, xlines etc) */ this->SendChannelModes(s); this->SendXLines(s); - FOREACH_MOD_I(this->ServerInstance,I_OnSyncOtherMetaData,OnSyncOtherMetaData((Module*)Utils->Creator,(void*)this)); + FOREACH_MOD_I(this->ServerInstance,I_OnSyncNetwork,OnSyncNetwork((Module*)Utils->Creator,(void*)this)); this->WriteLine(endburst); this->ServerInstance->SNO->WriteToSnoMask('l',"Finished bursting to \2"+name+"\2."); } @@ -219,12 +219,6 @@ void TreeSocket::SendChannelModes(TreeServer* Current) this->WriteLine(data); } FOREACH_MOD_I(this->ServerInstance,I_OnSyncChannel,OnSyncChannel(c->second,(Module*)Utils->Creator,(void*)this)); - list.clear(); - c->second->GetExtList(list); - for (unsigned int j = 0; j < list.size(); j++) - { - FOREACH_MOD_I(this->ServerInstance,I_OnSyncChannelMetaData,OnSyncChannelMetaData(c->second,(Module*)Utils->Creator,(void*)this,list[j])); - } } } @@ -232,7 +226,6 @@ void TreeSocket::SendChannelModes(TreeServer* Current) void TreeSocket::SendUsers(TreeServer* Current) { char data[MAXBUF]; - std::deque<std::string> list; std::string dataline; for (user_hash::iterator u = this->ServerInstance->Users->clientlist->begin(); u != this->ServerInstance->Users->clientlist->end(); u++) { @@ -267,12 +260,6 @@ void TreeSocket::SendUsers(TreeServer* Current) } FOREACH_MOD_I(this->ServerInstance,I_OnSyncUser,OnSyncUser(u->second,(Module*)Utils->Creator,(void*)this)); - list.clear(); - u->second->GetExtList(list); - for (unsigned int j = 0; j < list.size(); j++) - { - FOREACH_MOD_I(this->ServerInstance,I_OnSyncUserMetaData,OnSyncUserMetaData(u->second,(Module*)Utils->Creator,(void*)this,list[j])); - } } } } diff --git a/src/modules/m_spanningtree/protocolinterface.cpp b/src/modules/m_spanningtree/protocolinterface.cpp index 989e8b3e4..804a451ca 100644 --- a/src/modules/m_spanningtree/protocolinterface.cpp +++ b/src/modules/m_spanningtree/protocolinterface.cpp @@ -31,25 +31,19 @@ void SpanningTreeProtocolInterface::SendEncapsulatedData(parameterlist &encap) Utils->DoOneToMany(ServerInstance->Config->GetSID(), "ENCAP", encap); } -void SpanningTreeProtocolInterface::SendMetaData(void* target, TargetTypeFlags type, const std::string &key, const std::string &data) +void SpanningTreeProtocolInterface::SendMetaData(Extensible* target, const std::string &key, const std::string &data) { parameterlist params; - switch (type) - { - case TYPE_USER: - params.push_back(((User*)target)->uuid); - break; - case TYPE_CHANNEL: - params.push_back(((Channel*)target)->name); - break; - case TYPE_SERVER: - params.push_back("*"); - break; - default: - throw CoreException("I don't know how to handle TYPE_OTHER."); - break; - } + User* u = dynamic_cast<User*>(target); + Channel* c = dynamic_cast<Channel*>(target); + if (u) + params.push_back(u->uuid); + else if (c) + params.push_back(c->name); + else + params.push_back("*"); + params.push_back(key); params.push_back(":" + data); diff --git a/src/modules/m_spanningtree/protocolinterface.h b/src/modules/m_spanningtree/protocolinterface.h index 84da6d8cf..047d490b6 100644 --- a/src/modules/m_spanningtree/protocolinterface.h +++ b/src/modules/m_spanningtree/protocolinterface.h @@ -14,7 +14,7 @@ class SpanningTreeProtocolInterface : public ProtocolInterface virtual ~SpanningTreeProtocolInterface() { } virtual void SendEncapsulatedData(parameterlist &encap); - virtual void SendMetaData(void* target, TargetTypeFlags type, const std::string &key, const std::string &data); + virtual void SendMetaData(Extensible* target, const std::string &key, const std::string &data); virtual void SendTopic(Channel* channel, std::string &topic); virtual void SendMode(const std::string &target, const parameterlist &modedata, const std::vector<TranslateType> &types); virtual void SendModeNotice(const std::string &modes, const std::string &text); |