Search in sources :

Example 6 with BareJid

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

the class Roster method getPresenceResource.

/**
     * Returns the presence info for a particular user's resource, or unavailable presence
     * if the user is offline or if no presence information is available, such as
     * when you are not subscribed to the user's presence updates.
     *
     * @param userWithResource a fully qualified XMPP ID including a resource (user@domain/resource).
     * @return the user's current presence, or unavailable presence if the user is offline
     *         or if no presence information is available.
     */
public Presence getPresenceResource(FullJid userWithResource) {
    BareJid key = userWithResource.asBareJid();
    Resourcepart resource = userWithResource.getResourcepart();
    Map<Resourcepart, Presence> userPresences = getPresencesInternal(key);
    if (userPresences == null) {
        Presence presence = new Presence(Presence.Type.unavailable);
        presence.setFrom(userWithResource);
        return presence;
    } else {
        Presence presence = userPresences.get(resource);
        if (presence == null) {
            presence = new Presence(Presence.Type.unavailable);
            presence.setFrom(userWithResource);
            return presence;
        } else {
            return presence.clone();
        }
    }
}
Also used : EntityBareJid(org.jxmpp.jid.EntityBareJid) BareJid(org.jxmpp.jid.BareJid) Presence(org.jivesoftware.smack.packet.Presence) Resourcepart(org.jxmpp.jid.parts.Resourcepart)

Example 7 with BareJid

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

the class RosterUtil method ensureNotSubscribedToEachOther.

public static void ensureNotSubscribedToEachOther(XMPPConnection connectionOne, XMPPConnection connectionTwo) throws NotConnectedException, InterruptedException {
    final Roster rosterOne = Roster.getInstanceFor(connectionOne);
    final BareJid jidOne = connectionOne.getUser().asBareJid();
    final Roster rosterTwo = Roster.getInstanceFor(connectionTwo);
    final BareJid jidTwo = connectionTwo.getUser().asBareJid();
    ensureNotSubscribed(rosterOne, jidTwo);
    ensureNotSubscribed(rosterTwo, jidOne);
}
Also used : BareJid(org.jxmpp.jid.BareJid)

Example 8 with BareJid

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

the class PEPManager method isSupported.

public boolean isSupported() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    XMPPConnection connection = connection();
    ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
    BareJid localBareJid = connection.getUser().asBareJid();
    return serviceDiscoveryManager.supportsFeatures(localBareJid, REQUIRED_FEATURES);
}
Also used : EntityBareJid(org.jxmpp.jid.EntityBareJid) BareJid(org.jxmpp.jid.BareJid) XMPPConnection(org.jivesoftware.smack.XMPPConnection) ServiceDiscoveryManager(org.jivesoftware.smackx.disco.ServiceDiscoveryManager)

Example 9 with BareJid

use of org.jxmpp.jid.BareJid 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 10 with BareJid

use of org.jxmpp.jid.BareJid 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)

Aggregations

BareJid (org.jxmpp.jid.BareJid)26 RosterPacket (org.jivesoftware.smack.roster.packet.RosterPacket)9 Test (org.junit.Test)9 Item (org.jivesoftware.smack.roster.packet.RosterPacket.Item)8 Jid (org.jxmpp.jid.Jid)7 EntityBareJid (org.jxmpp.jid.EntityBareJid)6 Presence (org.jivesoftware.smack.packet.Presence)5 ErrorIQ (org.jivesoftware.smack.packet.ErrorIQ)3 ArrayList (java.util.ArrayList)2 SimpleResultSyncPoint (org.igniterealtime.smack.inttest.util.SimpleResultSyncPoint)2 SmackException (org.jivesoftware.smack.SmackException)2 IQ (org.jivesoftware.smack.packet.IQ)2 IoTIsFriendResponse (org.jivesoftware.smackx.iot.provisioning.element.IoTIsFriendResponse)2 XmlPullParser (org.xmlpull.v1.XmlPullParser)2 File (java.io.File)1 AbstractSmackIntegrationTest (org.igniterealtime.smack.inttest.AbstractSmackIntegrationTest)1 SmackIntegrationTest (org.igniterealtime.smack.inttest.SmackIntegrationTest)1 XMPPConnection (org.jivesoftware.smack.XMPPConnection)1 ServiceDiscoveryManager (org.jivesoftware.smackx.disco.ServiceDiscoveryManager)1 IoTRemove (org.jivesoftware.smackx.iot.discovery.element.IoTRemove)1