From bafde1af9f284d8d1daf001d59f4b338e5d2f922 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Thu, 15 May 2014 00:27:58 +0200 Subject: Stanza:get_name() only returns the name of the tag, without the namespace --- src/xmpp/xmpp_component.cpp | 10 +++++----- src/xmpp/xmpp_stanza.cpp | 9 +++++++-- src/xmpp/xmpp_stanza.hpp | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp index aa466f5..b87a023 100644 --- a/src/xmpp/xmpp_component.cpp +++ b/src/xmpp/xmpp_component.cpp @@ -61,15 +61,15 @@ XmppComponent::XmppComponent(const std::string& hostname, const std::string& sec std::placeholders::_1)); this->parser.add_stream_close_callback(std::bind(&XmppComponent::on_remote_stream_close, this, std::placeholders::_1)); - this->stanza_handlers.emplace(COMPONENT_NS":handshake", + this->stanza_handlers.emplace("handshake", std::bind(&XmppComponent::handle_handshake, this,std::placeholders::_1)); - this->stanza_handlers.emplace(COMPONENT_NS":presence", + this->stanza_handlers.emplace("presence", std::bind(&XmppComponent::handle_presence, this,std::placeholders::_1)); - this->stanza_handlers.emplace(COMPONENT_NS":message", + this->stanza_handlers.emplace("message", std::bind(&XmppComponent::handle_message, this,std::placeholders::_1)); - this->stanza_handlers.emplace(COMPONENT_NS":iq", + this->stanza_handlers.emplace("iq", std::bind(&XmppComponent::handle_iq, this,std::placeholders::_1)); - this->stanza_handlers.emplace(STREAM_NS":error", + this->stanza_handlers.emplace("error", std::bind(&XmppComponent::handle_error, this,std::placeholders::_1)); } diff --git a/src/xmpp/xmpp_stanza.cpp b/src/xmpp/xmpp_stanza.cpp index 948e5f5..400971b 100644 --- a/src/xmpp/xmpp_stanza.cpp +++ b/src/xmpp/xmpp_stanza.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include @@ -183,9 +184,13 @@ XmlNode* XmlNode::get_parent() const return this->parent; } -const std::string& XmlNode::get_name() const +const std::string XmlNode::get_name() const { - return this->name; + const std::vector splited = utils::split(this->name, ':', false); + if (splited.empty()) + return ""; + const std::string res = splited.back(); + return res; } std::string XmlNode::to_string() const diff --git a/src/xmpp/xmpp_stanza.hpp b/src/xmpp/xmpp_stanza.hpp index 1c63b86..9dee51f 100644 --- a/src/xmpp/xmpp_stanza.hpp +++ b/src/xmpp/xmpp_stanza.hpp @@ -85,7 +85,7 @@ public: */ void close(); XmlNode* get_parent() const; - const std::string& get_name() const; + const std::string get_name() const; /** * Serialize the stanza into a string */ -- cgit v1.2.3