mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-26 05:52:06 +01:00
Add RosterUtil.askForSubscriptionIfRequired(Roster, BareJid)
This commit is contained in:
parent
0e72213760
commit
88bf2528a2
1 changed files with 10 additions and 0 deletions
|
@ -23,6 +23,8 @@ import java.util.concurrent.locks.Condition;
|
|||
import java.util.concurrent.locks.Lock;
|
||||
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.Jid;
|
||||
|
||||
|
@ -80,4 +82,12 @@ public class RosterUtil {
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue