Search in sources :

Example 1 with MUCLightInfoIQ

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

the class MUCLightInfoTest method checkMUCLightInfoResult.

@Test
public void checkMUCLightInfoResult() throws Exception {
    IQ iqInfoResult = (IQ) PacketParserUtils.parseStanza(exampleInfoResult);
    MUCLightInfoIQ mucLightInfoResponseIQ = (MUCLightInfoIQ) iqInfoResult;
    Assert.assertEquals(mucLightInfoResponseIQ.getVersion(), "123456");
    Assert.assertEquals(mucLightInfoResponseIQ.getConfiguration().getRoomName(), "test");
    Assert.assertEquals(mucLightInfoResponseIQ.getOccupants().size(), 3);
    Assert.assertEquals(mucLightInfoResponseIQ.getOccupants().get(JidCreate.from("john@test.com")), MUCLightAffiliation.owner);
    Assert.assertEquals(mucLightInfoResponseIQ.getOccupants().get(JidCreate.from("charlie@test.com")), MUCLightAffiliation.member);
    Assert.assertEquals(mucLightInfoResponseIQ.getOccupants().get(JidCreate.from("pep@test.com")), MUCLightAffiliation.member);
}
Also used : MUCLightInfoIQ(org.jivesoftware.smackx.muclight.element.MUCLightInfoIQ) MUCLightGetInfoIQ(org.jivesoftware.smackx.muclight.element.MUCLightGetInfoIQ) IQ(org.jivesoftware.smack.packet.IQ) MUCLightInfoIQ(org.jivesoftware.smackx.muclight.element.MUCLightInfoIQ) Test(org.junit.Test)

Example 2 with MUCLightInfoIQ

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

the class MultiUserChatLight method getFullInfo.

/**
     * Get the MUC Light info.
     * 
     * @param version
     * @return the room info
     * @throws NoResponseException
     * @throws XMPPErrorException
     * @throws NotConnectedException
     * @throws InterruptedException
     */
public MUCLightRoomInfo getFullInfo(String version) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    MUCLightGetInfoIQ mucLightGetInfoIQ = new MUCLightGetInfoIQ(room, version);
    IQ responseIq = connection.createStanzaCollectorAndSend(mucLightGetInfoIQ).nextResultOrThrow();
    MUCLightInfoIQ mucLightInfoResponseIQ = (MUCLightInfoIQ) responseIq;
    return new MUCLightRoomInfo(mucLightInfoResponseIQ.getVersion(), room, mucLightInfoResponseIQ.getConfiguration(), mucLightInfoResponseIQ.getOccupants());
}
Also used : MUCLightGetInfoIQ(org.jivesoftware.smackx.muclight.element.MUCLightGetInfoIQ) 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) MUCLightInfoIQ(org.jivesoftware.smackx.muclight.element.MUCLightInfoIQ)

Example 3 with MUCLightInfoIQ

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

MUCLightInfoIQ (org.jivesoftware.smackx.muclight.element.MUCLightInfoIQ)3 IQ (org.jivesoftware.smack.packet.IQ)2 MUCLightGetInfoIQ (org.jivesoftware.smackx.muclight.element.MUCLightGetInfoIQ)2 HashMap (java.util.HashMap)1 MUCLightAffiliation (org.jivesoftware.smackx.muclight.MUCLightAffiliation)1 MUCLightRoomConfiguration (org.jivesoftware.smackx.muclight.MUCLightRoomConfiguration)1 MUCLightAffiliationsIQ (org.jivesoftware.smackx.muclight.element.MUCLightAffiliationsIQ)1 MUCLightChangeAffiliationsIQ (org.jivesoftware.smackx.muclight.element.MUCLightChangeAffiliationsIQ)1 MUCLightConfigurationIQ (org.jivesoftware.smackx.muclight.element.MUCLightConfigurationIQ)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 MUCLightGetConfigsIQ (org.jivesoftware.smackx.muclight.element.MUCLightGetConfigsIQ)1 MUCLightSetConfigsIQ (org.jivesoftware.smackx.muclight.element.MUCLightSetConfigsIQ)1 Test (org.junit.Test)1 Jid (org.jxmpp.jid.Jid)1