From baf76d883cd513251445c31680dc9847d6fa3877 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 31 Oct 2015 22:55:04 +0100 Subject: [PATCH] indicate cbe in chat message hint --- .../crypto/axolotl/AxolotlService.java | 16 ++++++++++++++++ .../conversations/ui/ConversationFragment.java | 8 +++++++- src/main/res/values/strings.xml | 5 +++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java index 8cda3c124..2aaadab71 100644 --- a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java +++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java @@ -778,6 +778,22 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded { return newSessions; } + public boolean trustedSessionVerified(final Conversation conversation) { + Set sessions = findSessionsforContact(conversation.getContact()); + sessions.addAll(findOwnSessions()); + boolean verified = false; + for(XmppAxolotlSession session : sessions) { + if (session.getTrust().trusted()) { + if (session.getTrust() == XmppAxolotlSession.Trust.TRUSTED_X509) { + verified = true; + } else { + return false; + } + } + } + return verified; + } + public boolean hasPendingKeyFetches(Account account, Contact contact) { AxolotlAddress ownAddress = new AxolotlAddress(account.getJid().toBareJid().toString(), 0); AxolotlAddress foreignAddress = new AxolotlAddress(contact.getJid().toBareJid().toString(), 0); diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 7b83c2bef..f7a0e2109 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -46,6 +46,7 @@ import java.util.concurrent.ConcurrentLinkedQueue; import eu.siacs.conversations.Config; import eu.siacs.conversations.R; import eu.siacs.conversations.crypto.PgpEngine; +import eu.siacs.conversations.crypto.axolotl.AxolotlService; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Conversation; @@ -363,7 +364,12 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa mEditMessage.setHint(getString(R.string.send_otr_message)); break; case Message.ENCRYPTION_AXOLOTL: - mEditMessage.setHint(getString(R.string.send_omemo_message)); + AxolotlService axolotlService = conversation.getAccount().getAxolotlService(); + if (axolotlService.trustedSessionVerified(conversation)) { + mEditMessage.setHint(getString(R.string.send_omemo_x509_message)); + } else { + mEditMessage.setHint(getString(R.string.send_omemo_message)); + } break; case Message.ENCRYPTION_PGP: mEditMessage.setHint(getString(R.string.send_pgp_message)); diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index e3dfb79de..fa484a825 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -82,6 +82,7 @@ Send unencrypted message Send OTR encrypted message Send OMEMO encrypted message + Send OMEMO (X.509 verified) encrypted message Send OpenPGP encrypted message Your nickname has been changed Send unencrypted @@ -211,9 +212,9 @@ Your fingerprint OTR fingerprint OMEMO fingerprint - OMEMO fingerprint (X509 verified) + OMEMO fingerprint (X.509 verified) OMEMO fingerprint of message - OMEMO fingerprint (X509 verified) of message + OMEMO fingerprint (X.509 verified) of message Own OMEMO fingerprint Other devices Trust OMEMO Fingerprints