make omemo default

This commit is contained in:
Daniel Gultsch 2018-03-06 10:50:28 +01:00
parent 13a4a78025
commit ed0ba89551
1 changed files with 10 additions and 37 deletions

View File

@ -71,8 +71,6 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
private transient MucOptions mucOptions = null; private transient MucOptions mucOptions = null;
private byte[] symmetricKey;
private boolean messagesLeftOnServer = true; private boolean messagesLeftOnServer = true;
private ChatState mOutgoingChatState = Config.DEFAULT_CHATSTATE; private ChatState mOutgoingChatState = Config.DEFAULT_CHATSTATE;
private ChatState mIncomingChatState = Config.DEFAULT_CHATSTATE; private ChatState mIncomingChatState = Config.DEFAULT_CHATSTATE;
@ -600,35 +598,18 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
} }
public int getNextEncryption() { public int getNextEncryption() {
return fixAvailableEncryption(this.getIntAttribute(ATTRIBUTE_NEXT_ENCRYPTION, getDefaultEncryption())); final int defaultEncryption;
}
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_PGP:
case Message.ENCRYPTION_DECRYPTED:
case Message.ENCRYPTION_DECRYPTION_FAILED:
return Config.supportOpenPgp() ? Message.ENCRYPTION_PGP : getDefaultEncryption();
default:
return getDefaultEncryption();
}
}
private int getDefaultEncryption() {
AxolotlService axolotlService = account.getAxolotlService(); AxolotlService axolotlService = account.getAxolotlService();
if (Config.supportUnencrypted()) { if (axolotlService != null && axolotlService.isConversationAxolotlCapable(this)) {
return Message.ENCRYPTION_NONE; defaultEncryption = Message.ENCRYPTION_AXOLOTL;
} else if (Config.supportOmemo()
&& (axolotlService != null && axolotlService.isConversationAxolotlCapable(this) || !Config.multipleEncryptionChoices())) {
return Message.ENCRYPTION_AXOLOTL;
} else if (Config.supportOpenPgp()) {
return Message.ENCRYPTION_PGP;
} else { } else {
return Message.ENCRYPTION_NONE; defaultEncryption = Message.ENCRYPTION_NONE;
}
int encryption = this.getIntAttribute(ATTRIBUTE_NEXT_ENCRYPTION, defaultEncryption);
if (encryption == Message.ENCRYPTION_OTR) {
return defaultEncryption;
} else {
return encryption;
} }
} }
@ -647,14 +628,6 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
return changed; return changed;
} }
public void setSymmetricKey(byte[] key) {
this.symmetricKey = key;
}
public byte[] getSymmetricKey() {
return this.symmetricKey;
}
public Bookmark getBookmark() { public Bookmark getBookmark() {
return this.account.getBookmark(this.contactJid); return this.account.getBookmark(this.contactJid);
} }