From abcf16bc28a5f72d9e7f964a5f2b432f55dfe5b6 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Mon, 17 Feb 2014 01:31:19 +0100 Subject: Log (xmpp) stream-level errors --- src/xmpp/xmpp_component.cpp | 13 +++++++++++++ src/xmpp/xmpp_component.hpp | 1 + 2 files changed, 14 insertions(+) (limited to 'src') 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: /** -- cgit v1.2.3