never parse show in presences as offline
This commit is contained in:
parent
ac687d6bbd
commit
49a3f6f281
|
@ -1,6 +1,7 @@
|
||||||
package eu.siacs.conversations.entities;
|
package eu.siacs.conversations.entities;
|
||||||
|
|
||||||
import java.lang.Comparable;
|
import java.lang.Comparable;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import eu.siacs.conversations.xml.Element;
|
import eu.siacs.conversations.xml.Element;
|
||||||
|
|
||||||
|
@ -32,21 +33,24 @@ public class Presence implements Comparable {
|
||||||
this.hash = hash;
|
this.hash = hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Presence parse(Element show, Element caps) {
|
public static Presence parse(String show, Element caps) {
|
||||||
final String hash = caps == null ? null : caps.getAttribute("hash");
|
final String hash = caps == null ? null : caps.getAttribute("hash");
|
||||||
final String ver = caps == null ? null : caps.getAttribute("ver");
|
final String ver = caps == null ? null : caps.getAttribute("ver");
|
||||||
if ((show == null) || (show.getContent() == null)) {
|
if (show == null) {
|
||||||
return new Presence(Status.ONLINE, ver, hash);
|
return new Presence(Status.ONLINE, ver, hash);
|
||||||
} else if (show.getContent().equals("away")) {
|
|
||||||
return new Presence(Status.AWAY, ver, hash);
|
|
||||||
} else if (show.getContent().equals("xa")) {
|
|
||||||
return new Presence(Status.XA, ver, hash);
|
|
||||||
} else if (show.getContent().equals("chat")) {
|
|
||||||
return new Presence(Status.CHAT, ver, hash);
|
|
||||||
} else if (show.getContent().equals("dnd")) {
|
|
||||||
return new Presence(Status.DND, ver, hash);
|
|
||||||
} else {
|
} else {
|
||||||
return new Presence(Status.OFFLINE, ver, hash);
|
switch (show.toLowerCase(Locale.US)) {
|
||||||
|
case "away":
|
||||||
|
return new Presence(Status.AWAY, ver, hash);
|
||||||
|
case "xa":
|
||||||
|
return new Presence(Status.XA, ver, hash);
|
||||||
|
case "dnd":
|
||||||
|
return new Presence(Status.DND, ver, hash);
|
||||||
|
case "chat":
|
||||||
|
return new Presence(Status.CHAT, ver, hash);
|
||||||
|
default:
|
||||||
|
return new Presence(Status.ONLINE, ver, hash);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,7 +186,7 @@ public class PresenceParser extends AbstractParser implements
|
||||||
}
|
}
|
||||||
int sizeBefore = contact.getPresences().size();
|
int sizeBefore = contact.getPresences().size();
|
||||||
|
|
||||||
final Element show = packet.findChild("show");
|
final String show = packet.findChildContent("show");
|
||||||
final Element caps = packet.findChild("c", "http://jabber.org/protocol/caps");
|
final Element caps = packet.findChild("c", "http://jabber.org/protocol/caps");
|
||||||
final Presence presence = Presence.parse(show, caps);
|
final Presence presence = Presence.parse(show, caps);
|
||||||
contact.updatePresence(resource, presence);
|
contact.updatePresence(resource, presence);
|
||||||
|
|
Loading…
Reference in New Issue