use of com.xabber.xmpp.form.DataFormType 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.xmpp.form.DataFormType in project xabber-android by redsolution.
the class Feature method isValid.
@Override
public boolean isValid() {
if (dataForm == null)
return false;
DataFormType dataFormType = getDataFormType();
if (dataFormType == null || dataFormType == DataFormType.cancel)
return false;
int selected = 0;
if (getAcceptValue() != null)
selected += 1;
if (getRenegotiateValue() != null)
selected += 1;
if (getTerminateValue() != null) {
if (!getTerminateValue() || getDataFormType() != DataFormType.submit)
return false;
selected += 1;
}
if (selected != 1)
return false;
return FORM_TYPE_VALUE.equals(getValue(FORM_TYPE_FIELD));
}
Aggregations