summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-07 18:32:31 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-07 18:32:31 +0000
commit4c6b7c70ce61cb431df07780eba935eca529a65b (patch)
tree8c52c386b50043bc8768a9a38ebc96e2e63872a1 /src
parent2d821f2980825be73e3f90b47ffff365b0ec5ecb (diff)
Added Metadata API (for transferring extensibles over a network transparent to the protocol)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2253 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/base.cpp10
-rw-r--r--src/modules.cpp4
-rw-r--r--src/modules/m_spanningtree.cpp70
3 files changed, 78 insertions, 6 deletions
diff --git a/src/base.cpp b/src/base.cpp
index 69468f59c..3b5baae59 100644
--- a/src/base.cpp
+++ b/src/base.cpp
@@ -18,6 +18,7 @@
#include "base.h"
#include <time.h>
#include <map>
+#include <deque>
#include <string>
#include "inspircd.h"
#include "modules.h"
@@ -59,10 +60,17 @@ char* Extensible::GetExt(std::string key)
{
return (this->Extension_Items.find(key))->second;
}
- log(DEBUG,"Cant find item %s",key.c_str());
return NULL;
}
+void Extensible::GetExtList(std::deque<std::string> &list)
+{
+ for (std::map<std::string,char*>::iterator u = Extension_Items.begin(); u != Extension_Items.end(); u++)
+ {
+ list.push_back(u->first);
+ }
+}
+
void BoolSet::Set(int number)
{
this->bits |= bitfields[number];
diff --git a/src/modules.cpp b/src/modules.cpp
index 58c950411..f47a2cb4e 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -368,6 +368,10 @@ void Module::OnGetServerDescription(std::string servername,std::string &descrip
void Module::OnSyncUser(userrec* user, Module* proto, void* opaque) { };
void Module::OnSyncChannel(chanrec* chan, Module* proto, void* opaque) { };
void Module::ProtoSendMode(void* opaque, int target_type, void* target, std::string modeline) { };
+void Module::OnSyncChannelMetaData(chanrec* chan, Module* proto,void* opaque, std::string extname) { };
+void Module::OnSyncUserMetaData(userrec* user, Module* proto,void* opaque, std::string extname) { };
+void Module::OnDecodeMetaData(int target_type, void* target, std::string extname, std::string extdata) { };
+void Module::ProtoSendMetaData(void* opaque, int target_type, void* target, std::string extname, std::string extdata) { };
void Module::OnWallops(userrec* user, std::string text) { };
void Module::OnChangeHost(userrec* user, std::string newhost) { };
void Module::OnChangeName(userrec* user, std::string gecos) { };
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index e049625fb..704407e7a 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -1001,6 +1001,7 @@ class TreeSocket : public InspSocket
void SendChannelModes(TreeServer* Current)
{
char data[MAXBUF];
+ std::deque<std::string> list;
for (chan_hash::iterator c = chanlist.begin(); c != chanlist.end(); c++)
{
SendFJoins(Current, c->second);
@@ -1017,6 +1018,12 @@ class TreeSocket : public InspSocket
this->WriteLine(data);
}
FOREACH_MOD OnSyncChannel(c->second,(Module*)TreeProtocolModule,(void*)this);
+ list.clear();
+ c->second->GetExtList(list);
+ for (unsigned int j = 0; j < list.size(); j++)
+ {
+ FOREACH_MOD OnSyncChannelMetaData(c->second,(Module*)TreeProtocolModule,(void*)this,list[j]);
+ }
}
}
@@ -1024,6 +1031,7 @@ class TreeSocket : public InspSocket
void SendUsers(TreeServer* Current)
{
char data[MAXBUF];
+ std::deque<std::string> list;
for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++)
{
if (u->second->registered == 7)
@@ -1034,12 +1042,13 @@ class TreeSocket : public InspSocket
{
this->WriteLine(":"+std::string(u->second->nick)+" OPERTYPE "+std::string(u->second->oper));
}
- //char* chl = chlist(u->second,u->second);
- //if (*chl)
- //{
- // this->WriteLine(":"+std::string(u->second->nick)+" FJOIN "+std::string(chl));
- //}
FOREACH_MOD OnSyncUser(u->second,(Module*)TreeProtocolModule,(void*)this);
+ list.clear();
+ u->second->GetExtList(list);
+ for (unsigned int j = 0; j < list.size(); j++)
+ {
+ FOREACH_MOD OnSyncUserMetaData(u->second,(Module*)TreeProtocolModule,(void*)this,list[j]);
+ }
}
}
}
@@ -1233,6 +1242,35 @@ class TreeSocket : public InspSocket
}
return true;
}
+
+ bool MetaData(std::string prefix, std::deque<std::string> &params)
+ {
+ if (params.size() < 3)
+ return true;
+ TreeServer* ServerSource = FindServer(prefix);
+ if (ServerSource)
+ {
+ if (*(params[0].c_str()) == '#')
+ {
+ chanrec* c = Srv->FindChannel(params[0]);
+ if (c)
+ {
+ FOREACH_MOD OnDecodeMetaData(TYPE_CHANNEL,c,params[1],params[2]);
+ }
+ }
+ else
+ {
+ userrec* u = Srv->FindNick(params[0]);
+ if (u)
+ {
+ FOREACH_MOD OnDecodeMetaData(TYPE_USER,u,params[1],params[2]);
+ }
+ }
+ }
+ params[2] = ":" + params[2];
+ DoOneToAllButSender(prefix,"METADATA",params,prefix);
+ return true;
+ }
bool ServerVersion(std::string prefix, std::deque<std::string> &params)
{
@@ -1629,6 +1667,10 @@ class TreeSocket : public InspSocket
{
return this->RemoteRehash(prefix,params);
}
+ else if (command == "METADATA")
+ {
+ return this->MetaData(prefix,params);
+ }
else if (command == "PING")
{
return this->LocalPing(prefix,params);
@@ -2668,6 +2710,24 @@ class ModuleSpanningTree : public Module
}
}
+ virtual void ProtoSendMetaData(void* opaque, int target_type, void* target, std::string extname, std::string extdata)
+ {
+ TreeSocket* s = (TreeSocket*)opaque;
+ if (target)
+ {
+ if (target_type == TYPE_USER)
+ {
+ userrec* u = (userrec*)target;
+ s->WriteLine(":"+Srv->GetServerName()+" METADATA "+u->nick+" "+extname+" :"+extdata);
+ }
+ else
+ {
+ chanrec* c = (chanrec*)target;
+ s->WriteLine(":"+Srv->GetServerName()+" METADATA "+c->name+" "+extname+" :"+extdata);
+ }
+ }
+ }
+
virtual ~ModuleSpanningTree()
{
}