summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-06-17 21:41:09 +0200
committerFlorent Le Coz <louiz@louiz.org>2014-06-20 10:45:42 +0200
commitb747f2825c43e31ade20267cecefe2c2a9c76241 (patch)
tree62f97b797b4c44b78de0cd3e8b3996cc946d0d87
parentaaf71774131198de2095c07e560fb420833c544d (diff)
downloadbiboumi-b747f2825c43e31ade20267cecefe2c2a9c76241.tar.gz
biboumi-b747f2825c43e31ade20267cecefe2c2a9c76241.tar.bz2
biboumi-b747f2825c43e31ade20267cecefe2c2a9c76241.tar.xz
biboumi-b747f2825c43e31ade20267cecefe2c2a9c76241.zip
Respond to IQ version on the gateway, a server or a chan with biboumi version
ref #2455
-rw-r--r--src/config.h.cmake3
-rw-r--r--src/xmpp/xmpp_component.cpp37
-rw-r--r--src/xmpp/xmpp_component.hpp4
3 files changed, 43 insertions, 1 deletions
diff --git a/src/config.h.cmake b/src/config.h.cmake
index bb4a5b8..d8833ad 100644
--- a/src/config.h.cmake
+++ b/src/config.h.cmake
@@ -1,6 +1,7 @@
+#define SYSTEM_NAME "${CMAKE_SYSTEM}"
#cmakedefine ICONV_SECOND_ARGUMENT_IS_CONST
#cmakedefine LIBIDN_FOUND
#cmakedefine SYSTEMDDAEMON_FOUND
#cmakedefine POLLER ${POLLER}
#cmakedefine BOTAN_FOUND
-#cmakedefine BIBOUMI_VERSION "${BIBOUMI_VERSION}" \ No newline at end of file
+#cmakedefine BIBOUMI_VERSION "${BIBOUMI_VERSION}"
diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp
index 5ecb283..c06b46b 100644
--- a/src/xmpp/xmpp_component.cpp
+++ b/src/xmpp/xmpp_component.cpp
@@ -506,6 +506,16 @@ void XmppComponent::handle_iq(const Stanza& stanza)
}
}
}
+ else if ((query = stanza.get_child("query", VERSION_NS)))
+ {
+ Iid iid(to.local);
+ if (!iid.is_user)
+ {
+ // On the gateway itself or on a channel
+ this->send_self_version(id, from, to_str);
+ }
+ stanza_error.disable();
+ }
else if ((query = stanza.get_child("query", DISCO_ITEMS_NS)))
{
const std::string node = query->get_tag("node");
@@ -973,6 +983,33 @@ void XmppComponent::send_self_disco_info(const std::string& id, const std::strin
this->send_stanza(iq);
}
+void XmppComponent::send_self_version(const std::string& id, const std::string& jid_to, const std::string& jid_from)
+{
+ Stanza iq("iq");
+ iq["type"] = "result";
+ iq["id"] = id;
+ iq["to"] = jid_to;
+ iq["from"] = jid_from;
+ XmlNode query("query");
+ query["xmlns"] = VERSION_NS;
+ XmlNode name("name");
+ name.set_inner("biboumi");
+ name.close();
+ query.add_child(std::move(name));
+ XmlNode version("version");
+ version.set_inner(BIBOUMI_VERSION);
+ version.close();
+ query.add_child(std::move(version));
+ XmlNode os("os");
+ os.set_inner(SYSTEM_NAME);
+ os.close();
+ query.add_child(std::move(os));
+ query.close();
+ iq.add_child(std::move(query));
+ iq.close();
+ this->send_stanza(iq);
+}
+
void XmppComponent::send_adhoc_commands_list(const std::string& id, const std::string& requester_jid)
{
Stanza iq("iq");
diff --git a/src/xmpp/xmpp_component.hpp b/src/xmpp/xmpp_component.hpp
index ac12e40..ab1d584 100644
--- a/src/xmpp/xmpp_component.hpp
+++ b/src/xmpp/xmpp_component.hpp
@@ -200,6 +200,10 @@ public:
*/
void send_self_disco_info(const std::string& id, const std::string& jid_to);
/**
+ * Send a result IQ with the gateway version.
+ */
+ void send_self_version(const std::string& id, const std::string& jid_to, const std::string& jid_from);
+ /**
* Send the list of all available ad-hoc commands to that JID. The list is
* different depending on what JID made the request.
*/