more npe checks in muc packet parser

This commit is contained in:
iNPUTmice 2014-11-13 14:27:10 +01:00
parent 61f046a675
commit 77ba68d61f

View file

@ -151,39 +151,42 @@ public class MucOptions {
String type = packet.getAttribute("type"); String type = packet.getAttribute("type");
if (type == null) { if (type == null) {
User user = new User(); User user = new User();
Element item = packet.findChild("x", Element x = packet.findChild("x","http://jabber.org/protocol/muc#user");
"http://jabber.org/protocol/muc#user") if (x != null) {
.findChild("item"); Element item = x.findChild("item");
user.setName(name); if (item != null) {
user.setAffiliation(item.getAttribute("affiliation")); user.setName(name);
user.setRole(item.getAttribute("role")); user.setAffiliation(item.getAttribute("affiliation"));
user.setJid(item.getAttribute("jid")); user.setRole(item.getAttribute("role"));
user.setName(name); user.setJid(item.getAttribute("jid"));
if (name.equals(this.joinnick)) { user.setName(name);
this.isOnline = true; if (name.equals(this.joinnick)) {
this.error = ERROR_NO_ERROR; this.isOnline = true;
self = user; this.error = ERROR_NO_ERROR;
if (aboutToRename) { self = user;
if (renameListener != null) { if (aboutToRename) {
renameListener.onRename(true); if (renameListener != null) {
} renameListener.onRename(true);
aboutToRename = false; }
} aboutToRename = false;
} else { }
addUser(user);
}
if (pgp != null) {
Element x = packet.findChild("x", "jabber:x:signed");
if (x != null) {
Element status = packet.findChild("status");
String msg;
if (status != null) {
msg = status.getContent();
} else { } else {
msg = ""; addUser(user);
}
if (pgp != null) {
Element signed = packet.findChild("x", "jabber:x:signed");
if (signed != null) {
Element status = packet.findChild("status");
String msg;
if (status != null) {
msg = status.getContent();
} else {
msg = "";
}
user.setPgpKeyId(pgp.fetchKeyId(account, msg,
signed.getContent()));
}
} }
user.setPgpKeyId(pgp.fetchKeyId(account, msg,
x.getContent()));
} }
} }
} else if (type.equals("unavailable") && name.equals(this.joinnick)) { } else if (type.equals("unavailable") && name.equals(this.joinnick)) {
@ -366,4 +369,4 @@ public class MucOptions {
public Conversation getConversation() { public Conversation getConversation() {
return this.conversation; return this.conversation;
} }
} }