summaryrefslogtreecommitdiff
path: root/src/bridge/bridge.cpp
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-06-19 22:21:49 +0200
committerFlorent Le Coz <louiz@louiz.org>2014-06-19 22:21:49 +0200
commit26ffc8fe121e03e1b663aa0015a71b0fc914f95e (patch)
tree098ca791e05911ecdc7ae22620c263669e37f7d3 /src/bridge/bridge.cpp
parenta705b9af7b1bbce6b6c94788398a4cff9cad9ec9 (diff)
downloadbiboumi-26ffc8fe121e03e1b663aa0015a71b0fc914f95e.tar.gz
biboumi-26ffc8fe121e03e1b663aa0015a71b0fc914f95e.tar.bz2
biboumi-26ffc8fe121e03e1b663aa0015a71b0fc914f95e.tar.xz
biboumi-26ffc8fe121e03e1b663aa0015a71b0fc914f95e.zip
Implement a way to add callbacks, waiting for an IRC event to return an iq
Diffstat (limited to 'src/bridge/bridge.cpp')
-rw-r--r--src/bridge/bridge.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp
index a0964df..c2ac11f 100644
--- a/src/bridge/bridge.cpp
+++ b/src/bridge/bridge.cpp
@@ -4,6 +4,7 @@
#include <irc/irc_message.hpp>
#include <network/poller.hpp>
#include <utils/encoding.hpp>
+#include <utils/tolower.hpp>
#include <logger/logger.hpp>
#include <utils/split.hpp>
#include <stdexcept>
@@ -369,3 +370,20 @@ void Bridge::remove_preferred_from_jid(const std::string& nick)
if (it != this->preferred_user_from.end())
this->preferred_user_from.erase(it);
}
+
+void Bridge::add_waiting_iq(iq_responder_callback_t&& callback)
+{
+ this->waiting_iq.emplace_back(std::move(callback));
+}
+
+void Bridge::trigger_response_iq(const std::string& irc_hostname, const IrcMessage& message)
+{
+ auto it = this->waiting_iq.begin();
+ while (it != this->waiting_iq.end())
+ {
+ if ((*it)(irc_hostname, message) == true)
+ it = this->waiting_iq.erase(it);
+ else
+ ++it;
+ }
+}