use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class AttentionManager method onSettingsChanged.
public void onSettingsChanged() {
synchronized (enabledLock) {
for (AccountJid account : AccountManager.getInstance().getEnabledAccounts()) {
AccountItem accountItem = AccountManager.getInstance().getAccount(account);
if (accountItem == null) {
continue;
}
ServiceDiscoveryManager manager = ServiceDiscoveryManager.getInstanceFor(accountItem.getConnection());
if (manager == null) {
continue;
}
boolean contains = false;
for (String feature : manager.getFeatures()) {
if (AttentionExtension.NAMESPACE.equals(feature)) {
contains = true;
}
}
if (SettingsManager.chatsAttention() == contains) {
continue;
}
if (SettingsManager.chatsAttention()) {
manager.addFeature(AttentionExtension.NAMESPACE);
} else {
manager.removeFeature(AttentionExtension.NAMESPACE);
}
}
AccountManager.getInstance().resendPresence();
}
}
use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class ChatMarkerManager method isClientSupportChatMarkers.
private boolean isClientSupportChatMarkers(AccountJid account, UserJid user) {
AccountItem accountItem = AccountManager.getInstance().getAccount(account);
if (accountItem == null)
return false;
XMPPConnection connection = accountItem.getConnection();
final List<Presence> allPresences = RosterManager.getInstance().getPresences(account, user.getJid());
boolean isChatMarkersSupport = false;
for (Presence presence : allPresences) {
Jid fromJid = presence.getFrom();
DiscoverInfo discoverInfo = null;
try {
discoverInfo = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(fromJid);
} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | InterruptedException | ClassCastException e) {
e.printStackTrace();
}
isChatMarkersSupport = discoverInfo != null && discoverInfo.containsFeature(ChatMarkersElements.NAMESPACE);
if (isChatMarkersSupport)
break;
}
return isChatMarkersSupport;
}
use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class AvatarManager method onStanza.
@Override
public void onStanza(ConnectionItem connection, Stanza stanza) {
if (!(stanza instanceof Presence)) {
return;
}
AccountJid account = ((AccountItem) connection).getAccount();
Presence presence = (Presence) stanza;
if (presence.getType() == Presence.Type.error) {
return;
}
for (ExtensionElement packetExtension : presence.getExtensions()) {
if (packetExtension instanceof VCardUpdate) {
VCardUpdate vCardUpdate = (VCardUpdate) packetExtension;
if (vCardUpdate.isValid() && vCardUpdate.isPhotoReady()) {
try {
onPhotoReady(account, UserJid.from(stanza.getFrom()), vCardUpdate);
} catch (UserJid.UserJidCreateException e) {
LogManager.exception(this, e);
}
}
}
}
}
use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class BookmarksManager method getConferencesFromBookmarks.
@NonNull
public List<BookmarkedConference> getConferencesFromBookmarks(AccountJid accountJid) throws SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException, XMPPException.XMPPErrorException {
AccountItem accountItem = AccountManager.getInstance().getAccount(accountJid);
List<BookmarkedConference> conferences = Collections.emptyList();
if (accountItem != null) {
BookmarkManager bookmarkManager = BookmarkManager.getBookmarkManager(accountItem.getConnection());
conferences = bookmarkManager.getBookmarkedConferences();
}
return conferences;
}
use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class PrivateStorageManager method setPrivateData.
private void setPrivateData(AccountJid accountJid, PrivateData privateData) {
AccountItem accountItem = AccountManager.getInstance().getAccount(accountJid);
if (accountItem == null || !accountItem.isEnabled())
return;
XMPPTCPConnection connection = accountItem.getConnection();
PrivateDataManager privateDataManager = PrivateDataManager.getInstanceFor(connection);
try {
if (!privateDataManager.isSupported())
return;
privateDataManager.setPrivateData(privateData);
} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | InterruptedException | IllegalArgumentException e) {
e.printStackTrace();
}
}
Aggregations