diff options
author | BrianBlade <n.gelbertz@gmail.com> | 2015-04-21 22:17:58 +0200 |
---|---|---|
committer | BrianBlade <n.gelbertz@gmail.com> | 2015-04-21 22:35:35 +0200 |
commit | d6443d9b2f4654a0724ca273c81f400730b644c1 (patch) | |
tree | f980f4490024e980131403d3533e845ead2f8d8e /src/main/java/eu/siacs/conversations/services | |
parent | e9783b80d18c5d1b64090d7e6fa4cf1e6b95f177 (diff) |
OTR: Fix onContactStatusChanged & dont archive OTR
- Fix session handling on contact status change: Do not reset
potentially active sessions; check peer's OTR-resource on disconnect
- use no-permanent-store hint instead of no-store to ensure
finished messages are delivered to offline/disconnected clients
- add no-permanent-store to ask compliant servers not to archive
OTR messages
Diffstat (limited to 'src/main/java/eu/siacs/conversations/services')
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/XmppConnectionService.java | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 3e8ce65f2..9ffffe0f6 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(); + } } } } |