Search in sources :

Example 21 with Jid

use of org.jxmpp.jid.Jid in project Smack by igniterealtime.

the class MamManager method ensureMamQueryResultMatchesThisManager.

private void ensureMamQueryResultMatchesThisManager(MamQueryResult mamQueryResult) {
    EntityFullJid localAddress = connection().getUser();
    EntityBareJid localBareAddress = null;
    if (localAddress != null) {
        localBareAddress = localAddress.asEntityBareJid();
    }
    boolean isLocalUserArchive = archiveAddress == null || archiveAddress.equals(localBareAddress);
    Jid finIqFrom = mamQueryResult.mamFin.getFrom();
    if (finIqFrom != null) {
        if (finIqFrom.equals(archiveAddress) || (isLocalUserArchive && finIqFrom.equals(localBareAddress))) {
            return;
        }
        throw new IllegalArgumentException("The given MamQueryResult is from the MAM archive '" + finIqFrom + "' whereas this MamManager is responsible for '" + archiveAddress + '\'');
    } else if (!isLocalUserArchive) {
        throw new IllegalArgumentException("The given MamQueryResult is from the local entity (user) MAM archive, whereas this MamManager is responsible for '" + archiveAddress + '\'');
    }
}
Also used : EntityBareJid(org.jxmpp.jid.EntityBareJid) Jid(org.jxmpp.jid.Jid) EntityFullJid(org.jxmpp.jid.EntityFullJid) EntityFullJid(org.jxmpp.jid.EntityFullJid) EntityBareJid(org.jxmpp.jid.EntityBareJid)

Example 22 with Jid

use of org.jxmpp.jid.Jid in project Smack by igniterealtime.

the class MamPrefsIQProvider method parse.

@Override
public MamPrefsIQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
    String iqType = parser.getAttributeValue("", "type");
    String defaultBehaviorString = parser.getAttributeValue("", "default");
    DefaultBehavior defaultBehavior = null;
    if (defaultBehaviorString != null) {
        defaultBehavior = DefaultBehavior.valueOf(defaultBehaviorString);
    }
    if (iqType == null) {
        iqType = "result";
    }
    List<Jid> alwaysJids = null;
    List<Jid> neverJids = null;
    outerloop: while (true) {
        final int eventType = parser.next();
        final String name = parser.getName();
        switch(eventType) {
            case XmlPullParser.START_TAG:
                switch(name) {
                    case "always":
                        alwaysJids = iterateJids(parser);
                        break;
                    case "never":
                        neverJids = iterateJids(parser);
                        break;
                }
                break;
            case XmlPullParser.END_TAG:
                if (parser.getDepth() == initialDepth) {
                    break outerloop;
                }
                break;
        }
    }
    return new MamPrefsIQ(alwaysJids, neverJids, defaultBehavior);
}
Also used : MamPrefsIQ(org.jivesoftware.smackx.mam.element.MamPrefsIQ) Jid(org.jxmpp.jid.Jid) DefaultBehavior(org.jivesoftware.smackx.mam.element.MamPrefsIQ.DefaultBehavior)

Example 23 with Jid

use of org.jxmpp.jid.Jid 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 24 with Jid

use of org.jxmpp.jid.Jid in project Smack by igniterealtime.

the class MUCLightBlockingIQProvider method parse.

@Override
public MUCLightBlockingIQ parse(XmlPullParser parser, int initialDepth) throws Exception {
    HashMap<Jid, Boolean> rooms = null;
    HashMap<Jid, Boolean> users = null;
    outerloop: while (true) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            if (parser.getName().equals("room")) {
                rooms = parseBlocking(parser, rooms);
            }
            if (parser.getName().equals("user")) {
                users = parseBlocking(parser, users);
            }
        } else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getDepth() == initialDepth) {
                break outerloop;
            }
        }
    }
    MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, users);
    mucLightBlockingIQ.setType(Type.result);
    return mucLightBlockingIQ;
}
Also used : Jid(org.jxmpp.jid.Jid) MUCLightBlockingIQ(org.jivesoftware.smackx.muclight.element.MUCLightBlockingIQ)

Example 25 with Jid

use of org.jxmpp.jid.Jid in project Smack by igniterealtime.

the class MultiUserChatLightManager method blockUsers.

/**
     * Block users.
     * 
     * @param mucLightService
     * @param usersJids
     * @throws NoResponseException
     * @throws XMPPErrorException
     * @throws NotConnectedException
     * @throws InterruptedException
     */
public void blockUsers(DomainBareJid mucLightService, List<Jid> usersJids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    HashMap<Jid, Boolean> users = new HashMap<>();
    for (Jid jid : usersJids) {
        users.put(jid, false);
    }
    sendBlockUsers(mucLightService, users);
}
Also used : Jid(org.jxmpp.jid.Jid) DomainBareJid(org.jxmpp.jid.DomainBareJid) EntityBareJid(org.jxmpp.jid.EntityBareJid) HashMap(java.util.HashMap) WeakHashMap(java.util.WeakHashMap)

Aggregations

Jid (org.jxmpp.jid.Jid)78 EntityBareJid (org.jxmpp.jid.EntityBareJid)18 ArrayList (java.util.ArrayList)15 HashMap (java.util.HashMap)14 Test (org.junit.Test)14 DomainBareJid (org.jxmpp.jid.DomainBareJid)14 EntityFullJid (org.jxmpp.jid.EntityFullJid)12 BareJid (org.jxmpp.jid.BareJid)11 IQ (org.jivesoftware.smack.packet.IQ)7 Presence (org.jivesoftware.smack.packet.Presence)7 MUCLightBlockingIQ (org.jivesoftware.smackx.muclight.element.MUCLightBlockingIQ)7 SmackException (org.jivesoftware.smack.SmackException)6 Message (org.jivesoftware.smack.packet.Message)6 WeakHashMap (java.util.WeakHashMap)4 XMPPConnection (org.jivesoftware.smack.XMPPConnection)4 Map (java.util.Map)3 SimpleResultSyncPoint (org.igniterealtime.smack.inttest.util.SimpleResultSyncPoint)3 FeatureNotSupportedException (org.jivesoftware.smack.SmackException.FeatureNotSupportedException)3 XMPPErrorException (org.jivesoftware.smack.XMPPException.XMPPErrorException)3 Bytestream (org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream)3