From eb6b8df7c59be796b1be93ee57be0ed5f6088fea Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Tue, 13 Jan 2015 12:59:07 +0100 Subject: [PATCH] Add MultiUserChat.requestVoice() --- .../smackx/muc/MultiUserChat.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java index 020906879..a76177afe 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java @@ -67,6 +67,8 @@ import org.jivesoftware.smackx.muc.packet.MUCOwner; import org.jivesoftware.smackx.muc.packet.MUCUser; import org.jivesoftware.smackx.muc.packet.MUCUser.Status; import org.jivesoftware.smackx.xdata.Form; +import org.jivesoftware.smackx.xdata.FormField; +import org.jivesoftware.smackx.xdata.packet.DataForm; /** * A MultiUserChat is a conversation that takes place among many users in a virtual @@ -920,6 +922,29 @@ public class MultiUserChat { changeRole(nickname, MUCRole.none, reason); } + /** + * Sends a voice request to the MUC. The room moderators usually need to approve this request. + * + * @throws NotConnectedException + * @see XEP-45 ยง 7.13 Requesting + * Voice + * @since 4.1 + */ + public void requestVoice() throws NotConnectedException { + DataForm form = new DataForm(DataForm.Type.submit); + FormField formTypeField = new FormField(FormField.FORM_TYPE); + formTypeField.addValue(MUCInitialPresence.NAMESPACE + "#request"); + form.addField(formTypeField); + FormField requestVoiceField = new FormField("muc#role"); + requestVoiceField.setType(FormField.Type.text_single); + requestVoiceField.setLabel("Requested role"); + requestVoiceField.addValue("participant"); + form.addField(requestVoiceField); + Message message = new Message(room); + message.addExtension(form); + connection.sendPacket(message); + } + /** * Grants voice to visitors in the room. In a moderated room, a moderator may want to manage * who does and does not have "voice" in the room. To have voice means that a room occupant