mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-23 20:42:06 +01:00
Fix ugly code
This commit is contained in:
parent
d088233153
commit
d1bc94bfaf
23 changed files with 122 additions and 158 deletions
|
@ -168,7 +168,7 @@ public final class JingleFileTransferManager extends Manager implements JingleDe
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notifyIncomingFileOfferListeners(JingleIncomingFileOffer offer) {
|
public void notifyIncomingFileOfferListeners(JingleIncomingFileOffer offer) {
|
||||||
LOGGER.log(Level.INFO, "Incoming File transfer: [" + offer.getNamespace() + ", "
|
LOGGER.log(Level.FINE, "Incoming File transfer: [" + offer.getNamespace() + ", "
|
||||||
+ offer.getParent().getTransport().getNamespace() + ", "
|
+ offer.getParent().getTransport().getNamespace() + ", "
|
||||||
+ (offer.getParent().getSecurity() != null ? offer.getParent().getSecurity().getNamespace() : "") + "]");
|
+ (offer.getParent().getSecurity() != null ? offer.getParent().getSecurity().getNamespace() : "") + "]");
|
||||||
for (IncomingFileOfferListener l : offerListeners) {
|
for (IncomingFileOfferListener l : offerListeners) {
|
||||||
|
|
|
@ -19,14 +19,10 @@ package org.jivesoftware.smackx.jingle_filetransfer.component;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.jivesoftware.smack.SmackException;
|
import org.jivesoftware.smack.SmackException;
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smackx.jingle.component.JingleDescription;
|
import org.jivesoftware.smackx.jingle.component.JingleDescription;
|
||||||
import org.jivesoftware.smackx.jingle.component.JingleSession;
|
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleElement;
|
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleReasonElement;
|
import org.jivesoftware.smackx.jingle.element.JingleReasonElement;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.controller.JingleFileTransferController;
|
import org.jivesoftware.smackx.jingle_filetransfer.controller.JingleFileTransferController;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferElement;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferElement;
|
||||||
|
@ -37,8 +33,6 @@ import org.jivesoftware.smackx.jingle_filetransfer.listener.ProgressListener;
|
||||||
*/
|
*/
|
||||||
public abstract class JingleFileTransfer extends JingleDescription<JingleFileTransferElement> implements JingleFileTransferController {
|
public abstract class JingleFileTransfer extends JingleDescription<JingleFileTransferElement> implements JingleFileTransferController {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(JingleFileTransfer.class.getName());
|
|
||||||
|
|
||||||
public static final String NAMESPACE_V5 = "urn:xmpp:jingle:apps:file-transfer:5";
|
public static final String NAMESPACE_V5 = "urn:xmpp:jingle:apps:file-transfer:5";
|
||||||
public static final String NAMESPACE = NAMESPACE_V5;
|
public static final String NAMESPACE = NAMESPACE_V5;
|
||||||
|
|
||||||
|
@ -81,25 +75,6 @@ public abstract class JingleFileTransfer extends JingleDescription<JingleFileTra
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancel(XMPPConnection connection) throws SmackException.NotConnectedException, InterruptedException {
|
public void cancel(XMPPConnection connection) throws SmackException.NotConnectedException, InterruptedException {
|
||||||
JingleSession session = getParent().getParent();
|
|
||||||
switch (state) {
|
|
||||||
case pending:
|
|
||||||
if (session.isResponder()) {
|
|
||||||
LOGGER.log(Level.INFO, "Cancel pending file transfer as responder.");
|
|
||||||
connection.createStanzaCollectorAndSend(JingleElement.createSessionTerminate(session.getPeer(), session.getSessionId(), JingleReasonElement.Reason.decline));
|
|
||||||
} else {
|
|
||||||
LOGGER.log(Level.INFO, "Cancel pending file transfer as initiator.");
|
|
||||||
connection.createStanzaCollectorAndSend(JingleElement.createSessionTerminate(session.getPeer(), session.getSessionId(), JingleReasonElement.Reason.cancel));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case active:
|
|
||||||
LOGGER.log(Level.INFO, "Cancel active file transfer.");
|
|
||||||
connection.createStanzaCollectorAndSend(JingleElement.createSessionTerminate(session.getPeer(), session.getSessionId(), JingleReasonElement.Reason.cancel));
|
|
||||||
break;
|
|
||||||
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
getParent().onContentCancel();
|
getParent().onContentCancel();
|
||||||
state = State.cancelled;
|
state = State.cancelled;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,10 +75,10 @@ public class JingleIncomingFileOffer extends AbstractJingleFileOffer implements
|
||||||
MessageDigest digest = null;
|
MessageDigest digest = null;
|
||||||
if (hashElement != null) {
|
if (hashElement != null) {
|
||||||
digest = HashManager.getMessageDigest(hashElement.getAlgorithm());
|
digest = HashManager.getMessageDigest(hashElement.getAlgorithm());
|
||||||
LOGGER.log(Level.INFO, "File offer had checksum: " + digest.toString() + ": " + hashElement.getHashB64());
|
LOGGER.log(Level.FINE, "File offer had checksum: " + digest.toString() + ": " + hashElement.getHashB64());
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGGER.log(Level.INFO, "Receive file");
|
LOGGER.log(Level.FINE, "Receive file");
|
||||||
|
|
||||||
InputStream inputStream = null;
|
InputStream inputStream = null;
|
||||||
try {
|
try {
|
||||||
|
@ -97,7 +97,7 @@ public class JingleIncomingFileOffer extends AbstractJingleFileOffer implements
|
||||||
}
|
}
|
||||||
target.write(bufbuf, 0, length);
|
target.write(bufbuf, 0, length);
|
||||||
read += length;
|
read += length;
|
||||||
LOGGER.log(Level.INFO, "Read " + read + " (" + length + ") of " + metadata.getSize() + " bytes.");
|
LOGGER.log(Level.FINER, "Read " + read + " (" + length + ") of " + metadata.getSize() + " bytes.");
|
||||||
|
|
||||||
percentage = ((float) read) / ((float) metadata.getSize());
|
percentage = ((float) read) / ((float) metadata.getSize());
|
||||||
|
|
||||||
|
@ -105,26 +105,26 @@ public class JingleIncomingFileOffer extends AbstractJingleFileOffer implements
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOGGER.log(Level.INFO, "Reading/Writing finished.");
|
LOGGER.log(Level.FINE, "Reading/Writing finished.");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.log(Level.SEVERE, "Cannot get InputStream from BytestreamSession: " + e, e);
|
LOGGER.log(Level.SEVERE, "Cannot get InputStream from BytestreamSession.", e);
|
||||||
} finally {
|
} finally {
|
||||||
state = State.ended;
|
state = State.ended;
|
||||||
if (inputStream != null) {
|
if (inputStream != null) {
|
||||||
try {
|
try {
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
LOGGER.log(Level.INFO, "CipherInputStream closed.");
|
LOGGER.log(Level.FINER, "CipherInputStream closed.");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.log(Level.SEVERE, "Could not close InputStream: " + e, e);
|
LOGGER.log(Level.SEVERE, "Could not close InputStream.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
try {
|
try {
|
||||||
target.close();
|
target.close();
|
||||||
LOGGER.log(Level.INFO, "FileOutputStream closed.");
|
LOGGER.log(Level.FINER, "FileOutputStream closed.");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.log(Level.SEVERE, "Could not close OutputStream: " + e, e);
|
LOGGER.log(Level.SEVERE, "Could not close OutputStream.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ public class JingleIncomingFileOffer extends AbstractJingleFileOffer implements
|
||||||
if (!Arrays.equals(hashElement.getHash(), mDigest)) {
|
if (!Arrays.equals(hashElement.getHash(), mDigest)) {
|
||||||
LOGGER.log(Level.WARNING, "CHECKSUM MISMATCH!");
|
LOGGER.log(Level.WARNING, "CHECKSUM MISMATCH!");
|
||||||
} else {
|
} else {
|
||||||
LOGGER.log(Level.INFO, "CHECKSUM MATCHED :)");
|
LOGGER.log(Level.FINE, "CHECKSUM MATCHED :)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
notifyProgressListenersTerminated(JingleReasonElement.Reason.success);
|
notifyProgressListenersTerminated(JingleReasonElement.Reason.success);
|
||||||
|
|
|
@ -92,13 +92,13 @@ public class JingleOutgoingFileOffer extends AbstractJingleFileOffer implements
|
||||||
outputStream.close();
|
outputStream.close();
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.log(Level.SEVERE, "Exception while sending file: " + e, e);
|
LOGGER.log(Level.SEVERE, "Exception while sending file.", e);
|
||||||
} finally {
|
} finally {
|
||||||
state = State.ended;
|
state = State.ended;
|
||||||
try {
|
try {
|
||||||
source.close();
|
source.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.log(Level.SEVERE, "Could not close FileInputStream: " + e, e);
|
LOGGER.log(Level.SEVERE, "Could not close FileInputStream.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.xmlpull.v1.XmlPullParser;
|
||||||
*/
|
*/
|
||||||
public class ChecksumProvider extends ExtensionElementProvider<ChecksumElement> {
|
public class ChecksumProvider extends ExtensionElementProvider<ChecksumElement> {
|
||||||
|
|
||||||
private static HashElementProvider hashProvider = new HashElementProvider();
|
private static final HashElementProvider hashProvider = new HashElementProvider();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChecksumElement parse(XmlPullParser parser, int initialDepth) throws Exception {
|
public ChecksumElement parse(XmlPullParser parser, int initialDepth) throws Exception {
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChi
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferElement;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferElement;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.Range;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.Range;
|
||||||
|
|
||||||
|
import org.jxmpp.util.XmppDateTime;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,8 +55,7 @@ public class JingleFileTransferProvider
|
||||||
if (tag == START_TAG) {
|
if (tag == START_TAG) {
|
||||||
switch (elem) {
|
switch (elem) {
|
||||||
case JingleFileTransferChildElement.ELEM_DATE:
|
case JingleFileTransferChildElement.ELEM_DATE:
|
||||||
//builder.setDate(XmppDateTime.parseXEP0082Date(parser.nextText()));
|
builder.setDate(XmppDateTime.parseXEP0082Date(parser.nextText()));
|
||||||
parser.nextText();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JingleFileTransferChildElement.ELEM_DESC:
|
case JingleFileTransferChildElement.ELEM_DESC:
|
||||||
|
|
|
@ -136,7 +136,7 @@ public final class JingleManager extends Manager {
|
||||||
if (jingle.getAction() == JingleAction.session_initiate) {
|
if (jingle.getAction() == JingleAction.session_initiate) {
|
||||||
//fresh. phew!
|
//fresh. phew!
|
||||||
try {
|
try {
|
||||||
LOGGER.log(Level.INFO, "Create new session with " + jingle.getFrom() + ": " + jingle.getSid());
|
LOGGER.log(Level.FINE, "Create new session with " + jingle.getFrom() + ": " + jingle.getSid());
|
||||||
session = JingleSession.fromSessionInitiate(JingleManager.this, jingle);
|
session = JingleSession.fromSessionInitiate(JingleManager.this, jingle);
|
||||||
jingleSessions.put(fullJidAndSessionId, session);
|
jingleSessions.put(fullJidAndSessionId, session);
|
||||||
} catch (UnsupportedDescriptionException e) {
|
} catch (UnsupportedDescriptionException e) {
|
||||||
|
@ -306,7 +306,7 @@ public final class JingleManager extends Manager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a {@link JingleDescriptionManager}.
|
* Add a {@link JingleDescriptionManager}.
|
||||||
* @param manager
|
* @param manager manager
|
||||||
*/
|
*/
|
||||||
public void addJingleDescriptionManager(JingleDescriptionManager manager) {
|
public void addJingleDescriptionManager(JingleDescriptionManager manager) {
|
||||||
descriptionManagers.put(manager.getNamespace(), manager);
|
descriptionManagers.put(manager.getNamespace(), manager);
|
||||||
|
@ -323,7 +323,7 @@ public final class JingleManager extends Manager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a {@link JingleTransportManager}.
|
* Add a {@link JingleTransportManager}.
|
||||||
* @param manager
|
* @param manager manager
|
||||||
*/
|
*/
|
||||||
public void addJingleTransportManager(JingleTransportManager manager) {
|
public void addJingleTransportManager(JingleTransportManager manager) {
|
||||||
transportManagers.put(manager.getNamespace(), manager);
|
transportManagers.put(manager.getNamespace(), manager);
|
||||||
|
@ -340,7 +340,7 @@ public final class JingleManager extends Manager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a {@link JingleSecurityManager}.
|
* Add a {@link JingleSecurityManager}.
|
||||||
* @param manager
|
* @param manager manager
|
||||||
*/
|
*/
|
||||||
public void addJingleSecurityManager(JingleSecurityManager manager) {
|
public void addJingleSecurityManager(JingleSecurityManager manager) {
|
||||||
securityManagers.put(manager.getNamespace(), manager);
|
securityManagers.put(manager.getNamespace(), manager);
|
||||||
|
|
|
@ -182,6 +182,7 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
|
||||||
* @param connection connection.
|
* @param connection connection.
|
||||||
*/
|
*/
|
||||||
void handleContentAccept(JingleElement request, XMPPConnection connection) {
|
void handleContentAccept(JingleElement request, XMPPConnection connection) {
|
||||||
|
LOGGER.log(Level.FINE, "Received content-accept from " + request.getFrom() + " for session " + request.getSid() + " and content " + getName());
|
||||||
start(connection);
|
start(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +193,7 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
|
||||||
* @return result.
|
* @return result.
|
||||||
*/
|
*/
|
||||||
IQ handleSessionAccept(JingleElement request, XMPPConnection connection) {
|
IQ handleSessionAccept(JingleElement request, XMPPConnection connection) {
|
||||||
LOGGER.log(Level.INFO, "RECEIVED SESSION ACCEPT!");
|
LOGGER.log(Level.FINE, "Received session-accept from " + request.getResponder() + " for session " + request.getSid());
|
||||||
JingleContentElement contentElement = null;
|
JingleContentElement contentElement = null;
|
||||||
for (JingleContentElement c : request.getContents()) {
|
for (JingleContentElement c : request.getContents()) {
|
||||||
if (c.getName().equals(getName())) {
|
if (c.getName().equals(getName())) {
|
||||||
|
@ -310,9 +311,10 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
|
||||||
*/
|
*/
|
||||||
private IQ handleTransportReject(JingleElement request, final XMPPConnection connection) {
|
private IQ handleTransportReject(JingleElement request, final XMPPConnection connection) {
|
||||||
if (pendingReplacingTransport == null) {
|
if (pendingReplacingTransport == null) {
|
||||||
// TODO: Throw other exception?
|
LOGGER.log(Level.WARNING, "Received transport-reject, but apparently we did not try to replace the transport.");
|
||||||
throw new AssertionError("We didn't try to replace the transport.");
|
return JingleElement.createJingleErrorOutOfOrder(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
Async.go(new Runnable() {
|
Async.go(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -321,10 +323,11 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
|
||||||
try {
|
try {
|
||||||
replaceTransport(transportBlacklist, connection);
|
replaceTransport(transportBlacklist, connection);
|
||||||
} catch (SmackException.NotConnectedException | SmackException.NoResponseException | XMPPException.XMPPErrorException | InterruptedException e) {
|
} catch (SmackException.NotConnectedException | SmackException.NoResponseException | XMPPException.XMPPErrorException | InterruptedException e) {
|
||||||
LOGGER.log(Level.SEVERE, "Could not replace transport: " + e, e);
|
LOGGER.log(Level.SEVERE, "Could not replace transport.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return IQ.createResultIQ(request);
|
return IQ.createResultIQ(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,9 +346,11 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
connection.createStanzaCollectorAndSend(JingleElement.createJingleErrorTieBreak(request)).nextResultOrThrow();
|
connection.createStanzaCollectorAndSend(JingleElement.createJingleErrorTieBreak(request))
|
||||||
} catch (SmackException.NoResponseException | SmackException.NotConnectedException | InterruptedException | XMPPException.XMPPErrorException e) {
|
.nextResultOrThrow();
|
||||||
LOGGER.log(Level.SEVERE, "Could not send tie-break: " + e, e);
|
} catch (SmackException.NoResponseException | SmackException.NotConnectedException |
|
||||||
|
InterruptedException | XMPPException.XMPPErrorException e) {
|
||||||
|
LOGGER.log(Level.SEVERE, "Could not send tie-break.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -374,10 +379,13 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
|
||||||
Async.go(new Runnable() {
|
Async.go(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
JingleElement reject = JingleElement.createTransportReject(session.getOurJid(),
|
||||||
|
session.getPeer(), session.getSessionId(), getCreator(), getName(), transportElement);
|
||||||
try {
|
try {
|
||||||
getParent().getJingleManager().getConnection().createStanzaCollectorAndSend(JingleElement.createTransportReject(session.getOurJid(), session.getPeer(), session.getSessionId(), getCreator(), getName(), transportElement));
|
connection.createStanzaCollectorAndSend(reject).nextResultOrThrow();
|
||||||
} catch (SmackException.NotConnectedException | InterruptedException e) {
|
} catch (SmackException.NotConnectedException | InterruptedException |
|
||||||
LOGGER.log(Level.SEVERE, "Could not send transport-reject: " + e, e);
|
XMPPException.XMPPErrorException | SmackException.NoResponseException e) {
|
||||||
|
LOGGER.log(Level.SEVERE, "Could not send transport-reject.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -390,10 +398,11 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
|
||||||
Async.go(new Runnable() {
|
Async.go(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
JingleElement accept = JingleElement.createTransportAccept(session.getOurJid(), session.getPeer(), session.getSessionId(), getCreator(), getName(), transport.getElement());
|
||||||
try {
|
try {
|
||||||
getParent().getJingleManager().getConnection().createStanzaCollectorAndSend(JingleElement.createTransportAccept(session.getOurJid(), session.getPeer(), session.getSessionId(), getCreator(), getName(), transport.getElement()));
|
getParent().getJingleManager().getConnection().createStanzaCollectorAndSend(accept).nextResultOrThrow();
|
||||||
} catch (SmackException.NotConnectedException | InterruptedException e) {
|
} catch (SmackException.NotConnectedException | InterruptedException | XMPPException.XMPPErrorException | SmackException.NoResponseException e) {
|
||||||
LOGGER.log(Level.SEVERE, "Could not send transport-accept: " + e, e);
|
LOGGER.log(Level.SEVERE, "Could not send transport-accept.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -579,17 +588,17 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
if (isReceiving()) {
|
if (isReceiving()) {
|
||||||
LOGGER.log(Level.INFO, "Establish incoming bytestream.");
|
LOGGER.log(Level.FINE, "Establish incoming bytestream.");
|
||||||
getTransport().establishIncomingBytestreamSession(connection, JingleContent.this, getParent());
|
getTransport().establishIncomingBytestreamSession(connection, JingleContent.this, getParent());
|
||||||
} else if (isSending()) {
|
} else if (isSending()) {
|
||||||
LOGGER.log(Level.INFO, "Establish outgoing bytestream.");
|
LOGGER.log(Level.FINE, "Establish outgoing bytestream.");
|
||||||
getTransport().establishOutgoingBytestreamSession(connection, JingleContent.this, getParent());
|
getTransport().establishOutgoingBytestreamSession(connection, JingleContent.this, getParent());
|
||||||
} else {
|
} else {
|
||||||
LOGGER.log(Level.INFO, "Neither receiving, nor sending. Assume receiving.");
|
LOGGER.log(Level.FINE, "Neither receiving, nor sending. Assume receiving.");
|
||||||
getTransport().establishIncomingBytestreamSession(connection, JingleContent.this, getParent());
|
getTransport().establishIncomingBytestreamSession(connection, JingleContent.this, getParent());
|
||||||
}
|
}
|
||||||
} catch (SmackException.NotConnectedException | InterruptedException e) {
|
} catch (SmackException.NotConnectedException | InterruptedException e) {
|
||||||
LOGGER.log(Level.SEVERE, "Error establishing connection: " + e, e);
|
LOGGER.log(Level.SEVERE, "Error establishing connection.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -597,17 +606,17 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTransportReady(BytestreamSession bytestreamSession) {
|
public void onTransportReady(BytestreamSession bytestreamSession) {
|
||||||
LOGGER.log(Level.INFO, "TransportReady: " + (isReceiving() ? "Receive" : "Send"));
|
LOGGER.log(Level.FINE, "TransportReady: " + (isReceiving() ? "Receive" : "Send"));
|
||||||
if (bytestreamSession == null) {
|
if (bytestreamSession == null) {
|
||||||
throw new AssertionError("bytestreamSession MUST NOT be null at this point.");
|
throw new AssertionError("bytestreamSession MUST NOT be null at this point.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (security != null) {
|
if (security != null) {
|
||||||
if (isReceiving()) {
|
if (isReceiving()) {
|
||||||
LOGGER.log(Level.INFO, "Decrypt incoming Bytestream.");
|
LOGGER.log(Level.FINE, "Decrypt incoming Bytestream.");
|
||||||
getSecurity().decryptIncomingBytestream(bytestreamSession, this);
|
getSecurity().decryptIncomingBytestream(bytestreamSession, this);
|
||||||
} else if (isSending()) {
|
} else if (isSending()) {
|
||||||
LOGGER.log(Level.INFO, "Encrypt outgoing Bytestream.");
|
LOGGER.log(Level.FINE, "Encrypt outgoing Bytestream.");
|
||||||
getSecurity().encryptOutgoingBytestream(bytestreamSession, this);
|
getSecurity().encryptOutgoingBytestream(bytestreamSession, this);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -625,7 +634,7 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
|
||||||
try {
|
try {
|
||||||
replaceTransport(getTransportBlacklist(), getParent().getJingleManager().getConnection());
|
replaceTransport(getTransportBlacklist(), getParent().getJingleManager().getConnection());
|
||||||
} catch (SmackException.NotConnectedException | InterruptedException | SmackException.NoResponseException | XMPPException.XMPPErrorException e1) {
|
} catch (SmackException.NotConnectedException | InterruptedException | SmackException.NoResponseException | XMPPException.XMPPErrorException e1) {
|
||||||
LOGGER.log(Level.SEVERE, "Could not send transport-replace: " + e, e);
|
LOGGER.log(Level.SEVERE, "Could not send transport-replace.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -637,7 +646,7 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSecurityFailed(Exception e) {
|
public void onSecurityFailed(Exception e) {
|
||||||
LOGGER.log(Level.SEVERE, "Security failed: " + e, e);
|
LOGGER.log(Level.SEVERE, "Security failed.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -163,7 +163,7 @@ public class JingleSession {
|
||||||
* @throws SmackException.NoResponseException
|
* @throws SmackException.NoResponseException
|
||||||
*/
|
*/
|
||||||
public void sendAccept(XMPPConnection connection) throws SmackException.NotConnectedException, InterruptedException, XMPPException.XMPPErrorException, SmackException.NoResponseException {
|
public void sendAccept(XMPPConnection connection) throws SmackException.NotConnectedException, InterruptedException, XMPPException.XMPPErrorException, SmackException.NoResponseException {
|
||||||
LOGGER.log(Level.INFO, "Accepted session.");
|
LOGGER.log(Level.FINE, "Accepted session.");
|
||||||
if (this.sessionState != SessionState.pending) {
|
if (this.sessionState != SessionState.pending) {
|
||||||
throw new IllegalStateException("Session is not in pending state.");
|
throw new IllegalStateException("Session is not in pending state.");
|
||||||
}
|
}
|
||||||
|
@ -233,17 +233,6 @@ public class JingleSession {
|
||||||
terminateSession(JingleReasonElement.Reason.success);
|
terminateSession(JingleReasonElement.Reason.success);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Session has still active contents left.
|
|
||||||
/*
|
|
||||||
try {
|
|
||||||
jingleManager.getConnection().createStanzaCollectorAndSend(JingleElement.createSessionTerminateContentCancel(
|
|
||||||
getPeer(), getSessionId(), jingleContent.getCreator(), jingleContent.getName()));
|
|
||||||
} catch (SmackException.NotConnectedException | InterruptedException e) {
|
|
||||||
LOGGER.log(Level.SEVERE, "Could not send content-cancel: " + e, e);
|
|
||||||
}
|
|
||||||
contents.remove(jingleContent.getName());
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -253,7 +242,8 @@ public class JingleSession {
|
||||||
*/
|
*/
|
||||||
void onContentCancel(JingleContent jingleContent) {
|
void onContentCancel(JingleContent jingleContent) {
|
||||||
if (contents.get(jingleContent.getName()) == null) {
|
if (contents.get(jingleContent.getName()) == null) {
|
||||||
LOGGER.log(Level.WARNING, "Session does not contain content " + jingleContent.getName() + ". Ignore onContentCancel.");
|
LOGGER.log(Level.WARNING, "Session does not contain content " + jingleContent.getName() +
|
||||||
|
". Ignore onContentCancel.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,10 +251,13 @@ public class JingleSession {
|
||||||
terminateSession(JingleReasonElement.Reason.cancel);
|
terminateSession(JingleReasonElement.Reason.cancel);
|
||||||
jingleManager.removeSession(this);
|
jingleManager.removeSession(this);
|
||||||
} else {
|
} else {
|
||||||
|
JingleElement cancel = JingleElement.createSessionTerminateContentCancel(
|
||||||
|
getPeer(), getSessionId(), jingleContent.getCreator(), jingleContent.getName());
|
||||||
try {
|
try {
|
||||||
jingleManager.getConnection().createStanzaCollectorAndSend(JingleElement.createSessionTerminateContentCancel(getPeer(), getSessionId(), jingleContent.getCreator(), jingleContent.getName()));
|
jingleManager.getConnection().createStanzaCollectorAndSend(cancel).nextResultOrThrow();
|
||||||
} catch (SmackException.NotConnectedException | InterruptedException e) {
|
} catch (SmackException.NotConnectedException | InterruptedException | XMPPException.XMPPErrorException |
|
||||||
LOGGER.log(Level.SEVERE, "Could not send content-cancel: " + e, e);
|
SmackException.NoResponseException e) {
|
||||||
|
LOGGER.log(Level.SEVERE, "Could not send content-cancel.", e);
|
||||||
}
|
}
|
||||||
contents.remove(jingleContent.getName());
|
contents.remove(jingleContent.getName());
|
||||||
}
|
}
|
||||||
|
@ -275,10 +268,11 @@ public class JingleSession {
|
||||||
* @param reason reason of termination.
|
* @param reason reason of termination.
|
||||||
*/
|
*/
|
||||||
public void terminateSession(JingleReasonElement.Reason reason) {
|
public void terminateSession(JingleReasonElement.Reason reason) {
|
||||||
|
JingleElement terminate = JingleElement.createSessionTerminate(getPeer(), getSessionId(), reason);
|
||||||
try {
|
try {
|
||||||
jingleManager.getConnection().createStanzaCollectorAndSend(JingleElement.createSessionTerminate(getPeer(), getSessionId(), reason));
|
jingleManager.getConnection().sendStanza(terminate);
|
||||||
} catch (SmackException.NotConnectedException | InterruptedException e) {
|
} catch (SmackException.NotConnectedException | InterruptedException e) {
|
||||||
LOGGER.log(Level.SEVERE, "Could not send session-terminate: " + e, e);
|
LOGGER.log(Level.SEVERE, "Could not send session-terminate.", e);
|
||||||
}
|
}
|
||||||
this.sessionState = SessionState.ended;
|
this.sessionState = SessionState.ended;
|
||||||
jingleManager.removeSession(this);
|
jingleManager.removeSession(this);
|
||||||
|
@ -360,10 +354,13 @@ public class JingleSession {
|
||||||
if (descriptionManager == null) {
|
if (descriptionManager == null) {
|
||||||
|
|
||||||
LOGGER.log(Level.WARNING, "Unsupported description type: " + description.getNamespace());
|
LOGGER.log(Level.WARNING, "Unsupported description type: " + description.getNamespace());
|
||||||
|
JingleElement terminate = JingleElement.createSessionTerminate(getPeer(), getSessionId(),
|
||||||
|
JingleReasonElement.Reason.unsupported_applications);
|
||||||
try {
|
try {
|
||||||
jingleManager.getConnection().createStanzaCollectorAndSend(JingleElement.createSessionTerminate(getPeer(), getSessionId(), JingleReasonElement.Reason.unsupported_applications));
|
jingleManager.getConnection().createStanzaCollectorAndSend(terminate).nextResultOrThrow();
|
||||||
} catch (SmackException.NotConnectedException | InterruptedException e) {
|
} catch (SmackException.NotConnectedException | InterruptedException | XMPPException.XMPPErrorException |
|
||||||
LOGGER.log(Level.SEVERE, "Could not send session-terminate: " + e, e);
|
SmackException.NoResponseException e) {
|
||||||
|
LOGGER.log(Level.SEVERE, "Could not send session-terminate.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -440,7 +437,8 @@ public class JingleSession {
|
||||||
private IQ handleContentAdd(JingleElement request) {
|
private IQ handleContentAdd(JingleElement request) {
|
||||||
final JingleContent proposed = getSoleProposedContentOrThrow(request);
|
final JingleContent proposed = getSoleProposedContentOrThrow(request);
|
||||||
|
|
||||||
final JingleDescriptionManager descriptionManager = jingleManager.getDescriptionManager(proposed.getDescription().getNamespace());
|
final JingleDescriptionManager descriptionManager = jingleManager.getDescriptionManager(proposed.getDescription()
|
||||||
|
.getNamespace());
|
||||||
|
|
||||||
if (descriptionManager == null) {
|
if (descriptionManager == null) {
|
||||||
throw new AssertionError("DescriptionManager is null: " + proposed.getDescription().getNamespace());
|
throw new AssertionError("DescriptionManager is null: " + proposed.getDescription().getNamespace());
|
||||||
|
@ -493,26 +491,6 @@ public class JingleSession {
|
||||||
*/
|
*/
|
||||||
private IQ handleContentRemove(final JingleElement request) {
|
private IQ handleContentRemove(final JingleElement request) {
|
||||||
return IQ.createErrorResponse(request, XMPPError.Condition.feature_not_implemented);
|
return IQ.createErrorResponse(request, XMPPError.Condition.feature_not_implemented);
|
||||||
/*
|
|
||||||
for (JingleContentElement r : request.getContents()) {
|
|
||||||
final JingleContent removed = contents.get(r.getName());
|
|
||||||
|
|
||||||
if (removed == null) {
|
|
||||||
throw new AssertionError("Illegal content name!");
|
|
||||||
}
|
|
||||||
|
|
||||||
contents.remove(removed.getName());
|
|
||||||
|
|
||||||
Async.go(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
removed.handleContentRemove(JingleSession.this, jingleManager.getConnection());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return IQ.createResultIQ(request);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,6 +20,8 @@ import org.jivesoftware.smack.packet.NamedElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An element found usually in 'description' elements.
|
* An element found usually in 'description' elements.
|
||||||
|
* <pre> {@code
|
||||||
|
*
|
||||||
* <jingle>
|
* <jingle>
|
||||||
* <content>
|
* <content>
|
||||||
* <description>
|
* <description>
|
||||||
|
@ -29,7 +31,6 @@ import org.jivesoftware.smack.packet.NamedElement;
|
||||||
* <security/>
|
* <security/>
|
||||||
* </content>
|
* </content>
|
||||||
* </jingle>
|
* </jingle>
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public abstract class JingleContentDescriptionChildElement implements NamedElement {
|
public abstract class JingleContentDescriptionChildElement implements NamedElement {
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@ import org.jivesoftware.smackx.jingle.component.JingleDescription;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link ExtensionElement} representing a {@link JingleDescription}.
|
* {@link ExtensionElement} representing a {@link JingleDescription}.
|
||||||
|
* <pre> {@code
|
||||||
|
*
|
||||||
* <jingle>
|
* <jingle>
|
||||||
* <content>
|
* <content>
|
||||||
* <description/> <- This element is us.
|
* <description/> <- This element is us.
|
||||||
|
@ -34,6 +36,7 @@ import org.jivesoftware.smackx.jingle.component.JingleDescription;
|
||||||
* </content>
|
* </content>
|
||||||
* </jingle>
|
* </jingle>
|
||||||
*
|
*
|
||||||
|
* } </pre>
|
||||||
*/
|
*/
|
||||||
public abstract class JingleContentDescriptionElement implements ExtensionElement {
|
public abstract class JingleContentDescriptionElement implements ExtensionElement {
|
||||||
|
|
||||||
|
|
|
@ -24,11 +24,15 @@ import org.jivesoftware.smackx.jingle.component.JingleContent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link NamedElement} representing a {@link JingleContent}.
|
* {@link NamedElement} representing a {@link JingleContent}.
|
||||||
|
* <pre> {@code
|
||||||
|
*
|
||||||
* <jingle>
|
* <jingle>
|
||||||
* <content> <- Me.
|
* <content> <- Me.
|
||||||
* ...
|
* ...
|
||||||
* </content>
|
* </content>
|
||||||
* </jingle>
|
* </jingle>
|
||||||
|
*
|
||||||
|
* } </pre>
|
||||||
*/
|
*/
|
||||||
public final class JingleContentElement implements NamedElement {
|
public final class JingleContentElement implements NamedElement {
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ import org.jivesoftware.smackx.jingle.component.JingleSecurity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link ExtensionElement} representing a {@link JingleSecurity}.
|
* {@link ExtensionElement} representing a {@link JingleSecurity}.
|
||||||
|
* <pre> {@code
|
||||||
|
*
|
||||||
* <jingle>
|
* <jingle>
|
||||||
* <content>
|
* <content>
|
||||||
* <description/>
|
* <description/>
|
||||||
|
@ -28,6 +30,9 @@ import org.jivesoftware.smackx.jingle.component.JingleSecurity;
|
||||||
* <security/> <- That's me :)
|
* <security/> <- That's me :)
|
||||||
* </content>
|
* </content>
|
||||||
* </jingle>
|
* </jingle>
|
||||||
|
*
|
||||||
|
* } </pre>
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class JingleContentSecurityElement implements ExtensionElement {
|
public abstract class JingleContentSecurityElement implements ExtensionElement {
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ import org.jivesoftware.smackx.jingle.component.JingleTransportCandidate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link NamedElement} representing a {@link JingleTransportCandidate}
|
* {@link NamedElement} representing a {@link JingleTransportCandidate}
|
||||||
|
*
|
||||||
|
* <pre> {@code
|
||||||
* <jingle>
|
* <jingle>
|
||||||
* <content>
|
* <content>
|
||||||
* <description/>
|
* <description/>
|
||||||
|
@ -30,6 +32,7 @@ import org.jivesoftware.smackx.jingle.component.JingleTransportCandidate;
|
||||||
* </transport>
|
* </transport>
|
||||||
* </content>
|
* </content>
|
||||||
* </jingle>
|
* </jingle>
|
||||||
|
* } </pre>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class JingleContentTransportCandidateElement implements NamedElement {
|
public abstract class JingleContentTransportCandidateElement implements NamedElement {
|
||||||
|
|
|
@ -25,6 +25,8 @@ import org.jivesoftware.smackx.jingle.component.JingleTransport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link ExtensionElement} representing a {@link JingleTransport}.
|
* {@link ExtensionElement} representing a {@link JingleTransport}.
|
||||||
|
*
|
||||||
|
* <pre> {@code
|
||||||
* <jingle>
|
* <jingle>
|
||||||
* <content>
|
* <content>
|
||||||
* <description/>
|
* <description/>
|
||||||
|
@ -32,6 +34,7 @@ import org.jivesoftware.smackx.jingle.component.JingleTransport;
|
||||||
* <security/>
|
* <security/>
|
||||||
* </content>
|
* </content>
|
||||||
* </jingle>
|
* </jingle>
|
||||||
|
* } </pre>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class JingleContentTransportElement implements ExtensionElement {
|
public abstract class JingleContentTransportElement implements ExtensionElement {
|
||||||
|
|
|
@ -22,6 +22,8 @@ import org.jivesoftware.smack.packet.NamedElement;
|
||||||
* Abstract JingleContentTransportInfo element.
|
* Abstract JingleContentTransportInfo element.
|
||||||
* The JingleContentTransportInfo element can have certain states defined by the respective Transport XEP.
|
* The JingleContentTransportInfo element can have certain states defined by the respective Transport XEP.
|
||||||
* Examples are Jingle Socks5Bytestream's <candidate-used/> (Example 5), <candidate-error/> (Example 7) etc.
|
* Examples are Jingle Socks5Bytestream's <candidate-used/> (Example 5), <candidate-error/> (Example 7) etc.
|
||||||
|
*
|
||||||
|
* <pre> {@code
|
||||||
* <jingle>
|
* <jingle>
|
||||||
* <content>
|
* <content>
|
||||||
* <description/>
|
* <description/>
|
||||||
|
@ -31,6 +33,7 @@ import org.jivesoftware.smack.packet.NamedElement;
|
||||||
* <security/>
|
* <security/>
|
||||||
* </content>
|
* </content>
|
||||||
* </jingle>
|
* </jingle>
|
||||||
|
* } </pre>
|
||||||
*/
|
*/
|
||||||
public abstract class JingleContentTransportInfoElement implements NamedElement {
|
public abstract class JingleContentTransportInfoElement implements NamedElement {
|
||||||
|
|
||||||
|
|
|
@ -88,11 +88,11 @@ public class JingleIBBTransport extends JingleTransport<JingleIBBTransportElemen
|
||||||
@Override
|
@Override
|
||||||
public void establishIncomingBytestreamSession(final XMPPConnection connection, final JingleTransportCallback callback, final JingleSession session) {
|
public void establishIncomingBytestreamSession(final XMPPConnection connection, final JingleTransportCallback callback, final JingleSession session) {
|
||||||
final InBandBytestreamManager inBandBytestreamManager = InBandBytestreamManager.getByteStreamManager(connection);
|
final InBandBytestreamManager inBandBytestreamManager = InBandBytestreamManager.getByteStreamManager(connection);
|
||||||
LOGGER.log(Level.INFO, "Listen for incoming IBB transports from " + session.getPeer() + ":" + getStreamId());
|
LOGGER.log(Level.FINE, "Listen for incoming IBB transports from " + session.getPeer() + ":" + getStreamId());
|
||||||
InBandBytestreamListener bytestreamListener = new InBandBytestreamListener() {
|
InBandBytestreamListener bytestreamListener = new InBandBytestreamListener() {
|
||||||
@Override
|
@Override
|
||||||
public void incomingBytestreamRequest(InBandBytestreamRequest request) {
|
public void incomingBytestreamRequest(InBandBytestreamRequest request) {
|
||||||
LOGGER.log(Level.INFO, "Incoming IBB stream: " + request.getFrom().asFullJidIfPossible() + ":" + request.getSessionID());
|
LOGGER.log(Level.FINE, "Incoming IBB stream: " + request.getFrom().asFullJidIfPossible() + ":" + request.getSessionID());
|
||||||
if (request.getFrom().asFullJidIfPossible().equals(session.getPeer())
|
if (request.getFrom().asFullJidIfPossible().equals(session.getPeer())
|
||||||
&& request.getSessionID().equals(getStreamId())) {
|
&& request.getSessionID().equals(getStreamId())) {
|
||||||
|
|
||||||
|
|
|
@ -219,7 +219,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
|
||||||
@Override
|
@Override
|
||||||
public void establishIncomingBytestreamSession(XMPPConnection connection, JingleTransportCallback callback, JingleSession session)
|
public void establishIncomingBytestreamSession(XMPPConnection connection, JingleTransportCallback callback, JingleSession session)
|
||||||
throws SmackException.NotConnectedException, InterruptedException {
|
throws SmackException.NotConnectedException, InterruptedException {
|
||||||
LOGGER.log(Level.INFO, "Establishing incoming bytestream.");
|
LOGGER.log(Level.FINE, "Establishing incoming bytestream.");
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
establishBytestreamSession(connection);
|
establishBytestreamSession(connection);
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
|
||||||
@Override
|
@Override
|
||||||
public void establishOutgoingBytestreamSession(XMPPConnection connection, JingleTransportCallback callback, JingleSession session)
|
public void establishOutgoingBytestreamSession(XMPPConnection connection, JingleTransportCallback callback, JingleSession session)
|
||||||
throws SmackException.NotConnectedException, InterruptedException {
|
throws SmackException.NotConnectedException, InterruptedException {
|
||||||
LOGGER.log(Level.INFO, "Establishing outgoing bytestream.");
|
LOGGER.log(Level.FINE, "Establishing outgoing bytestream.");
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
establishBytestreamSession(connection);
|
establishBytestreamSession(connection);
|
||||||
}
|
}
|
||||||
|
@ -255,7 +255,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
|
||||||
private JingleS5BTransportCandidate connectToCandidates(int timeout) {
|
private JingleS5BTransportCandidate connectToCandidates(int timeout) {
|
||||||
|
|
||||||
if (getTheirCandidates().size() == 0) {
|
if (getTheirCandidates().size() == 0) {
|
||||||
LOGGER.log(Level.INFO, "They provided 0 candidates.");
|
LOGGER.log(Level.FINE, "They provided 0 candidates.");
|
||||||
return CANDIDATE_FAILURE;
|
return CANDIDATE_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
|
||||||
try {
|
try {
|
||||||
return candidate.connect(_timeout, true);
|
return candidate.connect(_timeout, true);
|
||||||
} catch (IOException | TimeoutException | InterruptedException | SmackException | XMPPException e) {
|
} catch (IOException | TimeoutException | InterruptedException | SmackException | XMPPException e) {
|
||||||
LOGGER.log(Level.WARNING, "Exception while connecting to candidate: " + e, e);
|
LOGGER.log(Level.FINE, "Exception while connecting to candidate: " + e, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,17 +284,17 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
|
||||||
|
|
||||||
if (ourSelectedCandidate == null || theirSelectedCandidate == null) {
|
if (ourSelectedCandidate == null || theirSelectedCandidate == null) {
|
||||||
// Not yet ready if we or peer did not yet decide on a candidate.
|
// Not yet ready if we or peer did not yet decide on a candidate.
|
||||||
LOGGER.log(Level.INFO, "Not ready.");
|
LOGGER.log(Level.FINEST, "Not ready.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ourSelectedCandidate == CANDIDATE_FAILURE && theirSelectedCandidate == CANDIDATE_FAILURE) {
|
if (ourSelectedCandidate == CANDIDATE_FAILURE && theirSelectedCandidate == CANDIDATE_FAILURE) {
|
||||||
LOGGER.log(Level.INFO, "Failure.");
|
LOGGER.log(Level.FINE, "Failure.");
|
||||||
callback.onTransportFailed(new FailedTransportException(null));
|
callback.onTransportFailed(new FailedTransportException(null));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGGER.log(Level.INFO, (session.isInitiator() ? "Initiator" : "Responder") + " is ready.");
|
LOGGER.log(Level.FINE, (session.isInitiator() ? "Initiator" : "Responder") + " is ready.");
|
||||||
|
|
||||||
//Determine nominated candidate.
|
//Determine nominated candidate.
|
||||||
JingleS5BTransportCandidate nominated;
|
JingleS5BTransportCandidate nominated;
|
||||||
|
@ -318,7 +318,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
|
||||||
|
|
||||||
if (nominated == theirSelectedCandidate) {
|
if (nominated == theirSelectedCandidate) {
|
||||||
|
|
||||||
LOGGER.log(Level.INFO, "Their choice, so our proposed candidate is used.");
|
LOGGER.log(Level.FINE, "Their choice, so our proposed candidate is used.");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
nominated = nominated.connect(MAX_TIMEOUT, false);
|
nominated = nominated.connect(MAX_TIMEOUT, false);
|
||||||
|
@ -331,7 +331,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
|
||||||
try {
|
try {
|
||||||
session.getJingleManager().getConnection().createStanzaCollectorAndSend(JingleS5BTransportManager.createProxyError(JingleS5BTransport.this));
|
session.getJingleManager().getConnection().createStanzaCollectorAndSend(JingleS5BTransportManager.createProxyError(JingleS5BTransport.this));
|
||||||
} catch (SmackException.NotConnectedException | InterruptedException e1) {
|
} catch (SmackException.NotConnectedException | InterruptedException e1) {
|
||||||
LOGGER.log(Level.SEVERE, "Could not send proxy error: " + e, e);
|
LOGGER.log(Level.SEVERE, "Could not send proxy error.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -341,7 +341,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isProxy) {
|
if (isProxy) {
|
||||||
LOGGER.log(Level.INFO, "Send candidate-activate.");
|
LOGGER.log(Level.FINE, "Send candidate-activate.");
|
||||||
JingleElement candidateActivate = JingleS5BTransportManager.createCandidateActivated((JingleS5BTransport) nominated.getParent(), nominated);
|
JingleElement candidateActivate = JingleS5BTransportManager.createCandidateActivated((JingleS5BTransport) nominated.getParent(), nominated);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -354,20 +354,20 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGGER.log(Level.INFO, "Start transmission on " + nominated.getCandidateId());
|
LOGGER.log(Level.FINE, "Start transmission on " + nominated.getCandidateId());
|
||||||
this.bytestreamSession = new Socks5BytestreamSession(nominated.getSocket(), !isProxy);
|
this.bytestreamSession = new Socks5BytestreamSession(nominated.getSocket(), !isProxy);
|
||||||
callback.onTransportReady(this.bytestreamSession);
|
callback.onTransportReady(this.bytestreamSession);
|
||||||
|
|
||||||
}
|
}
|
||||||
//Our choice
|
//Our choice
|
||||||
else {
|
else {
|
||||||
LOGGER.log(Level.INFO, "Our choice, so their candidate was used.");
|
LOGGER.log(Level.FINE, "Our choice, so their candidate was used.");
|
||||||
if (!isProxy) {
|
if (!isProxy) {
|
||||||
LOGGER.log(Level.INFO, "Start transmission on " + nominated.getCandidateId());
|
LOGGER.log(Level.FINE, "Start transmission on " + nominated.getCandidateId());
|
||||||
this.bytestreamSession = new Socks5BytestreamSession(nominated.getSocket(), true);
|
this.bytestreamSession = new Socks5BytestreamSession(nominated.getSocket(), true);
|
||||||
callback.onTransportReady(this.bytestreamSession);
|
callback.onTransportReady(this.bytestreamSession);
|
||||||
} else {
|
} else {
|
||||||
LOGGER.log(Level.INFO, "Our choice was their external proxy. wait for candidate-activate.");
|
LOGGER.log(Level.FINE, "Our choice was their external proxy. wait for candidate-activate.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -419,7 +419,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
|
||||||
jingleManager.getConnection().sendStanza(JingleElement.createJingleErrorOutOfOrder(wrapping));
|
jingleManager.getConnection().sendStanza(JingleElement.createJingleErrorOutOfOrder(wrapping));
|
||||||
//jingleManager.getConnection().createStanzaCollectorAndSend(JingleElement.createJingleErrorOutOfOrder(wrapping));
|
//jingleManager.getConnection().createStanzaCollectorAndSend(JingleElement.createJingleErrorOutOfOrder(wrapping));
|
||||||
} catch (SmackException.NotConnectedException | InterruptedException e) {
|
} catch (SmackException.NotConnectedException | InterruptedException e) {
|
||||||
LOGGER.log(Level.SEVERE, "Could not respond to candidate-used transport-info: " + e, e);
|
LOGGER.log(Level.SEVERE, "Could not respond to candidate-used transport-info.", e);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -432,8 +432,9 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theirSelectedCandidate == null) {
|
if (theirSelectedCandidate == null) {
|
||||||
LOGGER.log(Level.SEVERE, "ILLEGAL CANDIDATE ID!!!");
|
LOGGER.log(Level.SEVERE, "Unknown candidateID.");
|
||||||
//TODO: Alert! Illegal candidateId!
|
//TODO: Alert! Illegal candidateId!
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
connectIfReady();
|
connectIfReady();
|
||||||
|
|
|
@ -103,12 +103,12 @@ public class JingleS5BTransportCandidate extends JingleTransportCandidate<Jingle
|
||||||
if (dstAddr == null) {
|
if (dstAddr == null) {
|
||||||
dstAddr = Socks5Utils.createDigest(transport.getStreamId(), transport.getParent().getParent().getPeer(), transport.getParent().getParent().getOurJid());
|
dstAddr = Socks5Utils.createDigest(transport.getStreamId(), transport.getParent().getParent().getPeer(), transport.getParent().getParent().getOurJid());
|
||||||
}
|
}
|
||||||
LOGGER.log(Level.INFO, "Connect to foreign candidate " + getCandidateId() + " using " + dstAddr);
|
LOGGER.log(Level.FINE, "Connect to foreign candidate " + getCandidateId() + " using " + dstAddr);
|
||||||
LOGGER.log(Level.INFO, getStreamHost().getAddress() + ":" + getStreamHost().getPort() + " " + getStreamHost().getJID().toString() + " " + getType());
|
LOGGER.log(Level.FINE, getStreamHost().getAddress() + ":" + getStreamHost().getPort() + " " + getStreamHost().getJID().toString() + " " + getType());
|
||||||
client = new Socks5Client(getStreamHost(), dstAddr);
|
client = new Socks5Client(getStreamHost(), dstAddr);
|
||||||
} else {
|
} else {
|
||||||
LOGGER.log(Level.INFO, "Connect to our candidate " + getCandidateId() + " using " + transport.getOurDstAddr());
|
LOGGER.log(Level.FINE, "Connect to our candidate " + getCandidateId() + " using " + transport.getOurDstAddr());
|
||||||
LOGGER.log(Level.INFO, getStreamHost().getAddress() + ":" + getStreamHost().getPort() + " " + getStreamHost().getJID().toString() + " " + getType());
|
LOGGER.log(Level.FINE, getStreamHost().getAddress() + ":" + getStreamHost().getPort() + " " + getStreamHost().getJID().toString() + " " + getType());
|
||||||
JingleContent content = transport.getParent();
|
JingleContent content = transport.getParent();
|
||||||
JingleSession session = content.getParent();
|
JingleSession session = content.getParent();
|
||||||
client = new Socks5ClientForInitiator(getStreamHost(), transport.getOurDstAddr(), session.getJingleManager().getConnection(), transport.getStreamId(), session.getPeer());
|
client = new Socks5ClientForInitiator(getStreamHost(), transport.getOurDstAddr(), session.getJingleManager().getConnection(), transport.getStreamId(), session.getPeer());
|
||||||
|
@ -117,7 +117,7 @@ public class JingleS5BTransportCandidate extends JingleTransportCandidate<Jingle
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
LOGGER.log(Level.INFO, "Unsupported candidate type: " + getType());
|
LOGGER.log(Level.FINE, "Unsupported candidate type: " + getType());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -276,7 +276,7 @@ public final class JingleS5BTransportManager extends Manager implements JingleTr
|
||||||
localStreamHosts = queryLocalStreamHosts();
|
localStreamHosts = queryLocalStreamHosts();
|
||||||
availableStreamHosts = queryServersStreamHosts();
|
availableStreamHosts = queryServersStreamHosts();
|
||||||
} catch (InterruptedException | SmackException.NoResponseException | SmackException.NotConnectedException | XMPPException.XMPPErrorException e) {
|
} catch (InterruptedException | SmackException.NoResponseException | SmackException.NotConnectedException | XMPPException.XMPPErrorException e) {
|
||||||
LOGGER.log(Level.WARNING, "Could not query available StreamHosts: " + e, e);
|
LOGGER.log(Level.WARNING, "Could not query available StreamHosts.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,6 @@ public class JingleTransportIntegrationTest extends AbstractSmackIntegrationTest
|
||||||
rTransport.establishIncomingBytestreamSession(rSession.getJingleManager().getConnection(), new JingleTransportCallback() {
|
rTransport.establishIncomingBytestreamSession(rSession.getJingleManager().getConnection(), new JingleTransportCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onTransportReady(final BytestreamSession bytestreamSession) {
|
public void onTransportReady(final BytestreamSession bytestreamSession) {
|
||||||
LOGGER.log(Level.INFO, "Receiving!");
|
|
||||||
Async.go(new Runnable() {
|
Async.go(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -128,11 +127,7 @@ public class JingleTransportIntegrationTest extends AbstractSmackIntegrationTest
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
LOGGER.log(Level.INFO, "Read " + r + " bytes (" + read + " of " + size + ")");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGGER.log(Level.INFO, "Success!");
|
|
||||||
|
|
||||||
bytestreamSession.getInputStream().close();
|
bytestreamSession.getInputStream().close();
|
||||||
recvPoint.signal();
|
recvPoint.signal();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -144,15 +139,13 @@ public class JingleTransportIntegrationTest extends AbstractSmackIntegrationTest
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTransportFailed(Exception e) {
|
public void onTransportFailed(Exception e) {
|
||||||
LOGGER.log(Level.SEVERE, e.toString());
|
recvPoint.signalFailure(e.toString());
|
||||||
recvPoint.signal();
|
|
||||||
}
|
}
|
||||||
}, rSession);
|
}, rSession);
|
||||||
|
|
||||||
sTransport.establishOutgoingBytestreamSession(sSession.getJingleManager().getConnection(), new JingleTransportCallback() {
|
sTransport.establishOutgoingBytestreamSession(sSession.getJingleManager().getConnection(), new JingleTransportCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onTransportReady(final BytestreamSession bytestreamSession) {
|
public void onTransportReady(final BytestreamSession bytestreamSession) {
|
||||||
LOGGER.log(Level.INFO, "Sending!");
|
|
||||||
Async.go(new Runnable() {
|
Async.go(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -164,7 +157,6 @@ public class JingleTransportIntegrationTest extends AbstractSmackIntegrationTest
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
fail(e.toString());
|
fail(e.toString());
|
||||||
}
|
}
|
||||||
LOGGER.log(Level.INFO, "Sending finished!");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,6 @@ import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import org.jivesoftware.smack.SmackException;
|
import org.jivesoftware.smack.SmackException;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
|
@ -83,12 +80,9 @@ public class JingleFileTransferIntegrationTest extends AbstractSmackIntegrationT
|
||||||
JingleFileTransferManager aftm = JingleFileTransferManager.getInstanceFor(conOne);
|
JingleFileTransferManager aftm = JingleFileTransferManager.getInstanceFor(conOne);
|
||||||
JingleFileTransferManager bftm = JingleFileTransferManager.getInstanceFor(conTwo);
|
JingleFileTransferManager bftm = JingleFileTransferManager.getInstanceFor(conTwo);
|
||||||
|
|
||||||
final ArrayList<Future<Void>> receiveFuture = new ArrayList<>(); //Uglaay
|
|
||||||
|
|
||||||
bftm.addIncomingFileOfferListener(new IncomingFileOfferListener() {
|
bftm.addIncomingFileOfferListener(new IncomingFileOfferListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onIncomingFileOffer(IncomingFileOfferController offer) {
|
public void onIncomingFileOffer(IncomingFileOfferController offer) {
|
||||||
LOGGER.log(Level.INFO, "INCOMING FILE TRANSFER!");
|
|
||||||
|
|
||||||
offer.addProgressListener(new ProgressListener() {
|
offer.addProgressListener(new ProgressListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -140,12 +134,10 @@ public class JingleFileTransferIntegrationTest extends AbstractSmackIntegrationT
|
||||||
fi = new FileInputStream(target);
|
fi = new FileInputStream(target);
|
||||||
fi.read(tBytes);
|
fi.read(tBytes);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.log(Level.SEVERE, "Could not read files.");
|
fail("Could not read files: " + e.toString() + " " + e.getMessage());
|
||||||
fail();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assertArrayEquals(sBytes, tBytes);
|
assertArrayEquals(sBytes, tBytes);
|
||||||
LOGGER.log(Level.INFO, "SUCCESSFULLY SENT AND RECEIVED");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import org.jivesoftware.smack.SmackException;
|
import org.jivesoftware.smack.SmackException;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
|
@ -97,8 +96,6 @@ public class JingleFileTransferTransportFallbackIntegrationTest extends Abstract
|
||||||
bftm.addIncomingFileOfferListener(new IncomingFileOfferListener() {
|
bftm.addIncomingFileOfferListener(new IncomingFileOfferListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onIncomingFileOffer(IncomingFileOfferController offer) {
|
public void onIncomingFileOffer(IncomingFileOfferController offer) {
|
||||||
LOGGER.log(Level.INFO, "INCOMING FILE TRANSFER!");
|
|
||||||
|
|
||||||
offer.addProgressListener(new ProgressListener() {
|
offer.addProgressListener(new ProgressListener() {
|
||||||
@Override
|
@Override
|
||||||
public void started() {
|
public void started() {
|
||||||
|
@ -149,12 +146,10 @@ public class JingleFileTransferTransportFallbackIntegrationTest extends Abstract
|
||||||
fi = new FileInputStream(target);
|
fi = new FileInputStream(target);
|
||||||
fi.read(tBytes);
|
fi.read(tBytes);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.log(Level.SEVERE, "Could not read files.");
|
fail("Could not read files: " + e.toString() + " " + e.getMessage());
|
||||||
fail();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assertArrayEquals(sBytes, tBytes);
|
assertArrayEquals(sBytes, tBytes);
|
||||||
LOGGER.log(Level.INFO, "SUCCESSFULLY SENT AND RECEIVED");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
|
Loading…
Reference in a new issue