Search in sources :

Example 1 with MUCOwner

use of org.jivesoftware.smackx.muc.packet.MUCOwner in project Smack by igniterealtime.

the class MUCOwnerProvider method parse.

@Override
public MUCOwner parse(XmlPullParser parser, int initialDepth) throws Exception {
    MUCOwner mucOwner = new MUCOwner();
    boolean done = false;
    while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            if (parser.getName().equals("item")) {
                mucOwner.addItem(MUCParserUtils.parseItem(parser));
            } else if (parser.getName().equals("destroy")) {
                mucOwner.setDestroy(MUCParserUtils.parseDestroy(parser));
            } else // Otherwise, it must be a packet extension.
            {
                PacketParserUtils.addExtensionElement(mucOwner, parser);
            }
        } else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals("query")) {
                done = true;
            }
        }
    }
    return mucOwner;
}
Also used : MUCOwner(org.jivesoftware.smackx.muc.packet.MUCOwner)

Example 2 with MUCOwner

use of org.jivesoftware.smackx.muc.packet.MUCOwner in project Smack by igniterealtime.

the class MultiUserChat method sendConfigurationForm.

/**
 * Sends the completed configuration form to the server. The room will be configured
 * with the new settings defined in the form.
 *
 * @param form the form with the new settings.
 * @throws XMPPErrorException if an error occurs setting the new rooms' configuration.
 * @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 void sendConfigurationForm(FillableForm form) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    final DataForm dataForm;
    if (form != null) {
        dataForm = form.getDataFormToSubmit();
    } else {
        // Instant room, cf. XEP-0045 ยง 10.1.2
        dataForm = DataForm.builder().build();
    }
    MUCOwner iq = new MUCOwner();
    iq.setTo(room);
    iq.setType(IQ.Type.set);
    iq.addExtension(dataForm);
    connection.sendIqRequestAndWaitForResponse(iq);
}
Also used : DataForm(org.jivesoftware.smackx.xdata.packet.DataForm) MUCOwner(org.jivesoftware.smackx.muc.packet.MUCOwner)

Example 3 with MUCOwner

use of org.jivesoftware.smackx.muc.packet.MUCOwner in project Smack by igniterealtime.

the class MUCOwnerProvider method parse.

@Override
public MUCOwner parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
    MUCOwner mucOwner = new MUCOwner();
    boolean done = false;
    while (!done) {
        XmlPullParser.Event eventType = parser.next();
        if (eventType == XmlPullParser.Event.START_ELEMENT) {
            if (parser.getName().equals("item")) {
                mucOwner.addItem(MUCParserUtils.parseItem(parser));
            } else if (parser.getName().equals("destroy")) {
                mucOwner.setDestroy(MUCParserUtils.parseDestroy(parser));
            } else // Otherwise, it must be a packet extension.
            {
                PacketParserUtils.addExtensionElement(mucOwner, parser, xmlEnvironment);
            }
        } else if (eventType == XmlPullParser.Event.END_ELEMENT) {
            if (parser.getName().equals("query")) {
                done = true;
            }
        }
    }
    return mucOwner;
}
Also used : XmlPullParser(org.jivesoftware.smack.xml.XmlPullParser) MUCOwner(org.jivesoftware.smackx.muc.packet.MUCOwner)

Example 4 with MUCOwner

use of org.jivesoftware.smackx.muc.packet.MUCOwner in project Smack by igniterealtime.

the class MultiUserChat method sendConfigurationForm.

/**
     * Sends the completed configuration form to the server. The room will be configured
     * with the new settings defined in the form.
     *
     * @param form the form with the new settings.
     * @throws XMPPErrorException if an error occurs setting the new rooms' configuration.
     * @throws NoResponseException if there was no response from the server.
     * @throws NotConnectedException 
     * @throws InterruptedException
     */
public void sendConfigurationForm(Form form) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    MUCOwner iq = new MUCOwner();
    iq.setTo(room);
    iq.setType(IQ.Type.set);
    iq.addExtension(form.getDataFormToSend());
    connection.createStanzaCollectorAndSend(iq).nextResultOrThrow();
}
Also used : MUCOwner(org.jivesoftware.smackx.muc.packet.MUCOwner)

Example 5 with MUCOwner

use of org.jivesoftware.smackx.muc.packet.MUCOwner in project Smack by igniterealtime.

the class MultiUserChat method getConfigurationForm.

/**
 * Returns the room's configuration form that the room's owner can use.
 * The configuration form allows to set the room's language,
 * enable logging, specify room's type, etc..
 *
 * @return the Form that contains the fields to complete together with the instrucions or
 * <code>null</code> if no configuration is possible.
 * @throws XMPPErrorException if an error occurs asking the configuration form for 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 getConfigurationForm() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    MUCOwner iq = new MUCOwner();
    iq.setTo(room);
    iq.setType(IQ.Type.get);
    IQ answer = connection.sendIqRequestAndWaitForResponse(iq);
    DataForm dataForm = DataForm.from(answer, MucConfigFormManager.FORM_TYPE);
    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) IQ(org.jivesoftware.smack.packet.IQ) DataForm(org.jivesoftware.smackx.xdata.packet.DataForm) MUCOwner(org.jivesoftware.smackx.muc.packet.MUCOwner)

Aggregations

MUCOwner (org.jivesoftware.smackx.muc.packet.MUCOwner)6 DataForm (org.jivesoftware.smackx.xdata.packet.DataForm)2 NoResponseException (org.jivesoftware.smack.SmackException.NoResponseException)1 NotConnectedException (org.jivesoftware.smack.SmackException.NotConnectedException)1 XMPPErrorException (org.jivesoftware.smack.XMPPException.XMPPErrorException)1 IQ (org.jivesoftware.smack.packet.IQ)1 XmlPullParser (org.jivesoftware.smack.xml.XmlPullParser)1 Destroy (org.jivesoftware.smackx.muc.packet.Destroy)1 FillableForm (org.jivesoftware.smackx.xdata.form.FillableForm)1 Form (org.jivesoftware.smackx.xdata.form.Form)1