only offer plain and omemo encryption when x509 verification is enabled

This commit is contained in:
Daniel Gultsch 2015-12-19 12:44:12 +01:00
parent f05f97251c
commit e8bf5cada4
2 changed files with 13 additions and 3 deletions

View file

@ -20,6 +20,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import eu.siacs.conversations.Config; import eu.siacs.conversations.Config;
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
import eu.siacs.conversations.xmpp.chatstate.ChatState; import eu.siacs.conversations.xmpp.chatstate.ChatState;
import eu.siacs.conversations.xmpp.jid.InvalidJidException; import eu.siacs.conversations.xmpp.jid.InvalidJidException;
import eu.siacs.conversations.xmpp.jid.Jid; import eu.siacs.conversations.xmpp.jid.Jid;
@ -607,6 +608,14 @@ public class Conversation extends AbstractEntity implements Blockable {
} }
public int getNextEncryption() { public int getNextEncryption() {
final AxolotlService axolotlService = getAccount().getAxolotlService();
if (Config.X509_VERIFICATION && mode == MODE_SINGLE) {
if (axolotlService != null && axolotlService.isContactAxolotlCapable(getContact())) {
return Message.ENCRYPTION_AXOLOTL;
} else {
return Message.ENCRYPTION_NONE;
}
}
int next = this.getIntAttribute(ATTRIBUTE_NEXT_ENCRYPTION, -1); int next = this.getIntAttribute(ATTRIBUTE_NEXT_ENCRYPTION, -1);
if (next == -1) { if (next == -1) {
int outgoing = this.getMostRecentlyUsedOutgoingEncryption(); int outgoing = this.getMostRecentlyUsedOutgoingEncryption();
@ -617,7 +626,7 @@ public class Conversation extends AbstractEntity implements Blockable {
} }
} }
if (Config.FORCE_ENCRYPTION && mode == MODE_SINGLE && next <= 0) { if (Config.FORCE_ENCRYPTION && mode == MODE_SINGLE && next <= 0) {
if (getAccount().getAxolotlService().isContactAxolotlCapable(getContact())) { if (axolotlService != null && axolotlService.isContactAxolotlCapable(getContact())) {
return Message.ENCRYPTION_AXOLOTL; return Message.ENCRYPTION_AXOLOTL;
} else { } else {
return Message.ENCRYPTION_OTR; return Message.ENCRYPTION_OTR;

View file

@ -414,7 +414,7 @@ public class ConversationActivity extends XmppActivity
menuContactDetails.setVisible(false); menuContactDetails.setVisible(false);
menuAttach.setVisible(getSelectedConversation().getAccount().httpUploadAvailable() && getSelectedConversation().getMucOptions().participating()); menuAttach.setVisible(getSelectedConversation().getAccount().httpUploadAvailable() && getSelectedConversation().getMucOptions().participating());
menuInviteContact.setVisible(getSelectedConversation().getMucOptions().canInvite()); menuInviteContact.setVisible(getSelectedConversation().getMucOptions().canInvite());
menuSecure.setVisible(!Config.HIDE_PGP_IN_UI); //if pgp is hidden conferences have no choice of encryption menuSecure.setVisible(!Config.HIDE_PGP_IN_UI && !Config.X509_VERIFICATION); //if pgp is hidden conferences have no choice of encryption
} else { } else {
menuMucDetails.setVisible(false); menuMucDetails.setVisible(false);
} }
@ -868,8 +868,9 @@ public class ConversationActivity extends XmppActivity
MenuItem none = popup.getMenu().findItem(R.id.encryption_choice_none); MenuItem none = popup.getMenu().findItem(R.id.encryption_choice_none);
MenuItem pgp = popup.getMenu().findItem(R.id.encryption_choice_pgp); MenuItem pgp = popup.getMenu().findItem(R.id.encryption_choice_pgp);
MenuItem axolotl = popup.getMenu().findItem(R.id.encryption_choice_axolotl); MenuItem axolotl = popup.getMenu().findItem(R.id.encryption_choice_axolotl);
pgp.setVisible(!Config.HIDE_PGP_IN_UI); pgp.setVisible(!Config.HIDE_PGP_IN_UI && !Config.X509_VERIFICATION);
none.setVisible(!Config.FORCE_ENCRYPTION); none.setVisible(!Config.FORCE_ENCRYPTION);
otr.setVisible(!Config.X509_VERIFICATION);
if (conversation.getMode() == Conversation.MODE_MULTI) { if (conversation.getMode() == Conversation.MODE_MULTI) {
otr.setVisible(false); otr.setVisible(false);
axolotl.setVisible(false); axolotl.setVisible(false);