Search in sources :

Example 1 with MUCAdmin

use of org.jivesoftware.smackx.muc.packet.MUCAdmin in project Smack by igniterealtime.

the class MUCAdminProvider method parse.

@Override
public MUCAdmin parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
    MUCAdmin mucAdmin = new MUCAdmin();
    boolean done = false;
    while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            if (parser.getName().equals("item")) {
                mucAdmin.addItem(MUCParserUtils.parseItem(parser));
            }
        } else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals("query")) {
                done = true;
            }
        }
    }
    return mucAdmin;
}
Also used : MUCAdmin(org.jivesoftware.smackx.muc.packet.MUCAdmin)

Example 2 with MUCAdmin

use of org.jivesoftware.smackx.muc.packet.MUCAdmin in project Smack by igniterealtime.

the class MultiUserChat method getAffiliatesByAdmin.

/**
 * 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 if the XMPP connection is not connected.
 * @throws InterruptedException if the calling thread was interrupted.
 */
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.sendIqRequestAndWaitForResponse(iq);
    // 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;
}
Also used : MUCItem(org.jivesoftware.smackx.muc.packet.MUCItem) MUCAdmin(org.jivesoftware.smackx.muc.packet.MUCAdmin) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList)

Example 3 with MUCAdmin

use of org.jivesoftware.smackx.muc.packet.MUCAdmin in project Smack by igniterealtime.

the class MultiUserChat method changeAffiliationByAdmin.

private void changeAffiliationByAdmin(Collection<? extends Jid> jids, MUCAffiliation affiliation) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    MUCAdmin iq = new MUCAdmin();
    iq.setTo(room);
    iq.setType(IQ.Type.set);
    for (Jid jid : jids) {
        // Set the new affiliation.
        MUCItem item = new MUCItem(affiliation, jid);
        iq.addItem(item);
    }
    connection.sendIqRequestAndWaitForResponse(iq);
}
Also used : MUCItem(org.jivesoftware.smackx.muc.packet.MUCItem) EntityJid(org.jxmpp.jid.EntityJid) DomainBareJid(org.jxmpp.jid.DomainBareJid) EntityBareJid(org.jxmpp.jid.EntityBareJid) Jid(org.jxmpp.jid.Jid) EntityFullJid(org.jxmpp.jid.EntityFullJid) MUCAdmin(org.jivesoftware.smackx.muc.packet.MUCAdmin)

Example 4 with MUCAdmin

use of org.jivesoftware.smackx.muc.packet.MUCAdmin in project Smack by igniterealtime.

the class MultiUserChat method changeAffiliationByAdmin.

/**
 * Tries to change the affiliation with an 'muc#admin' namespace
 *
 * @param jid TODO javadoc me please
 * @param affiliation TODO javadoc me please
 * @param reason the reason for the affiliation change (optional)
 * @throws XMPPErrorException if there was an XMPP error returned.
 * @throws NoResponseException if there was no response from the remote entity.
 * @throws NotConnectedException if the XMPP connection is not connected.
 * @throws InterruptedException if the calling thread was interrupted.
 */
private void changeAffiliationByAdmin(Jid jid, MUCAffiliation affiliation, String reason) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    MUCAdmin iq = new MUCAdmin();
    iq.setTo(room);
    iq.setType(IQ.Type.set);
    // Set the new affiliation.
    MUCItem item = new MUCItem(affiliation, jid, reason);
    iq.addItem(item);
    connection.sendIqRequestAndWaitForResponse(iq);
}
Also used : MUCItem(org.jivesoftware.smackx.muc.packet.MUCItem) MUCAdmin(org.jivesoftware.smackx.muc.packet.MUCAdmin)

Example 5 with MUCAdmin

use of org.jivesoftware.smackx.muc.packet.MUCAdmin in project Smack by igniterealtime.

the class MultiUserChat method changeRole.

private void changeRole(Resourcepart nickname, MUCRole role, String reason) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    MUCAdmin iq = new MUCAdmin();
    iq.setTo(room);
    iq.setType(IQ.Type.set);
    // Set the new role.
    MUCItem item = new MUCItem(role, nickname, reason);
    iq.addItem(item);
    connection.sendIqRequestAndWaitForResponse(iq);
}
Also used : MUCItem(org.jivesoftware.smackx.muc.packet.MUCItem) MUCAdmin(org.jivesoftware.smackx.muc.packet.MUCAdmin)

Aggregations

MUCAdmin (org.jivesoftware.smackx.muc.packet.MUCAdmin)8 MUCItem (org.jivesoftware.smackx.muc.packet.MUCItem)6 ArrayList (java.util.ArrayList)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 XmlPullParser (org.jivesoftware.smack.xml.XmlPullParser)1 DomainBareJid (org.jxmpp.jid.DomainBareJid)1 EntityBareJid (org.jxmpp.jid.EntityBareJid)1 EntityFullJid (org.jxmpp.jid.EntityFullJid)1 EntityJid (org.jxmpp.jid.EntityJid)1 Jid (org.jxmpp.jid.Jid)1 Resourcepart (org.jxmpp.jid.parts.Resourcepart)1