make omemo default when all resources support it
This commit is contained in:
parent
09e20f6e01
commit
908aa19a36
|
@ -53,6 +53,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
|
||||||
|
|
||||||
public static final String PEP_PREFIX = "eu.siacs.conversations.axolotl";
|
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 = 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_BUNDLES = PEP_PREFIX + ".bundles";
|
||||||
public static final String PEP_VERIFICATION = PEP_PREFIX + ".verification";
|
public static final String PEP_VERIFICATION = PEP_PREFIX + ".verification";
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ import eu.siacs.conversations.xmpp.chatstate.ChatState;
|
||||||
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
|
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
|
||||||
import eu.siacs.conversations.xmpp.jid.Jid;
|
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||||
|
|
||||||
|
|
||||||
public class Conversation extends AbstractEntity implements Blockable {
|
public class Conversation extends AbstractEntity implements Blockable {
|
||||||
public static final String TABLENAME = "conversations";
|
public static final String TABLENAME = "conversations";
|
||||||
|
|
||||||
|
@ -678,12 +679,12 @@ public class Conversation extends AbstractEntity implements Blockable {
|
||||||
final AxolotlService axolotlService = getAccount().getAxolotlService();
|
final AxolotlService axolotlService = getAccount().getAxolotlService();
|
||||||
int next = this.getIntAttribute(ATTRIBUTE_NEXT_ENCRYPTION, -1);
|
int next = this.getIntAttribute(ATTRIBUTE_NEXT_ENCRYPTION, -1);
|
||||||
if (next == -1) {
|
if (next == -1) {
|
||||||
if (Config.X509_VERIFICATION) {
|
if (Config.supportOmemo()
|
||||||
if (axolotlService != null && axolotlService.isConversationAxolotlCapable(this)) {
|
&& axolotlService != null
|
||||||
return Message.ENCRYPTION_AXOLOTL;
|
&& mode == MODE_SINGLE
|
||||||
} else {
|
&& axolotlService.isConversationAxolotlCapable(this)
|
||||||
return Message.ENCRYPTION_NONE;
|
&& getContact().getPresences().allOrNonSupport(AxolotlService.PEP_DEVICE_LIST_NOTIFY)) {
|
||||||
}
|
return Message.ENCRYPTION_AXOLOTL;
|
||||||
}
|
}
|
||||||
int outgoing = this.getMostRecentlyUsedOutgoingEncryption();
|
int outgoing = this.getMostRecentlyUsedOutgoingEncryption();
|
||||||
if (outgoing == Message.ENCRYPTION_NONE) {
|
if (outgoing == Message.ENCRYPTION_NONE) {
|
||||||
|
@ -695,7 +696,7 @@ public class Conversation extends AbstractEntity implements Blockable {
|
||||||
|
|
||||||
if (!Config.supportUnencrypted() && next <= 0) {
|
if (!Config.supportUnencrypted() && next <= 0) {
|
||||||
if (Config.supportOmemo()
|
if (Config.supportOmemo()
|
||||||
&& (axolotlService != null && axolotlService.isConversationAxolotlCapable(this) || !Config.multipleEncryptionChoices())) {
|
&& ((axolotlService != null && axolotlService.isConversationAxolotlCapable(this)) || !Config.multipleEncryptionChoices())) {
|
||||||
return Message.ENCRYPTION_AXOLOTL;
|
return Message.ENCRYPTION_AXOLOTL;
|
||||||
} else if (Config.supportOtr() && mode == MODE_SINGLE) {
|
} else if (Config.supportOtr() && mode == MODE_SINGLE) {
|
||||||
return Message.ENCRYPTION_OTR;
|
return Message.ENCRYPTION_OTR;
|
||||||
|
|
|
@ -40,11 +40,11 @@ public class Presence implements Comparable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final Status status;
|
private final Status status;
|
||||||
protected ServiceDiscoveryResult disco;
|
private ServiceDiscoveryResult disco;
|
||||||
protected final String ver;
|
private final String ver;
|
||||||
protected final String hash;
|
private final String hash;
|
||||||
protected final String message;
|
private final String message;
|
||||||
|
|
||||||
private Presence(Status status, String ver, String hash, String message) {
|
private Presence(Status status, String ver, String hash, String message) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
|
@ -79,7 +79,15 @@ public class Presence implements Comparable {
|
||||||
return this.hash;
|
return this.hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return this.message;
|
||||||
|
}
|
||||||
|
|
||||||
public void setServiceDiscoveryResult(ServiceDiscoveryResult disco) {
|
public void setServiceDiscoveryResult(ServiceDiscoveryResult disco) {
|
||||||
this.disco = disco;
|
this.disco = disco;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ServiceDiscoveryResult getServiceDiscoveryResult() {
|
||||||
|
return disco;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,11 +64,24 @@ public class Presences {
|
||||||
ArrayList<String> messages = new ArrayList<>();
|
ArrayList<String> messages = new ArrayList<>();
|
||||||
synchronized (this.presences) {
|
synchronized (this.presences) {
|
||||||
for(Presence presence : this.presences.values()) {
|
for(Presence presence : this.presences.values()) {
|
||||||
if (presence.message != null && !presence.message.trim().isEmpty()) {
|
String message = presence.getMessage();
|
||||||
messages.add(presence.message.trim());
|
if (message != null && !message.trim().isEmpty()) {
|
||||||
|
messages.add(message.trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return messages;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ public abstract class AbstractGenerator {
|
||||||
"urn:xmpp:ping",
|
"urn:xmpp:ping",
|
||||||
"jabber:iq:version",
|
"jabber:iq:version",
|
||||||
"http://jabber.org/protocol/chatstates",
|
"http://jabber.org/protocol/chatstates",
|
||||||
AxolotlService.PEP_DEVICE_LIST+"+notify"};
|
AxolotlService.PEP_DEVICE_LIST_NOTIFY};
|
||||||
private final String[] MESSAGE_CONFIRMATION_FEATURES = {
|
private final String[] MESSAGE_CONFIRMATION_FEATURES = {
|
||||||
"urn:xmpp:chat-markers:0",
|
"urn:xmpp:chat-markers:0",
|
||||||
"urn:xmpp:receipts"
|
"urn:xmpp:receipts"
|
||||||
|
|
Loading…
Reference in New Issue