Commit 1261a252 authored by JC Brand's avatar JC Brand

Use Strophe.RSM for result set management.

parent b77d76b3
...@@ -118,6 +118,11 @@ ...@@ -118,6 +118,11 @@
} }
}; };
// Global constants
// XEP-0059 Result Set Management
var RSM_ATTRIBUTES = ['max', 'first', 'last', 'after', 'before', 'index', 'count'];
var STATUS_WEIGHTS = { var STATUS_WEIGHTS = {
'offline': 6, 'offline': 6,
'unavailable': 5, 'unavailable': 5,
...@@ -6138,14 +6143,14 @@ ...@@ -6138,14 +6143,14 @@
} }
}); });
stanza.up(); stanza.up();
if (options.limit) { if (_.intersection(RSM_ATTRIBUTES, _.keys(options)).length) {
stanza.c('set', {'xmlns':Strophe.NS.RSM}).c('max').t(options.limit).up(); stanza.cnode(new Strophe.RSM(options).toXML());
}
if (options.after) {
stanza.c('after').t(options.after).up();
} }
} }
converse.connection.sendIQ(stanza, callback, errback); converse.connection.sendIQ(stanza, function (iq) {
var rsm = new Strophe.RSM({xml: iq.getElementsByTagName('set')[0]});
return _.bind(callback, this, arguments)(rsm);
}, errback);
} }
}, },
'rooms': { 'rooms': {
......
...@@ -27,17 +27,18 @@ require.config({ ...@@ -27,17 +27,18 @@ require.config({
"jquery.browser": "components/jquery.browser/dist/jquery.browser", "jquery.browser": "components/jquery.browser/dist/jquery.browser",
"jquery.easing": "components/jquery-easing-original/index", // XXX: Only required for https://conversejs.org website "jquery.easing": "components/jquery-easing-original/index", // XXX: Only required for https://conversejs.org website
"moment": "components/momentjs/moment", "moment": "components/momentjs/moment",
"strophe": "components/strophejs/src/wrapper",
"strophe-base64": "components/strophejs/src/base64", "strophe-base64": "components/strophejs/src/base64",
"strophe-bosh": "components/strophejs/src/bosh", "strophe-bosh": "components/strophejs/src/bosh",
"strophe-core": "components/strophejs/src/core", "strophe-core": "components/strophejs/src/core",
"strophe": "components/strophejs/src/wrapper",
"strophe-md5": "components/strophejs/src/md5", "strophe-md5": "components/strophejs/src/md5",
"strophe-polyfill": "components/strophejs/src/polyfills",
"strophe-sha1": "components/strophejs/src/sha1", "strophe-sha1": "components/strophejs/src/sha1",
"strophe-websocket": "components/strophejs/src/websocket", "strophe-websocket": "components/strophejs/src/websocket",
"strophe-polyfill": "components/strophejs/src/polyfills",
"strophe.disco": "components/strophejs-plugins/disco/strophe.disco", "strophe.disco": "components/strophejs-plugins/disco/strophe.disco",
"strophe.vcard": "src/strophe.vcard",
"strophe.ping": "src/strophe.ping", "strophe.ping": "src/strophe.ping",
"strophe.rsm": "components/strophejs-plugins/rsm/strophe.rsm",
"strophe.vcard": "src/strophe.vcard",
"text": 'components/requirejs-text/text', "text": 'components/requirejs-text/text',
"tpl": 'components/requirejs-tpl-jcbrand/tpl', "tpl": 'components/requirejs-tpl-jcbrand/tpl',
"typeahead": "components/typeahead.js/index", "typeahead": "components/typeahead.js/index",
...@@ -185,10 +186,9 @@ require.config({ ...@@ -185,10 +186,9 @@ require.config({
'crypto.sha1': { deps: ['crypto.core'] }, 'crypto.sha1': { deps: ['crypto.core'] },
'crypto.sha256': { deps: ['crypto.core'] }, 'crypto.sha256': { deps: ['crypto.core'] },
'bigint': { deps: ['crypto'] }, 'bigint': { deps: ['crypto'] },
'strophe.disco': { deps: ['strophe'] }, 'strophe.ping': { deps: ['strophe'] },
'strophe.register': { deps: ['strophe'] }, 'strophe.register': { deps: ['strophe'] },
'strophe.vcard': { deps: ['strophe'] }, 'strophe.vcard': { deps: ['strophe'] }
'strophe.ping': { deps: ['strophe'] }
} }
}); });
......
...@@ -161,7 +161,7 @@ ...@@ -161,7 +161,7 @@
Date.prototype.getTimezoneOffset = function () { Date.prototype.getTimezoneOffset = function () {
return -120; return -120;
}; };
converse_api.archive.query({'start': '2010-06-07T00:00:00Z', 'limit':10}); converse_api.archive.query({'start': '2010-06-07T00:00:00Z', 'max':10});
var queryid = $(sent_stanza.toString()).find('query').attr('queryid'); var queryid = $(sent_stanza.toString()).find('query').attr('queryid');
expect(sent_stanza.toString()).toBe( expect(sent_stanza.toString()).toBe(
"<iq type='set' xmlns='jabber:client' id='"+IQ_id+"'>"+ "<iq type='set' xmlns='jabber:client' id='"+IQ_id+"'>"+
...@@ -202,7 +202,7 @@ ...@@ -202,7 +202,7 @@
converse_api.archive.query({ converse_api.archive.query({
'start': '2010-06-07T00:00:00Z', 'start': '2010-06-07T00:00:00Z',
'after': '09af3-cc343-b409f', 'after': '09af3-cc343-b409f',
'limit':10 'max':10
}); });
var queryid = $(sent_stanza.toString()).find('query').attr('queryid'); var queryid = $(sent_stanza.toString()).find('query').attr('queryid');
expect(sent_stanza.toString()).toBe( expect(sent_stanza.toString()).toBe(
......
...@@ -4,9 +4,10 @@ define("converse-dependencies", [ ...@@ -4,9 +4,10 @@ define("converse-dependencies", [
"otr", "otr",
"moment_with_locales", "moment_with_locales",
"strophe", "strophe",
"strophe.vcard",
"strophe.disco", "strophe.disco",
"strophe.ping", "strophe.ping",
"strophe.rsm",
"strophe.vcard",
"backbone.browserStorage", "backbone.browserStorage",
"backbone.overview", "backbone.overview",
"jquery.browser", "jquery.browser",
......
...@@ -3,9 +3,10 @@ define("converse-dependencies", [ ...@@ -3,9 +3,10 @@ define("converse-dependencies", [
"utils", "utils",
"moment_with_locales", "moment_with_locales",
"strophe", "strophe",
"strophe.vcard",
"strophe.disco", "strophe.disco",
"strophe.ping", "strophe.ping",
"strophe.rsm",
"strophe.vcard",
"backbone.browserStorage", "backbone.browserStorage",
"backbone.overview", "backbone.overview",
"jquery.browser", "jquery.browser",
......
...@@ -3,9 +3,10 @@ define("converse-dependencies", [ ...@@ -3,9 +3,10 @@ define("converse-dependencies", [
"utils", "utils",
"moment_with_locales", "moment_with_locales",
"strophe", "strophe",
"strophe.vcard",
"strophe.disco", "strophe.disco",
"strophe.ping", "strophe.ping",
"strophe.rsm",
"strophe.vcard",
"bootstrapJS", // XXX: Can be removed, only for https://conversejs.org "bootstrapJS", // XXX: Can be removed, only for https://conversejs.org
"backbone.browserStorage", "backbone.browserStorage",
"backbone.overview", "backbone.overview",
......
...@@ -5,9 +5,10 @@ define("converse-dependencies", [ ...@@ -5,9 +5,10 @@ define("converse-dependencies", [
"otr", "otr",
"moment_with_locales", "moment_with_locales",
"strophe", "strophe",
"strophe.vcard",
"strophe.disco", "strophe.disco",
"strophe.ping", "strophe.ping",
"strophe.rsm",
"strophe.vcard",
"bootstrapJS", // XXX: Only for https://conversejs.org "bootstrapJS", // XXX: Only for https://conversejs.org
"backbone.browserStorage", "backbone.browserStorage",
"backbone.overview", "backbone.overview",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment