aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/entities
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/eu/siacs/conversations/entities
parent09e20f6e01f53ff1d4c038a5ff0cbd3d7868130a (diff)
make omemo default when all resources support it
Diffstat (limited to 'src/main/java/eu/siacs/conversations/entities')
-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
3 files changed, 36 insertions, 14 deletions
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;
+ }
}