@Override public Presence createPresence(Presence.Type presenceType) throws UnauthorizedException { Presence presence = new Presence(); presence.setType(presenceType); presence.setFrom(role.getRoleAddress()); return presence; }
if (originator) { MUCEventDispatcher.occupantLeft(getRole().getRoleAddress(), userAddress);
@Override public List<Presence> setMembersOnly(boolean membersOnly) { List<Presence> presences = new ArrayList<>(); if (membersOnly && !this.membersOnly) { // If the room was not members-only and now it is, kick occupants that aren't member // of the room for (MUCRole occupant : occupantsByFullJID.values()) { if (occupant.getAffiliation().compareTo(MUCRole.Affiliation.member) > 0) { try { presences.add(kickOccupant(occupant.getRoleAddress(), null, null, LocaleUtils.getLocalizedString("muc.roomIsNowMembersOnly"))); } catch (NotAllowedException e) { Log.error(e.getMessage(), e); } } } } this.membersOnly = membersOnly; return presences; }
public void nicknameChanged(ChangeNickname changeNickname) { List<MUCRole> occupants = occupantsByNickname.get(changeNickname.getOldNick().toLowerCase()); if (occupants != null && occupants.size() > 0) { for (MUCRole occupant : occupants) { // Update the role with the new info occupant.setPresence(changeNickname.getPresence()); occupant.changeNickname(changeNickname.getNewNick()); } if (changeNickname.isOriginator()) { // Fire event that user changed his nickname MUCEventDispatcher.nicknameChanged(getRole().getRoleAddress(), occupants.get(0).getUserAddress(), changeNickname.getOldNick(), changeNickname.getNewNick()); } // Associate the existing MUCRole with the new nickname occupantsByNickname.put(changeNickname.getNewNick().toLowerCase(), occupants); // Remove the old nickname occupantsByNickname.remove(changeNickname.getOldNick().toLowerCase()); } }
mucService.removeChatRoom(name); MUCEventDispatcher.roomDestroyed(getRole().getRoleAddress());
&& loadedRoom.getSubject().length() > 0) loadedRoom.getRoomHistory().addOldMessage( loadedRoom.getRole().getRoleAddress().toString(), null, loadedRoom.getModificationDate(),
answer.add(new DiscoItem(room.getRole().getRoleAddress(), room.getNaturalLanguageName(), null, null)); for (MUCRole role : room.getOccupants()) { answer.add(new DiscoItem(role.getRoleAddress(), null, null, null));
@Override public void serverBroadcast(String msg) { Message message = new Message(); message.setType(Message.Type.groupchat); message.setBody(msg); message.setFrom(role.getRoleAddress()); broadcast(message); }
@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); }
if (event.isOriginator()) { MUCEventDispatcher.occupantJoined(getRole().getRoleAddress(), event.getUserAddress(), joinRole.getNickname());
@Override public void sendPrivatePacket(Packet packet, MUCRole senderRole) throws NotFoundException, ForbiddenException { switch (senderRole.getRole()) { // intended fall-through case none: throw new ForbiddenException(); default: case visitor: if (canSendPrivateMessage().equals( "participants" )) throw new ForbiddenException(); case participant: if (canSendPrivateMessage().equals( "moderators" )) throw new ForbiddenException(); case moderator: if (canSendPrivateMessage().equals( "none" )) throw new ForbiddenException(); } String resource = packet.getTo().getResource(); List<MUCRole> occupants = occupantsByNickname.get(resource.toLowerCase()); if (occupants == null || occupants.size() == 0) { throw new NotFoundException(); } for (MUCRole occupant : occupants) { packet.setFrom(senderRole.getRoleAddress()); occupant.send(packet); if(packet instanceof Message) { Message message = (Message) packet; MUCEventDispatcher.privateMessageRecieved(occupant.getUserAddress(), senderRole.getUserAddress(), message); } } }
JID roomJID = room.getRole().getRoleAddress(); message.setFrom(room.getRole().getRoleAddress()); delayInformation.addAttribute("from", room.getRole().getRoleAddress().toString());
presence.setFrom(removedRole.getRoleAddress()); MUCEventDispatcher.roomDestroyed(getRole().getRoleAddress());
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 sendInvitationRejection(JID to, String reason, JID sender) { if (((MultiUserChatServiceImpl)mucService).getMUCDelegate() != null) { switch(((MultiUserChatServiceImpl)mucService).getMUCDelegate().sendingInvitationRejection(this, to, sender, reason)) { case HANDLED_BY_DELEGATE: //if the delegate is taking care of it, there's nothing for us to do return; case HANDLED_BY_OPENFIRE: //continue as normal if we're asked to handle it break; } } Message message = new Message(); message.setFrom(role.getRoleAddress()); message.setTo(to); Element frag = message.addChildElement("x", "http://jabber.org/protocol/muc#user"); frag.addElement("decline").addAttribute("from", sender.toBareJID()); if (reason != null && reason.length() > 0) { frag.element("decline").addElement("reason").setText(reason); } // Send the message with the invitation router.route(message); }
senderAddress = getRole().getRoleAddress();
@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(); } }
fromJID.equals(room.getRole().getRoleAddress()))) { return;
message.setFrom(role.getRoleAddress()); message.setTo(to); frag.addAttribute("jid", role.getRoleAddress().toBareJID());
MUCEventDispatcher.roomCreated(room.getRole().getRoleAddress());