use of org.jivesoftware.smackx.blocking.BlockingCommandManager in project xabber-android by redsolution.
the class BlockingManager method getBlockedContacts.
public List<UserJid> getBlockedContacts(AccountJid account) {
List<UserJid> blockedContacts = new ArrayList<>();
Boolean supported = isSupported(account);
BlockingCommandManager blockingCommandManager = getBlockingCommandManager(account);
if (blockingCommandManager != null && supported != null && supported) {
try {
List<Jid> blockedJids = blockingCommandManager.getBlockList();
for (Jid jid : blockedJids) {
blockedContacts.add(UserJid.from(jid));
}
} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | InterruptedException | SmackException.NotConnectedException | UserJid.UserJidCreateException e) {
LogManager.exception(LOG_TAG, e);
}
}
updateCachedBlockedContacts(account, blockedContacts);
return blockedContacts;
}
use of org.jivesoftware.smackx.blocking.BlockingCommandManager in project xabber-android by redsolution.
the class BlockingManager method onAuthorized.
public void onAuthorized(final ConnectionItem connection) {
final AccountJid account = connection.getAccount();
BlockingCommandManager blockingCommandManager = BlockingCommandManager.getInstanceFor(connection.getConnection());
try {
boolean supportedByServer = blockingCommandManager.isSupportedByServer();
if (supportedByServer) {
// cache block list inside
List<UserJid> blockedContacts = new ArrayList<>();
try {
List<Jid> blockedJids = blockingCommandManager.getBlockList();
for (Jid jid : blockedJids) {
blockedContacts.add(UserJid.from(jid));
}
} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | InterruptedException | SmackException.NotConnectedException | UserJid.UserJidCreateException e) {
LogManager.exception(LOG_TAG, e);
}
// Cache block inside manager
// For contact list building used only this list of blocked contacts
updateCachedBlockedContacts(account, blockedContacts);
}
addBlockedListener(blockingCommandManager, account);
addUnblockedListener(blockingCommandManager, account);
addUnblockedAllListener(blockingCommandManager, account);
// block list already cached successfully
supportForAccounts.put(account, supportedByServer);
BlockingManager.notify(account);
} catch (SmackException.NotConnectedException | XMPPException.XMPPErrorException | SmackException.NoResponseException | InterruptedException e) {
LogManager.exception(this, e);
}
}
Aggregations