summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-04-24 19:36:14 +0200
committerFlorent Le Coz <louiz@louiz.org>2014-04-24 19:36:14 +0200
commit6ebb586b6ce097d5768e3863411042f4dc6c979e (patch)
tree012ee0312b0e19503fa3b3dfe5d572633b51db2f
parent98ef49e78734b1d9cc3b0145ad256b8f14b769b6 (diff)
downloadbiboumi-6ebb586b6ce097d5768e3863411042f4dc6c979e.tar.gz
biboumi-6ebb586b6ce097d5768e3863411042f4dc6c979e.tar.bz2
biboumi-6ebb586b6ce097d5768e3863411042f4dc6c979e.tar.xz
biboumi-6ebb586b6ce097d5768e3863411042f4dc6c979e.zip
Respond to a disco query the gateway jid itself
-rw-r--r--src/xmpp/xmpp_component.cpp40
-rw-r--r--src/xmpp/xmpp_component.hpp4
2 files changed, 44 insertions, 0 deletions
diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp
index 78149c4..1eacf7c 100644
--- a/src/xmpp/xmpp_component.cpp
+++ b/src/xmpp/xmpp_component.cpp
@@ -416,6 +416,17 @@ void XmppComponent::handle_iq(const Stanza& stanza)
}
}
}
+ else if (type == "get")
+ {
+ XmlNode* query;
+ if ((query = stanza.get_child(DISCO_INFO_NS":query")))
+ { // Disco info
+ if (to_str == this->served_hostname)
+ { // On the gateway itself
+ this->send_self_disco_info(id, from);
+ }
+ }
+ }
else
{
error_type = "cancel";
@@ -735,3 +746,32 @@ void XmppComponent::send_affiliation_role_change(const std::string& muc_name,
presence.close();
this->send_stanza(presence);
}
+
+void XmppComponent::send_self_disco_info(const std::string& id, const std::string& jid_to)
+{
+ Stanza iq("iq");
+ iq["type"] = "result";
+ iq["id"] = id;
+ iq["to"] = jid_to;
+ iq["from"] = this->served_hostname;
+ XmlNode query("query");
+ query["xmlns"] = DISCO_INFO_NS;
+ XmlNode identity("identity");
+ identity["category"] = "conference";
+ identity["type"] = "irc";
+ identity["name"] = "Biboumi XMPP-IRC gateway";
+ identity.close();
+ query.add_child(std::move(identity));
+ for (const std::string& ns: {"http://jabber.org/protocol/disco#info",
+ "http://jabber.org/protocol/muc"})
+ {
+ XmlNode feature("feature");
+ feature["var"] = ns;
+ feature.close();
+ query.add_child(std::move(feature));
+ }
+ query.close();
+ iq.add_child(std::move(query));
+ iq.close();
+ this->send_stanza(iq);
+}
diff --git a/src/xmpp/xmpp_component.hpp b/src/xmpp/xmpp_component.hpp
index 3e13086..aa19be3 100644
--- a/src/xmpp/xmpp_component.hpp
+++ b/src/xmpp/xmpp_component.hpp
@@ -145,6 +145,10 @@ public:
const std::string& role,
const std::string& jid_to);
/**
+ * Send a result IQ with the gateway disco informations.
+ */
+ void send_self_disco_info(const std::string& id, const std::string& jid_to);
+ /**
* Handle the various stanza types
*/
void handle_handshake(const Stanza& stanza);