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();
}
}
}
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);
}
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);
}
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);
}
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;
}
Aggregations