1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-22 18:48:00 +01:00

Add Roster.isSubscribedToMyPresence(String)

This commit is contained in:
Florian Schmaus 2015-01-19 16:14:14 +01:00
parent b06c3e3607
commit bf9fb7d2d9

View file

@ -697,6 +697,32 @@ public class Roster {
return Collections.unmodifiableList(res);
}
/**
* Check if the given JID is subscribed to the user's presence.
* <p>
* If the JID is subscribed to the user's presence then it is allowed to see the presence and
* will get notified about presence changes.
* </p>
* Note that if the roster is not loaded, then this method will always return false.
*
* @param jid
* @return true if the given JID is allowed to see the users presence.
* @since 4.1
*/
public boolean isSubscribedToMyPresence(String jid) {
RosterEntry entry = getEntry(jid);
if (entry == null) {
return false;
}
switch (entry.getType()) {
case from:
case both:
return true;
default:
return false;
}
}
/**
* Returns the key to use in the presenceMap for a fully qualified XMPP ID.
* The roster can contain any valid address format such us "domain/resource",