From 711861d40e365564e3828a251066c16e924d30f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 22 May 2016 12:54:18 +0200 Subject: Add methods to know which resource is on which server or channel --- src/bridge/bridge.cpp | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'src/bridge/bridge.cpp') diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp index 6008dfc..484c860 100644 --- a/src/bridge/bridge.cpp +++ b/src/bridge/bridge.cpp @@ -46,11 +46,12 @@ Bridge::Bridge(const std::string& user_jid, BiboumiComponent& xmpp, std::shared_ } /** - * Return the role and affiliation, corresponding to the given irc mode */ + * Return the role and affiliation, corresponding to the given irc mode + */ static std::tuple get_role_affiliation_from_irc_mode(const char mode) { - if (mode == 'a' || mode == 'q') - return std::make_tuple("moderator", "owner"); + if (mode == 'a' || mode == 'q'){ + return std::make_tuple("moderator", "owner");} else if (mode == 'o') return std::make_tuple("moderator", "admin"); else if (mode == 'h') @@ -720,3 +721,32 @@ std::unordered_map>& Bridge::get_irc_cli { return this->irc_clients; } + +void Bridge::add_resource_to_chan(const std::string& channel, const std::string& resource) +{ + auto it = this->resources_in_chan.find(channel); + if (it == this->resources_in_chan.end()) + this->resources_in_chan[channel] = {resource}; + else + it->second.insert(resource); +} + +void Bridge::remove_resource_from_chan(const std::string& channel, const std::string& resource) +{ + auto it = this->resources_in_chan.find(channel); + if (it != this->resources_in_chan.end()) + { + it->second.erase(resource); + if (it->second.empty()) + this->resources_in_chan.erase(it); + } +} + +bool Bridge::is_resource_in_chan(const std::string& channel, const std::string& resource) const +{ + auto it = this->resources_in_chan.find(channel); + if (it != this->resources_in_chan.end()) + if (it->second.count(resource) == 1) + return true; + return false; +} -- cgit v1.2.3