private void processPresence(boolean canProceed, Presence presence) {
try {
if (Presence.Type.subscribe == presence.getType()) {
// Accept all presence requests if user has permissions
// Reply that the subscription request was approved or rejected
Presence reply = new Presence();
reply.setTo(presence.getFrom());
reply.setFrom(presence.getTo());
reply.setType(canProceed ? Presence.Type.subscribed : Presence.Type.unsubscribed);
componentManager.sendPacket(this, reply);
}
else if (Presence.Type.unsubscribe == presence.getType()) {
// Send confirmation of unsubscription
Presence reply = new Presence();
reply.setTo(presence.getFrom());
reply.setFrom(presence.getTo());
reply.setType(Presence.Type.unsubscribed);
componentManager.sendPacket(this, reply);
if (!canProceed) {
// Send unavailable presence of the service
reply = new Presence();
reply.setTo(presence.getFrom());
reply.setFrom(presence.getTo());
reply.setType(Presence.Type.unavailable);
componentManager.sendPacket(this, reply);
}
}
else if (Presence.Type.probe == presence.getType()) {
// Send that the service is available
Presence reply = new Presence();
reply.setTo(presence.getFrom());
reply.setFrom(presence.getTo());
if (!canProceed) {
// Send forbidden error since user is not allowed
reply.setError(PacketError.Condition.forbidden);
}
componentManager.sendPacket(this, reply);
}
}
catch (ComponentException e) {