summaryrefslogtreecommitdiff
path: root/src/xmpp
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-06-18 11:46:28 +0200
committerFlorent Le Coz <louiz@louiz.org>2014-06-20 11:51:49 +0200
commit545ab11ff3a334b242ba2d7fc87e2b6ba0185cb5 (patch)
treec8d914944c0d8061f3db4cb055c26ff6059d297b /src/xmpp
parentb747f2825c43e31ade20267cecefe2c2a9c76241 (diff)
downloadbiboumi-545ab11ff3a334b242ba2d7fc87e2b6ba0185cb5.tar.gz
biboumi-545ab11ff3a334b242ba2d7fc87e2b6ba0185cb5.tar.bz2
biboumi-545ab11ff3a334b242ba2d7fc87e2b6ba0185cb5.tar.xz
biboumi-545ab11ff3a334b242ba2d7fc87e2b6ba0185cb5.zip
Support version request to IRC users
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/xmpp_component.cpp53
-rw-r--r--src/xmpp/xmpp_component.hpp6
2 files changed, 42 insertions, 17 deletions
diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp
index c06b46b..b855d67 100644
--- a/src/xmpp/xmpp_component.cpp
+++ b/src/xmpp/xmpp_component.cpp
@@ -509,10 +509,22 @@ void XmppComponent::handle_iq(const Stanza& stanza)
else if ((query = stanza.get_child("query", VERSION_NS)))
{
Iid iid(to.local);
- if (!iid.is_user)
+ if (iid.is_user ||
+ (iid.is_channel && !to.resource.empty()))
+ {
+ // Get the IRC user version
+ std::string target;
+ if (iid.is_user)
+ target = iid.get_local();
+ else
+ target = to.resource;
+ bridge->send_irc_version_request(iid.get_server(), target, id,
+ from, to_str);
+ }
+ else
{
// On the gateway itself or on a channel
- this->send_self_version(id, from, to_str);
+ this->send_version(id, from, to_str);
}
stanza_error.disable();
}
@@ -983,7 +995,8 @@ 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)
+void XmppComponent::send_version(const std::string& id, const std::string& jid_to, const std::string& jid_from,
+ const std::string& version)
{
Stanza iq("iq");
iq["type"] = "result";
@@ -992,18 +1005,28 @@ void XmppComponent::send_self_version(const std::string& id, const std::string&
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));
+ if (version.empty())
+ {
+ 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));
+ }
+ else
+ {
+ XmlNode name("name");
+ name.set_inner(version);
+ name.close();
+ query.add_child(std::move(name));
+ }
query.close();
iq.add_child(std::move(query));
iq.close();
diff --git a/src/xmpp/xmpp_component.hpp b/src/xmpp/xmpp_component.hpp
index ab1d584..ce594ec 100644
--- a/src/xmpp/xmpp_component.hpp
+++ b/src/xmpp/xmpp_component.hpp
@@ -200,9 +200,11 @@ public:
*/
void send_self_disco_info(const std::string& id, const std::string& jid_to);
/**
- * Send a result IQ with the gateway version.
+ * Send a result IQ with the given version, or the gateway version if the
+ * passed string is empty.
*/
- void send_self_version(const std::string& id, const std::string& jid_to, const std::string& jid_from);
+ void send_version(const std::string& id, const std::string& jid_to, const std::string& jid_from,
+ const std::string& version="");
/**
* Send the list of all available ad-hoc commands to that JID. The list is
* different depending on what JID made the request.