1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-26 14:02:06 +01:00

MultiUserChat grant/revoke Admin must use #admin namepsace

SMACK-371
This commit is contained in:
Florian Schmaus 2014-08-24 17:43:29 +02:00
parent 659714c2be
commit 754bdada18

View file

@ -1311,7 +1311,7 @@ public class MultiUserChat {
* @throws NotConnectedException * @throws NotConnectedException
*/ */
public void grantAdmin(Collection<String> jids) throws XMPPErrorException, NoResponseException, NotConnectedException { public void grantAdmin(Collection<String> jids) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByOwner(jids, "admin"); changeAffiliationByAdmin(jids, "admin");
} }
/** /**
@ -1326,7 +1326,7 @@ public class MultiUserChat {
* @throws NotConnectedException * @throws NotConnectedException
*/ */
public void grantAdmin(String jid) throws XMPPErrorException, NoResponseException, NotConnectedException { public void grantAdmin(String jid) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByOwner(jid, "admin"); changeAffiliationByAdmin(jid, "admin");
} }
/** /**
@ -1340,7 +1340,7 @@ public class MultiUserChat {
* @throws NotConnectedException * @throws NotConnectedException
*/ */
public void revokeAdmin(Collection<String> jids) throws XMPPErrorException, NoResponseException, NotConnectedException { public void revokeAdmin(Collection<String> jids) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByOwner(jids, "member"); changeAffiliationByAdmin(jids, "member");
} }
/** /**
@ -1355,35 +1355,22 @@ public class MultiUserChat {
* @throws NotConnectedException * @throws NotConnectedException
*/ */
public void revokeAdmin(String jid) throws XMPPErrorException, NoResponseException, NotConnectedException { public void revokeAdmin(String jid) throws XMPPErrorException, NoResponseException, NotConnectedException {
changeAffiliationByOwner(jid, "member"); changeAffiliationByAdmin(jid, "member");
} }
private void changeAffiliationByOwner(String jid, String affiliation) /**
throws XMPPErrorException, NoResponseException, NotConnectedException { * Tries to change the affiliation with an 'muc#admin' namespace
MUCOwner iq = new MUCOwner(); *
iq.setTo(room); * @param jid
iq.setType(IQ.Type.set); * @param affiliation
// Set the new affiliation. * @throws XMPPErrorException
MUCItem item = new MUCItem(affiliation); * @throws NoResponseException
item.setJid(jid); * @throws NotConnectedException
iq.addItem(item); */
private void changeAffiliationByAdmin(String jid, String affiliation)
connection.createPacketCollectorAndSend(iq).nextResultOrThrow(); throws NoResponseException, XMPPErrorException,
} NotConnectedException {
changeAffiliationByAdmin(jid, affiliation, null);
private void changeAffiliationByOwner(Collection<String> jids, String affiliation)
throws NoResponseException, XMPPErrorException, NotConnectedException {
MUCOwner iq = new MUCOwner();
iq.setTo(room);
iq.setType(IQ.Type.set);
for (String jid : jids) {
// Set the new affiliation.
MUCItem item = new MUCItem(affiliation);
item.setJid(jid);
iq.addItem(item);
}
connection.createPacketCollectorAndSend(iq).nextResultOrThrow();
} }
/** /**