fixed otr bug

This commit is contained in:
Daniel Gultsch 2014-03-08 00:48:52 +01:00
parent 5955da3519
commit a1b72313d7

View File

@ -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();