From 37d1a5380634471b11c828cf265d4a39e818a1c1 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 28 Feb 2014 00:22:56 +0100 Subject: basic pgp support. --- src/de/gultsch/chat/utils/MessageParser.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/de/gultsch/chat/utils') diff --git a/src/de/gultsch/chat/utils/MessageParser.java b/src/de/gultsch/chat/utils/MessageParser.java index 1dca7343..a12ef58c 100644 --- a/src/de/gultsch/chat/utils/MessageParser.java +++ b/src/de/gultsch/chat/utils/MessageParser.java @@ -23,6 +23,12 @@ public class MessageParser { return new Message(conversation, packet.getFrom(), body, Message.ENCRYPTION_NONE, Message.STATUS_RECIEVED); } + public static Message parsePgpChat(String pgpBody, MessagePacket packet, Account account, XmppConnectionService service) { + String[] fromParts = packet.getFrom().split("/"); + Conversation conversation = service.findOrCreateConversation(account, fromParts[0],false); + return new Message(conversation, packet.getFrom(), pgpBody, Message.ENCRYPTION_PGP, Message.STATUS_RECIEVED); + } + public static Message parseOtrChat(MessagePacket packet, Account account, XmppConnectionService service) { String[] fromParts = packet.getFrom().split("/"); Conversation conversation = service.findOrCreateConversation(account, fromParts[0],false); @@ -131,4 +137,13 @@ public class MessageParser { } return new Message(conversation, packet.getFrom(), displayError, Message.ENCRYPTION_NONE, Message.STATUS_ERROR); } + + public static String getPgpBody(MessagePacket packet) { + for(Element child : packet.getChildren()) { + if (child.getName().equals("x")&&child.getAttribute("xmlns").equals("jabber:x:encrypted")) { + return child.getContent(); + } + } + return null; + } } -- cgit v1.2.3