Commit 303dccc8 authored by Alexander Ivanov's avatar Alexander Ivanov

Stop OTR session on disable OTR in the settings. Fixes #98.

parent 783bdbbc
......@@ -32,6 +32,7 @@ import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.account.StatusMode;
import com.xabber.android.data.connection.NetworkManager;
import com.xabber.android.data.extension.attention.AttentionManager;
import com.xabber.android.data.extension.otr.OTRManager;
import com.xabber.android.data.message.MessageManager;
import com.xabber.android.data.notification.NotificationManager;
import com.xabber.android.data.roster.AbstractContact;
......@@ -772,6 +773,9 @@ public class SettingsManager implements OnInitializedListener,
} else if (key.equals(Application.getInstance().getString(
R.string.chats_attention_key))) {
AttentionManager.getInstance().onSettingsChanged();
} else if (key.equals(Application.getInstance().getString(
R.string.security_otr_mode_key))) {
OTRManager.getInstance().onSettingsChanged();
}
}
......
......@@ -691,16 +691,25 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener,
});
}
@Override
public void onClose() {
private void endAllSessions() {
NestedMap<String> entities = new NestedMap<String>();
entities.addAll(actives);
for (Entry<String> entry : entities)
try {
endSession(entry.getFirst(), entry.getSecond());
} catch (NetworkException e) {
// Just ignore.
LogManager.exception(this, e);
}
}
@Override
public void onClose() {
endAllSessions();
}
public void onSettingsChanged() {
if (SettingsManager.securityOtrMode() == SecurityOtrMode.disabled)
endAllSessions();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment