diff --git a/chat/protocols/xmpp/xmpp-xml.jsm b/chat/protocols/xmpp/xmpp-xml.jsm index 464f4d13d5..30997db5c9 100644 --- a/chat/protocols/xmpp/xmpp-xml.jsm +++ b/chat/protocols/xmpp/xmpp-xml.jsm @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -this.EXPORTED_SYMBOLS = ["Stanza", "XMPPParser"]; +this.EXPORTED_SYMBOLS = ["Stanza", "XMPPParser", "SupportedFeatures"]; var {classes: Cc, interfaces: Ci, results: Cr, utils: Cu} = Components; @@ -47,6 +47,7 @@ var NS = { muc_user : "http://jabber.org/protocol/muc#user", muc_owner : "http://jabber.org/protocol/muc#owner", muc_admin : "http://jabber.org/protocol/muc#admin", + muc_rooms : "http://jabber.org/protocol/muc#rooms", conference : "jabber:x:conference", muc : "http://jabber.org/protocol/muc", register : "jabber:iq:register", @@ -91,6 +92,19 @@ var TOP_LEVEL_ELEMENTS = { "error" : "urn:ietf:params:xml:ns:xmpp-streams" }; +// Features that we support in XMPP. +// Don't forget to add your new features here. +var SupportedFeatures = [ + NS.chatstates, + NS.conference, + NS.disco_info, + NS.last, + NS.muc, + NS.ping, + NS.vcard, + NS.version +]; + /* Stanza Builder */ var Stanza = { NS: NS, diff --git a/chat/protocols/xmpp/xmpp.jsm b/chat/protocols/xmpp/xmpp.jsm index 8a85c710d7..a8185d7045 100644 --- a/chat/protocols/xmpp/xmpp.jsm +++ b/chat/protocols/xmpp/xmpp.jsm @@ -1703,6 +1703,27 @@ var XMPPAccountPrototype = { this.sendStanza(Stanza.iq("result", id, from, versionQuery)); return; } + if (query && query.uri == Stanza.NS.disco_info) { + // XEP-0030: Service Discovery. + let children = []; + if (aStanza.attributes["node"] == Stanza.NS.muc_rooms) { + // XEP-0045 (6.7): Room query. + // TODO: Currently, we return an empty element, but we + // should return non-private rooms. + } + else { + children = SupportedFeatures.map(feature => + Stanza.node("feature", null, {var: feature}) + ); + children.unshift(Stanza.node("identity", null, + {category: "client", type: "pc", + name: Services.appinfo.name})); + } + let discoveryQuery = + Stanza.node("query", Stanza.NS.disco_info, null, children); + this.sendStanza(Stanza.iq("result", id, from, discoveryQuery)); + return; + } } this.WARN(`Unhandled IQ ${type} stanza.`); },