Skip to content

Commit

Permalink
Merge pull request #31 from arielscarpinelli/archive-preferences
Browse files Browse the repository at this point in the history
Support to set and get auto archive preference
  • Loading branch information
jcbrand committed Sep 17, 2014
2 parents 3ef8a05 + 2e072e2 commit b1e5cbd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions archive/strophe.archive.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,24 @@ Strophe.addConnectionPlugin('archive', {
}
var responseRsm = new Strophe.RSM({xml: stanza.getElementsByTagName('set')[0]});
callback(collections, responseRsm);
},

getAutoArchiving: function(callback) {
var xml = $iq({type: 'get', id: this._connection.getUniqueId('pref')}).c('pref', {xmlns: Strophe.NS.ARCHIVE});
this._connection.sendIQ(xml, this._handleGetPreferencesResponse.bind(this, callback));
},

_handleGetPreferencesResponse: function(callback, stanza) {
var auto = false;
Strophe.forEachChild(stanza.children[0], 'auto', function(child) {
auto = child.attributes.save.value == "true";
});
callback(auto);
},

setAutoArchiving: function(save, success, error, timeout) {
var xml = $iq({type: 'set', id: this._connection.getUniqueId('auto')}).c('auto', {xmlns: Strophe.NS.ARCHIVE, save: save});
this._connection.sendIQ(xml, success, error, timeout);
}
});

Expand Down

0 comments on commit b1e5cbd

Please sign in to comment.