migrated more jid parsing to use getAttributeAsJid. added error logging
This commit is contained in:
parent
25d8546ae8
commit
e084266595
|
@ -60,16 +60,7 @@ public class Bookmark extends Element implements ListItem {
|
|||
|
||||
@Override
|
||||
public Jid getJid() {
|
||||
final String jid = this.getAttribute("jid");
|
||||
if (jid != null) {
|
||||
try {
|
||||
return Jid.fromString(jid);
|
||||
} catch (final InvalidJidException e) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return this.getAttributeAsJid("jid");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -53,12 +53,7 @@ public abstract class AbstractParser {
|
|||
|
||||
protected void updateLastseen(final Element packet, final Account account,
|
||||
final boolean presenceOverwrite) {
|
||||
Jid from;
|
||||
try {
|
||||
from = Jid.fromString(packet.getAttribute("from")).toBareJid();
|
||||
} catch (final InvalidJidException e) {
|
||||
return;
|
||||
}
|
||||
Jid from = packet.getAttributeAsJid("from");
|
||||
String presence = from == null || from.isBareJid() ? "" : from.getResourcepart();
|
||||
Contact contact = account.getRoster().getContact(from);
|
||||
long timestamp = getTimestamp(packet);
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package eu.siacs.conversations.xml;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
|
||||
import eu.siacs.conversations.Config;
|
||||
import eu.siacs.conversations.utils.XmlHelper;
|
||||
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
|
||||
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||
|
@ -111,6 +114,7 @@ public class Element {
|
|||
try {
|
||||
return Jid.fromString(jid);
|
||||
} catch (final InvalidJidException e) {
|
||||
Log.e(Config.LOGTAG, "could not parse jid " + jid);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package eu.siacs.conversations.xmpp.stanzas;
|
||||
|
||||
import eu.siacs.conversations.xml.Element;
|
||||
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
|
||||
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||
|
||||
public class AbstractStanza extends Element {
|
||||
|
@ -11,24 +10,11 @@ public class AbstractStanza extends Element {
|
|||
}
|
||||
|
||||
public Jid getTo() {
|
||||
try {
|
||||
return Jid.fromString(getAttribute("to"));
|
||||
} catch (final InvalidJidException e) {
|
||||
return null;
|
||||
}
|
||||
return getAttributeAsJid("to");
|
||||
}
|
||||
|
||||
public Jid getFrom() {
|
||||
String from = getAttribute("from");
|
||||
if (from == null) {
|
||||
return null;
|
||||
} else {
|
||||
try {
|
||||
return Jid.fromString(from);
|
||||
} catch (final InvalidJidException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return getAttributeAsJid("from");
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
|
Loading…
Reference in a new issue