aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/eu/siacs/conversations/parser/IqParser.java12
-rw-r--r--src/main/java/eu/siacs/conversations/xml/Element.java5
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java25
3 files changed, 23 insertions, 19 deletions
diff --git a/src/main/java/eu/siacs/conversations/parser/IqParser.java b/src/main/java/eu/siacs/conversations/parser/IqParser.java
index e74cb65c..4488eed8 100644
--- a/src/main/java/eu/siacs/conversations/parser/IqParser.java
+++ b/src/main/java/eu/siacs/conversations/parser/IqParser.java
@@ -236,7 +236,9 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
@Override
public void onIqPacketReceived(final Account account, final IqPacket packet) {
- if (packet.hasChild("query", Xmlns.ROSTER) && packet.fromServer(account)) {
+ if (packet.getType() == IqPacket.TYPE.ERROR) {
+ return;
+ } else 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) {
@@ -306,15 +308,13 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
final IqPacket response = packet.generateResponse(IqPacket.TYPE.RESULT);
mXmppConnectionService.sendIqPacket(account, response, null);
} else {
- if ((packet.getType() == IqPacket.TYPE.GET)
- || (packet.getType() == IqPacket.TYPE.SET)) {
+ if (packet.getType() == IqPacket.TYPE.GET || packet.getType() == IqPacket.TYPE.SET) {
final IqPacket response = packet.generateResponse(IqPacket.TYPE.ERROR);
final Element error = response.addChild("error");
error.setAttribute("type", "cancel");
- error.addChild("feature-not-implemented",
- "urn:ietf:params:xml:ns:xmpp-stanzas");
+ error.addChild("feature-not-implemented","urn:ietf:params:xml:ns:xmpp-stanzas");
account.getXmppConnection().sendIqPacket(response, null);
- }
+ }
}
}
diff --git a/src/main/java/eu/siacs/conversations/xml/Element.java b/src/main/java/eu/siacs/conversations/xml/Element.java
index dc5a68f6..7b4937b2 100644
--- a/src/main/java/eu/siacs/conversations/xml/Element.java
+++ b/src/main/java/eu/siacs/conversations/xml/Element.java
@@ -69,10 +69,9 @@ public class Element {
public Element findChild(String name, String xmlns) {
for (Element child : this.children) {
- if (child.getName().equals(name)
- && (child.getAttribute("xmlns").equals(xmlns))) {
+ if (name.equals(child.getName()) && xmlns.equals(child.getAttribute("xmlns"))) {
return child;
- }
+ }
}
return null;
}
diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
index 17b3c3ff..e75cbb95 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -1,13 +1,10 @@
package eu.siacs.conversations.xmpp;
-import android.content.Context;
-import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Parcelable;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.os.SystemClock;
-import android.preference.PreferenceManager;
import android.util.Log;
import android.util.Pair;
import android.util.SparseArray;
@@ -37,7 +34,6 @@ import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
import java.util.Map.Entry;
import javax.net.ssl.HostnameVerifier;
@@ -103,7 +99,7 @@ public class XmppConnection implements Runnable {
private long lastConnect = 0;
private long lastSessionStarted = 0;
private int attempt = 0;
- private final Map<String, Pair<IqPacket, OnIqPacketReceived>> packetCallbacks = new Hashtable<>();
+ private final Hashtable<String, Pair<IqPacket, OnIqPacketReceived>> packetCallbacks = new Hashtable<>();
private OnPresencePacketReceived presenceListener = null;
private OnJinglePacketReceived jingleListener = null;
private OnIqPacketReceived unregisteredIqListener = null;
@@ -727,9 +723,11 @@ public class XmppConnection implements Runnable {
sendPostBindInitialization();
}
} else {
+ Log.d(Config.LOGTAG,account.getJid()+": disconnecting because of bind failure");
disconnect(true);
}
} else {
+ Log.d(Config.LOGTAG,account.getJid()+": disconnecting because of bind failure");
disconnect(true);
}
}
@@ -737,15 +735,19 @@ public class XmppConnection implements Runnable {
}
private void clearIqCallbacks() {
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": clearing iq iq callbacks");
+ Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": clearing "+this.packetCallbacks.size()+" iq callbacks");
final IqPacket failurePacket = new IqPacket(IqPacket.TYPE.ERROR);
+ final ArrayList<OnIqPacketReceived> callbacks = new ArrayList<>();
synchronized (this.packetCallbacks) {
- Iterator<Entry<String, Pair<IqPacket, OnIqPacketReceived>>> iterator = this.packetCallbacks.entrySet().iterator();
+ final Iterator<Pair<IqPacket, OnIqPacketReceived>> iterator = this.packetCallbacks.values().iterator();
while (iterator.hasNext()) {
- Entry<String, Pair<IqPacket, OnIqPacketReceived>> entry = iterator.next();
- entry.getValue().second.onIqPacketReceived(account, failurePacket);
- iterator.remove();
+ Pair<IqPacket, OnIqPacketReceived> entry = iterator.next();
+ callbacks.add(entry.second);
}
+ this.packetCallbacks.clear();
+ }
+ for(OnIqPacketReceived callback : callbacks) {
+ callback.onIqPacketReceived(account,failurePacket);
}
}
@@ -758,6 +760,7 @@ public class XmppConnection implements Runnable {
if (packet.getType() == IqPacket.TYPE.RESULT) {
sendPostBindInitialization();
} else {
+ Log.d(Config.LOGTAG,account.getJid().toBareJid()+": could not init sessions");
disconnect(true);
}
}
@@ -887,6 +890,8 @@ public class XmppConnection implements Runnable {
Log.d(Config.LOGTAG,
account.getJid().toBareJid() + ": switching resource due to conflict ("
+ account.getResource() + ")");
+ } else if (streamError != null) {
+ Log.d(Config.LOGTAG,account.getJid().toBareJid()+": stream error "+streamError.toString());
}
}