From 7b382d2ba5ec828a786c58a4e9bd1703a3333657 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 10 Apr 2020 19:22:29 +0200 Subject: [PATCH] include more human readable text in application errors --- .../xmpp/jingle/JingleConnectionManager.java | 8 +++++--- .../xmpp/jingle/JingleRtpConnection.java | 17 ++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java index 30bcf66a4..99f20f7f9 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java @@ -18,7 +18,6 @@ import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.entities.Transferable; import eu.siacs.conversations.services.AbstractConnectionManager; import eu.siacs.conversations.services.XmppConnectionService; -import eu.siacs.conversations.ui.util.Attachment; import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xml.Namespace; import eu.siacs.conversations.xmpp.OnIqPacketReceived; @@ -47,7 +46,11 @@ public class JingleConnectionManager extends AbstractConnectionManager { } public void deliverPacket(final Account account, final JinglePacket packet) { - //TODO check that sessionId is not null + final String sessionId = packet.getSessionId(); + if (sessionId == null) { + respondWithJingleError(account, packet, "unknown-session", "item-not-found", "cancel"); + return; + } final AbstractJingleConnection.Id id = AbstractJingleConnection.Id.of(account, packet); final AbstractJingleConnection existingJingleConnection = connections.get(id); if (existingJingleConnection != null) { @@ -78,7 +81,6 @@ public class JingleConnectionManager extends AbstractConnectionManager { } else { Log.d(Config.LOGTAG, "unable to route jingle packet: " + packet); respondWithJingleError(account, packet, "unknown-session", "item-not-found", "cancel"); - } } 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 6cc3f69a7..d03505fd8 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java @@ -30,6 +30,12 @@ import rocks.xmpp.addr.Jid; public class JingleRtpConnection extends AbstractJingleConnection implements WebRTCWrapper.EventCallback { + public static final List STATES_SHOWING_ONGOING_CALL = Arrays.asList( + State.PROCEED, + State.SESSION_INITIALIZED, + State.SESSION_INITIALIZED_PRE_APPROVED, + State.SESSION_ACCEPTED + ); private static final Map> VALID_TRANSITIONS; static { @@ -74,13 +80,6 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web VALID_TRANSITIONS = transitionBuilder.build(); } - public static final List STATES_SHOWING_ONGOING_CALL = Arrays.asList( - State.PROCEED, - State.SESSION_INITIALIZED, - State.SESSION_INITIALIZED_PRE_APPROVED, - State.SESSION_ACCEPTED - ); - private final WebRTCWrapper webRTCWrapper = new WebRTCWrapper(this); private final ArrayDeque pendingIceCandidates = new ArrayDeque<>(); private State state = State.NULL; @@ -196,7 +195,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web contentMap.requireDTLSFingerprint(); } catch (final IllegalArgumentException | IllegalStateException | NullPointerException e) { respondOk(jinglePacket); - sendSessionTerminate(Reason.FAILED_APPLICATION); + sendSessionTerminate(Reason.FAILED_APPLICATION, e.getMessage()); Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": improperly formatted contents", e); return; } @@ -238,7 +237,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web respondOk(jinglePacket); Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": improperly formatted contents in session-accept", e); webRTCWrapper.close(); - sendSessionTerminate(Reason.FAILED_APPLICATION); + sendSessionTerminate(Reason.FAILED_APPLICATION, e.getMessage()); return; } Log.d(Config.LOGTAG, "processing session-accept with " + contentMap.contents.size() + " contents");