2017-06-30 15:03:13 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Copyright 2017 Paul Schaub
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
package org.jivesoftware.smackx.jingle;
|
|
|
|
|
|
|
|
import org.jivesoftware.smack.SmackException;
|
2021-05-12 10:12:59 +02:00
|
|
|
import org.jivesoftware.smack.SmackException.NoResponseException;
|
2017-06-30 15:03:13 +02:00
|
|
|
import org.jivesoftware.smack.XMPPConnection;
|
|
|
|
import org.jivesoftware.smack.XMPPException;
|
2021-05-12 10:12:59 +02:00
|
|
|
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
2017-06-30 15:03:13 +02:00
|
|
|
import org.jivesoftware.smack.packet.IQ;
|
2018-04-07 21:25:40 +02:00
|
|
|
import org.jivesoftware.smack.packet.StanzaError;
|
2019-05-06 22:06:13 +02:00
|
|
|
|
2017-06-30 15:03:13 +02:00
|
|
|
import org.jivesoftware.smackx.jingle.element.Jingle;
|
|
|
|
import org.jivesoftware.smackx.jingle.element.JingleAction;
|
|
|
|
import org.jivesoftware.smackx.jingle.element.JingleContent;
|
|
|
|
import org.jivesoftware.smackx.jingle.element.JingleContentDescription;
|
|
|
|
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
|
|
|
import org.jivesoftware.smackx.jingle.element.JingleError;
|
|
|
|
import org.jivesoftware.smackx.jingle.element.JingleReason;
|
|
|
|
|
|
|
|
import org.jxmpp.jid.FullJid;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Util to quickly create and send jingle stanzas.
|
|
|
|
*/
|
|
|
|
public class JingleUtil {
|
|
|
|
|
|
|
|
private final XMPPConnection connection;
|
|
|
|
|
|
|
|
public JingleUtil(XMPPConnection connection) {
|
|
|
|
this.connection = connection;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Jingle createSessionInitiate(FullJid recipient,
|
|
|
|
String sessionId,
|
|
|
|
JingleContent.Creator contentCreator,
|
|
|
|
String contentName,
|
|
|
|
JingleContent.Senders contentSenders,
|
|
|
|
JingleContentDescription description,
|
|
|
|
JingleContentTransport transport) {
|
|
|
|
|
|
|
|
Jingle.Builder jb = Jingle.getBuilder();
|
|
|
|
jb.setAction(JingleAction.session_initiate)
|
|
|
|
.setSessionId(sessionId)
|
|
|
|
.setInitiator(connection.getUser());
|
|
|
|
|
|
|
|
JingleContent.Builder cb = JingleContent.getBuilder();
|
|
|
|
cb.setCreator(contentCreator)
|
|
|
|
.setName(contentName)
|
|
|
|
.setSenders(contentSenders)
|
|
|
|
.setDescription(description)
|
|
|
|
.setTransport(transport);
|
|
|
|
|
|
|
|
Jingle jingle = jb.addJingleContent(cb.build()).build();
|
|
|
|
jingle.setFrom(connection.getUser());
|
|
|
|
jingle.setTo(recipient);
|
|
|
|
|
|
|
|
return jingle;
|
|
|
|
}
|
|
|
|
|
2017-07-03 10:35:46 +02:00
|
|
|
public Jingle createSessionInitiateFileOffer(FullJid recipient,
|
|
|
|
String sessionId,
|
|
|
|
JingleContent.Creator contentCreator,
|
|
|
|
String contentName,
|
|
|
|
JingleContentDescription description,
|
|
|
|
JingleContentTransport transport) {
|
|
|
|
return createSessionInitiate(recipient, sessionId, contentCreator, contentName,
|
|
|
|
JingleContent.Senders.initiator, description, transport);
|
|
|
|
}
|
|
|
|
|
|
|
|
public IQ sendSessionInitiateFileOffer(FullJid recipient,
|
|
|
|
String sessionId,
|
|
|
|
JingleContent.Creator contentCreator,
|
|
|
|
String contentName,
|
|
|
|
JingleContentDescription description,
|
|
|
|
JingleContentTransport transport)
|
|
|
|
throws SmackException.NotConnectedException, InterruptedException,
|
|
|
|
XMPPException.XMPPErrorException, SmackException.NoResponseException {
|
|
|
|
|
|
|
|
Jingle jingle = createSessionInitiateFileOffer(recipient, sessionId, contentCreator, contentName, description, transport);
|
2021-05-11 22:03:24 +02:00
|
|
|
return connection.sendIqRequestAndWaitForResponse(jingle);
|
2017-07-03 10:35:46 +02:00
|
|
|
}
|
|
|
|
|
2017-06-30 15:03:13 +02:00
|
|
|
public IQ sendSessionInitiate(FullJid recipient,
|
|
|
|
String sessionId,
|
|
|
|
JingleContent.Creator contentCreator,
|
|
|
|
String contentName,
|
|
|
|
JingleContent.Senders contentSenders,
|
|
|
|
JingleContentDescription description,
|
|
|
|
JingleContentTransport transport)
|
2021-05-12 10:12:59 +02:00
|
|
|
throws SmackException.NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException {
|
2017-06-30 15:03:13 +02:00
|
|
|
|
|
|
|
Jingle jingle = createSessionInitiate(recipient, sessionId, contentCreator, contentName, contentSenders,
|
|
|
|
description, transport);
|
|
|
|
|
2021-05-12 10:12:59 +02:00
|
|
|
return connection.sendIqRequestAndWaitForResponse(jingle);
|
2017-06-30 15:03:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Jingle createSessionAccept(FullJid recipient,
|
|
|
|
String sessionId,
|
|
|
|
JingleContent.Creator contentCreator,
|
|
|
|
String contentName,
|
|
|
|
JingleContent.Senders contentSenders,
|
|
|
|
JingleContentDescription description,
|
|
|
|
JingleContentTransport transport) {
|
|
|
|
|
|
|
|
Jingle.Builder jb = Jingle.getBuilder();
|
|
|
|
jb.setResponder(connection.getUser())
|
|
|
|
.setAction(JingleAction.session_accept)
|
|
|
|
.setSessionId(sessionId);
|
|
|
|
|
|
|
|
JingleContent.Builder cb = JingleContent.getBuilder();
|
|
|
|
cb.setCreator(contentCreator)
|
|
|
|
.setName(contentName)
|
|
|
|
.setSenders(contentSenders)
|
|
|
|
.setDescription(description)
|
|
|
|
.setTransport(transport);
|
|
|
|
|
|
|
|
Jingle jingle = jb.addJingleContent(cb.build()).build();
|
|
|
|
jingle.setTo(recipient);
|
|
|
|
jingle.setFrom(connection.getUser());
|
|
|
|
|
|
|
|
return jingle;
|
|
|
|
}
|
|
|
|
|
|
|
|
public IQ sendSessionAccept(FullJid recipient,
|
|
|
|
String sessionId,
|
|
|
|
JingleContent.Creator contentCreator,
|
|
|
|
String contentName,
|
|
|
|
JingleContent.Senders contentSenders,
|
|
|
|
JingleContentDescription description,
|
|
|
|
JingleContentTransport transport)
|
2021-05-12 10:12:59 +02:00
|
|
|
throws SmackException.NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException {
|
2017-06-30 15:03:13 +02:00
|
|
|
|
|
|
|
Jingle jingle = createSessionAccept(recipient, sessionId, contentCreator, contentName, contentSenders,
|
|
|
|
description, transport);
|
|
|
|
|
2021-05-12 10:12:59 +02:00
|
|
|
return connection.sendIqRequestAndWaitForResponse(jingle);
|
2017-06-30 15:03:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Jingle createSessionTerminate(FullJid recipient, String sessionId, JingleReason reason) {
|
|
|
|
Jingle.Builder jb = Jingle.getBuilder();
|
|
|
|
jb.setAction(JingleAction.session_terminate)
|
|
|
|
.setSessionId(sessionId)
|
|
|
|
.setReason(reason);
|
|
|
|
|
|
|
|
Jingle jingle = jb.build();
|
|
|
|
jingle.setFrom(connection.getUser());
|
|
|
|
jingle.setTo(recipient);
|
|
|
|
|
|
|
|
return jingle;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Jingle createSessionTerminate(FullJid recipient, String sessionId, JingleReason.Reason reason) {
|
|
|
|
return createSessionTerminate(recipient, sessionId, new JingleReason(reason));
|
|
|
|
}
|
|
|
|
|
|
|
|
public Jingle createSessionTerminateDecline(FullJid recipient, String sessionId) {
|
|
|
|
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.decline);
|
|
|
|
}
|
|
|
|
|
|
|
|
public IQ sendSessionTerminateDecline(FullJid recipient, String sessionId)
|
|
|
|
throws SmackException.NotConnectedException, InterruptedException,
|
|
|
|
XMPPException.XMPPErrorException, SmackException.NoResponseException {
|
|
|
|
|
|
|
|
Jingle jingle = createSessionTerminateDecline(recipient, sessionId);
|
2021-05-11 22:03:24 +02:00
|
|
|
return connection.sendIqRequestAndWaitForResponse(jingle);
|
2017-06-30 15:03:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Jingle createSessionTerminateSuccess(FullJid recipient, String sessionId) {
|
|
|
|
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.success);
|
|
|
|
}
|
|
|
|
|
|
|
|
public IQ sendSessionTerminateSuccess(FullJid recipient, String sessionId)
|
|
|
|
throws InterruptedException, XMPPException.XMPPErrorException,
|
|
|
|
SmackException.NotConnectedException, SmackException.NoResponseException {
|
|
|
|
|
|
|
|
Jingle jingle = createSessionTerminateSuccess(recipient, sessionId);
|
2021-05-11 22:03:24 +02:00
|
|
|
return connection.sendIqRequestAndWaitForResponse(jingle);
|
2017-06-30 15:03:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Jingle createSessionTerminateBusy(FullJid recipient, String sessionId) {
|
|
|
|
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.busy);
|
|
|
|
}
|
|
|
|
|
|
|
|
public IQ sendSessionTerminateBusy(FullJid recipient, String sessionId)
|
|
|
|
throws InterruptedException, XMPPException.XMPPErrorException,
|
|
|
|
SmackException.NotConnectedException, SmackException.NoResponseException {
|
|
|
|
|
|
|
|
Jingle jingle = createSessionTerminateBusy(recipient, sessionId);
|
2021-05-11 22:03:24 +02:00
|
|
|
return connection.sendIqRequestAndWaitForResponse(jingle);
|
2017-06-30 15:03:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Jingle createSessionTerminateAlternativeSession(FullJid recipient, String sessionId, String altSessionId) {
|
|
|
|
return createSessionTerminate(recipient, sessionId, JingleReason.AlternativeSession(altSessionId));
|
|
|
|
}
|
|
|
|
|
|
|
|
public IQ sendSessionTerminateAlternativeSession(FullJid recipient, String sessionId, String altSessionId)
|
|
|
|
throws InterruptedException, XMPPException.XMPPErrorException,
|
|
|
|
SmackException.NotConnectedException, SmackException.NoResponseException {
|
|
|
|
|
|
|
|
Jingle jingle = createSessionTerminateAlternativeSession(recipient, sessionId, altSessionId);
|
2021-05-11 22:03:24 +02:00
|
|
|
return connection.sendIqRequestAndWaitForResponse(jingle);
|
2017-06-30 15:03:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Jingle createSessionTerminateCancel(FullJid recipient, String sessionId) {
|
|
|
|
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.cancel);
|
|
|
|
}
|
|
|
|
|
|
|
|
public IQ sendSessionTerminateCancel(FullJid recipient,
|
|
|
|
String sessionId)
|
|
|
|
throws InterruptedException, XMPPException.XMPPErrorException,
|
|
|
|
SmackException.NotConnectedException, SmackException.NoResponseException {
|
|
|
|
|
|
|
|
Jingle jingle = createSessionTerminateCancel(recipient, sessionId);
|
2021-05-11 22:03:24 +02:00
|
|
|
return connection.sendIqRequestAndWaitForResponse(jingle);
|
2017-06-30 15:03:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Jingle createSessionTerminateContentCancel(FullJid recipient, String sessionId,
|
|
|
|
JingleContent.Creator contentCreator, String contentName) {
|
|
|
|
Jingle.Builder jb = Jingle.getBuilder();
|
|
|
|
jb.setAction(JingleAction.session_terminate)
|
|
|
|
.setSessionId(sessionId);
|
|
|
|
|
|
|
|
JingleContent.Builder cb = JingleContent.getBuilder();
|
|
|
|
cb.setCreator(contentCreator).setName(contentName);
|
|
|
|
|
|
|
|
Jingle jingle = jb.addJingleContent(cb.build()).build();
|
|
|
|
jingle.setFrom(connection.getUser());
|
|
|
|
jingle.setTo(recipient);
|
|
|
|
|
|
|
|
return jingle;
|
|
|
|
}
|
|
|
|
|
|
|
|
public IQ sendSessionTerminateContentCancel(FullJid recipient, String sessionId,
|
|
|
|
JingleContent.Creator contentCreator, String contentName)
|
|
|
|
throws SmackException.NotConnectedException, InterruptedException,
|
|
|
|
XMPPException.XMPPErrorException, SmackException.NoResponseException {
|
|
|
|
Jingle jingle = createSessionTerminateContentCancel(recipient, sessionId, contentCreator, contentName);
|
2021-05-11 22:03:24 +02:00
|
|
|
return connection.sendIqRequestAndWaitForResponse(jingle);
|
2017-06-30 15:03:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Jingle createSessionTerminateUnsupportedTransports(FullJid recipient, String sessionId) {
|
|
|
|
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.unsupported_transports);
|
|
|
|
}
|
|
|
|
|
|
|
|
public IQ sendSessionTerminateUnsupportedTransports(FullJid recipient, String sessionId)
|
|
|
|
throws InterruptedException, XMPPException.XMPPErrorException,
|
|
|
|
SmackException.NotConnectedException, SmackException.NoResponseException {
|
|
|
|
Jingle jingle = createSessionTerminateUnsupportedTransports(recipient, sessionId);
|
2021-05-11 22:03:24 +02:00
|
|
|
return connection.sendIqRequestAndWaitForResponse(jingle);
|
2017-06-30 15:03:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Jingle createSessionTerminateFailedTransport(FullJid recipient, String sessionId) {
|
|
|
|
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.failed_transport);
|
|
|
|
}
|
|
|
|
|
|
|
|
public IQ sendSessionTerminateFailedTransport(FullJid recipient, String sessionId)
|
|
|
|
throws InterruptedException, XMPPException.XMPPErrorException,
|
|
|
|
SmackException.NotConnectedException, SmackException.NoResponseException {
|
|
|
|
Jingle jingle = createSessionTerminateFailedTransport(recipient, sessionId);
|
2021-05-11 22:03:24 +02:00
|
|
|
return connection.sendIqRequestAndWaitForResponse(jingle);
|
2017-06-30 15:03:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Jingle createSessionTerminateUnsupportedApplications(FullJid recipient, String sessionId) {
|
|
|
|
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.unsupported_applications);
|
|
|
|
}
|
|
|
|
|
|
|
|
public IQ sendSessionTerminateUnsupportedApplications(FullJid recipient, String sessionId)
|
|
|
|
throws InterruptedException, XMPPException.XMPPErrorException,
|
|
|
|
SmackException.NotConnectedException, SmackException.NoResponseException {
|
|
|
|
Jingle jingle = createSessionTerminateUnsupportedApplications(recipient, sessionId);
|
2021-05-11 22:03:24 +02:00
|
|
|
return connection.sendIqRequestAndWaitForResponse(jingle);
|
2017-06-30 15:03:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Jingle createSessionTerminateFailedApplication(FullJid recipient, String sessionId) {
|
|
|
|
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.failed_application);
|
|
|
|
}
|
|
|
|
|
|
|
|
public IQ sendSessionTerminateFailedApplication(FullJid recipient, String sessionId)
|
|
|
|
throws InterruptedException, XMPPException.XMPPErrorException,
|
|
|
|
SmackException.NotConnectedException, SmackException.NoResponseException {
|
|
|
|
Jingle jingle = createSessionTerminateFailedApplication(recipient, sessionId);
|
2021-05-11 22:03:24 +02:00
|
|
|
return connection.sendIqRequestAndWaitForResponse(jingle);
|
2017-06-30 15:03:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Jingle createSessionTerminateIncompatibleParameters(FullJid recipient, String sessionId) {
|
|
|
|
return createSessionTerminate(recipient, sessionId, JingleReason.Reason.incompatible_parameters);
|
|
|
|
}
|
|
|
|
|
|
|
|
public IQ sendSessionTerminateIncompatibleParameters(FullJid recipient, String sessionId)
|
|
|
|
throws InterruptedException, XMPPException.XMPPErrorException,
|
|
|
|
SmackException.NotConnectedException, SmackException.NoResponseException {
|
|
|
|
Jingle jingle = createSessionTerminateIncompatibleParameters(recipient, sessionId);
|
2021-05-11 22:03:24 +02:00
|
|
|
return connection.sendIqRequestAndWaitForResponse(jingle);
|
2017-06-30 15:03:13 +02:00
|
|
|
}
|
|
|
|
|
2017-07-03 10:35:46 +02:00
|
|
|
public IQ sendContentRejectFileNotAvailable(FullJid recipient, String sessionId, JingleContentDescription description) {
|
|
|
|
return null; //TODO Later
|
|
|
|
}
|
|
|
|
|
2017-06-30 15:03:13 +02:00
|
|
|
public Jingle createSessionPing(FullJid recipient, String sessionId) {
|
|
|
|
Jingle.Builder jb = Jingle.getBuilder();
|
|
|
|
jb.setSessionId(sessionId)
|
|
|
|
.setAction(JingleAction.session_info);
|
|
|
|
|
|
|
|
Jingle jingle = jb.build();
|
|
|
|
jingle.setFrom(connection.getUser());
|
|
|
|
jingle.setTo(recipient);
|
|
|
|
|
|
|
|
return jingle;
|
|
|
|
}
|
|
|
|
|
|
|
|
public IQ sendSessionPing(FullJid recipient, String sessionId)
|
|
|
|
throws SmackException.NotConnectedException, InterruptedException,
|
|
|
|
XMPPException.XMPPErrorException, SmackException.NoResponseException {
|
|
|
|
Jingle jingle = createSessionPing(recipient, sessionId);
|
2021-05-11 22:03:24 +02:00
|
|
|
return connection.sendIqRequestAndWaitForResponse(jingle);
|
2017-06-30 15:03:13 +02:00
|
|
|
}
|
|
|
|
|
2017-07-03 10:35:46 +02:00
|
|
|
public IQ createAck(Jingle jingle) {
|
|
|
|
return IQ.createResultIQ(jingle);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void sendAck(Jingle jingle) throws SmackException.NotConnectedException, InterruptedException {
|
|
|
|
connection.sendStanza(createAck(jingle));
|
|
|
|
}
|
|
|
|
|
|
|
|
public Jingle createTransportReplace(FullJid recipient, FullJid initiator, String sessionId,
|
|
|
|
JingleContent.Creator contentCreator, String contentName,
|
|
|
|
JingleContentTransport transport) {
|
|
|
|
Jingle.Builder jb = Jingle.getBuilder();
|
|
|
|
jb.setInitiator(initiator)
|
|
|
|
.setSessionId(sessionId)
|
|
|
|
.setAction(JingleAction.transport_replace);
|
|
|
|
|
|
|
|
JingleContent.Builder cb = JingleContent.getBuilder();
|
|
|
|
cb.setName(contentName).setCreator(contentCreator).setTransport(transport);
|
|
|
|
Jingle jingle = jb.addJingleContent(cb.build()).build();
|
|
|
|
|
|
|
|
jingle.setTo(recipient);
|
|
|
|
jingle.setFrom(connection.getUser());
|
|
|
|
|
|
|
|
return jingle;
|
|
|
|
}
|
|
|
|
|
|
|
|
public IQ sendTransportReplace(FullJid recipient, FullJid initiator, String sessionId,
|
|
|
|
JingleContent.Creator contentCreator, String contentName,
|
|
|
|
JingleContentTransport transport)
|
|
|
|
throws SmackException.NotConnectedException, InterruptedException,
|
|
|
|
XMPPException.XMPPErrorException, SmackException.NoResponseException {
|
|
|
|
Jingle jingle = createTransportReplace(recipient, initiator, sessionId, contentCreator, contentName, transport);
|
2021-05-11 22:03:24 +02:00
|
|
|
return connection.sendIqRequestAndWaitForResponse(jingle);
|
2017-07-03 10:35:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Jingle createTransportAccept(FullJid recipient, FullJid initiator, String sessionId,
|
|
|
|
JingleContent.Creator contentCreator, String contentName,
|
|
|
|
JingleContentTransport transport) {
|
|
|
|
Jingle.Builder jb = Jingle.getBuilder();
|
|
|
|
jb.setAction(JingleAction.transport_accept)
|
|
|
|
.setInitiator(initiator)
|
|
|
|
.setSessionId(sessionId);
|
|
|
|
|
|
|
|
JingleContent.Builder cb = JingleContent.getBuilder();
|
|
|
|
cb.setCreator(contentCreator).setName(contentName).setTransport(transport);
|
|
|
|
|
|
|
|
Jingle jingle = jb.addJingleContent(cb.build()).build();
|
|
|
|
jingle.setTo(recipient);
|
|
|
|
jingle.setFrom(connection.getUser());
|
|
|
|
|
|
|
|
return jingle;
|
|
|
|
}
|
|
|
|
|
|
|
|
public IQ sendTransportAccept(FullJid recipient, FullJid initiator, String sessionId,
|
|
|
|
JingleContent.Creator contentCreator, String contentName,
|
|
|
|
JingleContentTransport transport)
|
|
|
|
throws SmackException.NotConnectedException, InterruptedException,
|
|
|
|
XMPPException.XMPPErrorException, SmackException.NoResponseException {
|
|
|
|
Jingle jingle = createTransportAccept(recipient, initiator, sessionId, contentCreator, contentName, transport);
|
2021-05-11 22:03:24 +02:00
|
|
|
return connection.sendIqRequestAndWaitForResponse(jingle);
|
2017-07-03 10:35:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Jingle createTransportReject(FullJid recipient, FullJid initiator, String sessionId,
|
|
|
|
JingleContent.Creator contentCreator, String contentName,
|
|
|
|
JingleContentTransport transport) {
|
|
|
|
Jingle.Builder jb = Jingle.getBuilder();
|
|
|
|
jb.setAction(JingleAction.transport_reject)
|
|
|
|
.setInitiator(initiator)
|
|
|
|
.setSessionId(sessionId);
|
|
|
|
|
|
|
|
JingleContent.Builder cb = JingleContent.getBuilder();
|
|
|
|
cb.setCreator(contentCreator).setName(contentName).setTransport(transport);
|
|
|
|
|
|
|
|
Jingle jingle = jb.addJingleContent(cb.build()).build();
|
|
|
|
jingle.setTo(recipient);
|
|
|
|
jingle.setFrom(connection.getUser());
|
|
|
|
|
|
|
|
return jingle;
|
|
|
|
}
|
|
|
|
|
|
|
|
public IQ sendTransportReject(FullJid recipient, FullJid initiator, String sessionId,
|
|
|
|
JingleContent.Creator contentCreator, String contentName,
|
|
|
|
JingleContentTransport transport)
|
|
|
|
throws SmackException.NotConnectedException, InterruptedException,
|
|
|
|
XMPPException.XMPPErrorException, SmackException.NoResponseException {
|
|
|
|
Jingle jingle = createTransportReject(recipient, initiator, sessionId, contentCreator, contentName, transport);
|
2021-05-11 22:03:24 +02:00
|
|
|
return connection.sendIqRequestAndWaitForResponse(jingle);
|
2017-07-03 10:35:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ####################################################################################################
|
|
|
|
*/
|
|
|
|
|
2017-06-30 15:03:13 +02:00
|
|
|
public IQ createErrorUnknownSession(Jingle request) {
|
2019-10-24 15:45:08 +02:00
|
|
|
StanzaError error = StanzaError.getBuilder()
|
|
|
|
.setCondition(StanzaError.Condition.item_not_found)
|
|
|
|
.addExtension(JingleError.UNKNOWN_SESSION)
|
|
|
|
.build();
|
2017-06-30 15:03:13 +02:00
|
|
|
return IQ.createErrorResponse(request, error);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void sendErrorUnknownSession(Jingle request)
|
|
|
|
throws SmackException.NotConnectedException, InterruptedException {
|
|
|
|
connection.sendStanza(createErrorUnknownSession(request));
|
|
|
|
}
|
|
|
|
|
|
|
|
public IQ createErrorUnknownInitiator(Jingle request) {
|
2018-04-07 21:25:40 +02:00
|
|
|
return IQ.createErrorResponse(request, StanzaError.Condition.service_unavailable);
|
2017-06-30 15:03:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void sendErrorUnknownInitiator(Jingle request)
|
|
|
|
throws SmackException.NotConnectedException, InterruptedException {
|
|
|
|
connection.sendStanza(createErrorUnknownInitiator(request));
|
|
|
|
}
|
|
|
|
|
|
|
|
public IQ createErrorUnsupportedInfo(Jingle request) {
|
2019-10-24 15:45:08 +02:00
|
|
|
StanzaError error = StanzaError.getBuilder()
|
|
|
|
.setCondition(StanzaError.Condition.feature_not_implemented)
|
|
|
|
.addExtension(JingleError.UNSUPPORTED_INFO)
|
|
|
|
.build();
|
2017-06-30 15:03:13 +02:00
|
|
|
return IQ.createErrorResponse(request, error);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void sendErrorUnsupportedInfo(Jingle request)
|
|
|
|
throws SmackException.NotConnectedException, InterruptedException {
|
|
|
|
connection.sendStanza(createErrorUnsupportedInfo(request));
|
|
|
|
}
|
|
|
|
|
|
|
|
public IQ createErrorTieBreak(Jingle request) {
|
2019-10-24 15:45:08 +02:00
|
|
|
StanzaError error = StanzaError.getBuilder()
|
|
|
|
.setCondition(StanzaError.Condition.conflict)
|
|
|
|
.addExtension(JingleError.TIE_BREAK)
|
|
|
|
.build();
|
2017-06-30 15:03:13 +02:00
|
|
|
return IQ.createErrorResponse(request, error);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void sendErrorTieBreak(Jingle request)
|
|
|
|
throws SmackException.NotConnectedException, InterruptedException {
|
|
|
|
connection.sendStanza(createErrorTieBreak(request));
|
|
|
|
}
|
|
|
|
|
|
|
|
public IQ createErrorOutOfOrder(Jingle request) {
|
2019-10-24 15:45:08 +02:00
|
|
|
StanzaError error = StanzaError.getBuilder()
|
|
|
|
.setCondition(StanzaError.Condition.unexpected_request)
|
|
|
|
.addExtension(JingleError.OUT_OF_ORDER)
|
|
|
|
.build();
|
2017-06-30 15:03:13 +02:00
|
|
|
return IQ.createErrorResponse(request, error);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void sendErrorOutOfOrder(Jingle request)
|
|
|
|
throws SmackException.NotConnectedException, InterruptedException {
|
|
|
|
connection.sendStanza(createErrorOutOfOrder(request));
|
|
|
|
}
|
2017-07-03 10:35:46 +02:00
|
|
|
|
|
|
|
public IQ createErrorMalformedRequest(Jingle request) {
|
2018-04-07 21:25:40 +02:00
|
|
|
return IQ.createErrorResponse(request, StanzaError.Condition.bad_request);
|
2017-07-03 10:35:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void sendErrorMalformedRequest(Jingle request)
|
|
|
|
throws SmackException.NotConnectedException, InterruptedException {
|
|
|
|
connection.sendStanza(createErrorMalformedRequest(request));
|
|
|
|
}
|
2017-06-30 15:03:13 +02:00
|
|
|
}
|