diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/base.cpp | 65 | ||||
-rw-r--r-- | src/coremods/core_reloadmodule.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_check.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_httpd_stats.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/metadata.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree/netburst.cpp | 4 |
7 files changed, 74 insertions, 9 deletions
diff --git a/src/base.cpp b/src/base.cpp index 8749aee8e..8cb336985 100644 --- a/src/base.cpp +++ b/src/base.cpp @@ -219,6 +219,71 @@ Extensible::~Extensible() ServerInstance->Logs->Log("CULLLIST", LOG_DEBUG, "Extensible destructor called without cull @%p", (void*)this); } +void ExtensionItem::FromInternal(Extensible* container, const std::string& value) +{ + FromNetwork(container, value); +} + +void ExtensionItem::FromNetwork(Extensible* container, const std::string& value) +{ +} + +std::string ExtensionItem::ToHuman(const Extensible* container, void* item) const +{ + // Try to use the network form by default. + std::string ret = ToNetwork(container, item); + + // If there's no network form then fall back to the internal form. + if (ret.empty()) + ret = ToInternal(container, item); + + return ret; +} + +std::string ExtensionItem::ToInternal(const Extensible* container, void* item) const +{ + return ToNetwork(container, item); +} + +std::string ExtensionItem::ToNetwork(const Extensible* container, void* item) const +{ + return std::string(); +} + +std::string ExtensionItem::serialize(SerializeFormat format, const Extensible* container, void* item) const +{ + // Wrap the deprecated API with the new API. + switch (format) + { + case FORMAT_USER: + return ToHuman(container, item); + case FORMAT_INTERNAL: + case FORMAT_PERSIST: + return ToInternal(container, item); + case FORMAT_NETWORK: + return ToNetwork(container, item); + } + return ""; +} + + +void ExtensionItem::unserialize(SerializeFormat format, Extensible* container, const std::string& value) +{ + // Wrap the deprecated API with the new API. + switch (format) + { + case FORMAT_USER: + break; + case FORMAT_INTERNAL: + case FORMAT_PERSIST: + FromInternal(container, value); + break; + case FORMAT_NETWORK: + FromNetwork(container, value); + break; + } +} + LocalExtItem::LocalExtItem(const std::string& Key, ExtensibleType exttype, Module* mod) : ExtensionItem(Key, exttype, mod) { diff --git a/src/coremods/core_reloadmodule.cpp b/src/coremods/core_reloadmodule.cpp index ea5d40abd..06648fcb2 100644 --- a/src/coremods/core_reloadmodule.cpp +++ b/src/coremods/core_reloadmodule.cpp @@ -379,7 +379,7 @@ void DataKeeper::SaveExtensions(Extensible* extensible, std::vector<InstanceData if (it == setexts.end()) continue; - std::string value = item->serialize(FORMAT_INTERNAL, extensible, it->second); + std::string value = item->ToInternal(extensible, it->second); // If the serialized value is empty the extension won't be saved and restored if (!value.empty()) extdata.push_back(InstanceData(index, value)); @@ -597,7 +597,7 @@ void DataKeeper::RestoreExtensions(const std::vector<InstanceData>& list, Extens for (std::vector<InstanceData>::const_iterator i = list.begin(); i != list.end(); ++i) { const InstanceData& id = *i; - handledexts[id.index].extitem->unserialize(FORMAT_INTERNAL, extensible, id.serialized); + handledexts[id.index].extitem->FromInternal(extensible, id.serialized); } } diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index abbaaab8d..404f20999 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -90,7 +90,7 @@ class CheckContext for(Extensible::ExtensibleStore::const_iterator i = ext->GetExtList().begin(); i != ext->GetExtList().end(); ++i) { ExtensionItem* item = i->first; - std::string value = item->serialize(FORMAT_USER, ext, i->second); + std::string value = item->ToHuman(ext, i->second); if (!value.empty()) Write("meta:" + item->name, value); else if (!item->name.empty()) diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp index 3be8ec970..bb4080fd2 100644 --- a/src/modules/m_httpd_stats.cpp +++ b/src/modules/m_httpd_stats.cpp @@ -86,7 +86,7 @@ namespace Stats for (Extensible::ExtensibleStore::const_iterator i = ext->GetExtList().begin(); i != ext->GetExtList().end(); i++) { ExtensionItem* item = i->first; - std::string value = item->serialize(FORMAT_USER, ext, i->second); + std::string value = item->ToHuman(ext, i->second); if (!value.empty()) data << "<meta name=\"" << item->name << "\">" << Sanitize(value) << "</meta>"; else if (!item->name.empty()) diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 484d72e6d..43417bc3c 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -486,7 +486,7 @@ void ModuleSpanningTree::OnUserConnect(LocalUser* user) for(Extensible::ExtensibleStore::const_iterator i = user->GetExtList().begin(); i != user->GetExtList().end(); i++) { ExtensionItem* item = i->first; - std::string value = item->serialize(FORMAT_NETWORK, user, i->second); + std::string value = item->ToNetwork(user, i->second); if (!value.empty()) ServerInstance->PI->SendMetaData(user, item->name, value); } diff --git a/src/modules/m_spanningtree/metadata.cpp b/src/modules/m_spanningtree/metadata.cpp index 52267c522..816d0758a 100644 --- a/src/modules/m_spanningtree/metadata.cpp +++ b/src/modules/m_spanningtree/metadata.cpp @@ -50,7 +50,7 @@ CmdResult CommandMetadata::Handle(User* srcuser, Params& params) ExtensionItem* item = ServerInstance->Extensions.GetItem(params[2]); if ((item) && (item->type == ExtensionItem::EXT_CHANNEL)) - item->unserialize(FORMAT_NETWORK, c, value); + item->FromNetwork(c, value); FOREACH_MOD(OnDecodeMetaData, (c,params[2],value)); } else @@ -62,7 +62,7 @@ CmdResult CommandMetadata::Handle(User* srcuser, Params& params) std::string value = params.size() < 3 ? "" : params[2]; if ((item) && (item->type == ExtensionItem::EXT_USER)) - item->unserialize(FORMAT_NETWORK, u, value); + item->FromNetwork(u, value); FOREACH_MOD(OnDecodeMetaData, (u,params[1],value)); } } diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index f3f2ea7ac..6d6ada9a5 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -259,7 +259,7 @@ void TreeSocket::SyncChannel(Channel* chan, BurstState& bs) for (Extensible::ExtensibleStore::const_iterator i = chan->GetExtList().begin(); i != chan->GetExtList().end(); i++) { ExtensionItem* item = i->first; - std::string value = item->serialize(FORMAT_NETWORK, chan, i->second); + std::string value = item->ToNetwork(chan, i->second); if (!value.empty()) this->WriteLine(CommandMetadata::Builder(chan, item->name, value)); } @@ -295,7 +295,7 @@ void TreeSocket::SendUsers(BurstState& bs) for (Extensible::ExtensibleStore::const_iterator i = exts.begin(); i != exts.end(); ++i) { ExtensionItem* item = i->first; - std::string value = item->serialize(FORMAT_NETWORK, u->second, i->second); + std::string value = item->ToNetwork(u->second, i->second); if (!value.empty()) this->WriteLine(CommandMetadata::Builder(user, item->name, value)); } |