mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 12:02:05 +01:00
[muc] Add roomconfig_changesubject support to MucConfigFormManager
This commit is contained in:
parent
147071ff64
commit
a708387210
1 changed files with 33 additions and 0 deletions
|
@ -25,6 +25,7 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.muc.MultiUserChatException.MucConfigurationNotSupportedException;
|
import org.jivesoftware.smackx.muc.MultiUserChatException.MucConfigurationNotSupportedException;
|
||||||
|
import org.jivesoftware.smackx.xdata.BooleanFormField;
|
||||||
import org.jivesoftware.smackx.xdata.FormField;
|
import org.jivesoftware.smackx.xdata.FormField;
|
||||||
import org.jivesoftware.smackx.xdata.form.FillableForm;
|
import org.jivesoftware.smackx.xdata.form.FillableForm;
|
||||||
import org.jivesoftware.smackx.xdata.form.FilledForm;
|
import org.jivesoftware.smackx.xdata.form.FilledForm;
|
||||||
|
@ -98,6 +99,11 @@ public class MucConfigFormManager {
|
||||||
*/
|
*/
|
||||||
public static final String MUC_ROOMCONFIG_ENABLE_PUBLIC_LOGGING = "muc#roomconfig_enablelogging";
|
public static final String MUC_ROOMCONFIG_ENABLE_PUBLIC_LOGGING = "muc#roomconfig_enablelogging";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The constant String {@value}.
|
||||||
|
*/
|
||||||
|
public static final String MUC_ROOMCONFIG_CHANGE_SUBJECT = "muc#roomconfig_changesubject";
|
||||||
|
|
||||||
private final MultiUserChat multiUserChat;
|
private final MultiUserChat multiUserChat;
|
||||||
private final FillableForm answerForm;
|
private final FillableForm answerForm;
|
||||||
private final List<Jid> owners;
|
private final List<Jid> owners;
|
||||||
|
@ -374,6 +380,33 @@ public class MucConfigFormManager {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean supportsChangeSubjectByOccupant() {
|
||||||
|
return answerForm.hasField(MUC_ROOMCONFIG_CHANGE_SUBJECT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean occupantsAreAllowedToChangeSubject() throws MucConfigurationNotSupportedException {
|
||||||
|
if (!supportsChangeSubjectByOccupant()) {
|
||||||
|
throw new MucConfigurationNotSupportedException(MUC_ROOMCONFIG_CHANGE_SUBJECT);
|
||||||
|
}
|
||||||
|
return answerForm.getField(MUC_ROOMCONFIG_CHANGE_SUBJECT).ifPossibleAsOrThrow(BooleanFormField.class).getValueAsBoolean();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MucConfigFormManager setChangeSubjectByOccupant(boolean enabled) throws MucConfigurationNotSupportedException {
|
||||||
|
if (!supportsChangeSubjectByOccupant()) {
|
||||||
|
throw new MucConfigurationNotSupportedException(MUC_ROOMCONFIG_CHANGE_SUBJECT);
|
||||||
|
}
|
||||||
|
answerForm.setAnswer(MUC_ROOMCONFIG_CHANGE_SUBJECT, enabled);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MucConfigFormManager allowOccupantsToChangeSubject() throws MucConfigurationNotSupportedException {
|
||||||
|
return setChangeSubjectByOccupant(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MucConfigFormManager disallowOccupantsToChangeSubject() throws MucConfigurationNotSupportedException {
|
||||||
|
return setChangeSubjectByOccupant(false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Submit the configuration as {@link FilledForm} to the room.
|
* Submit the configuration as {@link FilledForm} to the room.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue