aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-12-15 17:29:17 +0100
committeriNPUTmice <daniel@gultsch.de>2014-12-15 17:29:17 +0100
commite084266595855033d04950bf2fc1ea4ab244f1fe (patch)
tree438f7401b1e6343d47f83c84b9633eb60ef6b097 /src/main/java/eu/siacs/conversations
parent25d8546ae89da97e975e72e9eb2f0608fb38aad5 (diff)
migrated more jid parsing to use getAttributeAsJid. added error logging
Diffstat (limited to 'src/main/java/eu/siacs/conversations')
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Bookmark.java11
-rw-r--r--src/main/java/eu/siacs/conversations/parser/AbstractParser.java7
-rw-r--r--src/main/java/eu/siacs/conversations/xml/Element.java4
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/stanzas/AbstractStanza.java18
4 files changed, 8 insertions, 32 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Bookmark.java b/src/main/java/eu/siacs/conversations/entities/Bookmark.java
index 70d852fe8..209056485 100644
--- a/src/main/java/eu/siacs/conversations/entities/Bookmark.java
+++ b/src/main/java/eu/siacs/conversations/entities/Bookmark.java
@@ -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
diff --git a/src/main/java/eu/siacs/conversations/parser/AbstractParser.java b/src/main/java/eu/siacs/conversations/parser/AbstractParser.java
index c80346b7d..39cbff4f1 100644
--- a/src/main/java/eu/siacs/conversations/parser/AbstractParser.java
+++ b/src/main/java/eu/siacs/conversations/parser/AbstractParser.java
@@ -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);
diff --git a/src/main/java/eu/siacs/conversations/xml/Element.java b/src/main/java/eu/siacs/conversations/xml/Element.java
index c25b90175..9455d9e8f 100644
--- a/src/main/java/eu/siacs/conversations/xml/Element.java
+++ b/src/main/java/eu/siacs/conversations/xml/Element.java
@@ -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;
}
}
diff --git a/src/main/java/eu/siacs/conversations/xmpp/stanzas/AbstractStanza.java b/src/main/java/eu/siacs/conversations/xmpp/stanzas/AbstractStanza.java
index 9e0514729..1a49b45e3 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/stanzas/AbstractStanza.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/stanzas/AbstractStanza.java
@@ -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() {