decrypt pgp message corrections

This commit is contained in:
Daniel Gultsch 2016-02-19 21:02:33 +01:00
parent a2cb009f4c
commit e6f8b7d9fa
1 changed files with 9 additions and 8 deletions

View File

@ -117,13 +117,6 @@ public class MessageParser extends AbstractParser implements
return finishedMessage; return finishedMessage;
} }
private Message parsePGPChat(final Conversation conversation, String pgpEncrypted, int status) {
final Message message = new Message(conversation, pgpEncrypted, Message.ENCRYPTION_PGP, status);
PgpDecryptionService pgpDecryptionService = conversation.getAccount().getPgpDecryptionService();
pgpDecryptionService.add(message);
return message;
}
private class Invite { private class Invite {
Jid jid; Jid jid;
String password; String password;
@ -362,7 +355,7 @@ public class MessageParser extends AbstractParser implements
message = new Message(conversation, body, Message.ENCRYPTION_NONE, status); message = new Message(conversation, body, Message.ENCRYPTION_NONE, status);
} }
} else if (pgpEncrypted != null) { } else if (pgpEncrypted != null) {
message = parsePGPChat(conversation, pgpEncrypted, status); message = new Message(conversation, pgpEncrypted, Message.ENCRYPTION_PGP, status);
} else if (axolotlEncrypted != null) { } else if (axolotlEncrypted != null) {
message = parseAxolotlChat(axolotlEncrypted, from, remoteMsgId, conversation, status); message = parseAxolotlChat(axolotlEncrypted, from, remoteMsgId, conversation, status);
if (message == null) { if (message == null) {
@ -410,6 +403,7 @@ public class MessageParser extends AbstractParser implements
replacedMessage.setBody(message.getBody()); replacedMessage.setBody(message.getBody());
replacedMessage.setEdited(replacedMessage.getRemoteMsgId()); replacedMessage.setEdited(replacedMessage.getRemoteMsgId());
replacedMessage.setRemoteMsgId(remoteMsgId); replacedMessage.setRemoteMsgId(remoteMsgId);
replacedMessage.setEncryption(message.getEncryption());
if (replacedMessage.getStatus() == Message.STATUS_RECEIVED) { if (replacedMessage.getStatus() == Message.STATUS_RECEIVED) {
replacedMessage.markUnread(); replacedMessage.markUnread();
} }
@ -417,6 +411,9 @@ public class MessageParser extends AbstractParser implements
if (mXmppConnectionService.confirmMessages() && remoteMsgId != null && !isForwarded && !isTypeGroupChat) { if (mXmppConnectionService.confirmMessages() && remoteMsgId != null && !isForwarded && !isTypeGroupChat) {
sendMessageReceipts(account, packet); sendMessageReceipts(account, packet);
} }
if (replacedMessage.getEncryption() == Message.ENCRYPTION_PGP) {
conversation.getAccount().getPgpDecryptionService().add(replacedMessage);
}
return; return;
} else { } else {
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": received message correction but verification didn't check out"); Log.d(Config.LOGTAG,account.getJid().toBareJid()+": received message correction but verification didn't check out");
@ -438,6 +435,10 @@ public class MessageParser extends AbstractParser implements
conversation.add(message); conversation.add(message);
} }
if (message.getEncryption() == Message.ENCRYPTION_PGP) {
conversation.getAccount().getPgpDecryptionService().add(message);
}
if (query == null || query.getWith() == null) { //either no mam or catchup if (query == null || query.getWith() == null) { //either no mam or catchup
if (status == Message.STATUS_SEND || status == Message.STATUS_SEND_RECEIVED) { if (status == Message.STATUS_SEND || status == Message.STATUS_SEND_RECEIVED) {
mXmppConnectionService.markRead(conversation); mXmppConnectionService.markRead(conversation);