use of org.jivesoftware.smackx.packet.MUCAdmin in project ecf by eclipse.
the class MultiUserChat method changeAffiliationByAdmin.
/**
* Tries to change the affiliation with an 'muc#admin' namespace
*
* @param jid
* @param affiliation
* @param reason the reason for the affiliation change (optional)
* @throws XMPPException
*/
private void changeAffiliationByAdmin(String jid, String affiliation, String reason) throws XMPPException {
MUCAdmin iq = new MUCAdmin();
iq.setTo(room);
iq.setType(IQ.Type.SET);
// Set the new affiliation.
MUCAdmin.Item item = new MUCAdmin.Item(affiliation, null);
item.setJid(jid);
item.setReason(reason);
iq.addItem(item);
// Wait for a response packet back from the server.
PacketFilter responseFilter = new PacketIDFilter(iq.getPacketID());
PacketCollector response = connection.createPacketCollector(responseFilter);
// Send the change request to the server.
connection.sendPacket(iq);
// Wait up to a certain number of seconds for a reply.
IQ answer = (IQ) response.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Stop queuing results
response.cancel();
if (answer == null) {
throw new XMPPException("No response from server.");
} else if (answer.getError() != null) {
throw new XMPPException(answer.getError());
}
}
use of org.jivesoftware.smackx.packet.MUCAdmin in project ecf by eclipse.
the class MUCAdminProvider method parseIQ.
public IQ parseIQ(XmlPullParser parser) throws Exception {
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(parseItem(parser));
}
} else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals("query")) {
done = true;
}
}
}
return mucAdmin;
}
Aggregations