Bug 1142142 - Implement responding to service discovery (XEP-0030) requests. r=aleth
This commit is contained in:
Родитель
ae10a8a2ec
Коммит
a97f89c1a0
|
@ -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,
|
||||
|
|
|
@ -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 <query/> 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.`);
|
||||
},
|
||||
|
|
Загрузка…
Ссылка в новой задаче