Search in sources :

Example 31 with Jid

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

the class RemoteDisablingProvider method parse.

@Override
public RemoteDisablingExtension parse(XmlPullParser parser, int initialDepth) throws Exception {
    Jid userJid = null;
    String node = parser.getAttributeValue("", "node");
    outerloop: while (true) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            if (parser.getName().equals("affiliation")) {
                userJid = JidCreate.from(parser.getAttributeValue("", "jid"));
                String affiliation = parser.getAttributeValue("", "affiliation");
                if (affiliation == null || !affiliation.equals("none")) {
                    return null;
                }
            }
        } else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getDepth() == initialDepth) {
                break outerloop;
            }
        }
    }
    return new RemoteDisablingExtension(node, userJid);
}
Also used : RemoteDisablingExtension(org.jivesoftware.smackx.push_notifications.element.PushNotificationsElements.RemoteDisablingExtension) Jid(org.jxmpp.jid.Jid)

Example 32 with Jid

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

the class IoTDiscoveryManager method removeThing.

public void removeThing(BareJid thing, NodeInfo nodeInfo) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    Jid registry = findRegistry();
    removeThing(registry, thing, nodeInfo);
}
Also used : Jid(org.jxmpp.jid.Jid) BareJid(org.jxmpp.jid.BareJid)

Example 33 with Jid

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

the class IoTDiscoveryManager method isRegistry.

// Registry utility methods
public boolean isRegistry(BareJid jid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    Objects.requireNonNull(jid, "JID argument must not be null");
    // At some point 'usedRegistries' will also contain the registry returned by findRegistry(), but since this is
    // not the case from the beginning, we perform findRegistry().equals(jid) too.
    Jid registry = findRegistry();
    if (jid.equals(registry)) {
        return true;
    }
    if (usedRegistries.contains(jid)) {
        return true;
    }
    return false;
}
Also used : Jid(org.jxmpp.jid.Jid) BareJid(org.jxmpp.jid.BareJid)

Example 34 with Jid

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

the class IoTDiscoveryIntegrationTest method checkPrerequisites.

static void checkPrerequisites(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, TestNotPossibleException {
    IoTDiscoveryManager discoveryManager = IoTDiscoveryManager.getInstanceFor(connection);
    Jid registry = discoveryManager.findRegistry();
    if (registry == null) {
        throw new TestNotPossibleException("Could not find IoT Registry");
    }
}
Also used : TestNotPossibleException(org.igniterealtime.smack.inttest.TestNotPossibleException) Jid(org.jxmpp.jid.Jid) IoTDiscoveryManager(org.jivesoftware.smackx.iot.discovery.IoTDiscoveryManager)

Example 35 with Jid

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

the class RosterIntegrationTest method ensureSubscribedTo.

private static void ensureSubscribedTo(final XMPPConnection conOne, final XMPPConnection conTwo, long timeout) throws TimeoutException, Exception {
    Roster rosterOne = Roster.getInstanceFor(conOne);
    Roster rosterTwo = Roster.getInstanceFor(conTwo);
    if (rosterOne.isSubscribedToMyPresence(conTwo.getUser())) {
        return;
    }
    final SubscribeListener subscribeListener = new SubscribeListener() {

        @Override
        public SubscribeAnswer processSubscribe(Jid from, Presence subscribeRequest) {
            if (from.equals(conTwo.getUser().asBareJid())) {
                return SubscribeAnswer.Approve;
            }
            return SubscribeAnswer.Deny;
        }
    };
    rosterOne.addSubscribeListener(subscribeListener);
    final SimpleResultSyncPoint syncPoint = new SimpleResultSyncPoint();
    rosterTwo.addPresenceEventListener(new AbstractPresenceEventListener() {

        @Override
        public void presenceSubscribed(BareJid address, Presence subscribedPresence) {
            if (!address.equals(conOne.getUser().asBareJid())) {
                return;
            }
            syncPoint.signal();
        }
    });
    rosterTwo.sendSubscriptionRequest(conOne.getUser().asBareJid());
    try {
        syncPoint.waitForResult(timeout);
    } finally {
        rosterOne.removeSubscribeListener(subscribeListener);
    }
}
Also used : Jid(org.jxmpp.jid.Jid) BareJid(org.jxmpp.jid.BareJid) BareJid(org.jxmpp.jid.BareJid) Presence(org.jivesoftware.smack.packet.Presence) SimpleResultSyncPoint(org.igniterealtime.smack.inttest.util.SimpleResultSyncPoint)

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