From a1b72313d7858a69c794d706e7ebb00a50a7000a Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 8 Mar 2014 00:48:52 +0100 Subject: fixed otr bug --- src/eu/siacs/conversations/utils/MessageParser.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/eu/siacs/conversations') 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(); -- cgit v1.2.3