/** * Returns a collection of <code>Affiliate</code> that have the specified room affiliation * sending a request in the admin namespace. * * @param affiliation the affiliation of the users in the room. * @return a collection of <code>Affiliate</code> that have the specified room affiliation. * @throws XMPPErrorException if 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<Affiliate> getAffiliatesByAdmin(MUCAffiliation affiliation) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { MUCAdmin iq = new MUCAdmin(); iq.setTo(room); iq.setType(IQ.Type.get); // Set the specified affiliation. This may request the list of owners/admins/members/outcasts. MUCItem item = new MUCItem(affiliation); iq.addItem(item); MUCAdmin answer = (MUCAdmin) connection.createStanzaCollectorAndSend(iq).nextResultOrThrow(); // Get the list of affiliates from the server's answer List<Affiliate> affiliates = new ArrayList<Affiliate>(); for (MUCItem mucadminItem : answer.getItems()) { affiliates.add(new Affiliate(mucadminItem)); } return affiliates; }
/** * Loads all banned users in a ChatRoom. */ public void loadAllBannedUsers() { // Clear all elements from model listModel.clear(); Iterator<Affiliate> bannedUsers = null; try { bannedUsers = chat.getOutcasts().iterator(); } catch (XMPPException | SmackException | InterruptedException e) { Log.error("Error loading all banned users", e); } while (bannedUsers != null && bannedUsers.hasNext()) { Affiliate bannedUser = bannedUsers.next(); ImageIcon icon = SparkRes.getImageIcon(SparkRes.STAR_RED_IMAGE); icon.setDescription(bannedUser.getJid().toString()); listModel.addElement(icon); } }
public List<String> retriveAllAffialiateOfMuc(MultiUserChat muc) throws NoResponseException, XMPPErrorException, NotConnectedException { List<Affiliate> affiliatesMembers = new ArrayList<Affiliate>(); if (muc.getAdmins() != null) { affiliatesMembers.addAll( muc.getAdmins() ); } if ( muc.getMembers() != null) { affiliatesMembers.addAll( muc.getMembers() ); } if ( muc.getOwners() != null ) { affiliatesMembers.addAll( muc.getOwners() ); } if (affiliatesMembers.size() == 0) { System.out.println("Error: looking for a non existant room"); return new ArrayList<String>(0); } List<String> affiliateMembersNames = new ArrayList<String>(affiliatesMembers.size()); for (Affiliate affiliate : affiliatesMembers) { affiliateMembersNames.add(affiliate.getJid().toString()); } return affiliateMembersNames; }
affiliates.add(new Affiliate((MUCAdmin.Item) it.next()));
Affiliate bannedUser = bannedUsers.next(); ImageIcon icon = SparkRes.getImageIcon(SparkRes.RED_BALL); JMenuItem bannedItem = new JMenuItem(bannedUser.getJid().toString(), icon); unbanMenu.add(bannedItem);
affiliates.add(new Affiliate(it.next()));
affiliates.add(new Affiliate((MUCOwner.Item) it.next()));
affiliates.add(new Affiliate((MUCAdmin.Item) it.next()));
affiliates.add(new Affiliate((MUCOwner.Item) it.next()));
affiliates.add(new Affiliate((MUCOwner.Item) it.next()));
affiliates.add(new Affiliate((MUCAdmin.Item) it.next()));
affiliates.add(new Affiliate(it.next()));