Search in sources :

Example 11 with Registration

use of org.jivesoftware.smackx.iqregister.packet.Registration in project Smack by igniterealtime.

the class MultiUserChat method getRegistrationForm.

/**
 * Returns the room's registration form that an unaffiliated user, can use to become a member
 * of the room or <code>null</code> if no registration is possible. Some rooms may restrict the
 * privilege to register members and allow only room admins to add new members.<p>
 *
 * If the user requesting registration requirements is not allowed to register with the room
 * (e.g. because that privilege has been restricted), the room will return a "Not Allowed"
 * error to the user (error code 405).
 *
 * @return the registration Form that contains the fields to complete together with the
 * instrucions or <code>null</code> if no registration is possible.
 * @throws XMPPErrorException if an error occurs asking the registration form for the room or a
 * 405 error if the user is not allowed to register with the room.
 * @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.
 */
public Form getRegistrationForm() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    Registration reg = new Registration();
    reg.setType(IQ.Type.get);
    reg.setTo(room);
    IQ result = connection.sendIqRequestAndWaitForResponse(reg);
    DataForm dataForm = DataForm.from(result);
    return new Form(dataForm);
}
Also used : Form(org.jivesoftware.smackx.xdata.form.Form) DataForm(org.jivesoftware.smackx.xdata.packet.DataForm) FillableForm(org.jivesoftware.smackx.xdata.form.FillableForm) Registration(org.jivesoftware.smackx.iqregister.packet.Registration) IQ(org.jivesoftware.smack.packet.IQ) DataForm(org.jivesoftware.smackx.xdata.packet.DataForm)

Aggregations

Registration (org.jivesoftware.smackx.iqregister.packet.Registration)11 HashMap (java.util.HashMap)6 LinkedList (java.util.LinkedList)2 WeakHashMap (java.util.WeakHashMap)2 IQReplyFilter (org.jivesoftware.smack.filter.IQReplyFilter)2 IQ (org.jivesoftware.smack.packet.IQ)2 ExtensionElement (org.jivesoftware.smack.packet.ExtensionElement)1 XmlElement (org.jivesoftware.smack.packet.XmlElement)1 FillableForm (org.jivesoftware.smackx.xdata.form.FillableForm)1 Form (org.jivesoftware.smackx.xdata.form.Form)1 DataForm (org.jivesoftware.smackx.xdata.packet.DataForm)1