From 32d55346ccd81a6474b77d974db6b2643fd9f341 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 18 Jul 2020 16:14:05 +0200 Subject: [PATCH] ensure server triggered jingle iq-errors get routed properly --- .../java/eu/siacs/conversations/xmpp/XmppConnection.java | 4 +++- .../conversations/xmpp/jingle/stanzas/JinglePacket.java | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index 7ae1d3b3f..9929a9c81 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -710,7 +710,9 @@ public class XmppConnection implements Runnable { if (Config.BACKGROUND_STANZA_LOGGING && mXmppConnectionService.checkListeners()) { Log.d(Config.LOGTAG, "[background stanza] " + element); } - if (element instanceof IqPacket && element.hasChild("jingle", Namespace.JINGLE)) { + if (element instanceof IqPacket + && (((IqPacket) element).getType() == IqPacket.TYPE.SET) + && element.hasChild("jingle", Namespace.JINGLE)) { return JinglePacket.upgrade((IqPacket) element); } else { return element; diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/stanzas/JinglePacket.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/stanzas/JinglePacket.java index 2195ba47b..21b1d5089 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/stanzas/JinglePacket.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/stanzas/JinglePacket.java @@ -29,6 +29,7 @@ public class JinglePacket extends IqPacket { public static JinglePacket upgrade(final IqPacket iqPacket) { Preconditions.checkArgument(iqPacket.hasChild("jingle", Namespace.JINGLE)); + Preconditions.checkArgument(iqPacket.getType() == TYPE.SET); final JinglePacket jinglePacket = new JinglePacket(); jinglePacket.setAttributes(iqPacket.getAttributes()); jinglePacket.setChildren(iqPacket.getChildren()); @@ -70,11 +71,11 @@ public class JinglePacket extends IqPacket { public ReasonWrapper getReason() { final Element reasonElement = getJingleChild("reason"); if (reasonElement == null) { - return new ReasonWrapper(Reason.UNKNOWN,null); + return new ReasonWrapper(Reason.UNKNOWN, null); } String text = null; Reason reason = Reason.UNKNOWN; - for(Element child : reasonElement.getChildren()) { + for (Element child : reasonElement.getChildren()) { if ("text".equals(child.getName())) { text = child.getContent(); } else {