summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-02-17 01:31:19 +0100
committerFlorent Le Coz <louiz@louiz.org>2014-02-17 01:31:19 +0100
commitabcf16bc28a5f72d9e7f964a5f2b432f55dfe5b6 (patch)
tree42411a48056b8ead10855b24bdf2641520dd5853
parent6dbf36b974cd641f4541599496b04ad48ab41c87 (diff)
downloadbiboumi-abcf16bc28a5f72d9e7f964a5f2b432f55dfe5b6.tar.gz
biboumi-abcf16bc28a5f72d9e7f964a5f2b432f55dfe5b6.tar.bz2
biboumi-abcf16bc28a5f72d9e7f964a5f2b432f55dfe5b6.tar.xz
biboumi-abcf16bc28a5f72d9e7f964a5f2b432f55dfe5b6.zip
Log (xmpp) stream-level errors
-rw-r--r--src/xmpp/xmpp_component.cpp13
-rw-r--r--src/xmpp/xmpp_component.hpp1
2 files changed, 14 insertions, 0 deletions
diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp
index 92c614c..bf06101 100644
--- a/src/xmpp/xmpp_component.cpp
+++ b/src/xmpp/xmpp_component.cpp
@@ -20,6 +20,7 @@
#define DISCO_INFO_NS DISCO_NS"#info"
#define XHTMLIM_NS "http://jabber.org/protocol/xhtml-im"
#define STANZA_NS "urn:ietf:params:xml:ns:xmpp-stanzas"
+#define STREAMS_NS "urn:ietf:params:xml:ns:xmpp-streams"
XmppComponent::XmppComponent(const std::string& hostname, const std::string& secret):
served_hostname(hostname),
@@ -41,6 +42,8 @@ XmppComponent::XmppComponent(const std::string& hostname, const std::string& sec
std::bind(&XmppComponent::handle_message, this,std::placeholders::_1));
this->stanza_handlers.emplace(COMPONENT_NS":iq",
std::bind(&XmppComponent::handle_iq, this,std::placeholders::_1));
+ this->stanza_handlers.emplace(STREAM_NS":error",
+ std::bind(&XmppComponent::handle_error, this,std::placeholders::_1));
}
XmppComponent::~XmppComponent()
@@ -179,6 +182,7 @@ void XmppComponent::handle_handshake(const Stanza& stanza)
{
(void)stanza;
this->authenticated = true;
+ log_info("Authenticated with the XMPP server");
}
void XmppComponent::handle_presence(const Stanza& stanza)
@@ -271,6 +275,15 @@ void XmppComponent::handle_iq(const Stanza& stanza)
}
}
+void XmppComponent::handle_error(const Stanza& stanza)
+{
+ XmlNode* text = stanza.get_child(STREAMS_NS":text");
+ std::string error_message("Unspecified error");
+ if (text)
+ error_message = text->get_inner();
+ log_error("Stream error received from the XMPP server: " << error_message);
+}
+
Bridge* XmppComponent::get_user_bridge(const std::string& user_jid)
{
try
diff --git a/src/xmpp/xmpp_component.hpp b/src/xmpp/xmpp_component.hpp
index f86d930..fb9282b 100644
--- a/src/xmpp/xmpp_component.hpp
+++ b/src/xmpp/xmpp_component.hpp
@@ -128,6 +128,7 @@ public:
void handle_presence(const Stanza& stanza);
void handle_message(const Stanza& stanza);
void handle_iq(const Stanza& stanza);
+ void handle_error(const Stanza& stanza);
private:
/**