if (Presence.Type.unavailable.equals(type)) {
removeOccupant(occupantURI);
if (occupantURI.equalsNoResource(session.getCurrentUserURI())) {
status = RoomStatus.locked;
roomManager.closeRoom(this);
eventBus.fireEventFromSource(new RoomChatChangedEvent(ChangeType.closed, this), roomManager);
}
} else if (!Presence.Type.error.equals(type)) {
final XMLPacket xmuc = presence.getExtension("x", XmppNamespaces.MUC_USER);
if (xmuc != null) {
final XMLPacket item = xmuc.getFirstChild("item");
final String affiliation = item.getAttribute("affiliation");
final String role = item.getAttribute("role");
final XmppURI userUri = XmppURI.uri(item.getAttribute("jid"));
setOccupantPresence(userUri, occupantURI, affiliation, role, presence.getShow(), presence.getStatus());
if (hasStatus(xmuc, 201)) {
final IQ iq = new IQ(IQ.Type.set);
iq.setTo(roomUri.getJID());
iq.addQuery(XmppNamespaces.MUC_OWNER).addChild(new Form(Form.Type.submit));
session.sendIQ("rooms", iq, new IQCallback() {
@Override
public void onIQSuccess(final IQ iq) {
status = RoomStatus.ready;
eventBus.fireEventFromSource(new RoomChatChangedEvent(ChangeType.opened, RoomChat.this), roomManager);
}
@Override
public void onIQFailure(final IQ iq) {
}
});
} else {
status = RoomStatus.ready;
eventBus.fireEventFromSource(new RoomChatChangedEvent(ChangeType.opened, this), roomManager);
}
}
}
eventBus.fireEventFromSource(new PresenceReceivedEvent(presence), this);