diff options
author | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-03-21 21:25:28 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-03-21 21:25:28 +0100 |
commit | 079712060c2a61515867e97ffb98c7c4e88e0d5a (patch) | |
tree | 58d39fd3dd67f6ba51bd7e7d6d6c657d24e77737 | |
parent | bbfe102e91a4c708134228ce195497f8fe6446ff (diff) |
otr safety guard
Diffstat (limited to '')
-rw-r--r-- | src/eu/siacs/conversations/utils/MessageParser.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/eu/siacs/conversations/utils/MessageParser.java b/src/eu/siacs/conversations/utils/MessageParser.java index 1e1ec46f..5cbdfd7b 100644 --- a/src/eu/siacs/conversations/utils/MessageParser.java +++ b/src/eu/siacs/conversations/utils/MessageParser.java @@ -31,6 +31,7 @@ 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); @@ -39,6 +40,7 @@ public class MessageParser { 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; @@ -50,6 +52,7 @@ public class MessageParser { if (properlyAddressed) { Log.d("xmppService","replacing otr session with "+packet.getFrom()); conversation.startOtrSession(service.getApplicationContext(), fromParts[1]); + justStarted = true; } else { return null; } @@ -86,7 +89,13 @@ public class MessageParser { Log.d(LOGTAG,"otr session stoped"); } } catch (Exception e) { - conversation.resetOtrSession(); + Log.d(LOGTAG,"otr execption"); + if (justStarted) { + Log.d(LOGTAG,"ran into safeguard"); + } else { + Log.d(LOGTAG,"resett otr session"); + conversation.resetOtrSession(); + } return null; } |