From dd956b7531e97fd46a3fccdda97905448859c7b3 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 8 Sep 2016 11:01:27 +0200 Subject: provide hint on why conference can not be encrypted --- .../messenger/crypto/axolotl/AxolotlService.java | 28 ++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java') diff --git a/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java b/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java index 3ebc6e06f..4e293c9a1 100644 --- a/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java +++ b/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java @@ -647,14 +647,38 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded { }); } + public enum AxolotlCapability { + FULL, + MISSING_PRESENCE, + MISSING_KEYS, + WRONG_CONFIGURATION, + NO_MEMBERS + } + public boolean isConversationAxolotlCapable(Conversation conversation) { + return isConversationAxolotlCapableDetailed(conversation).first == AxolotlCapability.FULL; + } + + public Pair isConversationAxolotlCapableDetailed(Conversation conversation) { final List jids = getCryptoTargets(conversation); for(Jid jid : jids) { if (!hasAny(jid) && (!deviceIds.containsKey(jid) || deviceIds.get(jid).isEmpty())) { - return false; + if (conversation.getAccount().getRoster().getContact(jid).trusted()) { + return new Pair<>(AxolotlCapability.MISSING_KEYS,jid); + } else { + return new Pair<>(AxolotlCapability.MISSING_PRESENCE,jid); + } + } + } + if (jids.size() > 0) { + return new Pair<>(AxolotlCapability.FULL, null); + } else { + if (conversation.getMucOptions().membersOnly() && conversation.getMucOptions().nonanonymous()) { + return new Pair<>(AxolotlCapability.NO_MEMBERS, null); + } else { + return new Pair<>(AxolotlCapability.WRONG_CONFIGURATION, null); } } - return jids.size() > 0; } public List getCryptoTargets(Conversation conversation) { -- cgit v1.2.3