private Element addAffiliationToResult(String affiliation, Element parent, JID jid) { Element result = parent.addElement("item", "http://jabber.org/protocol/muc#admin"); result.addAttribute("affiliation", affiliation); result.addAttribute("jid", jid.toString()); try { List<MUCRole> roles = room.getOccupantsByBareJID(jid); MUCRole role = roles.get(0); result.addAttribute("role", role.getRole().toString()); result.addAttribute("nick", role.getNickname()); } catch (UserNotFoundException e) { // the JID is note currently an occupant } return result; } }
@Override public void changeSubject(Message packet, MUCRole role) throws ForbiddenException { if ((canOccupantsChangeSubject() && role.getRole().compareTo(MUCRole.Role.visitor) < 0) || MUCRole.Role.moderator == role.getRole()) { // Set the new subject to the room subject = packet.getSubject(); MUCPersistenceManager.updateRoomSubject(this); // Notify all the occupants that the subject has changed packet.setFrom(role.getRoleAddress()); send(packet); // Fire event signifying that the room's subject has changed. MUCEventDispatcher.roomSubjectChanged(getJID(), role.getUserAddress(), subject); // Let other cluster nodes that the room has been updated CacheFactory.doClusterTask(new RoomUpdatedEvent(this)); } else { throw new ForbiddenException(); } }
private Element addAffiliationToResult(String affiliation, Element parent, JID jid) { Element result = parent.addElement("item", "http://jabber.org/protocol/muc#admin"); result.addAttribute("affiliation", affiliation); result.addAttribute("jid", jid.toString()); try { List<MUCRole> roles = room.getOccupantsByBareJID(jid); MUCRole role = roles.get(0); result.addAttribute("role", role.getRole().toString()); result.addAttribute("nick", role.getNickname()); } catch (UserNotFoundException e) { // the JID is note currently an occupant } return result; } }
public MUCRole.Role getRole() { return MUCRole.Role.values()[role]; }
public MUCRole.Role getRole() { return MUCRole.Role.values()[role]; }
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { serviceDomain = ExternalizableUtil.getInstance().readSafeUTF(in); presence = new Presence((Element)ExternalizableUtil.getInstance().readSerializable(in), true); role = Role.values()[ExternalizableUtil.getInstance().readInt(in)]; affiliation = Affiliation.values()[ExternalizableUtil.getInstance().readInt(in)]; nickname = ExternalizableUtil.getInstance().readSafeUTF(in); voiceOnly = ExternalizableUtil.getInstance().readBoolean(in); roleAddress = (JID) ExternalizableUtil.getInstance().readSerializable(in); userAddress = (JID) ExternalizableUtil.getInstance().readSerializable(in); nodeID = NodeID.getInstance(ExternalizableUtil.getInstance().readByteArray(in)); } }
public MUCRole.Role getRole() { return MUCRole.Role.values()[role]; }
@Override public void sendPublicMessage(Message message, MUCRole senderRole) throws ForbiddenException { // Check that if the room is moderated then the sender of the message has to have voice if (isModerated() && senderRole.getRole().compareTo(MUCRole.Role.participant) > 0) { throw new ForbiddenException(); } // Send the message to all occupants message.setFrom(senderRole.getRoleAddress()); send(message); // Fire event that message was received by the room MUCEventDispatcher.messageReceived(getRole().getRoleAddress(), senderRole.getUserAddress(), senderRole.getNickname(), message); }
public UpdateOccupantRequest(LocalMUCRoom room, String nickname, MUCRole.Affiliation newAffiliation, MUCRole.Role newRole) { super(room); this.nickname = nickname; this.role = newRole.ordinal(); this.affiliation = newAffiliation; }
/** * Calculates and sets the extended presence information to add to the presence. * The information to add contains the user's jid, affiliation and role. */ private void calculateExtendedInformation() { ElementUtil.setProperty(extendedInformation, "x.item:jid", user.getAddress().toString()); ElementUtil.setProperty(extendedInformation, "x.item:affiliation", affiliation.toString()); ElementUtil.setProperty(extendedInformation, "x.item:role", role.toString()); updatePresence(); }
@Override public void writeExternal(ObjectOutput out) throws IOException { ExternalizableUtil.getInstance().writeSafeUTF(out, serviceDomain); ExternalizableUtil.getInstance().writeSerializable(out, (DefaultElement) presence.getElement()); ExternalizableUtil.getInstance().writeInt(out, role.ordinal()); ExternalizableUtil.getInstance().writeInt(out, affiliation.ordinal()); ExternalizableUtil.getInstance().writeSafeUTF(out, nickname); ExternalizableUtil.getInstance().writeBoolean(out, voiceOnly); ExternalizableUtil.getInstance().writeSerializable(out, roleAddress); ExternalizableUtil.getInstance().writeSerializable(out, userAddress); ExternalizableUtil.getInstance().writeByteArray(out, nodeID.toByteArray()); }
public UpdateOccupant(LocalMUCRoom room, MUCRole role) { super(room); this.presence = role.getPresence(); this.nickname = role.getNickname(); this.role = role.getRole().ordinal(); this.affiliation = role.getAffiliation().ordinal(); }
public OccupantAddedEvent(LocalMUCRoom room, MUCRole occupant) { super(room); presence = occupant.getPresence(); role = occupant.getRole().ordinal(); affiliation = occupant.getAffiliation().ordinal(); voiceOnly = occupant.isVoiceOnly(); roleAddress = occupant.getRoleAddress(); userAddress = occupant.getUserAddress(); nodeID = XMPPServer.getInstance().getNodeID(); }
@Override public void changeSubject(Message packet, MUCRole role) throws ForbiddenException { if ((canOccupantsChangeSubject() && role.getRole().compareTo(MUCRole.Role.visitor) < 0) || MUCRole.Role.moderator == role.getRole()) { // Set the new subject to the room subject = packet.getSubject(); MUCPersistenceManager.updateRoomSubject(this); // Notify all the occupants that the subject has changed packet.setFrom(role.getRoleAddress()); send(packet); // Fire event signifying that the room's subject has changed. MUCEventDispatcher.roomSubjectChanged(getJID(), role.getUserAddress(), subject); // Let other cluster nodes that the room has been updated CacheFactory.doClusterTask(new RoomUpdatedEvent(this)); } else { throw new ForbiddenException(); } }
public MUCRole.Role getRole() { return MUCRole.Role.values()[role]; }
public MUCRole.Role getRole() { return MUCRole.Role.values()[role]; }
public MUCRole.Role getRole() { return MUCRole.Role.values()[role]; }
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { serviceDomain = ExternalizableUtil.getInstance().readSafeUTF(in); presence = new Presence((Element)ExternalizableUtil.getInstance().readSerializable(in), true); role = Role.values()[ExternalizableUtil.getInstance().readInt(in)]; affiliation = Affiliation.values()[ExternalizableUtil.getInstance().readInt(in)]; nickname = ExternalizableUtil.getInstance().readSafeUTF(in); voiceOnly = ExternalizableUtil.getInstance().readBoolean(in); roleAddress = (JID) ExternalizableUtil.getInstance().readSerializable(in); userAddress = (JID) ExternalizableUtil.getInstance().readSerializable(in); nodeID = NodeID.getInstance(ExternalizableUtil.getInstance().readByteArray(in)); } }
@Override public void sendPublicMessage(Message message, MUCRole senderRole) throws ForbiddenException { // Check that if the room is moderated then the sender of the message has to have voice if (isModerated() && senderRole.getRole().compareTo(MUCRole.Role.participant) > 0) { throw new ForbiddenException(); } // Send the message to all occupants message.setFrom(senderRole.getRoleAddress()); send(message); // Fire event that message was received by the room MUCEventDispatcher.messageReceived(getRole().getRoleAddress(), senderRole.getUserAddress(), senderRole.getNickname(), message); }
public UpdateOccupant(LocalMUCRoom room, MUCRole role) { super(room); this.presence = role.getPresence(); this.nickname = role.getNickname(); this.role = role.getRole().ordinal(); this.affiliation = role.getAffiliation().ordinal(); }