Commit 7d78cc65 authored by guus's avatar guus

OF-98: Applying patch provided by Florian Schmaus - makes Openfire compatible...

OF-98: Applying patch provided by Florian Schmaus - makes Openfire compatible with specs, but also backwards compatible.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13065 b35dd754-fafc-0310-a699-88a17e54d16e
parent 2b41883a
......@@ -202,6 +202,44 @@ public class IQAdminHandler {
metaData.addAttribute("nick", role.getNickname());
metaData.addAttribute("affiliation", role.getAffiliation().toString());
}
} else if ("owner".equals(affiliation)) {
// The client is requesting the list of owners
Element ownerMetaData;
MUCRole role;
for (JID jid : room.getOwners()) {
ownerMetaData = result.addElement("item", "http://jabber.org/protocol/muc#admin");
ownerMetaData.addAttribute("affiliation", "owner");
ownerMetaData.addAttribute("jid", jid.toBareJID());
// Add role and nick to the metadata if the user is in the room
try {
List<MUCRole> roles = room.getOccupantsByBareJID(jid);
role = roles.get(0);
ownerMetaData.addAttribute("role", role.getRole().toString());
ownerMetaData.addAttribute("nick", role.getNickname());
}
catch (UserNotFoundException e) {
// Do nothing
}
}
} else if ("admin".equals(affiliation)) {
// The client is requesting the list of admins
Element adminMetaData;
MUCRole role;
for (JID jid : room.getAdmins()) {
adminMetaData = result.addElement("item", "http://jabber.org/protocol/muc#admin");
adminMetaData.addAttribute("affiliation", "admin");
adminMetaData.addAttribute("jid", jid.toBareJID());
// Add role and nick to the metadata if the user is in the room
try {
List<MUCRole> roles = room.getOccupantsByBareJID(jid);
role = roles.get(0);
adminMetaData.addAttribute("role", role.getRole().toString());
adminMetaData.addAttribute("nick", role.getNickname());
}
catch (UserNotFoundException e) {
// Do nothing
}
}
} else {
reply.setError(PacketError.Condition.bad_request);
}
......@@ -238,6 +276,10 @@ public class IQAdminHandler {
if ("moderator".equals(target)) {
// Add the user as a moderator of the room based on the full JID
presences.add(room.addModerator(jid, senderRole));
} else if ("owner".equals(target)) {
presences.addAll(room.addOwner(jid, senderRole));
} else if ("admin".equals(target)) {
presences.addAll(room.addAdmin(jid, senderRole));
} else if ("participant".equals(target)) {
// Add the user as a participant of the room based on the full JID
presences.add(room.addParticipant(jid,
......
......@@ -179,6 +179,9 @@ public class IQOwnerHandler {
// Create the result that will hold an item for each owner or admin
Element result = reply.setChildElement("query", "http://jabber.org/protocol/muc#owner");
// muc#owner shouldn't be used as namespace for owner and admin
// listings according to the newest versions of XEP-0045
// this code remains here for backwards compatibility
if ("owner".equals(affiliation)) {
// The client is requesting the list of owners
Element ownerMetaData;
......@@ -262,6 +265,9 @@ public class IQOwnerHandler {
try {
for (JID jid : jids.keySet()) {
String targetAffiliation = jids.get(jid);
// muc#owner shouldn't be used as namespace for owner and admin
// changes according to the newest versions of XEP-0045
// this code remains here for backwards compatibility
if ("owner".equals(targetAffiliation)) {
// Add the new user as an owner of the room
presences.addAll(room.addOwner(jid, senderRole));
......
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