mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 17:49:38 +02:00
Improve progress listener
This commit is contained in:
parent
a92e0c876e
commit
50704c45f1
9 changed files with 85 additions and 48 deletions
|
@ -480,6 +480,10 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
|
|||
session.onContentCancel(this);
|
||||
}
|
||||
|
||||
public void handleContentTerminate(JingleReasonElement.Reason reason) {
|
||||
description.handleContentTerminate(reason);
|
||||
}
|
||||
|
||||
private void replaceTransport(Set<String> blacklist, XMPPConnection connection)
|
||||
throws SmackException.NotConnectedException, InterruptedException,
|
||||
XMPPException.XMPPErrorException, SmackException.NoResponseException {
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
|||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionElement;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionInfoElement;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleElement;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleReasonElement;
|
||||
|
||||
/**
|
||||
* Class that represents a contents description component.
|
||||
|
@ -45,4 +46,6 @@ public abstract class JingleDescription<D extends JingleContentDescriptionElemen
|
|||
public abstract void onBytestreamReady(BytestreamSession bytestreamSession);
|
||||
|
||||
public abstract String getNamespace();
|
||||
|
||||
public abstract void handleContentTerminate(JingleReasonElement.Reason reason);
|
||||
}
|
||||
|
|
|
@ -145,6 +145,10 @@ public class JingleSession {
|
|||
return JingleElement.createSessionAccept(getInitiator(), getResponder(), getSessionId(), contentElements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle local content finished event. This includes terminating the session.
|
||||
* @param jingleContent content which finished.
|
||||
*/
|
||||
void onContentFinished(JingleContent jingleContent) {
|
||||
if (contents.get(jingleContent.getName()) == null) {
|
||||
LOGGER.log(Level.WARNING, "Session does not contain content " + jingleContent.getName() + ". Ignore contentFinished.");
|
||||
|
@ -169,6 +173,11 @@ public class JingleSession {
|
|||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle local content cancel event. This happens when the local user cancels a content.
|
||||
* If there is only one content in the session, terminate the session, otherwise just cancel the one content.
|
||||
* @param jingleContent content that gets cancelled.
|
||||
*/
|
||||
void onContentCancel(JingleContent jingleContent) {
|
||||
if (contents.get(jingleContent.getName()) == null) {
|
||||
LOGGER.log(Level.WARNING, "Session does not contain content " + jingleContent.getName() + ". Ignore onContentCancel.");
|
||||
|
@ -188,6 +197,10 @@ public class JingleSession {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a session terminate and remove the session from the list of active sessions.
|
||||
* @param reason reason of termination.
|
||||
*/
|
||||
public void terminateSession(JingleReasonElement.Reason reason) {
|
||||
try {
|
||||
jingleManager.getConnection().createStanzaCollectorAndSend(JingleElement.createSessionTerminate(getPeer(), getSessionId(), reason));
|
||||
|
@ -285,7 +298,12 @@ public class JingleSession {
|
|||
throw new AssertionError("Reason MUST not be null! (I guess)...");
|
||||
}
|
||||
|
||||
//TODO: Inform client.
|
||||
JingleReasonElement.Reason r = reason.asEnum();
|
||||
|
||||
for (JingleContent content : contents.values()) {
|
||||
content.handleContentTerminate(r);
|
||||
}
|
||||
|
||||
jingleManager.removeSession(this);
|
||||
|
||||
return IQ.createResultIQ(request);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue