/** * Returns the Occupant information for a particular occupant, or <tt>null</tt> if the * user is not in the room. The Occupant object may include information such as full * JID of the user as well as the role and affiliation of the user in the room.<p> * * @param user the room occupant to search for his presence. The format of user must * be: roomName@service/nickname (e.g. darkcave@macbeth.shakespeare.lit/thirdwitch). * @return the Occupant or <tt>null</tt> if the user is unavailable (i.e. not in the room). */ public Occupant getOccupant(EntityFullJid user) { Presence presence = getOccupantPresence(user); if (presence != null) { return new Occupant(presence); } return null; }
recipients.add(muc.getOccupant(e).getJid().asBareJid());
@Override public ChatRoomMemberRole getRole() { if (this.role == null) { Occupant o = chatRoom.getOccupant(this); if (o == null) { return ChatRoomMemberRole.GUEST; } else { this.role = ChatRoomJabberImpl.smackRoleToScRole( o.getRole(), o.getAffiliation()); } } return this.role; }
/** * Checks to see if the Occupant is the owner of the room. * * @param occupant the occupant of a room. * @return true if the user is an owner. */ public boolean isOwner(Occupant occupant) { return occupant != null && occupant.getAffiliation() == MUCAffiliation.owner; }
/** * Checks to see if the Occupant is a moderator. * * @param occupant the Occupant of a room. * @return true if the user is a moderator. */ public boolean isModerator(Occupant occupant) { return occupant != null && occupant.getRole() == MUCRole.moderator; }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final FakeRosterEntry other = (FakeRosterEntry) obj; if (this.occupant != other.occupant && (this.occupant == null || !this.occupant.equals(other.occupant))) { return false; } return true; }
final boolean userIsAdmin = userManager.isAdmin(groupChatRoom, occupant.getNick()); final boolean userIsOwner = userManager.isOwner(occupant); final boolean userIsModerator = userManager.isModerator(occupant);
@Override public ChatRoomMemberRole getUserRole() { if (this.role == null) { Occupant o = muc.getOccupant(myOccupantJid); if (o == null) { return null; } else { this.role = ChatRoomJabberImpl.smackRoleToScRole( o.getRole(), o.getAffiliation()); } } return this.role; }
/** * Checks if the Occupant is a Member in this Room<br> * <b>admins and owners are also members!!!</b> * @param occupant * @return true if member, else false */ public boolean isMember(Occupant occupant) { return occupant != null && ( occupant.getAffiliation() == MUCAffiliation.owner || occupant.getAffiliation() == MUCAffiliation.member || occupant.getAffiliation() == MUCAffiliation.admin ); }
public boolean hasVoice(GroupChatRoom groupChatRoom, Resourcepart nickname) { Occupant occupant = getOccupant(groupChatRoom, nickname); if (occupant != null) { if ( MUCRole.visitor == occupant.getRole()) { return false; } } return true; }
/** * Returns a list of <code>Occupant</code> that have the specified room role. * * @param role the role of the occupant in the room. * @return a list of <code>Occupant</code> that have the specified room role. * @throws XMPPErrorException if an error occured while performing the request to the server or you * don't have enough privileges to get this information. * @throws NoResponseException if there was no response from the server. * @throws NotConnectedException * @throws InterruptedException */ private List<Occupant> getOccupants(MUCRole role) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { MUCAdmin iq = new MUCAdmin(); iq.setTo(room); iq.setType(IQ.Type.get); // Set the specified role. This may request the list of moderators/participants. MUCItem item = new MUCItem(role); iq.addItem(item); MUCAdmin answer = (MUCAdmin) connection.createStanzaCollectorAndSend(iq).nextResultOrThrow(); // Get the list of participants from the server's answer List<Occupant> participants = new ArrayList<Occupant>(); for (MUCItem mucadminItem : answer.getItems()) { participants.add(new Occupant(mucadminItem)); } return participants; }
if (muc != null) { Occupant occupant = muc.getOccupant(stanza.getFrom().asEntityFullJidIfPossible()); Jid occupantJid = occupant.getJid();
/** * Checks to see if the Occupant is an admin. * * @param occupant the occupant of a room. * @return true if the user is an admin. */ public boolean isAdmin(Occupant occupant) { return occupant != null && occupant.getAffiliation() == MUCAffiliation.admin; }
/** * Returns the Occupant information for a particular occupant, or <tt>null</tt> if the * user is not in the room. The Occupant object may include information such as full * JID of the user as well as the role and affiliation of the user in the room.<p> * * @param user the room occupant to search for his presence. The format of user must * be: roomName@service/nickname (e.g. darkcave@macbeth.shakespeare.lit/thirdwitch). * @return the Occupant or <tt>null</tt> if the user is unavailable (i.e. not in the room). */ public Occupant getOccupant(String user) { Presence presence = occupantsMap.get(user); if (presence != null) { return new Occupant(presence); } return null; }
return; Jid occupantJid = occupant.getJid();
/** * Returns the Occupant information for a particular occupant, or <tt>null</tt> if the * user is not in the room. The Occupant object may include information such as full * JID of the user as well as the role and affiliation of the user in the room.<p> * * @param user the room occupant to search for his presence. The format of user must * be: roomName@service/nickname (e.g. darkcave@macbeth.shakespeare.lit/thirdwitch). * @return the Occupant or <tt>null</tt> if the user is unavailable (i.e. not in the room). */ public Occupant getOccupant(String user) { Presence presence = (Presence) occupantsMap.get(user); if (presence != null) { return new Occupant(presence); } return null; }
public String getUser() { return StringUtils.parseName(occupant.getJid()); }
/** * Returns the Occupant information for a particular occupant, or <tt>null</tt> if the * user is not in the room. The Occupant object may include information such as full * JID of the user as well as the role and affiliation of the user in the room.<p> * * @param user the room occupant to search for his presence. The format of user must * be: roomName@service/nickname (e.g. darkcave@macbeth.shakespeare.lit/thirdwitch). * @return the Occupant or <tt>null</tt> if the user is unavailable (i.e. not in the room). */ public Occupant getOccupant(String user) { Presence presence = occupantsMap.get(user); if (presence != null) { return new Occupant(presence); } return null; }
public String getJid() { return StringUtils.parseBareAddress(occupant.getJid()); }
/** * Returns the Occupant information for a particular occupant, or <tt>null</tt> if the * user is not in the room. The Occupant object may include information such as full * JID of the user as well as the role and affiliation of the user in the room.<p> * * @param user the room occupant to search for his presence. The format of user must * be: roomName@service/nickname (e.g. darkcave@macbeth.shakespeare.lit/thirdwitch). * @return the Occupant or <tt>null</tt> if the user is unavailable (i.e. not in the room). */ public Occupant getOccupant(String user) { Presence presence = occupantsMap.get(user); if (presence != null) { return new Occupant(presence); } return null; }