From b605577cd912e9974263b53f65d0614821403680 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 22 May 2014 16:17:51 +0200 Subject: encrypted group messages are now properly decrypted --- src/eu/siacs/conversations/parser/MessageParser.java | 17 +++++++++++------ .../conversations/services/XmppConnectionService.java | 1 - 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/eu/siacs/conversations/parser/MessageParser.java b/src/eu/siacs/conversations/parser/MessageParser.java index 3733767f9..2ccbe05c6 100644 --- a/src/eu/siacs/conversations/parser/MessageParser.java +++ b/src/eu/siacs/conversations/parser/MessageParser.java @@ -120,7 +120,12 @@ public class MessageParser { } else { status = Message.STATUS_RECIEVED; } - return new Message(conversation, counterPart, packet.getBody(), Message.ENCRYPTION_NONE, status); + String pgpBody = getPgpBody(packet); + if (pgpBody==null) { + return new Message(conversation, counterPart, packet.getBody(), Message.ENCRYPTION_NONE, status); + } else { + return new Message(conversation, counterPart, pgpBody, Message.ENCRYPTION_PGP, status); + } } public Message parseCarbonMessage(MessagePacket packet,Account account) { @@ -160,11 +165,11 @@ public class MessageParser { } public String getPgpBody(MessagePacket packet) { - for(Element child : packet.getChildren()) { - if (child.getName().equals("x")&&child.getAttribute("xmlns").equals("jabber:x:encrypted")) { - return child.getContent(); - } + Element child = packet.findChild("x", "jabber:x:encrypted"); + if (child==null) { + return null; + } else { + return child.getContent(); } - return null; } } diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java index 3347ea1f9..d1692a440 100644 --- a/src/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/eu/siacs/conversations/services/XmppConnectionService.java @@ -873,7 +873,6 @@ public class XmppConnectionService extends Service { packet.setBody(message.getBody()); packet.setTo(message.getCounterpart().split("/")[0]); packet.setFrom(account.getJid()); - packet.addChild("x", "jabber:x:encrypted").setContent("test"); } packet.setId(message.getUuid()); return packet; -- cgit v1.2.3