Search in sources :

Example 1 with MUCLightConfigurationIQ

use of org.jivesoftware.smackx.muclight.element.MUCLightConfigurationIQ in project Smack by igniterealtime.

the class MUCLightConfigurationIQProvider method parse.

@Override
public MUCLightConfigurationIQ parse(XmlPullParser parser, int initialDepth) throws Exception {
    String version = null;
    String roomName = null;
    String subject = null;
    HashMap<String, String> customConfigs = null;
    outerloop: while (true) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            if (parser.getName().equals("version")) {
                version = parser.nextText();
            } else if (parser.getName().equals("roomname")) {
                roomName = parser.nextText();
            } else if (parser.getName().equals("subject")) {
                subject = parser.nextText();
            } else {
                if (customConfigs == null) {
                    customConfigs = new HashMap<>();
                }
                customConfigs.put(parser.getName(), parser.nextText());
            }
        } else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getDepth() == initialDepth) {
                break outerloop;
            }
        }
    }
    MUCLightRoomConfiguration configuration = new MUCLightRoomConfiguration(roomName, subject, customConfigs);
    return new MUCLightConfigurationIQ(version, configuration);
}
Also used : MUCLightConfigurationIQ(org.jivesoftware.smackx.muclight.element.MUCLightConfigurationIQ) MUCLightRoomConfiguration(org.jivesoftware.smackx.muclight.MUCLightRoomConfiguration) HashMap(java.util.HashMap)

Example 2 with MUCLightConfigurationIQ

use of org.jivesoftware.smackx.muclight.element.MUCLightConfigurationIQ in project Smack by igniterealtime.

the class MUCLightGetConfigsTest method checkGetConfigsResponse.

@Test
public void checkGetConfigsResponse() throws Exception {
    IQ iqInfoResult = (IQ) PacketParserUtils.parseStanza(getConfigsResponseExample);
    MUCLightConfigurationIQ mucLightConfigurationIQ = (MUCLightConfigurationIQ) iqInfoResult;
    Assert.assertEquals("123456", mucLightConfigurationIQ.getVersion());
    Assert.assertEquals("A Dark Cave", mucLightConfigurationIQ.getConfiguration().getRoomName());
    Assert.assertEquals("A subject", mucLightConfigurationIQ.getConfiguration().getSubject());
    Assert.assertNull(mucLightConfigurationIQ.getConfiguration().getCustomConfigs());
}
Also used : MUCLightConfigurationIQ(org.jivesoftware.smackx.muclight.element.MUCLightConfigurationIQ) MUCLightConfigurationIQ(org.jivesoftware.smackx.muclight.element.MUCLightConfigurationIQ) MUCLightGetConfigsIQ(org.jivesoftware.smackx.muclight.element.MUCLightGetConfigsIQ) IQ(org.jivesoftware.smack.packet.IQ) Test(org.junit.Test)

Example 3 with MUCLightConfigurationIQ

use of org.jivesoftware.smackx.muclight.element.MUCLightConfigurationIQ in project Smack by igniterealtime.

the class MUCLightGetConfigsTest method checkGetConfigsResponseWithCustomConfigs.

@Test
public void checkGetConfigsResponseWithCustomConfigs() throws Exception {
    IQ iqInfoResult = (IQ) PacketParserUtils.parseStanza(getConfigsResponseExampleWithCustomConfigs);
    MUCLightConfigurationIQ mucLightConfigurationIQ = (MUCLightConfigurationIQ) iqInfoResult;
    Assert.assertEquals("123456", mucLightConfigurationIQ.getVersion());
    Assert.assertEquals("A Dark Cave", mucLightConfigurationIQ.getConfiguration().getRoomName());
    Assert.assertNull(mucLightConfigurationIQ.getConfiguration().getSubject());
    HashMap<String, String> customConfigs = mucLightConfigurationIQ.getConfiguration().getCustomConfigs();
    Assert.assertEquals("blue", customConfigs.get("color"));
    Assert.assertEquals("20", customConfigs.get("size"));
}
Also used : MUCLightConfigurationIQ(org.jivesoftware.smackx.muclight.element.MUCLightConfigurationIQ) MUCLightConfigurationIQ(org.jivesoftware.smackx.muclight.element.MUCLightConfigurationIQ) MUCLightGetConfigsIQ(org.jivesoftware.smackx.muclight.element.MUCLightGetConfigsIQ) IQ(org.jivesoftware.smack.packet.IQ) Test(org.junit.Test)

Example 4 with MUCLightConfigurationIQ

use of org.jivesoftware.smackx.muclight.element.MUCLightConfigurationIQ in project Smack by igniterealtime.

the class MultiUserChatLight method getConfiguration.

/**
     * Get the MUC Light configuration.
     * 
     * @param version
     * @return the room configuration
     * @throws NoResponseException
     * @throws XMPPErrorException
     * @throws NotConnectedException
     * @throws InterruptedException
     */
public MUCLightRoomConfiguration getConfiguration(String version) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    MUCLightGetConfigsIQ mucLightGetConfigsIQ = new MUCLightGetConfigsIQ(room, version);
    IQ responseIq = connection.createStanzaCollectorAndSend(mucLightGetConfigsIQ).nextResultOrThrow();
    MUCLightConfigurationIQ mucLightConfigurationIQ = (MUCLightConfigurationIQ) responseIq;
    return mucLightConfigurationIQ.getConfiguration();
}
Also used : MUCLightConfigurationIQ(org.jivesoftware.smackx.muclight.element.MUCLightConfigurationIQ) MUCLightGetConfigsIQ(org.jivesoftware.smackx.muclight.element.MUCLightGetConfigsIQ) MUCLightDestroyIQ(org.jivesoftware.smackx.muclight.element.MUCLightDestroyIQ) MUCLightChangeAffiliationsIQ(org.jivesoftware.smackx.muclight.element.MUCLightChangeAffiliationsIQ) MUCLightConfigurationIQ(org.jivesoftware.smackx.muclight.element.MUCLightConfigurationIQ) MUCLightInfoIQ(org.jivesoftware.smackx.muclight.element.MUCLightInfoIQ) MUCLightGetAffiliationsIQ(org.jivesoftware.smackx.muclight.element.MUCLightGetAffiliationsIQ) MUCLightGetConfigsIQ(org.jivesoftware.smackx.muclight.element.MUCLightGetConfigsIQ) MUCLightCreateIQ(org.jivesoftware.smackx.muclight.element.MUCLightCreateIQ) MUCLightAffiliationsIQ(org.jivesoftware.smackx.muclight.element.MUCLightAffiliationsIQ) MUCLightSetConfigsIQ(org.jivesoftware.smackx.muclight.element.MUCLightSetConfigsIQ) MUCLightGetInfoIQ(org.jivesoftware.smackx.muclight.element.MUCLightGetInfoIQ) IQ(org.jivesoftware.smack.packet.IQ)

Aggregations

MUCLightConfigurationIQ (org.jivesoftware.smackx.muclight.element.MUCLightConfigurationIQ)4 IQ (org.jivesoftware.smack.packet.IQ)3 MUCLightGetConfigsIQ (org.jivesoftware.smackx.muclight.element.MUCLightGetConfigsIQ)3 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 MUCLightRoomConfiguration (org.jivesoftware.smackx.muclight.MUCLightRoomConfiguration)1 MUCLightAffiliationsIQ (org.jivesoftware.smackx.muclight.element.MUCLightAffiliationsIQ)1 MUCLightChangeAffiliationsIQ (org.jivesoftware.smackx.muclight.element.MUCLightChangeAffiliationsIQ)1 MUCLightCreateIQ (org.jivesoftware.smackx.muclight.element.MUCLightCreateIQ)1 MUCLightDestroyIQ (org.jivesoftware.smackx.muclight.element.MUCLightDestroyIQ)1 MUCLightGetAffiliationsIQ (org.jivesoftware.smackx.muclight.element.MUCLightGetAffiliationsIQ)1 MUCLightGetInfoIQ (org.jivesoftware.smackx.muclight.element.MUCLightGetInfoIQ)1 MUCLightInfoIQ (org.jivesoftware.smackx.muclight.element.MUCLightInfoIQ)1 MUCLightSetConfigsIQ (org.jivesoftware.smackx.muclight.element.MUCLightSetConfigsIQ)1