summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp4
-rw-r--r--src/modules/extra/m_ssl_openssl.cpp4
-rw-r--r--src/modules/m_callerid.cpp23
-rw-r--r--src/modules/m_cban.cpp4
-rw-r--r--src/modules/m_cgiirc.cpp31
-rw-r--r--src/modules/m_check.cpp39
-rw-r--r--src/modules/m_cloaking.cpp13
-rw-r--r--src/modules/m_customtitle.cpp28
-rw-r--r--src/modules/m_filter.cpp14
-rw-r--r--src/modules/m_namesx.cpp8
-rw-r--r--src/modules/m_sasl.cpp2
-rw-r--r--src/modules/m_services_account.cpp33
-rw-r--r--src/modules/m_spanningtree/main.cpp40
-rw-r--r--src/modules/m_spanningtree/main.h3
-rw-r--r--src/modules/m_spanningtree/metadata.cpp6
-rw-r--r--src/modules/m_spanningtree/netburst.cpp15
-rw-r--r--src/modules/m_spanningtree/protocolinterface.cpp26
-rw-r--r--src/modules/m_spanningtree/protocolinterface.h2
-rw-r--r--src/modules/m_sslinfo.cpp42
-rw-r--r--src/modules/m_svshold.cpp4
-rw-r--r--src/modules/m_swhois.cpp69
-rw-r--r--src/modules/m_taxonomy.cpp39
-rw-r--r--src/modules/m_uhnames.cpp8
23 files changed, 188 insertions, 269 deletions
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index 665a6723f..a769bd12b 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -697,9 +697,9 @@ class ModuleSSLGnuTLS : public Module
user->WriteServ("NOTICE %s :*** You are connected using SSL cipher \"%s\"", user->nick.c_str(), cipher.c_str());
}
- ServerInstance->PI->SendMetaData(user, TYPE_USER, "ssl", "ON");
+ ServerInstance->PI->SendMetaData(user, "ssl", "ON");
if (certdata)
- ServerInstance->PI->SendMetaData(user, TYPE_USER, "ssl_cert", certdata->GetMetaLine().c_str());
+ ServerInstance->PI->SendMetaData(user, "ssl_cert", certdata->GetMetaLine().c_str());
}
}
diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp
index 447f35940..9bce0d05e 100644
--- a/src/modules/extra/m_ssl_openssl.cpp
+++ b/src/modules/extra/m_ssl_openssl.cpp
@@ -777,9 +777,9 @@ class ModuleSSLOpenSSL : public Module
if (sessions[user->GetFd()].sess)
user->WriteServ("NOTICE %s :*** You are connected using SSL cipher \"%s\"", user->nick.c_str(), SSL_get_cipher(sessions[user->GetFd()].sess));
- ServerInstance->PI->SendMetaData(user, TYPE_USER, "ssl", "ON");
+ ServerInstance->PI->SendMetaData(user, "ssl", "ON");
if (certdata)
- ServerInstance->PI->SendMetaData(user, TYPE_USER, "ssl_cert", certdata->GetMetaLine().c_str());
+ ServerInstance->PI->SendMetaData(user, "ssl_cert", certdata->GetMetaLine().c_str());
}
}
diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp
index 1b9492ce1..29ba7fd60 100644
--- a/src/modules/m_callerid.cpp
+++ b/src/modules/m_callerid.cpp
@@ -56,14 +56,14 @@ class callerid_data : public classbase
}
}
- std::string ToString(bool displayable) const
+ std::string ToString(Module* proto) const
{
std::ostringstream oss;
oss << lastnotify;
for (std::set<User*>::const_iterator i = accepting.begin(); i != accepting.end(); ++i)
{
// Encode UIDs.
- oss << "," << (displayable ? (*i)->nick : (*i)->uuid);
+ oss << "," << proto->ProtoTranslate(*i);
}
oss << std::ends;
return oss.str();
@@ -430,24 +430,21 @@ public:
RemoveData(u);
}
- virtual void OnSyncUserMetaData(User* user, Module* proto, void* opaque, const std::string& extname, bool displayable)
+ virtual void OnSyncUser(User* user, Module* proto, void* opaque)
{
- if (extname == "callerid_data")
+ callerid_data* dat = GetData(user, false);
+ if (dat)
{
- callerid_data* dat = GetData(user, false);
- if (dat)
- {
- std::string str = dat->ToString(displayable);
- proto->ProtoSendMetaData(opaque, TYPE_USER, user, extname, str);
- }
+ std::string str = dat->ToString(proto);
+ proto->ProtoSendMetaData(opaque, user, "callerid_data", str);
}
}
- virtual void OnDecodeMetaData(int target_type, void* target, const std::string& extname, const std::string& extdata)
+ virtual void OnDecodeMetaData(Extensible* target, const std::string& extname, const std::string& extdata)
{
- if (target_type == TYPE_USER && extname == "callerid_data")
+ User* u = dynamic_cast<User*>(target);
+ if (u && extname == "callerid_data")
{
- User* u = (User*)target;
callerid_data* dat = new callerid_data(extdata, ServerInstance);
u->Extend("callerid_data", dat);
}
diff --git a/src/modules/m_cban.cpp b/src/modules/m_cban.cpp
index 4b0319d87..11bd32c8a 100644
--- a/src/modules/m_cban.cpp
+++ b/src/modules/m_cban.cpp
@@ -165,8 +165,8 @@ class ModuleCBan : public Module
ServerInstance->XLines->RegisterFactory(&f);
ServerInstance->AddCommand(&mycommand);
- Implementation eventlist[] = { I_OnUserPreJoin, I_OnSyncOtherMetaData, I_OnDecodeMetaData, I_OnStats };
- ServerInstance->Modules->Attach(eventlist, this, 4);
+ Implementation eventlist[] = { I_OnUserPreJoin, I_OnStats };
+ ServerInstance->Modules->Attach(eventlist, this, 2);
}
virtual ~ModuleCBan()
diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp
index 8b7a77941..3e00f498d 100644
--- a/src/modules/m_cgiirc.cpp
+++ b/src/modules/m_cgiirc.cpp
@@ -143,7 +143,7 @@ public:
OnRehash(NULL);
ServerInstance->AddCommand(&cmd);
- Implementation eventlist[] = { I_OnRehash, I_OnUserRegister, I_OnCleanup, I_OnSyncUserMetaData, I_OnDecodeMetaData, I_OnUserDisconnect, I_OnUserConnect };
+ Implementation eventlist[] = { I_OnRehash, I_OnUserRegister, I_OnCleanup, I_OnSyncUser, I_OnDecodeMetaData, I_OnUserDisconnect, I_OnUserConnect };
ServerInstance->Modules->Attach(eventlist, this, 7);
}
@@ -224,29 +224,22 @@ public:
}
}
- virtual void OnSyncUserMetaData(User* user, Module* proto, void* opaque, const std::string &extname, bool displayable)
+ virtual void OnSyncUser(User* user, Module* proto, void* opaque)
{
- if((extname == "cgiirc_realhost") || (extname == "cgiirc_realip"))
- {
- std::string* data;
-
- if(user->GetExt(extname, data))
- {
- proto->ProtoSendMetaData(opaque, TYPE_USER, user, extname, *data);
- }
- }
+ std::string* data;
+ if (user->GetExt("cgiirc_realhost", data))
+ proto->ProtoSendMetaData(opaque, user, "cgiirc_realhost", *data);
+ if (user->GetExt("cgiirc_realip", data))
+ proto->ProtoSendMetaData(opaque, user, "cgiirc_realip", *data);
}
- virtual void OnDecodeMetaData(int target_type, void* target, const std::string &extname, const std::string &extdata)
+ virtual void OnDecodeMetaData(Extensible* target, const std::string &extname, const std::string &extdata)
{
- if(target_type == TYPE_USER)
+ User* dest = dynamic_cast<User*>(target);
+ std::string* bleh;
+ if(dest && ((extname == "cgiirc_realhost") || (extname == "cgiirc_realip")) && (!dest->GetExt(extname, bleh)))
{
- User* dest = (User*)target;
- std::string* bleh;
- if(((extname == "cgiirc_realhost") || (extname == "cgiirc_realip")) && (!dest->GetExt(extname, bleh)))
- {
- dest->Extend(extname, new std::string(extdata));
- }
+ dest->Extend(extname, new std::string(extdata));
}
}
diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp
index 3b79081ad..42be6a350 100644
--- a/src/modules/m_check.cpp
+++ b/src/modules/m_check.cpp
@@ -99,18 +99,7 @@ class CommandCheck : public Command
ServerInstance->DumpText(user,checkstr + " onchans ", dump);
- std::deque<std::string> extlist;
- targuser->GetExtList(extlist);
- std::stringstream dumpkeys;
- for(std::deque<std::string>::iterator i = extlist.begin(); i != extlist.end(); i++)
- {
- md_sent = false;
- FOREACH_MOD_I(ServerInstance,I_OnSyncUserMetaData,OnSyncUserMetaData(targuser,Parent,(void*)user,*i, true));
- if (!md_sent)
- dumpkeys << " " << *i;
- }
- if (!dumpkeys.str().empty())
- ServerInstance->DumpText(user,checkstr + " metadata ", dumpkeys);
+ FOREACH_MOD_I(ServerInstance,I_OnSyncUser,OnSyncUser(targuser,Parent,(void*)user));
}
else if (targchan)
{
@@ -143,18 +132,7 @@ class CommandCheck : public Command
user->WriteServ(checkstr + " member " + tmpbuf);
}
- std::deque<std::string> extlist;
- targchan->GetExtList(extlist);
- std::stringstream dumpkeys;
- for(std::deque<std::string>::iterator i = extlist.begin(); i != extlist.end(); i++)
- {
- md_sent = false;
- FOREACH_MOD_I(ServerInstance,I_OnSyncChannelMetaData,OnSyncChannelMetaData(targchan,Parent,(void*)user,*i, true));
- if (!md_sent)
- dumpkeys << " " << *i;
- }
- if (!dumpkeys.str().empty())
- ServerInstance->DumpText(user,checkstr + " metadata ", dumpkeys);
+ FOREACH_MOD_I(ServerInstance,I_OnSyncChannel,OnSyncChannel(targchan,Parent,(void*)user));
}
else
{
@@ -206,12 +184,23 @@ class ModuleCheck : public Module
return Version("$Id$", VF_VENDOR, API_VERSION);
}
- virtual void ProtoSendMetaData(void* opaque, TargetTypeFlags type, void* target, const std::string& name, const std::string& value)
+ virtual void ProtoSendMetaData(void* opaque, Extensible* target, const std::string& name, const std::string& value)
{
User* user = static_cast<User*>(opaque);
user->WriteServ("304 " + std::string(user->nick) + " :CHECK meta:" + name + " " + value);
mycommand.md_sent = true;
}
+
+ virtual std::string ProtoTranslate(Extensible* item)
+ {
+ User* u = dynamic_cast<User*>(item);
+ Channel* c = dynamic_cast<Channel*>(item);
+ if (u)
+ return u->nick;
+ if (c)
+ return c->name;
+ return "?";
+ }
};
MODULE_INIT(ModuleCheck)
diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp
index a236300f1..458d833df 100644
--- a/src/modules/m_cloaking.cpp
+++ b/src/modules/m_cloaking.cpp
@@ -282,20 +282,17 @@ class ModuleCloaking : public Module
ServerInstance->Modules->UseInterface("HashRequest");
- Implementation eventlist[] = { I_OnRehash, I_OnUserDisconnect, I_OnCleanup, I_OnCheckBan, I_OnUserConnect, I_OnSyncUserMetaData, I_OnCleanup };
+ Implementation eventlist[] = { I_OnRehash, I_OnUserDisconnect, I_OnCleanup, I_OnCheckBan, I_OnUserConnect, I_OnSyncUser, I_OnCleanup };
ServerInstance->Modules->Attach(eventlist, this, 6);
CloakExistingUsers();
}
- void OnSyncUserMetaData(User* user, Module* proto,void* opaque, const std::string &extname, bool displayable)
+ void OnSyncUser(User* user, Module* proto,void* opaque)
{
- if ((displayable) && (extname == "cloaked_host"))
- {
- std::string* cloak;
- if (user->GetExt("cloaked_host", cloak))
- proto->ProtoSendMetaData(opaque, TYPE_USER, user, extname, *cloak);
- }
+ std::string* cloak;
+ if (user->GetExt("cloaked_host", cloak) && proto->ProtoTranslate(NULL) == "?")
+ proto->ProtoSendMetaData(opaque, user, "cloaked_host", *cloak);
}
void CloakExistingUsers()
diff --git a/src/modules/m_customtitle.cpp b/src/modules/m_customtitle.cpp
index 35992d505..499886535 100644
--- a/src/modules/m_customtitle.cpp
+++ b/src/modules/m_customtitle.cpp
@@ -71,7 +71,7 @@ class CommandTitle : public Command
text = new std::string(title);
user->Extend("ctitle", text);
- ServerInstance->PI->SendMetaData(user, TYPE_USER, "ctitle", *text);
+ ServerInstance->PI->SendMetaData(user, "ctitle", *text);
if (!vhost.empty())
user->ChangeDisplayedHost(vhost.c_str());
@@ -96,7 +96,7 @@ class ModuleCustomTitle : public Module
ModuleCustomTitle(InspIRCd* Me) : Module(Me), cmd(Me)
{
ServerInstance->AddCommand(&cmd);
- Implementation eventlist[] = { I_OnDecodeMetaData, I_OnWhoisLine, I_OnSyncUserMetaData, I_OnUserQuit, I_OnCleanup };
+ Implementation eventlist[] = { I_OnDecodeMetaData, I_OnWhoisLine, I_OnSyncUser, I_OnUserQuit, I_OnCleanup };
ServerInstance->Modules->Attach(eventlist, this, 5);
}
@@ -123,20 +123,12 @@ class ModuleCustomTitle : public Module
// this method is called. We should use the ProtoSendMetaData function after we've
// corrected decided how the data should look, to send the metadata on its way if
// it is ours.
- virtual void OnSyncUserMetaData(User* user, Module* proto, void* opaque, const std::string &extname, bool displayable)
+ virtual void OnSyncUser(User* user, Module* proto, void* opaque)
{
- // check if the linking module wants to know about OUR metadata
- if (extname == "ctitle")
- {
- // check if this user has an ctitle field to send
- std::string* ctitle;
- if (user->GetExt("ctitle", ctitle))
- {
- // call this function in the linking module, let it format the data how it
- // sees fit, and send it on its way. We dont need or want to know how.
- proto->ProtoSendMetaData(opaque,TYPE_USER,user,extname,*ctitle);
- }
- }
+ // check if this user has an ctitle field to send
+ std::string* ctitle;
+ if (user->GetExt("ctitle", ctitle))
+ proto->ProtoSendMetaData(opaque,user,"ctitle",*ctitle);
}
// when a user quits, tidy up their metadata
@@ -172,12 +164,12 @@ class ModuleCustomTitle : public Module
// In our case we're only sending a single string around, so we just construct a std::string.
// Some modules will probably get much more complex and format more detailed structs and classes
// in a textual way for sending over the link.
- virtual void OnDecodeMetaData(int target_type, void* target, const std::string &extname, const std::string &extdata)
+ virtual void OnDecodeMetaData(Extensible* target, const std::string &extname, const std::string &extdata)
{
+ User* dest = dynamic_cast<User*>(target);
// check if its our metadata key, and its associated with a user
- if ((target_type == TYPE_USER) && (extname == "ctitle"))
+ if (dest && (extname == "ctitle"))
{
- User* dest = (User*)target;
std::string* text;
if (dest->GetExt("ctitle", text))
{
diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp
index 9c4788f46..6490e4c86 100644
--- a/src/modules/m_filter.cpp
+++ b/src/modules/m_filter.cpp
@@ -134,8 +134,8 @@ protected:
virtual Version GetVersion();
std::string EncodeFilter(FilterResult* filter);
FilterResult DecodeFilter(const std::string &data);
- virtual void OnSyncOtherMetaData(Module* proto, void* opaque, bool displayable = false);
- virtual void OnDecodeMetaData(int target_type, void* target, const std::string &extname, const std::string &extdata);
+ virtual void OnSyncNetwork(Module* proto, void* opaque);
+ virtual void OnDecodeMetaData(Extensible* target, const std::string &extname, const std::string &extdata);
virtual int OnStats(char symbol, User* user, string_list &results) = 0;
virtual int OnPreCommand(std::string &command, std::vector<std::string> &parameters, User *user, bool validated, const std::string &original_line);
bool AppliesToMe(User* user, FilterResult* filter, int flags);
@@ -240,7 +240,7 @@ FilterBase::FilterBase(InspIRCd* Me, const std::string &source) : Module(Me), fi
{
Me->Modules->UseInterface("RegularExpression");
ServerInstance->AddCommand(&filtcommand);
- Implementation eventlist[] = { I_OnPreCommand, I_OnStats, I_OnSyncOtherMetaData, I_OnDecodeMetaData, I_OnUserPreMessage, I_OnUserPreNotice, I_OnRehash, I_OnLoadModule };
+ Implementation eventlist[] = { I_OnPreCommand, I_OnStats, I_OnSyncNetwork, I_OnDecodeMetaData, I_OnUserPreMessage, I_OnUserPreNotice, I_OnRehash, I_OnLoadModule };
ServerInstance->Modules->Attach(eventlist, this, 8);
}
@@ -510,19 +510,19 @@ FilterResult FilterBase::DecodeFilter(const std::string &data)
return res;
}
-void FilterBase::OnSyncOtherMetaData(Module* proto, void* opaque, bool displayable)
+void FilterBase::OnSyncNetwork(Module* proto, void* opaque)
{
this->SyncFilters(proto, opaque);
}
void FilterBase::SendFilter(Module* proto, void* opaque, FilterResult* iter)
{
- proto->ProtoSendMetaData(opaque, TYPE_OTHER, NULL, "filter", EncodeFilter(iter));
+ proto->ProtoSendMetaData(opaque, NULL, "filter", EncodeFilter(iter));
}
-void FilterBase::OnDecodeMetaData(int target_type, void* target, const std::string &extname, const std::string &extdata)
+void FilterBase::OnDecodeMetaData(Extensible* target, const std::string &extname, const std::string &extdata)
{
- if ((target_type == TYPE_OTHER) && (extname == "filter"))
+ if ((target == NULL) && (extname == "filter"))
{
FilterResult data = DecodeFilter(extdata);
this->AddFilter(data.freeform, data.action, data.reason, data.gline_time, data.flags);
diff --git a/src/modules/m_namesx.cpp b/src/modules/m_namesx.cpp
index 794cd5b46..377c9b1f0 100644
--- a/src/modules/m_namesx.cpp
+++ b/src/modules/m_namesx.cpp
@@ -23,7 +23,7 @@ class ModuleNamesX : public Module
ModuleNamesX(InspIRCd* Me)
: Module(Me)
{
- Implementation eventlist[] = { I_OnSyncUserMetaData, I_OnPreCommand, I_OnNamesListItem, I_On005Numeric, I_OnEvent };
+ Implementation eventlist[] = { I_OnSyncUser, I_OnPreCommand, I_OnNamesListItem, I_On005Numeric, I_OnEvent };
ServerInstance->Modules->Attach(eventlist, this, 5);
}
@@ -32,10 +32,10 @@ class ModuleNamesX : public Module
{
}
- void OnSyncUserMetaData(User* user, Module* proto,void* opaque, const std::string &extname, bool displayable)
+ void OnSyncUser(User* user, Module* proto,void* opaque)
{
- if ((displayable) && (extname == "NAMESX"))
- proto->ProtoSendMetaData(opaque, TYPE_USER, user, extname, "Enabled");
+ if (proto->ProtoTranslate(NULL) == "?" && user->GetExt("NAMESX"))
+ proto->ProtoSendMetaData(opaque, user, "NAMESX", "Enabled");
}
virtual Version GetVersion()
diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp
index b205f91c1..08f136374 100644
--- a/src/modules/m_sasl.cpp
+++ b/src/modules/m_sasl.cpp
@@ -272,7 +272,7 @@ class ModuleSASL : public Module
std::string* str = NULL;
if (user->GetExt("accountname", str))
- ServerInstance->PI->SendMetaData(user, TYPE_USER, "accountname", *str);
+ ServerInstance->PI->SendMetaData(user, "accountname", *str);
return;
}
diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp
index d6cf0b1e7..30baccadf 100644
--- a/src/modules/m_services_account.cpp
+++ b/src/modules/m_services_account.cpp
@@ -115,7 +115,7 @@ class ModuleServicesAccount : public Module
throw ModuleException("Some other module has claimed our modes!");
Implementation eventlist[] = { I_OnWhois, I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserPreJoin, I_OnCheckBan,
- I_OnSyncUserMetaData, I_OnUserQuit, I_OnCleanup, I_OnDecodeMetaData, I_On005Numeric, I_OnUserPostNick };
+ I_OnSyncUser, I_OnUserQuit, I_OnCleanup, I_OnDecodeMetaData, I_On005Numeric, I_OnUserPostNick };
ServerInstance->Modules->Attach(eventlist, this, 10);
}
@@ -254,23 +254,19 @@ class ModuleServicesAccount : public Module
// this method is called. We should use the ProtoSendMetaData function after we've
// corrected decided how the data should look, to send the metadata on its way if
// it is ours.
- virtual void OnSyncUserMetaData(User* user, Module* proto, void* opaque, const std::string &extname, bool displayable)
+ virtual void OnSyncUser(User* user, Module* proto, void* opaque)
{
- // check if the linking module wants to know about OUR metadata
- if (extname == "accountname")
+ // check if this user has an swhois field to send
+ std::string* account;
+ user->GetExt("accountname", account);
+ if (account)
{
- // check if this user has an swhois field to send
- std::string* account;
- user->GetExt("accountname", account);
- if (account)
- {
- // remove any accidental leading/trailing spaces
- trim(*account);
+ // remove any accidental leading/trailing spaces
+ trim(*account);
- // call this function in the linking module, let it format the data how it
- // sees fit, and send it on its way. We dont need or want to know how.
- proto->ProtoSendMetaData(opaque,TYPE_USER,user,extname,*account);
- }
+ // call this function in the linking module, let it format the data how it
+ // sees fit, and send it on its way. We dont need or want to know how.
+ proto->ProtoSendMetaData(opaque,user,"accountname",*account);
}
}
@@ -309,13 +305,12 @@ class ModuleServicesAccount : public Module
// In our case we're only sending a single string around, so we just construct a std::string.
// Some modules will probably get much more complex and format more detailed structs and classes
// in a textual way for sending over the link.
- virtual void OnDecodeMetaData(int target_type, void* target, const std::string &extname, const std::string &extdata)
+ virtual void OnDecodeMetaData(Extensible* target, const std::string &extname, const std::string &extdata)
{
+ User* dest = dynamic_cast<User*>(target);
// check if its our metadata key, and its associated with a user
- if ((target_type == TYPE_USER) && (extname == "accountname"))
+ if (dest && (extname == "accountname"))
{
- User* dest = (User*)target;
-
std::string* account;
if (dest->GetExt("accountname", account)) {
// remove old account so that we can set new (or leave unset)
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 &params)
{
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 &params)
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);
diff --git a/src/modules/m_sslinfo.cpp b/src/modules/m_sslinfo.cpp
index 01509653c..185df5375 100644
--- a/src/modules/m_sslinfo.cpp
+++ b/src/modules/m_sslinfo.cpp
@@ -70,7 +70,7 @@ class ModuleSSLInfo : public Module
{
ServerInstance->AddCommand(&cmd);
- Implementation eventlist[] = { I_OnSyncUserMetaData, I_OnDecodeMetaData, I_OnWhois, I_OnPreCommand };
+ Implementation eventlist[] = { I_OnSyncUser, I_OnDecodeMetaData, I_OnWhois, I_OnPreCommand };
ServerInstance->Modules->Attach(eventlist, this, 4);
}
@@ -92,44 +92,30 @@ class ModuleSSLInfo : public Module
}
}
- virtual void OnSyncUserMetaData(User* user, Module* proto, void* opaque, const std::string &extname, bool displayable)
+ virtual void OnSyncUser(User* user, Module* proto, void* opaque)
{
- // check if the linking module wants to know about OUR metadata
- if (extname == "ssl")
- {
- // check if this user has an ssl field to send
- if (!user->GetExt(extname))
- return;
-
- // call this function in the linking module, let it format the data how it
- // sees fit, and send it on its way. We dont need or want to know how.
- proto->ProtoSendMetaData(opaque, TYPE_USER, user, extname, displayable ? "Enabled" : "ON");
- }
- else if (extname == "ssl_cert")
- {
- ssl_cert* cert;
- if (!user->GetExt("ssl_cert", cert))
- return;
-
- proto->ProtoSendMetaData(opaque, TYPE_USER, user, extname, cert->GetMetaLine().c_str());
- }
+ if (user->GetExt("ssl"))
+ proto->ProtoSendMetaData(opaque, user, "ssl", "ON");
+
+ ssl_cert* cert;
+ if (user->GetExt("ssl_cert", cert))
+ proto->ProtoSendMetaData(opaque, user, "ssl_cert", cert->GetMetaLine().c_str());
}
- virtual void OnDecodeMetaData(int target_type, void* target, const std::string &extname, const std::string &extdata)
+ virtual void OnDecodeMetaData(Extensible* target, const std::string &extname, const std::string &extdata)
{
+ User* dest = dynamic_cast<User*>(target);
// check if its our metadata key, and its associated with a user
- if ((target_type == TYPE_USER) && (extname == "ssl"))
+ if (dest && (extname == "ssl"))
{
- User* dest = static_cast<User*>(target);
// if they dont already have an ssl flag, accept the remote server's
if (!dest->GetExt(extname))
{
dest->Extend(extname);
}
}
- else if ((target_type == TYPE_USER) && (extname == "ssl_cert"))
+ else if (dest && (extname == "ssl_cert"))
{
- User* dest = static_cast<User*>(target);
if (dest->GetExt(extname))
return;
@@ -173,9 +159,9 @@ class ModuleSSLInfo : public Module
virtual int OnPreCommand(std::string &command, std::vector<std::string> &parameters, User *user, bool validated, const std::string &original_line)
{
- irc::string cmd = command.c_str();
+ irc::string pcmd = command.c_str();
- if ((cmd == "OPER") && (validated))
+ if ((pcmd == "OPER") && (validated))
{
ConfigReader cf(ServerInstance);
char TheHost[MAXBUF];
diff --git a/src/modules/m_svshold.cpp b/src/modules/m_svshold.cpp
index ada7fbc68..276fef038 100644
--- a/src/modules/m_svshold.cpp
+++ b/src/modules/m_svshold.cpp
@@ -151,8 +151,8 @@ class ModuleSVSHold : public Module
{
ServerInstance->XLines->RegisterFactory(&s);
ServerInstance->AddCommand(&cmd);
- Implementation eventlist[] = { I_OnUserPreNick, I_OnSyncOtherMetaData, I_OnDecodeMetaData, I_OnStats };
- ServerInstance->Modules->Attach(eventlist, this, 4);
+ Implementation eventlist[] = { I_OnUserPreNick, I_OnStats };
+ ServerInstance->Modules->Attach(eventlist, this, 2);
}
diff --git a/src/modules/m_swhois.cpp b/src/modules/m_swhois.cpp
index 5a253069e..9939a83a2 100644
--- a/src/modules/m_swhois.cpp
+++ b/src/modules/m_swhois.cpp
@@ -64,7 +64,7 @@ class CommandSwhois : public Command
* Sorry w00t i know this was your fix, but i got bored and wanted to clear down the tracker :)
* -- Brain
*/
- ServerInstance->PI->SendMetaData(dest, TYPE_USER, "swhois", *text);
+ ServerInstance->PI->SendMetaData(dest, "swhois", *text);
// If it's an empty swhois, unset it (not ideal, but ok)
if (text->empty())
@@ -90,7 +90,7 @@ class ModuleSWhois : public Module
Conf = new ConfigReader(ServerInstance);
ServerInstance->AddCommand(&cmd);
- Implementation eventlist[] = { I_OnDecodeMetaData, I_OnWhoisLine, I_OnSyncUserMetaData, I_OnUserQuit, I_OnCleanup, I_OnRehash, I_OnPostCommand };
+ Implementation eventlist[] = { I_OnDecodeMetaData, I_OnWhoisLine, I_OnSyncUser, I_OnUserQuit, I_OnCleanup, I_OnRehash, I_OnPostCommand };
ServerInstance->Modules->Attach(eventlist, this, 7);
}
@@ -124,20 +124,12 @@ class ModuleSWhois : public Module
// this method is called. We should use the ProtoSendMetaData function after we've
// corrected decided how the data should look, to send the metadata on its way if
// it is ours.
- virtual void OnSyncUserMetaData(User* user, Module* proto, void* opaque, const std::string &extname, bool displayable)
+ virtual void OnSyncUser(User* user, Module* proto, void* opaque)
{
- // check if the linking module wants to know about OUR metadata
- if (extname == "swhois")
- {
- // check if this user has an swhois field to send
- std::string* swhois;
- if (user->GetExt("swhois", swhois))
- {
- // call this function in the linking module, let it format the data how it
- // sees fit, and send it on its way. We dont need or want to know how.
- proto->ProtoSendMetaData(opaque,TYPE_USER,user,extname,*swhois);
- }
- }
+ // check if this user has an swhois field to send
+ std::string* swhois;
+ if (user->GetExt("swhois", swhois))
+ proto->ProtoSendMetaData(opaque,user,"swhois",*swhois);
}
// when a user quits, tidy up their metadata
@@ -154,15 +146,13 @@ class ModuleSWhois : public Module
// if the module is unloaded, tidy up all our dangling metadata
virtual void OnCleanup(int target_type, void* item)
{
- if (target_type == TYPE_USER)
+ if (target_type != TYPE_USER) return;
+ User* user = static_cast<User*>(item);
+ std::string* swhois;
+ if (user && user->GetExt("swhois", swhois))
{
- User* user = (User*)item;
- std::string* swhois;
- if (user->GetExt("swhois", swhois))
- {
- user->Shrink("swhois");
- delete swhois;
- }
+ user->Shrink("swhois");
+ delete swhois;
}
}
@@ -173,27 +163,26 @@ class ModuleSWhois : public Module
// In our case we're only sending a single string around, so we just construct a std::string.
// Some modules will probably get much more complex and format more detailed structs and classes
// in a textual way for sending over the link.
- virtual void OnDecodeMetaData(int target_type, void* target, const std::string &extname, const std::string &extdata)
+ virtual void OnDecodeMetaData(Extensible* target, const std::string &extname, const std::string &extdata)
{
+ User* dest = dynamic_cast<User*>(target);
// check if its our metadata key, and its associated with a user
- if ((target_type == TYPE_USER) && (extname == "swhois"))
- {
- User* dest = (User*)target;
+ if (extname != "swhois" || !dest)
+ return;
- // if they already have an swhois field, trash it and replace it with the remote one.
- std::string* text;
- if (dest->GetExt("swhois", text))
- {
- dest->Shrink("swhois");
- delete text;
- }
+ // if they already have an swhois field, trash it and replace it with the remote one.
+ std::string* text;
+ if (dest->GetExt("swhois", text))
+ {
+ dest->Shrink("swhois");
+ delete text;
+ }
- if (extdata.empty())
- return; // XXX does the command parser even allow sending blank mdata? it needs to here! -- w00t
+ if (extdata.empty())
+ return;
- text = new std::string(extdata);
- dest->Extend("swhois", text);
- }
+ text = new std::string(extdata);
+ dest->Extend("swhois", text);
}
virtual void OnPostCommand(const std::string &command, const std::vector<std::string> &params, User *user, CmdResult result, const std::string &original_line)
@@ -240,7 +229,7 @@ class ModuleSWhois : public Module
std::string *text = new std::string(swhois);
user->Extend("swhois", text);
- ServerInstance->PI->SendMetaData(user, TYPE_USER, "swhois", *text);
+ ServerInstance->PI->SendMetaData(user, "swhois", *text);
}
virtual ~ModuleSWhois()
diff --git a/src/modules/m_taxonomy.cpp b/src/modules/m_taxonomy.cpp
index 6f06b3660..83ee05749 100644
--- a/src/modules/m_taxonomy.cpp
+++ b/src/modules/m_taxonomy.cpp
@@ -20,10 +20,9 @@
class CommandTaxonomy : public Command
{
Module* Creator;
- bool& claimed;
public:
/* Command 'taxonomy', takes no parameters and needs no special modes */
- CommandTaxonomy (InspIRCd* Instance, Module* maker, bool &claim) : Command(Instance,"TAXONOMY", "o", 1), Creator(maker), claimed(claim)
+ CommandTaxonomy (InspIRCd* Instance, Module* maker) : Command(Instance,"TAXONOMY", "o", 1), Creator(maker)
{
this->source = "m_taxonomy.so";
syntax = "<nickname>";
@@ -37,15 +36,7 @@ class CommandTaxonomy : public Command
std::deque<std::string> list;
dest->GetExtList(list);
user->WriteNumeric(304, "" + std::string(user->nick) + ":TAXONOMY ITEMS " + std::string(dest->nick) + " " +ConvToStr(list.size()));
- for (unsigned int j = 0; j < list.size(); j++)
- {
- claimed = false;
- FOREACH_MOD(I_OnSyncUserMetaData, OnSyncUserMetaData(dest, Creator, user, list[j], true));
- if (!claimed)
- {
- user->WriteNumeric(304, "" + std::string(user->nick) + ":TAXONOMY METADATA " + list[j] + " = <unknown>");
- }
- }
+ FOREACH_MOD(I_OnSyncUser, OnSyncUser(dest, Creator, user));
user->WriteNumeric(304, "" + std::string(user->nick) + ":TAXONOMY END");
}
return CMD_LOCALONLY;
@@ -55,24 +46,19 @@ class CommandTaxonomy : public Command
class ModuleTaxonomy : public Module
{
CommandTaxonomy cmd;
- bool claimed;
public:
ModuleTaxonomy(InspIRCd* Me)
- : Module(Me), cmd(Me, this, claimed)
+ : Module(Me), cmd(Me, this)
{
ServerInstance->AddCommand(&cmd);
}
- void ProtoSendMetaData(void* opaque, TargetTypeFlags target_type, void* target, const std::string &extname, const std::string &extdata)
+ void ProtoSendMetaData(void* opaque, Extensible* target, const std::string &extname, const std::string &extdata)
{
- if (target_type == TYPE_USER)
- {
- User* spoolto = (User*)opaque;
- std::string taxstr = "304 " + std::string(spoolto->nick) + ":TAXONOMY METADATA "+extname+" = "+extdata;
- spoolto->WriteServ(taxstr);
- claimed = true;
- }
+ User* spoolto = (User*)opaque;
+ std::string taxstr = "304 " + std::string(spoolto->nick) + ":TAXONOMY METADATA "+extname+" = "+extdata;
+ spoolto->WriteServ(taxstr);
}
virtual ~ModuleTaxonomy()
@@ -83,6 +69,17 @@ class ModuleTaxonomy : public Module
{
return Version("$Id$", VF_VENDOR, API_VERSION);
}
+
+ virtual std::string ProtoTranslate(Extensible* item)
+ {
+ User* u = dynamic_cast<User*>(item);
+ Channel* c = dynamic_cast<Channel*>(item);
+ if (u)
+ return u->nick;
+ if (c)
+ return c->name;
+ return "?";
+ }
};
MODULE_INIT(ModuleTaxonomy)
diff --git a/src/modules/m_uhnames.cpp b/src/modules/m_uhnames.cpp
index e9038e57a..70036d5a2 100644
--- a/src/modules/m_uhnames.cpp
+++ b/src/modules/m_uhnames.cpp
@@ -24,7 +24,7 @@ class ModuleUHNames : public Module
ModuleUHNames(InspIRCd* Me)
: Module(Me)
{
- Implementation eventlist[] = { I_OnEvent, I_OnSyncUserMetaData, I_OnPreCommand, I_OnNamesListItem, I_On005Numeric };
+ Implementation eventlist[] = { I_OnEvent, I_OnSyncUser, I_OnPreCommand, I_OnNamesListItem, I_On005Numeric };
ServerInstance->Modules->Attach(eventlist, this, 5);
}
@@ -32,10 +32,10 @@ class ModuleUHNames : public Module
{
}
- void OnSyncUserMetaData(User* user, Module* proto,void* opaque, const std::string &extname, bool displayable)
+ void OnSyncUser(User* user, Module* proto,void* opaque)
{
- if ((displayable) && (extname == "UHNAMES"))
- proto->ProtoSendMetaData(opaque, TYPE_USER, user, extname, "Enabled");
+ if (proto->ProtoTranslate(NULL) == "?" && user->GetExt("UHNAMES"))
+ proto->ProtoSendMetaData(opaque, user, "UHNAMES", "Enabled");
}
virtual Version GetVersion()