From d3b20544c96b19a3710519ab343a825f488c6e39 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 1 May 2018 17:35:29 +0200 Subject: [PATCH] do not invoke onPushFailed() on timeout --- .../crypto/axolotl/AxolotlService.java | 14 ++++++++++---- .../services/XmppConnectionService.java | 6 +++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java index 6e3d1756c..d92bf736a 100644 --- a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java +++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java @@ -574,8 +574,9 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded { mXmppConnectionService.sendIqPacket(account, publish, new OnIqPacketReceived() { @Override public void onIqPacketReceived(Account account, IqPacket packet) { - Element error = packet.getType() == IqPacket.TYPE.ERROR ? packet.findChild("error") : null; - if (firstAttempt && error != null && error.hasChild("precondition-not-met", Namespace.PUBSUB_ERROR)) { + final Element error = packet.getType() == IqPacket.TYPE.ERROR ? packet.findChild("error") : null; + final boolean preConditionNotMet = error != null && error.hasChild("precondition-not-met", Namespace.PUBSUB_ERROR); + if (firstAttempt && preConditionNotMet) { Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": precondition wasn't met for device list. pushing node configuration"); mXmppConnectionService.pushNodeConfiguration(account, AxolotlService.PEP_DEVICE_LIST, publishOptions, new XmppConnectionService.OnConfigurationPushed() { @Override @@ -595,8 +596,13 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded { mXmppConnectionService.databaseBackend.updateAccount(account); } if (packet.getType() == IqPacket.TYPE.ERROR) { - pepBroken = true; - Log.d(Config.LOGTAG, getLogprefix(account) + "Error received while publishing own device id" + packet.findChild("error")); + if (preConditionNotMet) { + Log.d(Config.LOGTAG,account.getJid().asBareJid()+": pre condition still not met on second attempt"); + } else if (error != null) { + pepBroken = true; + Log.d(Config.LOGTAG, getLogprefix(account) + "Error received while publishing own device id" + packet.findChild("error")); + } + } } } diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 92e413c42..7fab30190 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -2546,15 +2546,15 @@ public class XmppConnectionService extends Service { public void onIqPacketReceived(Account account, IqPacket packet) { if (packet.getType() == IqPacket.TYPE.RESULT && callback != null) { callback.onPushSucceeded(); - } else { - Log.d(Config.LOGTAG, packet.toString()); + } else if (packet.getType() == IqPacket.TYPE.ERROR && callback != null) { + callback.onPushFailed(); } } }); } else if (callback != null) { callback.onPushFailed(); } - } else if (callback != null) { + } else if (packet.getType() == IqPacket.TYPE.ERROR && callback != null) { callback.onPushFailed(); } }