use of com.xabber.android.data.entity.AccountJid 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.entity.AccountJid in project xabber-android by redsolution.
the class CapabilitiesManager method onPresence.
public void onPresence(final AccountJid accountJid, final Presence presence) {
final Jid from = presence.getFrom();
discoverInfoCache.remove(from);
clientInfoCache.remove(from);
DiscoverInfo discoverInfoByUser = EntityCapsManager.getDiscoverInfoByUser(from);
if (discoverInfoByUser != null) {
return;
}
Application.getInstance().runInBackground(new Runnable() {
@Override
public void run() {
updateClientInfo(accountJid, from);
}
});
}
use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.
the class ChatStateManager method onStanza.
@Override
public void onStanza(ConnectionItem connection, Stanza stanza) {
if (stanza.getFrom() == null) {
return;
}
final Resourcepart resource = stanza.getFrom().getResourceOrNull();
if (resource == null) {
return;
}
final AccountJid account = ((AccountItem) connection).getAccount();
final UserJid bareUserJid;
try {
bareUserJid = UserJid.from(stanza.getFrom()).getBareUserJid();
} catch (UserJid.UserJidCreateException e) {
return;
}
if (stanza instanceof Presence) {
Presence presence = (Presence) stanza;
if (presence.getType() != Type.unavailable) {
return;
}
chatStates.remove(account.toString(), bareUserJid.toString(), resource);
removeCallback(account, bareUserJid.getBareJid(), resource);
supports.remove(account.toString(), bareUserJid.toString(), resource);
} else if (stanza instanceof Message) {
boolean support = false;
for (ExtensionElement extension : stanza.getExtensions()) if (extension instanceof ChatStateExtension) {
removeCallback(account, bareUserJid.getBareJid(), resource);
ChatState chatState = ((ChatStateExtension) extension).getChatState();
chatStates.put(account.toString(), bareUserJid.toString(), resource, chatState);
if (chatState != ChatState.active) {
Runnable runnable = new Runnable() {
@Override
public void run() {
if (this != stateCleaners.get(account.toString(), bareUserJid.toString(), resource)) {
return;
}
chatStates.remove(account.toString(), bareUserJid.toString(), resource);
removeCallback(account, bareUserJid.getBareJid(), resource);
RosterManager.onChatStateChanged(account, bareUserJid);
}
};
handler.postDelayed(runnable, REMOVE_STATE_DELAY);
stateCleaners.put(account.toString(), bareUserJid.toString(), resource, runnable);
}
RosterManager.onChatStateChanged(account, bareUserJid);
support = true;
break;
}
Message message = (Message) stanza;
if (message.getType() != Message.Type.chat && message.getType() != Message.Type.groupchat) {
return;
}
if (support) {
supports.put(account.toString(), bareUserJid.toString(), resource, true);
} else if (supports.get(account.toString(), bareUserJid.toString(), resource) == null) {
// Disable only if there no information about support.
supports.put(account.toString(), bareUserJid.toString(), resource, false);
}
}
}
use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.
the class ChatStateManager method onDisconnect.
@Override
public void onDisconnect(ConnectionItem connection) {
if (!(connection instanceof AccountItem))
return;
AccountJid account = ((AccountItem) connection).getAccount();
chatStates.clear(account.toString());
for (Map<Resourcepart, Runnable> map : stateCleaners.getNested(account.toString()).values()) {
for (Runnable runnable : map.values()) {
handler.removeCallbacks(runnable);
}
}
stateCleaners.clear(account.toString());
supports.clear(account.toString());
sent.clear(account.toString());
for (PendingIntent pendingIntent : pauseIntents.getNested(account.toString()).values()) {
alarmManager.cancel(pendingIntent);
}
pauseIntents.clear(account.toString());
}
use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.
the class SSNManager method onStanza.
@Override
public void onStanza(ConnectionItem connection, Stanza stanza) {
Jid from = stanza.getFrom();
if (from == null) {
return;
}
if (!(connection instanceof AccountItem) || !(stanza instanceof Message)) {
return;
}
AccountJid account = ((AccountItem) connection).getAccount();
Message message = (Message) stanza;
String session = message.getThread();
if (session == null) {
return;
}
for (ExtensionElement packetExtension : stanza.getExtensions()) {
if (packetExtension instanceof Feature) {
Feature feature = (Feature) packetExtension;
if (!feature.isValid()) {
continue;
}
DataForm.Type dataFormType = feature.getDataFormType();
if (dataFormType == DataForm.Type.form) {
onFormReceived(account, from, session, feature);
} else if (dataFormType == DataForm.Type.submit) {
onSubmitReceived(account, from, session, feature);
} else if (dataFormType == DataForm.Type.result) {
onResultReceived(account, session, feature);
}
}
}
}
Aggregations