diff options
Diffstat (limited to 'src/main/java/de')
-rw-r--r-- | src/main/java/de/pixart/messenger/entities/Conversation.java | 43 |
1 files changed, 12 insertions, 31 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Conversation.java b/src/main/java/de/pixart/messenger/entities/Conversation.java index e4ec95f3b..c9bbbfca2 100644 --- a/src/main/java/de/pixart/messenger/entities/Conversation.java +++ b/src/main/java/de/pixart/messenger/entities/Conversation.java @@ -760,40 +760,21 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl } public int getNextEncryption() { - return fixAvailableEncryption(this.getIntAttribute(ATTRIBUTE_NEXT_ENCRYPTION, getDefaultEncryption())); - } - - private int fixAvailableEncryption(int selectedEncryption) { - switch (selectedEncryption) { - case Message.ENCRYPTION_NONE: - return Config.supportUnencrypted() ? selectedEncryption : getDefaultEncryption(); - case Message.ENCRYPTION_AXOLOTL: - return Config.supportOmemo() ? selectedEncryption : getDefaultEncryption(); - case Message.ENCRYPTION_OTR: - return Config.supportOtr() ? selectedEncryption : getDefaultEncryption(); - case Message.ENCRYPTION_PGP: - case Message.ENCRYPTION_DECRYPTED: - case Message.ENCRYPTION_DECRYPTION_FAILED: - return Config.supportOpenPgp() ? Message.ENCRYPTION_PGP : getDefaultEncryption(); - default: - return getDefaultEncryption(); - } - } - - private int getDefaultEncryption() { + final int defaultEncryption; AxolotlService axolotlService = account.getAxolotlService(); - if (Config.supportUnencrypted()) { - return Message.ENCRYPTION_NONE; - } else if (Config.supportOmemo() - && (axolotlService != null && axolotlService.isConversationAxolotlCapable(this) || !Config.multipleEncryptionChoices())) { - return Message.ENCRYPTION_AXOLOTL; - } else if (Config.supportOtr() && mode == MODE_SINGLE) { - return Message.ENCRYPTION_OTR; - } else if (Config.supportOpenPgp()) { - return Message.ENCRYPTION_PGP; + if (axolotlService != null && axolotlService.isConversationAxolotlCapable(this)) { + defaultEncryption = Message.ENCRYPTION_AXOLOTL; } else { - return Message.ENCRYPTION_NONE; + defaultEncryption = Message.ENCRYPTION_NONE; } + int encryption = this.getIntAttribute(ATTRIBUTE_NEXT_ENCRYPTION, defaultEncryption); + // don't ignore OTR + /*if (encryption == Message.ENCRYPTION_OTR) { + return defaultEncryption; + } else { + return encryption; + }*/ + return encryption; } public void setNextEncryption(int encryption) { |