mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-22 20:47:57 +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