diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-07-12 02:36:37 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-07-12 02:36:37 +0200 |
commit | 789383e5cb900baf55595e91f47f6d3ab4cec75e (patch) | |
tree | 2ea05116d7465ba2b2b323f4e320a3be15e2eabb /src/eu/siacs/conversations/parser/PresenceParser.java | |
parent | 7a26f272121107084a835638f4a287d49c44a7fe (diff) |
made message parser and presence parser implement interface On*PacketReceived
Diffstat (limited to 'src/eu/siacs/conversations/parser/PresenceParser.java')
-rw-r--r-- | src/eu/siacs/conversations/parser/PresenceParser.java | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/eu/siacs/conversations/parser/PresenceParser.java b/src/eu/siacs/conversations/parser/PresenceParser.java index ab32c707..b050f4ca 100644 --- a/src/eu/siacs/conversations/parser/PresenceParser.java +++ b/src/eu/siacs/conversations/parser/PresenceParser.java @@ -7,9 +7,11 @@ import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Presences; import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.xml.Element; +import eu.siacs.conversations.xmpp.OnPresencePacketReceived; import eu.siacs.conversations.xmpp.stanzas.PresencePacket; -public class PresenceParser extends AbstractParser { +public class PresenceParser extends AbstractParser implements + OnPresencePacketReceived { public PresenceParser(XmppConnectionService service) { super(service); @@ -37,7 +39,7 @@ public class PresenceParser extends AbstractParser { } public void parseContactPresence(PresencePacket packet, Account account) { - if (packet.getFrom()==null) { + if (packet.getFrom() == null) { return; } String[] fromParts = packet.getFrom().split("/"); @@ -75,9 +77,9 @@ public class PresenceParser extends AbstractParser { } } boolean online = sizeBefore < contact.getPresences().size(); - updateLastseen(packet, account,true); + updateLastseen(packet, account, true); mXmppConnectionService.onContactStatusChanged - .onContactStatusChanged(contact,online); + .onContactStatusChanged(contact, online); } } else if (type.equals("unavailable")) { if (fromParts.length != 2) { @@ -86,7 +88,7 @@ public class PresenceParser extends AbstractParser { contact.removePresence(fromParts[1]); } mXmppConnectionService.onContactStatusChanged - .onContactStatusChanged(contact,false); + .onContactStatusChanged(contact, false); } else if (type.equals("subscribe")) { if (contact.getOption(Contact.Options.PREEMPTIVE_GRANT)) { mXmppConnectionService.sendPresenceUpdatesTo(contact); @@ -102,4 +104,15 @@ public class PresenceParser extends AbstractParser { } } + @Override + public void onPresencePacketReceived(Account account, PresencePacket packet) { + if (packet.hasChild("x", "http://jabber.org/protocol/muc#user")) { + this.parseConferencePresence(packet, account); + } else if (packet.hasChild("x", "http://jabber.org/protocol/muc")) { + this.parseConferencePresence(packet, account); + } else { + this.parseContactPresence(packet, account); + } + } + } |