response = null;
response = new Presence(Presence.Type.subscribe);
response.setTo(presence.getFrom());
connection.sendPacket(response);
// update the roster with the new user
RosterPacket rosterPacket = new RosterPacket();
rosterPacket.setType(IQ.Type.SET);
RosterPacket.Item item = new RosterPacket.Item(presence.getFrom(), parseName(presence.getFrom()));
item.addGroupName(OLATBUDDIES);
item.setItemType(RosterPacket.ItemType.both);
// item.setItemStatus(RosterPacket.ItemStatus.fromString());
rosterPacket.addRosterItem(item);
connection.sendPacket(rosterPacket);
}
}
if (presence.getType() == Presence.Type.subscribe) {
subscribedUsers.add(presence.getFrom());