diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-05-12 14:20:11 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-05-13 21:52:13 +0200 |
commit | ed6a572bde9750f5df497f1db83a89cc18c079e7 (patch) | |
tree | 52b5917d7fd4976a63cb61d1fb27e07163efa7e3 /src | |
parent | 363b290138af4ba7b70dba43bb7c022850b01c1a (diff) |
make omemo default when all resources support it
Diffstat (limited to 'src')
5 files changed, 38 insertions, 15 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 86d237619..ae1b3a03f 100644 --- a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java +++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java @@ -53,6 +53,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded { public static final String PEP_PREFIX = "eu.siacs.conversations.axolotl"; public static final String PEP_DEVICE_LIST = PEP_PREFIX + ".devicelist"; + public static final String PEP_DEVICE_LIST_NOTIFY = PEP_DEVICE_LIST + "+notify"; public static final String PEP_BUNDLES = PEP_PREFIX + ".bundles"; public static final String PEP_VERIFICATION = PEP_PREFIX + ".verification"; diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index 35c46a3de..b8cbc0bd4 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -28,6 +28,7 @@ import eu.siacs.conversations.xmpp.chatstate.ChatState; import eu.siacs.conversations.xmpp.jid.InvalidJidException; import eu.siacs.conversations.xmpp.jid.Jid; + public class Conversation extends AbstractEntity implements Blockable { public static final String TABLENAME = "conversations"; @@ -692,12 +693,12 @@ public class Conversation extends AbstractEntity implements Blockable { final AxolotlService axolotlService = getAccount().getAxolotlService(); int next = this.getIntAttribute(ATTRIBUTE_NEXT_ENCRYPTION, -1); if (next == -1) { - if (Config.X509_VERIFICATION) { - if (axolotlService != null && axolotlService.isConversationAxolotlCapable(this)) { - return Message.ENCRYPTION_AXOLOTL; - } else { - return Message.ENCRYPTION_NONE; - } + if (Config.supportOmemo() + && axolotlService != null + && mode == MODE_SINGLE + && axolotlService.isConversationAxolotlCapable(this) + && getContact().getPresences().allOrNonSupport(AxolotlService.PEP_DEVICE_LIST_NOTIFY)) { + return Message.ENCRYPTION_AXOLOTL; } int outgoing = this.getMostRecentlyUsedOutgoingEncryption(); if (outgoing == Message.ENCRYPTION_NONE) { @@ -709,7 +710,7 @@ public class Conversation extends AbstractEntity implements Blockable { if (!Config.supportUnencrypted() && next <= 0) { if (Config.supportOmemo() - && (axolotlService != null && axolotlService.isConversationAxolotlCapable(this) || !Config.multipleEncryptionChoices())) { + && ((axolotlService != null && axolotlService.isConversationAxolotlCapable(this)) || !Config.multipleEncryptionChoices())) { return Message.ENCRYPTION_AXOLOTL; } else if (Config.supportOtr() && mode == MODE_SINGLE) { return Message.ENCRYPTION_OTR; diff --git a/src/main/java/eu/siacs/conversations/entities/Presence.java b/src/main/java/eu/siacs/conversations/entities/Presence.java index 485adaa13..e9f6d0d16 100644 --- a/src/main/java/eu/siacs/conversations/entities/Presence.java +++ b/src/main/java/eu/siacs/conversations/entities/Presence.java @@ -40,11 +40,11 @@ public class Presence implements Comparable { } } - protected final Status status; - protected ServiceDiscoveryResult disco; - protected final String ver; - protected final String hash; - protected final String message; + private final Status status; + private ServiceDiscoveryResult disco; + private final String ver; + private final String hash; + private final String message; private Presence(Status status, String ver, String hash, String message) { this.status = status; @@ -79,7 +79,15 @@ public class Presence implements Comparable { return this.hash; } + public String getMessage() { + return this.message; + } + public void setServiceDiscoveryResult(ServiceDiscoveryResult disco) { this.disco = disco; } + + public ServiceDiscoveryResult getServiceDiscoveryResult() { + return disco; + } } diff --git a/src/main/java/eu/siacs/conversations/entities/Presences.java b/src/main/java/eu/siacs/conversations/entities/Presences.java index 5fe10de0f..754175ab2 100644 --- a/src/main/java/eu/siacs/conversations/entities/Presences.java +++ b/src/main/java/eu/siacs/conversations/entities/Presences.java @@ -64,11 +64,24 @@ public class Presences { ArrayList<String> messages = new ArrayList<>(); synchronized (this.presences) { for(Presence presence : this.presences.values()) { - if (presence.message != null && !presence.message.trim().isEmpty()) { - messages.add(presence.message.trim()); + String message = presence.getMessage(); + if (message != null && !message.trim().isEmpty()) { + messages.add(message.trim()); } } } return messages; } + + public boolean allOrNonSupport(String namespace) { + synchronized (this.presences) { + for(Presence presence : this.presences.values()) { + ServiceDiscoveryResult disco = presence.getServiceDiscoveryResult(); + if (disco == null || !disco.getFeatures().contains(namespace)) { + return false; + } + } + } + return true; + } } diff --git a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java index f63b4d092..cc974e5fb 100644 --- a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java +++ b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java @@ -33,7 +33,7 @@ public abstract class AbstractGenerator { "urn:xmpp:ping", "jabber:iq:version", "http://jabber.org/protocol/chatstates", - AxolotlService.PEP_DEVICE_LIST+"+notify"}; + AxolotlService.PEP_DEVICE_LIST_NOTIFY}; private final String[] MESSAGE_CONFIRMATION_FEATURES = { "urn:xmpp:chat-markers:0", "urn:xmpp:receipts" |