aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/parser/PresenceParser.java
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-12-20 17:23:03 +0100
committeriNPUTmice <daniel@gultsch.de>2014-12-20 17:23:03 +0100
commit15176417132a88364efeb64713f8ac1267001cc4 (patch)
tree1603ac6d4ee9979a7de9b7763688b9925f60a7b9 /src/main/java/eu/siacs/conversations/parser/PresenceParser.java
parentce4848f74225a59ddc8469a2a3e3481519c0f0d5 (diff)
get rid of special self presence object and incorporate that into roster
Diffstat (limited to 'src/main/java/eu/siacs/conversations/parser/PresenceParser.java')
-rw-r--r--src/main/java/eu/siacs/conversations/parser/PresenceParser.java100
1 files changed, 44 insertions, 56 deletions
diff --git a/src/main/java/eu/siacs/conversations/parser/PresenceParser.java b/src/main/java/eu/siacs/conversations/parser/PresenceParser.java
index 43c8fa8d..684713f0 100644
--- a/src/main/java/eu/siacs/conversations/parser/PresenceParser.java
+++ b/src/main/java/eu/siacs/conversations/parser/PresenceParser.java
@@ -45,69 +45,57 @@ public class PresenceParser extends AbstractParser implements
}
final Jid from = packet.getFrom();
String type = packet.getAttribute("type");
- if (from.toBareJid().equals(account.getJid().toBareJid())) {
+ Contact contact = account.getRoster().getContact(packet.getFrom());
+ if (type == null) {
+ String presence;
if (!from.isBareJid()) {
- if (type == null) {
- account.updatePresence(from.getResourcepart(),
- Presences.parseShow(packet.findChild("show")));
- } else if (type.equals("unavailable")) {
- account.removePresence(from.getResourcepart());
- account.deactivateGracePeriod();
- }
+ presence = from.getResourcepart();
+ } else {
+ presence = "";
}
- } else {
- Contact contact = account.getRoster().getContact(packet.getFrom());
- if (type == null) {
- String presence;
- if (!from.isBareJid()) {
- presence = from.getResourcepart();
- } else {
- presence = "";
- }
- int sizeBefore = contact.getPresences().size();
- contact.updatePresence(presence,
- Presences.parseShow(packet.findChild("show")));
- PgpEngine pgp = mXmppConnectionService.getPgpEngine();
- if (pgp != null) {
- Element x = packet.findChild("x", "jabber:x:signed");
- if (x != null) {
- Element status = packet.findChild("status");
- String msg;
- if (status != null) {
- msg = status.getContent();
- } else {
- msg = "";
- }
- contact.setPgpKeyId(pgp.fetchKeyId(account, msg,
- x.getContent()));
+ int sizeBefore = contact.getPresences().size();
+ contact.updatePresence(presence,
+ Presences.parseShow(packet.findChild("show")));
+ PgpEngine pgp = mXmppConnectionService.getPgpEngine();
+ if (pgp != null) {
+ Element x = packet.findChild("x", "jabber:x:signed");
+ if (x != null) {
+ Element status = packet.findChild("status");
+ String msg;
+ if (status != null) {
+ msg = status.getContent();
+ } else {
+ msg = "";
}
+ contact.setPgpKeyId(pgp.fetchKeyId(account, msg,
+ x.getContent()));
}
- boolean online = sizeBefore < contact.getPresences().size();
- updateLastseen(packet, account, true);
- mXmppConnectionService.onContactStatusChanged
- .onContactStatusChanged(contact, online);
- } else if (type.equals("unavailable")) {
- if (from.isBareJid()) {
- contact.clearPresences();
- } else {
- contact.removePresence(from.getResourcepart());
- }
- mXmppConnectionService.onContactStatusChanged
- .onContactStatusChanged(contact, false);
- } else if (type.equals("subscribe")) {
- if (contact.getOption(Contact.Options.PREEMPTIVE_GRANT)) {
- mXmppConnectionService.sendPresencePacket(account,
- mPresenceGenerator.sendPresenceUpdatesTo(contact));
- } else {
- contact.setOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST);
- }
}
- Element nick = packet.findChild("nick",
- "http://jabber.org/protocol/nick");
- if (nick != null) {
- contact.setPresenceName(nick.getContent());
+ boolean online = sizeBefore < contact.getPresences().size();
+ updateLastseen(packet, account, true);
+ mXmppConnectionService.onContactStatusChanged
+ .onContactStatusChanged(contact, online);
+ } else if (type.equals("unavailable")) {
+ if (from.isBareJid()) {
+ contact.clearPresences();
+ } else {
+ contact.removePresence(from.getResourcepart());
+ }
+ mXmppConnectionService.onContactStatusChanged
+ .onContactStatusChanged(contact, false);
+ } else if (type.equals("subscribe")) {
+ if (contact.getOption(Contact.Options.PREEMPTIVE_GRANT)) {
+ mXmppConnectionService.sendPresencePacket(account,
+ mPresenceGenerator.sendPresenceUpdatesTo(contact));
+ } else {
+ contact.setOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST);
}
}
+ Element nick = packet.findChild("nick",
+ "http://jabber.org/protocol/nick");
+ if (nick != null) {
+ contact.setPresenceName(nick.getContent());
+ }
mXmppConnectionService.updateRosterUi();
}