From a0dde05ee59058bfd71968eb4072aaaa9be5c090 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 23 May 2014 10:54:40 +0200 Subject: end otr sessions earlier / more often. can lead to unesessary handshakes but can improve reliabilty --- src/eu/siacs/conversations/entities/Conversation.java | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'src/eu/siacs/conversations/entities') diff --git a/src/eu/siacs/conversations/entities/Conversation.java b/src/eu/siacs/conversations/entities/Conversation.java index e61537da..37a230df 100644 --- a/src/eu/siacs/conversations/entities/Conversation.java +++ b/src/eu/siacs/conversations/entities/Conversation.java @@ -10,11 +10,11 @@ import net.java.otr4j.crypto.OtrCryptoException; import net.java.otr4j.session.SessionID; import net.java.otr4j.session.SessionImpl; import net.java.otr4j.session.SessionStatus; - import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.net.Uri; +import android.util.Log; public class Conversation extends AbstractEntity { @@ -240,6 +240,7 @@ public class Conversation extends AbstractEntity { public void endOtrIfNeeded() { if (this.otrSession != null) { if (this.otrSession.getSessionStatus() == SessionStatus.ENCRYPTED) { + Log.d("xmppService","ending otr session with "+getContactJid()); try { this.otrSession.endSession(); this.resetOtrSession(); @@ -251,20 +252,7 @@ public class Conversation extends AbstractEntity { } public boolean hasValidOtrSession() { - if (this.otrSession == null) { - return false; - } else { - String foreignPresence = this.otrSession.getSessionID().getUserID(); - if (getContact()==null) { - return true; - } else { - if (!getContact().getPresences().containsKey(foreignPresence)) { - this.resetOtrSession(); - return false; - } - return true; - } - } + return this.otrSession != null; } public String getOtrFingerprint() { -- cgit v1.2.3