Search in sources :

Example 1 with MUCLightAffiliation

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

the class MUCLightChangeAffiliationsIQ method getIQChildElementBuilder.

@Override
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
    xml.rightAngleBracket();
    if (affiliations != null) {
        Iterator<Map.Entry<Jid, MUCLightAffiliation>> it = affiliations.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry<Jid, MUCLightAffiliation> pair = it.next();
            xml.element(new UserWithAffiliationElement(pair.getKey(), pair.getValue()));
        }
    }
    return xml;
}
Also used : MUCLightAffiliation(org.jivesoftware.smackx.muclight.MUCLightAffiliation) Jid(org.jxmpp.jid.Jid) UserWithAffiliationElement(org.jivesoftware.smackx.muclight.element.MUCLightElements.UserWithAffiliationElement) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with MUCLightAffiliation

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

the class MUCLightAffiliationsIQ method getIQChildElementBuilder.

@Override
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
    xml.rightAngleBracket();
    xml.optElement("version", version);
    Iterator<Map.Entry<Jid, MUCLightAffiliation>> it = affiliations.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry<Jid, MUCLightAffiliation> pair = it.next();
        xml.element(new UserWithAffiliationElement(pair.getKey(), pair.getValue()));
    }
    return xml;
}
Also used : MUCLightAffiliation(org.jivesoftware.smackx.muclight.MUCLightAffiliation) Jid(org.jxmpp.jid.Jid) UserWithAffiliationElement(org.jivesoftware.smackx.muclight.element.MUCLightElements.UserWithAffiliationElement) Map(java.util.Map) HashMap(java.util.HashMap)

Example 3 with MUCLightAffiliation

use of org.jivesoftware.smackx.muclight.MUCLightAffiliation 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)3 MUCLightAffiliation (org.jivesoftware.smackx.muclight.MUCLightAffiliation)3 Jid (org.jxmpp.jid.Jid)3 Map (java.util.Map)2 UserWithAffiliationElement (org.jivesoftware.smackx.muclight.element.MUCLightElements.UserWithAffiliationElement)2 MUCLightRoomConfiguration (org.jivesoftware.smackx.muclight.MUCLightRoomConfiguration)1 MUCLightInfoIQ (org.jivesoftware.smackx.muclight.element.MUCLightInfoIQ)1