aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/parser
diff options
context:
space:
mode:
authorSam Whited <sam@samwhited.com>2014-12-30 08:50:51 -0500
committerSam Whited <sam@samwhited.com>2015-01-04 08:28:13 -0500
commit88704ce5cd68047008375c2eba6751e2e3cdd8c0 (patch)
treea5f653ca019d55fde10773ce00c5d82f2747cd4b /src/main/java/eu/siacs/conversations/parser
parenteb7e683403e9335165341ed65cf949cb60319ebc (diff)
Verify IQ responses
Fixes #20 Move fromServer/toServer to AbstractStanza
Diffstat (limited to 'src/main/java/eu/siacs/conversations/parser')
-rw-r--r--src/main/java/eu/siacs/conversations/parser/IqParser.java13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/main/java/eu/siacs/conversations/parser/IqParser.java b/src/main/java/eu/siacs/conversations/parser/IqParser.java
index 70a6e3f7..3b501f33 100644
--- a/src/main/java/eu/siacs/conversations/parser/IqParser.java
+++ b/src/main/java/eu/siacs/conversations/parser/IqParser.java
@@ -71,16 +71,9 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
return super.avatarData(items);
}
- public static boolean fromServer(final Account account, final IqPacket packet) {
- return packet.getFrom() == null
- || packet.getFrom().equals(account.getServer())
- || packet.getFrom().equals(account.getJid().toBareJid())
- || packet.getFrom().equals(account.getJid());
- }
-
@Override
public void onIqPacketReceived(final Account account, final IqPacket packet) {
- if (packet.hasChild("query", Xmlns.ROSTER) && fromServer(account, packet)) {
+ if (packet.hasChild("query", Xmlns.ROSTER) && packet.fromServer(account)) {
final Element query = packet.findChild("query");
// If this is in response to a query for the whole roster:
if (packet.getType() == IqPacket.TYPE.RESULT) {
@@ -88,7 +81,7 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
}
this.rosterItems(account, query);
} else if ((packet.hasChild("block", Xmlns.BLOCKING) || packet.hasChild("blocklist", Xmlns.BLOCKING)) &&
- fromServer(account, packet)) {
+ packet.fromServer(account)) {
// Block list or block push.
Log.d(Config.LOGTAG, "Received blocklist update from server");
final Element blocklist = packet.findChild("blocklist", Xmlns.BLOCKING);
@@ -116,7 +109,7 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
// Update the UI
mXmppConnectionService.updateBlocklistUi(OnUpdateBlocklist.Status.BLOCKED);
} else if (packet.hasChild("unblock", Xmlns.BLOCKING) &&
- fromServer(account, packet) && packet.getType() == IqPacket.TYPE.SET) {
+ packet.fromServer(account) && packet.getType() == IqPacket.TYPE.SET) {
Log.d(Config.LOGTAG, "Received unblock update from server");
final Collection<Element> items = packet.findChild("unblock", Xmlns.BLOCKING).getChildren();
if (items.size() == 0) {