avoided some null pointers

This commit is contained in:
iNPUTmice 2014-11-17 20:45:00 +01:00
parent f41c3eee04
commit abbadcb58b
3 changed files with 35 additions and 24 deletions

View File

@ -20,7 +20,7 @@ public abstract class AbstractGenerator {
"http://jabber.org/protocol/disco#info", "http://jabber.org/protocol/disco#info",
"urn:xmpp:avatar:metadata+notify", "urn:xmpp:avatar:metadata+notify",
"urn:xmpp:ping"}; "urn:xmpp:ping"};
public final String IDENTITY_NAME = "Conversations 0.8.3"; public final String IDENTITY_NAME = "Conversations 0.9-alpha";
public final String IDENTITY_TYPE = "phone"; public final String IDENTITY_TYPE = "phone";
protected XmppConnectionService mXmppConnectionService; protected XmppConnectionService mXmppConnectionService;

View File

@ -1,5 +1,8 @@
package eu.siacs.conversations.parser; package eu.siacs.conversations.parser;
import android.util.Log;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.services.XmppConnectionService;
@ -73,12 +76,15 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
Element query = packet.findChild("query"); Element query = packet.findChild("query");
this.rosterItems(account, query); this.rosterItems(account, query);
} }
} else {
if (packet.getFrom() == null) {
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": received iq with invalid from "+packet.toString());
return;
} else if (packet.hasChild("open", "http://jabber.org/protocol/ibb") } else if (packet.hasChild("open", "http://jabber.org/protocol/ibb")
|| packet.hasChild("data", "http://jabber.org/protocol/ibb")) { || packet.hasChild("data", "http://jabber.org/protocol/ibb")) {
mXmppConnectionService.getJingleConnectionManager() mXmppConnectionService.getJingleConnectionManager()
.deliverIbbPacket(account, packet); .deliverIbbPacket(account, packet);
} else if (packet.hasChild("query", } else if (packet.hasChild("query", "http://jabber.org/protocol/disco#info")) {
"http://jabber.org/protocol/disco#info")) {
IqPacket response = mXmppConnectionService.getIqGenerator() IqPacket response = mXmppConnectionService.getIqGenerator()
.discoResponse(packet); .discoResponse(packet);
account.getXmppConnection().sendIqPacket(response, null); account.getXmppConnection().sendIqPacket(response, null);
@ -97,5 +103,6 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
} }
} }
} }
}
} }

View File

@ -36,12 +36,16 @@ public class AbstractStanza extends Element {
} }
public void setTo(final Jid to) { public void setTo(final Jid to) {
if (to != null) {
setAttribute("to", to.toString()); setAttribute("to", to.toString());
} }
}
public void setFrom(final Jid from) { public void setFrom(final Jid from) {
if (from != null) {
setAttribute("from", from.toString()); setAttribute("from", from.toString());
} }
}
public void setId(final String id) { public void setId(final String id) {
setAttribute("id", id); setAttribute("id", id);