aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/xmpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/eu/siacs/conversations/xmpp')
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/stanzas/AbstractStanza.java4
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/stanzas/MessagePacket.java24
2 files changed, 18 insertions, 10 deletions
diff --git a/src/main/java/eu/siacs/conversations/xmpp/stanzas/AbstractStanza.java b/src/main/java/eu/siacs/conversations/xmpp/stanzas/AbstractStanza.java
index 55256ece..bd706b57 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/stanzas/AbstractStanza.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/stanzas/AbstractStanza.java
@@ -51,4 +51,8 @@ public class AbstractStanza extends Element {
|| getTo().equals(account.getJid().toBareJid())
|| getTo().equals(account.getJid());
}
+
+ public boolean fromAccount(final Account account) {
+ return getFrom() != null && getFrom().toBareJid().equals(account.getJid().toBareJid());
+ }
}
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 11c3452b..e32811af 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/stanzas/MessagePacket.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/stanzas/MessagePacket.java
@@ -1,5 +1,10 @@
package eu.siacs.conversations.xmpp.stanzas;
+import android.util.Pair;
+
+import java.text.ParseException;
+
+import eu.siacs.conversations.parser.AbstractParser;
import eu.siacs.conversations.xml.Element;
public class MessagePacket extends AbstractStanza {
@@ -14,12 +19,7 @@ public class MessagePacket extends AbstractStanza {
}
public String getBody() {
- Element body = this.findChild("body");
- if (body != null) {
- return body.getContent();
- } else {
- return null;
- }
+ return findChildContent("body");
}
public void setBody(String text) {
@@ -67,19 +67,23 @@ public class MessagePacket extends AbstractStanza {
}
}
- public MessagePacket getForwardedMessagePacket(String name, String namespace) {
+ public Pair<MessagePacket,Long> getForwardedMessagePacket(String name, String namespace) {
Element wrapper = findChild(name, namespace);
if (wrapper == null) {
return null;
}
- Element forwarded = wrapper.findChild("forwarded","urn:xmpp:forward:0");
+ Element forwarded = wrapper.findChild("forwarded", "urn:xmpp:forward:0");
if (forwarded == null) {
return null;
}
- return MessagePacket.create(forwarded.findChild("message"));
+ MessagePacket packet = create(forwarded.findChild("message"));
+ if (packet == null) {
+ return null;
+ }
+ Long timestamp = AbstractParser.getTimestamp(forwarded,null);
+ return new Pair(packet,timestamp);
}
-
public static MessagePacket create(Element element) {
if (element == null) {
return null;