diff options
Diffstat (limited to 'src/eu/siacs/conversations/utils/MessageParser.java')
-rw-r--r-- | src/eu/siacs/conversations/utils/MessageParser.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/eu/siacs/conversations/utils/MessageParser.java b/src/eu/siacs/conversations/utils/MessageParser.java index de8f4de8..58235678 100644 --- a/src/eu/siacs/conversations/utils/MessageParser.java +++ b/src/eu/siacs/conversations/utils/MessageParser.java @@ -2,7 +2,6 @@ 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; @@ -31,13 +30,16 @@ public class MessageParser { } public static Message parseOtrChat(MessagePacket packet, Account account, XmppConnectionService service) { + boolean justStarted = false; boolean properlyAddressed = (packet.getTo().split("/").length == 2) || (account.countPresences() == 1); String[] fromParts = packet.getFrom().split("/"); Conversation conversation = service.findOrCreateConversation(account, fromParts[0],false); String body = packet.getBody(); if (!conversation.hasValidOtrSession()) { if (properlyAddressed) { + Log.d("xmppService","starting new otr session with "+packet.getFrom()+" because no valid otr session has been found"); conversation.startOtrSession(service.getApplicationContext(), fromParts[1]); + justStarted = true; } else { Log.d("xmppService",account.getJid()+": ignoring otr session with "+fromParts[0]); return null; @@ -47,7 +49,9 @@ public class MessageParser { if (!foreignPresence.equals(fromParts[1])) { conversation.resetOtrSession(); if (properlyAddressed) { + Log.d("xmppService","replacing otr session with "+packet.getFrom()); conversation.startOtrSession(service.getApplicationContext(), fromParts[1]); + justStarted = true; } else { return null; } @@ -84,7 +88,9 @@ public class MessageParser { Log.d(LOGTAG,"otr session stoped"); } } catch (Exception e) { - conversation.resetOtrSession(); + if (!justStarted) { + conversation.resetOtrSession(); + } return null; } |