aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/parser/AbstractParser.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/parser/AbstractParser.java')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/parser/AbstractParser.java20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/parser/AbstractParser.java b/src/main/java/de/thedevstack/conversationsplus/parser/AbstractParser.java
index 1b520bbe..bebe41d0 100644
--- a/src/main/java/de/thedevstack/conversationsplus/parser/AbstractParser.java
+++ b/src/main/java/de/thedevstack/conversationsplus/parser/AbstractParser.java
@@ -10,6 +10,7 @@ import de.thedevstack.conversationsplus.entities.Contact;
import de.thedevstack.conversationsplus.services.XmppConnectionService;
import de.thedevstack.conversationsplus.xml.Element;
import de.thedevstack.conversationsplus.xmpp.jid.Jid;
+import de.thedevstack.conversationsplus.xmpp.stanzas.AbstractStanza;
public abstract class AbstractParser {
@@ -70,16 +71,13 @@ public abstract class AbstractParser {
return dateFormat.parse(timestamp);
}
- protected void updateLastseen(final Element packet, final Account account,
- final boolean presenceOverwrite) {
- final Jid from = packet.getAttributeAsJid("from");
- updateLastseen(packet, account, from, presenceOverwrite);
- }
+ protected void updateLastseen(final AbstractStanza packet, final Account account, final boolean presenceOverwrite) {
+ updateLastseen(getTimestamp(packet), account, packet.getFrom(), presenceOverwrite);
+ }
- protected void updateLastseen(final Element packet, final Account account, final Jid from, final boolean presenceOverwrite) {
+ protected void updateLastseen(long timestamp, final Account account, final Jid from, final boolean presenceOverwrite) {
final String presence = from == null || from.isBareJid() ? "" : from.getResourcepart();
final Contact contact = account.getRoster().getContact(from);
- final long timestamp = getTimestamp(packet);
if (timestamp >= contact.lastseen.time) {
contact.lastseen.time = timestamp;
if (!presence.isEmpty() && presenceOverwrite) {
@@ -87,4 +85,12 @@ public abstract class AbstractParser {
}
}
}
+
+ protected String avatarData(Element items) {
+ Element item = items.findChild("item");
+ if (item == null) {
+ return null;
+ }
+ return item.findChildContent("data", "urn:xmpp:avatar:data");
+ }
}