bugfix: changed condition of onOtrSessionEstablished being called

fixed #1263
fixed #1260
fixed #1293
This commit is contained in:
Daniel Gultsch 2015-07-21 11:46:51 +02:00
parent 74e05023b4
commit f74ee765a2

View File

@ -70,18 +70,18 @@ public class MessageParser extends AbstractParser implements
try { try {
conversation.setLastReceivedOtrMessageId(id); conversation.setLastReceivedOtrMessageId(id);
Session otrSession = conversation.getOtrSession(); Session otrSession = conversation.getOtrSession();
SessionStatus before = otrSession.getSessionStatus();
body = otrSession.transformReceiving(body); body = otrSession.transformReceiving(body);
SessionStatus after = otrSession.getSessionStatus(); SessionStatus status = otrSession.getSessionStatus();
if ((before != after) && (after == SessionStatus.ENCRYPTED)) { if (body == null && status == SessionStatus.ENCRYPTED) {
conversation.setNextEncryption(Message.ENCRYPTION_OTR); conversation.setNextEncryption(Message.ENCRYPTION_OTR);
mXmppConnectionService.onOtrSessionEstablished(conversation); mXmppConnectionService.onOtrSessionEstablished(conversation);
} else if ((before != after) && (after == SessionStatus.FINISHED)) { return null;
} else if (body == null && status == SessionStatus.FINISHED) {
conversation.setNextEncryption(Message.ENCRYPTION_NONE); conversation.setNextEncryption(Message.ENCRYPTION_NONE);
conversation.resetOtrSession(); conversation.resetOtrSession();
mXmppConnectionService.updateConversationUi(); mXmppConnectionService.updateConversationUi();
} return null;
if ((body == null) || (body.isEmpty())) { } else if (body == null || (body.isEmpty())) {
return null; return null;
} }
if (body.startsWith(CryptoHelper.FILETRANSFER)) { if (body.startsWith(CryptoHelper.FILETRANSFER)) {