1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 14:22:05 +01:00

Add RosterUtil.askForSubscriptionIfRequired(Roster, BareJid)

This commit is contained in:
Florian Schmaus 2016-08-09 11:38:26 +02:00
parent 0e72213760
commit 88bf2528a2

View file

@ -23,6 +23,8 @@ import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.SmackException.NotLoggedInException;
import org.jxmpp.jid.BareJid; import org.jxmpp.jid.BareJid;
import org.jxmpp.jid.Jid; import org.jxmpp.jid.Jid;
@ -80,4 +82,12 @@ public class RosterUtil {
roster.removeRosterListener(rosterListener); roster.removeRosterListener(rosterListener);
} }
} }
public static void askForSubscriptionIfRequired(Roster roster, BareJid jid)
throws NotLoggedInException, NotConnectedException, InterruptedException {
RosterEntry entry = roster.getEntry(jid);
if (entry == null || !(entry.canSeeHisPresence() || entry.isSubscriptionPending())) {
roster.sendSubscriptionRequest(jid);
}
}
} }