include more human readable text in application errors

This commit is contained in:
Daniel Gultsch 2020-04-10 19:22:29 +02:00
parent 07e671d7c3
commit 7b382d2ba5
2 changed files with 13 additions and 12 deletions

View file

@ -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");
}
}

View file

@ -30,6 +30,12 @@ import rocks.xmpp.addr.Jid;
public class JingleRtpConnection extends AbstractJingleConnection implements WebRTCWrapper.EventCallback {
public static final List<State> STATES_SHOWING_ONGOING_CALL = Arrays.asList(
State.PROCEED,
State.SESSION_INITIALIZED,
State.SESSION_INITIALIZED_PRE_APPROVED,
State.SESSION_ACCEPTED
);
private static final Map<State, Collection<State>> VALID_TRANSITIONS;
static {
@ -74,13 +80,6 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
VALID_TRANSITIONS = transitionBuilder.build();
}
public static final List<State> 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<IceCandidate> 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");