aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-09-08 11:01:27 +0200
committerDaniel Gultsch <daniel@gultsch.de>2016-09-08 11:01:27 +0200
commitac9f13a9f2137ff3f126b118fa24d2a5b599d762 (patch)
treed3d4cffe5f4df9f35579480c35d0328622454bb1 /src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java
parenta54a7dca305dbb6bf41fb6354b55f3eedf73bfac (diff)
provide hint on why conference can not be encrypted
Diffstat (limited to 'src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java')
-rw-r--r--src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java28
1 files changed, 26 insertions, 2 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 9e54c0c7..28085085 100644
--- a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java
+++ b/src/main/java/eu/siacs/conversations/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<AxolotlCapability,Jid> isConversationAxolotlCapableDetailed(Conversation conversation) {
final List<Jid> 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<Jid> getCryptoTargets(Conversation conversation) {