Commit eb40ce72 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

1. Fixed bug that was sending presence of existing occupants to new occupant...

1. Fixed bug that was sending presence of existing occupants to new occupant even if the existing occupant was "invisible"
2. Fixed NPE
3. Removed TODO


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@715 b35dd754-fafc-0310-a699-88a17e54d16e
parent 3e2584f7
...@@ -464,6 +464,15 @@ public class MUCRoomImpl implements MUCRoom { ...@@ -464,6 +464,15 @@ public class MUCRoomImpl implements MUCRoom {
for (MUCRole occupantsRole : occupants.values()) { for (MUCRole occupantsRole : occupants.values()) {
Presence occupantsPresence = (Presence) occupantsRole.getPresence() Presence occupantsPresence = (Presence) occupantsRole.getPresence()
.createCopy(); .createCopy();
// Skip to the next occupant if we cannot send presence of this occupant
if (hasToCheckRoleToBroadcastPresence()) {
Element frag = occupantsPresence.getChildElement("x",
"http://jabber.org/protocol/muc#user");
// Check if we can broadcast the presence for this role
if (!canBroadcastPresence(frag.element("item").attributeValue("role"))) {
continue;
}
}
occupantsPresence.setFrom(occupantsRole.getRoleAddress()); occupantsPresence.setFrom(occupantsRole.getRoleAddress());
// Don't include the occupant's JID if the room is semi-anon and the new occupant // Don't include the occupant's JID if the room is semi-anon and the new occupant
// is not a moderator // is not a moderator
...@@ -581,10 +590,11 @@ public class MUCRoomImpl implements MUCRoom { ...@@ -581,10 +590,11 @@ public class MUCRoomImpl implements MUCRoom {
if (leaveRole != null) { if (leaveRole != null) {
try { try {
Presence presence = createPresence(Presence.Type.unavailable); Presence presence = (Presence) leaveRole.getPresence().createCopy();
// Switch the presence to OFFLINE
presence.setType(Presence.Type.unavailable);
presence.setFrom(leaveRole.getRoleAddress()); presence.setFrom(leaveRole.getRoleAddress());
presence.getElement().add(leaveRole.getExtendedPresenceInformation().createCopy()); broadcastPresence(presence);
broadcastPresence(presence.createCopy());
leaveRole.kick(); leaveRole.kick();
List params = new ArrayList(); List params = new ArrayList();
params.add(nickname); params.add(nickname);
...@@ -633,10 +643,8 @@ public class MUCRoomImpl implements MUCRoom { ...@@ -633,10 +643,8 @@ public class MUCRoomImpl implements MUCRoom {
presence.setTo(leaveRole.getChatUser().getAddress()); presence.setTo(leaveRole.getChatUser().getAddress());
// A fragment containing the x-extension for room destruction. // A fragment containing the x-extension for room destruction.
// TODO Analyze if we need/can reuse the same fragment instead of creating a Element fragment = presence.addChildElement("x",
// new one each time "http://jabber.org/protocol/muc#user");
Element fragment;
fragment = presence.addChildElement("x", "http://jabber.org/protocol/muc#user");
Element item = fragment.addElement("item"); Element item = fragment.addElement("item");
item.addAttribute("affiliation", "none"); item.addAttribute("affiliation", "none");
item.addAttribute("role", "none"); item.addAttribute("role", "none");
...@@ -787,7 +795,7 @@ public class MUCRoomImpl implements MUCRoom { ...@@ -787,7 +795,7 @@ public class MUCRoomImpl implements MUCRoom {
if (isLogEnabled()) { if (isLogEnabled()) {
MUCRole senderRole = null; MUCRole senderRole = null;
JID senderAddress = null; JID senderAddress = null;
if (message.getTo().getResource() != null) { if (message.getTo() != null && message.getTo().getResource() != null) {
senderRole = occupants.get(message.getTo().getResource()); senderRole = occupants.get(message.getTo().getResource());
} }
if (senderRole == null) { if (senderRole == null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment