sstrigler/JSJaC — pull request #65 by spicajames (2013-10-29 14:52:00+00:00)
Title: Added stanzas for adding and removing groups and users from roster

## SetPresenceSubscription

This allows to accept subscriptions
in HandleIQ you could check each contact
```js
.
.
.
$jQuery('item',xmlDoc).each(function(i){
var contact =$jQuery(this)[0].getAttribute("jid");
var name =$jQuery(this)[0].getAttribute("name");
var subscription =$jQuery(this)[0].getAttribute("subscription");
if(subscription == "to"){
var roster = new JSJaCPresence();
var randomnumber=Math.floor(Math.random()*100001)
roster.setPresenceSubscription(null,contact,'subscribed','ps'+randomnumber);
con.send(roster, {result_handler: function(aIq, arg) {
var node = aIq.getQuery();
}});
.
.
.
```

## SetGroup
You can add a member to a new group using something like this
```js
//type can be 'subscribed' most of the times
functionaddGroup(grups, contact, nick, type){
var roster = new JSJaCIQ();
var randomnumber=Math.floor(Math.random()*100001)
roster.setIQ(null, 'set', 'rs'+randomnumber);
roster.setGroup(grups,contact,nick);
con.sendIQ(roster, {result_handler: function(aIq, arg) {
var roster = new JSJaCPresence();
var randomnumber=Math.floor(Math.random()*100001)
roster.setPresenceSubscription(null,contact,type,'ps'+randomnumber);
con.send(roster, {result_handler: function(aIq, arg) {
var node = aIq.getQuery();
alert("Result: " +aIq.xml().htmlEnc());
}});
}});
}
```
## RemoveRoster
You can delete a contact from a group using:
```js
var roster = new JSJaCIQ();
var randomnumber=Math.floor(Math.random()*100001)
roster.setIQ(null, 'set', 'rs'+randomnumber);
roster.removeRoster(contact);
```