diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2015-05-14 14:42:21 +0200 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2015-05-20 03:48:14 +0200 |
commit | e32f380dae4913d8152fc92b76193de241089cf8 (patch) | |
tree | 788ee2f2a2c5f3eeff479d66b817f2ab059ca629 /src/main/java/eu/siacs/conversations/xmpp/stanzas | |
parent | 7824c01748a89688c5f76307cc1f4221a9e2ffb5 (diff) |
provide helper function for getting the content of a child directly
Diffstat (limited to 'src/main/java/eu/siacs/conversations/xmpp/stanzas')
-rw-r--r-- | src/main/java/eu/siacs/conversations/xmpp/stanzas/MessagePacket.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/xmpp/stanzas/MessagePacket.java b/src/main/java/eu/siacs/conversations/xmpp/stanzas/MessagePacket.java index 93aaa68cf..11c3452b0 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/stanzas/MessagePacket.java +++ b/src/main/java/eu/siacs/conversations/xmpp/stanzas/MessagePacket.java @@ -66,4 +66,27 @@ public class MessagePacket extends AbstractStanza { return TYPE_NORMAL; } } + + public MessagePacket getForwardedMessagePacket(String name, String namespace) { + Element wrapper = findChild(name, namespace); + if (wrapper == null) { + return null; + } + Element forwarded = wrapper.findChild("forwarded","urn:xmpp:forward:0"); + if (forwarded == null) { + return null; + } + return MessagePacket.create(forwarded.findChild("message")); + } + + + public static MessagePacket create(Element element) { + if (element == null) { + return null; + } + MessagePacket packet = new MessagePacket(); + packet.setAttributes(element.getAttributes()); + packet.setChildren(element.getChildren()); + return packet; + } } |