diff options
author | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-02-28 00:22:56 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-02-28 00:22:56 +0100 |
commit | 37d1a5380634471b11c828cf265d4a39e818a1c1 (patch) | |
tree | bbd6d58171beb79369c9c452098286591e6a6eae /src/de/gultsch/chat/utils/MessageParser.java | |
parent | bfee69b00b2762a910f7f3f1714d18fddc99a9ad (diff) |
basic pgp support.
Diffstat (limited to 'src/de/gultsch/chat/utils/MessageParser.java')
-rw-r--r-- | src/de/gultsch/chat/utils/MessageParser.java | 15 |
1 files changed, 15 insertions, 0 deletions
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; + } } |