use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class AttentionManager method onPacket.
@Override
public void onPacket(ConnectionItem connection, String bareAddress, Stanza packet) {
if (!(connection instanceof AccountItem))
return;
if (!(packet instanceof Message))
return;
if (!SettingsManager.chatsAttention())
return;
final String account = ((AccountItem) connection).getAccount();
if (bareAddress == null)
return;
for (ExtensionElement packetExtension : packet.getExtensions()) {
if (packetExtension instanceof Attention) {
MessageManager.getInstance().openChat(account, bareAddress);
MessageManager.getInstance().getOrCreateChat(account, bareAddress).newAction(null, null, ChatAction.attention_requested);
attentionRequestProvider.add(new AttentionRequest(account, bareAddress), true);
}
}
}
use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class PingManager method onPacket.
@Override
public void onPacket(ConnectionItem connection, final String bareAddress, Stanza packet) {
if (!(connection instanceof AccountItem))
return;
final String account = ((AccountItem) connection).getAccount();
if (!(packet instanceof Ping))
return;
final Ping ping = (Ping) packet;
if (ping.getType() != IQ.Type.get)
return;
try {
ConnectionManager.getInstance().sendStanza(account, IQ.createResultIQ(ping));
} catch (NetworkException e) {
LogManager.exception(this, e);
}
}
use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class SSNManager method onPacket.
@Override
public void onPacket(ConnectionItem connection, final String bareAddress, Stanza packet) {
String from = packet.getFrom();
if (from == null)
return;
if (!(connection instanceof AccountItem) || !(packet instanceof Message))
return;
String account = ((AccountItem) connection).getAccount();
Message message = (Message) packet;
String session = message.getThread();
if (session == null)
return;
for (ExtensionElement packetExtension : packet.getExtensions()) if (packetExtension instanceof Feature) {
Feature feature = (Feature) packetExtension;
if (!feature.isValid())
continue;
DataFormType type = feature.getDataFormType();
if (type == DataFormType.form)
onFormReceived(account, from, bareAddress, session, feature);
else if (type == DataFormType.submit)
onSubmitReceived(account, from, bareAddress, session, feature);
else if (type == DataFormType.result)
onResultReceived(account, from, bareAddress, session, feature);
}
}
use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class ClientStateManager method sendClientState.
protected static void sendClientState(PlainStreamElement element) {
AccountManager accountManager = AccountManager.getInstance();
for (String accountName : accountManager.getAccounts()) {
AccountItem account = accountManager.getAccount(accountName);
if (account == null) {
continue;
}
ConnectionThread connectionThread = account.getConnectionThread();
if (connectionThread == null) {
continue;
}
AbstractXMPPConnection xmppConnection = connectionThread.getXMPPConnection();
if (xmppConnection == null) {
continue;
}
if (xmppConnection.hasFeature("csi", ClientStateIndication.NAMESPACE))
try {
xmppConnection.send(element);
} catch (SmackException.NotConnectedException e) {
// not connected
}
}
}
use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class TimeManager method onServerInfoReceived.
@Override
public void onServerInfoReceived(ConnectionItem connection) {
if (!(connection instanceof AccountItem)) {
onAvailable(connection);
return;
}
String account = ((AccountItem) connection).getAccount();
if (ServerInfoManager.getInstance().isProtocolSupported(account, FEATURE) && offsets.get(account) == null) {
sents.put(account, new Date());
Time packet = new Time();
packet.setTo(Jid.getServer(account));
packet.setType(Type.get);
try {
ConnectionManager.getInstance().sendRequest(account, packet, this);
} catch (NetworkException e) {
}
return;
}
onAvailable(connection);
}
Aggregations