Skip to content

Commit b1e5cbd

Browse files
committed
Merge pull request #31 from arielscarpinelli/archive-preferences
Support to set and get auto archive preference
2 parents 3ef8a05 + 2e072e2 commit b1e5cbd

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

archive/strophe.archive.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,24 @@ Strophe.addConnectionPlugin('archive', {
2424
}
2525
var responseRsm = new Strophe.RSM({xml: stanza.getElementsByTagName('set')[0]});
2626
callback(collections, responseRsm);
27+
},
28+
29+
getAutoArchiving: function(callback) {
30+
var xml = $iq({type: 'get', id: this._connection.getUniqueId('pref')}).c('pref', {xmlns: Strophe.NS.ARCHIVE});
31+
this._connection.sendIQ(xml, this._handleGetPreferencesResponse.bind(this, callback));
32+
},
33+
34+
_handleGetPreferencesResponse: function(callback, stanza) {
35+
var auto = false;
36+
Strophe.forEachChild(stanza.children[0], 'auto', function(child) {
37+
auto = child.attributes.save.value == "true";
38+
});
39+
callback(auto);
40+
},
41+
42+
setAutoArchiving: function(save, success, error, timeout) {
43+
var xml = $iq({type: 'set', id: this._connection.getUniqueId('auto')}).c('auto', {xmlns: Strophe.NS.ARCHIVE, save: save});
44+
this._connection.sendIQ(xml, success, error, timeout);
2745
}
2846
});
2947

0 commit comments

Comments
 (0)