use of com.xabber.android.data.NetworkException 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));
}
use of com.xabber.android.data.NetworkException in project xabber-android by redsolution.
the class CapabilitiesManager method request.
/**
* Requests disco info.
*
* @param account
* @param user
* @param capability
*/
private void request(String account, String user, Capability capability) {
for (DiscoverInfoRequest check : requests) {
if (capability.equals(check.getCapability())) {
return;
}
}
DiscoverInfo packet = new DiscoverInfo();
packet.setTo(user);
packet.setType(Type.get);
if (capability.getNode() != null && capability.getVersion() != null)
packet.setNode(capability.getNode() + "#" + capability.getVersion());
try {
ConnectionManager.getInstance().sendStanza(account, packet);
} catch (NetworkException e) {
return;
}
requests.add(new DiscoverInfoRequest(account, Jid.getStringPrep(user), packet.getStanzaId(), capability));
}
use of com.xabber.android.data.NetworkException in project xabber-android by redsolution.
the class MessageArchiveManager method onPreferencesResponce.
private void onPreferencesResponce(String account, Pref pref) {
defaults.remove(account);
for (Map<String, ArchivePreference> map : items.get(account).values()) map.clear();
sessionSaves.clear(account);
checkForDefaults(account, pref.getDefault());
Boolean autoSave = pref.getAutoSave();
if (autoSave != null) {
if (autoSave) {
// TODO: check whether record can be disabled.
} else if (AccountManager.getInstance().getArchiveMode(account) == ArchiveMode.server) {
Auto auto = new Auto();
auto.setSave(true);
auto.setType(Type.set);
try {
ConnectionManager.getInstance().sendStanza(account, auto);
} catch (NetworkException e) {
}
// TODO: track results.
saves.put(account, true);
}
}
onPreferenceReceived(account, pref);
}
Aggregations