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);
}
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());
}
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"));
}
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();
}
Aggregations