aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-05-12 14:20:11 +0200
committerDaniel Gultsch <daniel@gultsch.de>2016-05-12 14:20:11 +0200
commit908aa19a36eaf80442da153cbac729d3fdb0aa31 (patch)
treece9cddf6c20605cca5fa3d4689015538263c9fd0 /src/main/java
parent09e20f6e01f53ff1d4c038a5ff0cbd3d7868130a (diff)
make omemo default when all resources support it
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java1
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Conversation.java15
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Presence.java18
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Presences.java17
-rw-r--r--src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java2
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 86d23761..ae1b3a03 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 b1d597df..646bc2be 100644
--- a/src/main/java/eu/siacs/conversations/entities/Conversation.java
+++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java
@@ -27,6 +27,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";
@@ -678,12 +679,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) {
@@ -695,7 +696,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 485adaa1..e9f6d0d1 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 5fe10de0..754175ab 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 05fa0b82..4be6c621 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"