fix bug with presences with no resource attached

This commit is contained in:
Daniel Gultsch 2014-03-18 14:35:19 +01:00
parent dd71e252ae
commit 3a98a695d4
1 changed files with 29 additions and 25 deletions

View File

@ -241,34 +241,38 @@ public class XmppConnectionService extends Service {
} }
String type = packet.getAttribute("type"); String type = packet.getAttribute("type");
if (type == null) { if (type == null) {
Element show = packet.findChild("show"); if (fromParts.length == 2) {
if (show == null) { Element show = packet.findChild("show");
contact.updatePresence(fromParts[1], Presences.ONLINE); if (show == null) {
} else if (show.getContent().equals("away")) { contact.updatePresence(fromParts[1], Presences.ONLINE);
contact.updatePresence(fromParts[1], Presences.AWAY); } else if (show.getContent().equals("away")) {
} else if (show.getContent().equals("xa")) { contact.updatePresence(fromParts[1], Presences.AWAY);
contact.updatePresence(fromParts[1], Presences.XA); } else if (show.getContent().equals("xa")) {
} else if (show.getContent().equals("chat")) { contact.updatePresence(fromParts[1], Presences.XA);
contact.updatePresence(fromParts[1], Presences.CHAT); } else if (show.getContent().equals("chat")) {
} else if (show.getContent().equals("dnd")) { contact.updatePresence(fromParts[1], Presences.CHAT);
contact.updatePresence(fromParts[1], Presences.DND); } else if (show.getContent().equals("dnd")) {
} contact.updatePresence(fromParts[1], Presences.DND);
PgpEngine pgp = getPgpEngine(); }
if (pgp != null) { PgpEngine pgp = getPgpEngine();
Element x = packet.findChild("x"); if (pgp != null) {
if ((x != null) Element x = packet.findChild("x");
&& (x.getAttribute("xmlns") if ((x != null)
.equals("jabber:x:signed"))) { && (x.getAttribute("xmlns")
try { .equals("jabber:x:signed"))) {
contact.setPgpKeyId(pgp.fetchKeyId(packet try {
.findChild("status").getContent(), x contact.setPgpKeyId(pgp.fetchKeyId(packet
.getContent())); .findChild("status").getContent(), x
} catch (OpenPgpException e) { .getContent()));
Log.d(LOGTAG, "faulty pgp. just ignore"); } 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")) { } else if (type.equals("unavailable")) {
if (fromParts.length != 2) { if (fromParts.length != 2) {
// Log.d(LOGTAG,"received presence with no resource "+packet.toString()); // Log.d(LOGTAG,"received presence with no resource "+packet.toString());