diff options
-rw-r--r-- | src/eu/siacs/conversations/utils/MessageParser.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/eu/siacs/conversations/utils/MessageParser.java b/src/eu/siacs/conversations/utils/MessageParser.java index 65186957..614683a2 100644 --- a/src/eu/siacs/conversations/utils/MessageParser.java +++ b/src/eu/siacs/conversations/utils/MessageParser.java @@ -2,6 +2,7 @@ package eu.siacs.conversations.utils; import java.util.List; +import net.java.otr4j.OtrException; import net.java.otr4j.session.Session; import net.java.otr4j.session.SessionStatus; import android.util.Log; @@ -35,6 +36,17 @@ public class MessageParser { String body = packet.getBody(); if (!conversation.hasValidOtrSession()) { conversation.startOtrSession(service.getApplicationContext(), fromParts[1]); + } else { + if (body.startsWith("?OTRv")) { + Log.d("xmppService","new otr during existing otr session requested. ending old one"); + try { + conversation.getOtrSession().endSession(); + } catch (OtrException e) { + Log.d("xmppService","couldnt end old session"); + } + Log.d("xmppService","starting new one with "+fromParts[1]); + conversation.startOtrSession(service.getApplicationContext(), fromParts[1]); + } } try { Session otrSession = conversation.getOtrSession(); |