make omemo default when all resources support it

This commit is contained in:
Daniel Gultsch 2016-05-12 14:20:11 +02:00
parent 09e20f6e01
commit 908aa19a36
5 changed files with 38 additions and 15 deletions

View file

@ -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";

View file

@ -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;

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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"