summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/base.h9
-rw-r--r--include/modules.h8
-rw-r--r--src/base.cpp10
-rw-r--r--src/modules.cpp4
-rw-r--r--src/modules/m_spanningtree.cpp70
5 files changed, 95 insertions, 6 deletions
diff --git a/include/base.h b/include/base.h
index cec519e5c..ac03a748c 100644
--- a/include/base.h
+++ b/include/base.h
@@ -20,6 +20,7 @@
#include "inspircd_config.h"
#include <time.h>
#include <map>
+#include <deque>
#include <string>
typedef void* VoidPointer;
@@ -86,6 +87,14 @@ public:
* @return If you provide a non-existent key name, the function returns NULL, otherwise a pointer to the item referenced by the key is returned.
*/
char* GetExt(std::string key);
+
+ /** Get a list of all extension items names.
+ *
+ * @param list A deque of strings to receive the list
+ *
+ * @return This function writes a list of all extension items stored in this object by name into the given deque and returns void.
+ */
+ void GetExtList(std::deque<std::string> &list);
};
/** BoolSet is a utility class designed to hold eight bools in a bitmask.
diff --git a/include/modules.h b/include/modules.h
index de9ba0c79..2c1cf4ff7 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -435,7 +435,15 @@ class Module : public classbase
virtual void OnSyncChannel(chanrec* chan, Module* proto, void* opaque);
+ virtual void OnSyncChannelMetaData(chanrec* chan, Module* proto,void* opaque, std::string extname);
+
+ virtual void OnSyncUserMetaData(userrec* user, Module* proto,void* opaque, std::string extname);
+
+ virtual void OnDecodeMetaData(int target_type, void* target, std::string extname, std::string extdata);
+
virtual void ProtoSendMode(void* opaque, int target_type, void* target, std::string modeline);
+
+ virtual void ProtoSendMetaData(void* opaque, int target_type, void* target, std::string extname, std::string extdata);
virtual void OnWallops(userrec* user, std::string text);
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()
{
}