aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-04-25 14:09:38 +0200
committerDaniel Gultsch <daniel@gultsch.de>2015-04-25 14:09:38 +0200
commit77caf73103abb134e698e3eecaeefe799bc1265f (patch)
treed04fe714bdef27fa32367c612a7c74d7732edf82 /src/main/java/eu/siacs/conversations
parentd07baccf9722a464111273f7a364139ce534fad4 (diff)
parentd6443d9b2f4654a0724ca273c81f400730b644c1 (diff)
Merge pull request #1146 from BrianBlade/minor_otr_tweaks
OTR: Fix onContactStatusChanged & dont archive OTR
Diffstat (limited to 'src/main/java/eu/siacs/conversations')
-rw-r--r--src/main/java/eu/siacs/conversations/crypto/OtrEngine.java2
-rw-r--r--src/main/java/eu/siacs/conversations/generator/MessageGenerator.java1
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java20
3 files changed, 17 insertions, 6 deletions
diff --git a/src/main/java/eu/siacs/conversations/crypto/OtrEngine.java b/src/main/java/eu/siacs/conversations/crypto/OtrEngine.java
index 263f60890..0dc7c37e4 100644
--- a/src/main/java/eu/siacs/conversations/crypto/OtrEngine.java
+++ b/src/main/java/eu/siacs/conversations/crypto/OtrEngine.java
@@ -182,7 +182,7 @@ public class OtrEngine extends OtrCryptoEngineImpl implements OtrEngineHost {
packet.setBody(body);
packet.addChild("private", "urn:xmpp:carbons:2");
packet.addChild("no-copy", "urn:xmpp:hints");
- packet.addChild("no-store", "urn:xmpp:hints");
+ packet.addChild("no-permanent-store", "urn:xmpp:hints");
try {
Jid jid = Jid.fromSessionID(session);
diff --git a/src/main/java/eu/siacs/conversations/generator/MessageGenerator.java b/src/main/java/eu/siacs/conversations/generator/MessageGenerator.java
index a60c5613f..474a3e1dc 100644
--- a/src/main/java/eu/siacs/conversations/generator/MessageGenerator.java
+++ b/src/main/java/eu/siacs/conversations/generator/MessageGenerator.java
@@ -71,6 +71,7 @@ public class MessageGenerator extends AbstractGenerator {
MessagePacket packet = preparePacket(message, addDelay);
packet.addChild("private", "urn:xmpp:carbons:2");
packet.addChild("no-copy", "urn:xmpp:hints");
+ packet.addChild("no-permanent-store", "urn:xmpp:hints");
try {
packet.setBody(otrSession.transformSending(message.getBody())[0]);
return packet;
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index c0b609f3f..ec0b3f928 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -36,6 +36,7 @@ import org.openintents.openpgp.util.OpenPgpServiceConnection;
import java.math.BigInteger;
import java.security.SecureRandom;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
@@ -174,13 +175,22 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
public void onContactStatusChanged(Contact contact, boolean online) {
Conversation conversation = find(getConversations(), contact);
if (conversation != null) {
- if (online && contact.getPresences().size() > 1) {
+ if (online) {
conversation.endOtrIfNeeded();
+ if (contact.getPresences().size() == 1) {
+ sendUnsentMessages(conversation);
+ }
} else {
- conversation.resetOtrSession();
- }
- if (online && (contact.getPresences().size() == 1)) {
- sendUnsentMessages(conversation);
+ if (contact.getPresences().size() >= 1) {
+ if (conversation.hasValidOtrSession()) {
+ String otrResource = conversation.getOtrSession().getSessionID().getUserID();
+ if (!(Arrays.asList(contact.getPresences().asStringArray()).contains(otrResource))) {
+ conversation.endOtrIfNeeded();
+ }
+ }
+ } else {
+ conversation.endOtrIfNeeded();
+ }
}
}
}