~singpolyma/biboumi

61ca40fa0e6c819aa72f3f2364667c7b990855d4 — Florent Le Coz 10 years ago 190c4ff
Delete empty bridges objects
3 files changed, 15 insertions(+), 1 deletions(-)

M src/bridge/bridge.cpp
M src/bridge/bridge.hpp
M src/xmpp/xmpp_component.cpp
M src/bridge/bridge.cpp => src/bridge/bridge.cpp +5 -0
@@ 249,6 249,11 @@ std::string Bridge::get_own_nick(const Iid& iid)
  return "";
}

size_t Bridge::connected_clients() const
{
  return this->irc_clients.size();
}

void Bridge::kick_muc_user(Iid&& iid, const std::string& target, const std::string& reason, const std::string& author)
{
  this->xmpp->kick_user(iid.chan + "%" + iid.server, target, reason, author, this->user_jid);

M src/bridge/bridge.hpp => src/bridge/bridge.hpp +4 -0
@@ 104,6 104,10 @@ public:
   * Misc
   */
  std::string get_own_nick(const Iid& iid);
  /**
   * Get the number of server to which this bridge is connected.
   */
  size_t connected_clients() const;

private:
  /**

M src/xmpp/xmpp_component.cpp => src/xmpp/xmpp_component.cpp +6 -1
@@ 99,9 99,14 @@ void XmppComponent::shutdown()

void XmppComponent::clean()
{
  for (auto it = this->bridges.begin(); it != this->bridges.end(); ++it)
  auto it = this->bridges.begin();
  while (it != this->bridges.end())
  {
    it->second->clean();
    if (it->second->connected_clients() == 0)
      it = this->bridges.erase(it);
    else
      ++it;
  }
}