aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-11-20 18:42:47 +0100
committeriNPUTmice <daniel@gultsch.de>2014-11-20 18:42:47 +0100
commita2072408818602353cc6e76fa673fc1b1a6860d3 (patch)
tree32e9426a9187c2f45c9fae6f19362c02c8aa61a9 /src
parenta142dcc2634ea664057e6a4a4a87cf648c2c435f (diff)
fixed potential NPEs
Diffstat (limited to 'src')
-rw-r--r--src/main/java/eu/siacs/conversations/parser/MessageParser.java82
1 files changed, 43 insertions, 39 deletions
diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java
index b7aef931..ce2103dc 100644
--- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java
+++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java
@@ -344,50 +344,54 @@ public class MessageParser extends AbstractParser implements
private void parseEvent(final Element event, final Jid from, final Account account) {
Element items = event.findChild("items");
+ if (items == null) {
+ return;
+ }
String node = items.getAttribute("node");
- if (node != null) {
- if (node.equals("urn:xmpp:avatar:metadata")) {
- Avatar avatar = Avatar.parseMetadata(items);
- if (avatar != null) {
- avatar.owner = from;
- if (mXmppConnectionService.getFileBackend().isAvatarCached(
- avatar)) {
- if (account.getJid().toBareJid().equals(from)) {
- if (account.setAvatar(avatar.getFilename())) {
- mXmppConnectionService.databaseBackend
- .updateAccount(account);
- }
- mXmppConnectionService.getAvatarService().clear(
- account);
- mXmppConnectionService.updateConversationUi();
- mXmppConnectionService.updateAccountUi();
- } else {
- Contact contact = account.getRoster().getContact(
- from);
- contact.setAvatar(avatar.getFilename());
- mXmppConnectionService.getAvatarService().clear(
- contact);
- mXmppConnectionService.updateConversationUi();
- mXmppConnectionService.updateRosterUi();
+ if (node == null) {
+ return;
+ }
+ if (node.equals("urn:xmpp:avatar:metadata")) {
+ Avatar avatar = Avatar.parseMetadata(items);
+ if (avatar != null) {
+ avatar.owner = from;
+ if (mXmppConnectionService.getFileBackend().isAvatarCached(
+ avatar)) {
+ if (account.getJid().toBareJid().equals(from)) {
+ if (account.setAvatar(avatar.getFilename())) {
+ mXmppConnectionService.databaseBackend
+ .updateAccount(account);
}
+ mXmppConnectionService.getAvatarService().clear(
+ account);
+ mXmppConnectionService.updateConversationUi();
+ mXmppConnectionService.updateAccountUi();
} else {
- mXmppConnectionService.fetchAvatar(account, avatar);
+ Contact contact = account.getRoster().getContact(
+ from);
+ contact.setAvatar(avatar.getFilename());
+ mXmppConnectionService.getAvatarService().clear(
+ contact);
+ mXmppConnectionService.updateConversationUi();
+ mXmppConnectionService.updateRosterUi();
}
+ } else {
+ mXmppConnectionService.fetchAvatar(account, avatar);
}
- } else if (node.equals("http://jabber.org/protocol/nick")) {
- Element item = items.findChild("item");
- if (item != null) {
- Element nick = item.findChild("nick",
- "http://jabber.org/protocol/nick");
- if (nick != null) {
- if (from != null) {
- Contact contact = account.getRoster().getContact(
- from);
- contact.setPresenceName(nick.getContent());
- mXmppConnectionService.getAvatarService().clear(account);
- mXmppConnectionService.updateConversationUi();
- mXmppConnectionService.updateAccountUi();
- }
+ }
+ } else if (node.equals("http://jabber.org/protocol/nick")) {
+ Element item = items.findChild("item");
+ if (item != null) {
+ Element nick = item.findChild("nick",
+ "http://jabber.org/protocol/nick");
+ if (nick != null) {
+ if (from != null) {
+ Contact contact = account.getRoster().getContact(
+ from);
+ contact.setPresenceName(nick.getContent());
+ mXmppConnectionService.getAvatarService().clear(account);
+ mXmppConnectionService.updateConversationUi();
+ mXmppConnectionService.updateAccountUi();
}
}
}