use of com.xabber.xmpp.ssn.DisclosureValue in project xabber-android by redsolution.
the class SSNManager method onFormReceived.
private void onFormReceived(String account, String from, String bareAddress, String session, Feature feature) {
OtrMode otrMode = getOtrMode(account, bareAddress, session);
boolean cancel = false;
Collection<DisclosureValue> disclosureValues = feature.getDisclosureOptions();
DisclosureValue disclosureValue = DisclosureValue.never;
if (disclosureValues == null)
disclosureValue = null;
else if (!disclosureValues.contains(disclosureValue))
cancel = true;
Collection<SecurityValue> securityValues = feature.getSecurityOptions();
SecurityValue securityValue;
if (AccountManager.getInstance().getAccount(account).getConnectionSettings().getTlsMode() == TLSMode.required)
securityValue = SecurityValue.c2s;
else
securityValue = SecurityValue.none;
if (securityValues == null)
securityValue = null;
else if (!securityValues.contains(securityValue))
cancel = true;
Collection<LoggingValue> loggingValues = feature.getLoggingOptions();
LoggingValue loggingValue;
if (loggingValues == null)
loggingValue = null;
else {
loggingValue = otrMode.selectLoggingValue(loggingValues);
if (loggingValue == null)
cancel = true;
}
if (cancel) {
DataForm dataForm = Feature.createDataForm(DataFormType.submit);
if (feature.getAcceptValue() != null) {
Feature.addAcceptField(dataForm, false);
sessionStates.remove(account, session);
} else {
Feature.addRenegotiateField(dataForm, false);
}
sendFeature(account, from, session, new Feature(dataForm));
return;
}
DataForm dataForm = Feature.createDataForm(DataFormType.submit);
if (feature.getAcceptValue() != null)
Feature.addAcceptField(dataForm, true);
else
Feature.addRenegotiateField(dataForm, true);
if (disclosureValue != null)
Feature.addDisclosureField(dataForm, null, disclosureValue);
if (securityValue != null)
Feature.addSecurityField(dataForm, null, securityValue);
if (loggingValue != null) {
try {
if (loggingValue == LoggingValue.mustnot)
MessageArchiveManager.getInstance().setSaveMode(account, from, session, SaveMode.fls);
else
MessageArchiveManager.getInstance().setSaveMode(account, from, session, SaveMode.body);
} catch (NetworkException e) {
}
Feature.addLoggingField(dataForm, null, loggingValue);
}
sessionStates.put(account, session, SessionState.active);
sendFeature(account, from, session, new Feature(dataForm));
}
Aggregations