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, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException {
MUCAdmin mucAdmin = new MUCAdmin();
boolean done = false;
while (!done) {
XmlPullParser.Event eventType = parser.next();
if (eventType == XmlPullParser.Event.START_ELEMENT) {
if (parser.getName().equals("item")) {
mucAdmin.addItem(MUCParserUtils.parseItem(parser));
}
} else if (eventType == XmlPullParser.Event.END_ELEMENT) {
if (parser.getName().equals("query")) {
done = true;
}
}
}
return mucAdmin;
}
use of org.jivesoftware.smackx.muc.packet.MUCAdmin in project Smack by igniterealtime.
the class MultiUserChat method getOccupants.
/**
* 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 occurred 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 if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
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.sendIqRequestAndWaitForResponse(iq);
// 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;
}
use of org.jivesoftware.smackx.muc.packet.MUCAdmin in project Smack by igniterealtime.
the class MultiUserChat method changeRole.
private void changeRole(Collection<Resourcepart> nicknames, MUCRole role) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
MUCAdmin iq = new MUCAdmin();
iq.setTo(room);
iq.setType(IQ.Type.set);
for (Resourcepart nickname : nicknames) {
// Set the new role.
MUCItem item = new MUCItem(role, nickname);
iq.addItem(item);
}
connection.sendIqRequestAndWaitForResponse(iq);
}
Aggregations