Search in sources :

Example 1 with MUCLightRoomConfiguration

use of org.jivesoftware.smackx.muclight.MUCLightRoomConfiguration 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 MUCLightRoomConfiguration

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

the class MUCLightInfoIQProvider method parse.

@Override
public MUCLightInfoIQ parse(XmlPullParser parser, int initialDepth) throws Exception {
    String version = null;
    String roomName = null;
    String subject = null;
    HashMap<String, String> customConfigs = null;
    HashMap<Jid, MUCLightAffiliation> occupants = new HashMap<>();
    outerloop: while (true) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            if (parser.getName().equals("version")) {
                version = parser.nextText();
            }
            if (parser.getName().equals("configuration")) {
                int depth = parser.getDepth();
                outerloop2: while (true) {
                    eventType = parser.next();
                    if (eventType == XmlPullParser.START_TAG) {
                        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() == depth) {
                            break outerloop2;
                        }
                    }
                }
            }
            if (parser.getName().equals("occupants")) {
                occupants = iterateOccupants(parser);
            }
        } else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getDepth() == initialDepth) {
                break outerloop;
            }
        }
    }
    return new MUCLightInfoIQ(version, new MUCLightRoomConfiguration(roomName, subject, customConfigs), occupants);
}
Also used : MUCLightAffiliation(org.jivesoftware.smackx.muclight.MUCLightAffiliation) MUCLightRoomConfiguration(org.jivesoftware.smackx.muclight.MUCLightRoomConfiguration) Jid(org.jxmpp.jid.Jid) HashMap(java.util.HashMap) MUCLightInfoIQ(org.jivesoftware.smackx.muclight.element.MUCLightInfoIQ)

Aggregations

HashMap (java.util.HashMap)2 MUCLightRoomConfiguration (org.jivesoftware.smackx.muclight.MUCLightRoomConfiguration)2 MUCLightAffiliation (org.jivesoftware.smackx.muclight.MUCLightAffiliation)1 MUCLightConfigurationIQ (org.jivesoftware.smackx.muclight.element.MUCLightConfigurationIQ)1 MUCLightInfoIQ (org.jivesoftware.smackx.muclight.element.MUCLightInfoIQ)1 Jid (org.jxmpp.jid.Jid)1