From 39e3791345eed83f1c381a71ab53c47722ee0ea3 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 9 Apr 2020 20:35:44 +0200 Subject: [PATCH] incude human readable text in some session-terminates --- .../xmpp/jingle/JingleFileTransferConnection.java | 2 +- .../xmpp/jingle/JingleRtpConnection.java | 13 ++++++++----- .../xmpp/jingle/stanzas/JinglePacket.java | 9 +++++++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleFileTransferConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleFileTransferConnection.java index e309e4289..dab5b8381 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleFileTransferConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleFileTransferConnection.java @@ -1064,7 +1064,7 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple private void sendSessionTerminate(Reason reason) { final JinglePacket packet = bootstrapPacket(JinglePacket.Action.SESSION_TERMINATE); - packet.setReason(reason); + packet.setReason(reason, null); this.sendJinglePacket(packet); } diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java index e023d6b4e..7c1c6c8c5 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java @@ -246,10 +246,10 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web final SessionDescription sessionDescription; try { sessionDescription = SessionDescription.of(contentMap); - } catch (IllegalArgumentException e) { + } catch (final IllegalArgumentException e) { Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": unable convert offer from session-accept to SDP", e); webRTCWrapper.close(); - sendSessionTerminate(Reason.FAILED_APPLICATION); + sendSessionTerminate(Reason.FAILED_APPLICATION, e.getMessage()); return; } org.webrtc.SessionDescription answer = new org.webrtc.SessionDescription( @@ -276,8 +276,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web } catch (final IllegalArgumentException e) { Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": unable convert offer from session-initiate to SDP", e); webRTCWrapper.close(); - sendSessionTerminate(Reason.FAILED_APPLICATION); - ; + sendSessionTerminate(Reason.FAILED_APPLICATION, e.getMessage()); return; } sendSessionAccept(offer); @@ -470,10 +469,14 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web } private void sendSessionTerminate(final Reason reason) { + sendSessionTerminate(reason, null); + } + + private void sendSessionTerminate(final Reason reason, final String text) { final State target = reasonToState(reason); transitionOrThrow(target); final JinglePacket jinglePacket = new JinglePacket(JinglePacket.Action.SESSION_TERMINATE, id.sessionId); - jinglePacket.setReason(reason); + jinglePacket.setReason(reason, text); send(jinglePacket); Log.d(Config.LOGTAG, jinglePacket.toString()); jingleConnectionManager.finishConnection(this); 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 90867ed25..ef769be8e 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 @@ -4,6 +4,7 @@ import android.support.annotation.NonNull; import com.google.common.base.CaseFormat; import com.google.common.base.Preconditions; +import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; import java.util.Map; @@ -81,9 +82,13 @@ public class JinglePacket extends IqPacket { return Reason.UNKNOWN; } - public void setReason(final Reason reason) { + public void setReason(final Reason reason, final String text) { final Element jingle = findChild("jingle", Namespace.JINGLE); - jingle.addChild("reason").addChild(reason.toString()); + final Element reasonElement = jingle.addChild("reason"); + reasonElement.addChild(reason.toString()); + if (!Strings.isNullOrEmpty(text)) { + reasonElement.addChild("text").setContent(text); + } } //RECOMMENDED for session-initiate, NOT RECOMMENDED otherwise