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;
}
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;
}
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);
}
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);
}
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);
}
Aggregations