From 3a98a695d4c77cf879a76262b2d370d79e8b4fdb Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 18 Mar 2014 14:35:19 +0100 Subject: fix bug with presences with no resource attached --- .../services/XmppConnectionService.java | 54 ++++++++++++---------- 1 file changed, 29 insertions(+), 25 deletions(-) (limited to 'src/eu/siacs') diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java index 0e4852af2..c1136f5ed 100644 --- a/src/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/eu/siacs/conversations/services/XmppConnectionService.java @@ -241,34 +241,38 @@ public class XmppConnectionService extends Service { } String type = packet.getAttribute("type"); if (type == null) { - Element show = packet.findChild("show"); - if (show == null) { - contact.updatePresence(fromParts[1], Presences.ONLINE); - } else if (show.getContent().equals("away")) { - contact.updatePresence(fromParts[1], Presences.AWAY); - } else if (show.getContent().equals("xa")) { - contact.updatePresence(fromParts[1], Presences.XA); - } else if (show.getContent().equals("chat")) { - contact.updatePresence(fromParts[1], Presences.CHAT); - } else if (show.getContent().equals("dnd")) { - contact.updatePresence(fromParts[1], Presences.DND); - } - PgpEngine pgp = getPgpEngine(); - if (pgp != null) { - Element x = packet.findChild("x"); - if ((x != null) - && (x.getAttribute("xmlns") - .equals("jabber:x:signed"))) { - try { - contact.setPgpKeyId(pgp.fetchKeyId(packet - .findChild("status").getContent(), x - .getContent())); - } catch (OpenPgpException e) { - Log.d(LOGTAG, "faulty pgp. just ignore"); + if (fromParts.length == 2) { + Element show = packet.findChild("show"); + if (show == null) { + contact.updatePresence(fromParts[1], Presences.ONLINE); + } else if (show.getContent().equals("away")) { + contact.updatePresence(fromParts[1], Presences.AWAY); + } else if (show.getContent().equals("xa")) { + contact.updatePresence(fromParts[1], Presences.XA); + } else if (show.getContent().equals("chat")) { + contact.updatePresence(fromParts[1], Presences.CHAT); + } else if (show.getContent().equals("dnd")) { + contact.updatePresence(fromParts[1], Presences.DND); + } + PgpEngine pgp = getPgpEngine(); + if (pgp != null) { + Element x = packet.findChild("x"); + if ((x != null) + && (x.getAttribute("xmlns") + .equals("jabber:x:signed"))) { + try { + contact.setPgpKeyId(pgp.fetchKeyId(packet + .findChild("status").getContent(), x + .getContent())); + } catch (OpenPgpException e) { + Log.d(LOGTAG, "faulty pgp. just ignore"); + } } } + databaseBackend.updateContact(contact); + } else { + //Log.d(LOGTAG,"presence without resource "+packet.toString()); } - databaseBackend.updateContact(contact); } else if (type.equals("unavailable")) { if (fromParts.length != 2) { // Log.d(LOGTAG,"received presence with no resource "+packet.toString()); -- cgit v1.2.3