1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-14 16:22:07 +01:00

Fix ugly code

This commit is contained in:
vanitasvitae 2017-08-28 11:20:37 +02:00
parent d088233153
commit d1bc94bfaf
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
23 changed files with 122 additions and 158 deletions

View file

@ -168,7 +168,7 @@ public final class JingleFileTransferManager extends Manager implements JingleDe
}
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().getSecurity() != null ? offer.getParent().getSecurity().getNamespace() : "") + "]");
for (IncomingFileOfferListener l : offerListeners) {

View file

@ -19,14 +19,10 @@ package org.jivesoftware.smackx.jingle_filetransfer.component;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPConnection;
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_filetransfer.controller.JingleFileTransferController;
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 {
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 = NAMESPACE_V5;
@ -81,25 +75,6 @@ public abstract class JingleFileTransfer extends JingleDescription<JingleFileTra
@Override
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();
state = State.cancelled;
}

View file

@ -75,10 +75,10 @@ public class JingleIncomingFileOffer extends AbstractJingleFileOffer implements
MessageDigest digest = null;
if (hashElement != null) {
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;
try {
@ -97,7 +97,7 @@ public class JingleIncomingFileOffer extends AbstractJingleFileOffer implements
}
target.write(bufbuf, 0, 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());
@ -105,26 +105,26 @@ public class JingleIncomingFileOffer extends AbstractJingleFileOffer implements
break;
}
}
LOGGER.log(Level.INFO, "Reading/Writing finished.");
LOGGER.log(Level.FINE, "Reading/Writing finished.");
} 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 {
state = State.ended;
if (inputStream != null) {
try {
inputStream.close();
LOGGER.log(Level.INFO, "CipherInputStream closed.");
LOGGER.log(Level.FINER, "CipherInputStream closed.");
} 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) {
try {
target.close();
LOGGER.log(Level.INFO, "FileOutputStream closed.");
LOGGER.log(Level.FINER, "FileOutputStream closed.");
} 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)) {
LOGGER.log(Level.WARNING, "CHECKSUM MISMATCH!");
} else {
LOGGER.log(Level.INFO, "CHECKSUM MATCHED :)");
LOGGER.log(Level.FINE, "CHECKSUM MATCHED :)");
}
}
notifyProgressListenersTerminated(JingleReasonElement.Reason.success);

View file

@ -92,13 +92,13 @@ public class JingleOutgoingFileOffer extends AbstractJingleFileOffer implements
outputStream.close();
} catch (IOException e) {
LOGGER.log(Level.SEVERE, "Exception while sending file: " + e, e);
LOGGER.log(Level.SEVERE, "Exception while sending file.", e);
} finally {
state = State.ended;
try {
source.close();
} catch (IOException e) {
LOGGER.log(Level.SEVERE, "Could not close FileInputStream: " + e, e);
LOGGER.log(Level.SEVERE, "Could not close FileInputStream.", e);
}
}

View file

@ -36,7 +36,7 @@ import org.xmlpull.v1.XmlPullParser;
*/
public class ChecksumProvider extends ExtensionElementProvider<ChecksumElement> {
private static HashElementProvider hashProvider = new HashElementProvider();
private static final HashElementProvider hashProvider = new HashElementProvider();
@Override
public ChecksumElement parse(XmlPullParser parser, int initialDepth) throws Exception {

View file

@ -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.Range;
import org.jxmpp.util.XmppDateTime;
import org.xmlpull.v1.XmlPullParser;
/**
@ -54,8 +55,7 @@ public class JingleFileTransferProvider
if (tag == START_TAG) {
switch (elem) {
case JingleFileTransferChildElement.ELEM_DATE:
//builder.setDate(XmppDateTime.parseXEP0082Date(parser.nextText()));
parser.nextText();
builder.setDate(XmppDateTime.parseXEP0082Date(parser.nextText()));
break;
case JingleFileTransferChildElement.ELEM_DESC:

View file

@ -136,7 +136,7 @@ public final class JingleManager extends Manager {
if (jingle.getAction() == JingleAction.session_initiate) {
//fresh. phew!
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);
jingleSessions.put(fullJidAndSessionId, session);
} catch (UnsupportedDescriptionException e) {
@ -306,7 +306,7 @@ public final class JingleManager extends Manager {
/**
* Add a {@link JingleDescriptionManager}.
* @param manager
* @param manager manager
*/
public void addJingleDescriptionManager(JingleDescriptionManager manager) {
descriptionManagers.put(manager.getNamespace(), manager);
@ -323,7 +323,7 @@ public final class JingleManager extends Manager {
/**
* Add a {@link JingleTransportManager}.
* @param manager
* @param manager manager
*/
public void addJingleTransportManager(JingleTransportManager manager) {
transportManagers.put(manager.getNamespace(), manager);
@ -340,7 +340,7 @@ public final class JingleManager extends Manager {
/**
* Add a {@link JingleSecurityManager}.
* @param manager
* @param manager manager
*/
public void addJingleSecurityManager(JingleSecurityManager manager) {
securityManagers.put(manager.getNamespace(), manager);

View file

@ -182,6 +182,7 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
* @param connection 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);
}
@ -192,7 +193,7 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
* @return result.
*/
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;
for (JingleContentElement c : request.getContents()) {
if (c.getName().equals(getName())) {
@ -310,9 +311,10 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
*/
private IQ handleTransportReject(JingleElement request, final XMPPConnection connection) {
if (pendingReplacingTransport == null) {
// TODO: Throw other exception?
throw new AssertionError("We didn't try to replace the transport.");
LOGGER.log(Level.WARNING, "Received transport-reject, but apparently we did not try to replace the transport.");
return JingleElement.createJingleErrorOutOfOrder(request);
}
Async.go(new Runnable() {
@Override
public void run() {
@ -321,10 +323,11 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
try {
replaceTransport(transportBlacklist, connection);
} 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);
}
@ -343,9 +346,11 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
@Override
public void run() {
try {
connection.createStanzaCollectorAndSend(JingleElement.createJingleErrorTieBreak(request)).nextResultOrThrow();
} catch (SmackException.NoResponseException | SmackException.NotConnectedException | InterruptedException | XMPPException.XMPPErrorException e) {
LOGGER.log(Level.SEVERE, "Could not send tie-break: " + e, e);
connection.createStanzaCollectorAndSend(JingleElement.createJingleErrorTieBreak(request))
.nextResultOrThrow();
} 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() {
@Override
public void run() {
JingleElement reject = JingleElement.createTransportReject(session.getOurJid(),
session.getPeer(), session.getSessionId(), getCreator(), getName(), transportElement);
try {
getParent().getJingleManager().getConnection().createStanzaCollectorAndSend(JingleElement.createTransportReject(session.getOurJid(), session.getPeer(), session.getSessionId(), getCreator(), getName(), transportElement));
} catch (SmackException.NotConnectedException | InterruptedException e) {
LOGGER.log(Level.SEVERE, "Could not send transport-reject: " + e, e);
connection.createStanzaCollectorAndSend(reject).nextResultOrThrow();
} catch (SmackException.NotConnectedException | InterruptedException |
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() {
@Override
public void run() {
JingleElement accept = JingleElement.createTransportAccept(session.getOurJid(), session.getPeer(), session.getSessionId(), getCreator(), getName(), transport.getElement());
try {
getParent().getJingleManager().getConnection().createStanzaCollectorAndSend(JingleElement.createTransportAccept(session.getOurJid(), session.getPeer(), session.getSessionId(), getCreator(), getName(), transport.getElement()));
} catch (SmackException.NotConnectedException | InterruptedException e) {
LOGGER.log(Level.SEVERE, "Could not send transport-accept: " + e, e);
getParent().getJingleManager().getConnection().createStanzaCollectorAndSend(accept).nextResultOrThrow();
} catch (SmackException.NotConnectedException | InterruptedException | XMPPException.XMPPErrorException | SmackException.NoResponseException e) {
LOGGER.log(Level.SEVERE, "Could not send transport-accept.", e);
}
}
});
@ -579,17 +588,17 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
public void run() {
try {
if (isReceiving()) {
LOGGER.log(Level.INFO, "Establish incoming bytestream.");
LOGGER.log(Level.FINE, "Establish incoming bytestream.");
getTransport().establishIncomingBytestreamSession(connection, JingleContent.this, getParent());
} else if (isSending()) {
LOGGER.log(Level.INFO, "Establish outgoing bytestream.");
LOGGER.log(Level.FINE, "Establish outgoing bytestream.");
getTransport().establishOutgoingBytestreamSession(connection, JingleContent.this, getParent());
} 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());
}
} 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
public void onTransportReady(BytestreamSession bytestreamSession) {
LOGGER.log(Level.INFO, "TransportReady: " + (isReceiving() ? "Receive" : "Send"));
LOGGER.log(Level.FINE, "TransportReady: " + (isReceiving() ? "Receive" : "Send"));
if (bytestreamSession == null) {
throw new AssertionError("bytestreamSession MUST NOT be null at this point.");
}
if (security != null) {
if (isReceiving()) {
LOGGER.log(Level.INFO, "Decrypt incoming Bytestream.");
LOGGER.log(Level.FINE, "Decrypt incoming Bytestream.");
getSecurity().decryptIncomingBytestream(bytestreamSession, this);
} else if (isSending()) {
LOGGER.log(Level.INFO, "Encrypt outgoing Bytestream.");
LOGGER.log(Level.FINE, "Encrypt outgoing Bytestream.");
getSecurity().encryptOutgoingBytestream(bytestreamSession, this);
}
} else {
@ -625,7 +634,7 @@ public class JingleContent implements JingleTransportCallback, JingleSecurityCal
try {
replaceTransport(getTransportBlacklist(), getParent().getJingleManager().getConnection());
} 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
public void onSecurityFailed(Exception e) {
LOGGER.log(Level.SEVERE, "Security failed: " + e, e);
LOGGER.log(Level.SEVERE, "Security failed.", e);
}
/**

View file

@ -163,7 +163,7 @@ public class JingleSession {
* @throws 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) {
throw new IllegalStateException("Session is not in pending state.");
}
@ -233,17 +233,6 @@ public class JingleSession {
terminateSession(JingleReasonElement.Reason.success);
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) {
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;
}
@ -261,10 +251,13 @@ public class JingleSession {
terminateSession(JingleReasonElement.Reason.cancel);
jingleManager.removeSession(this);
} else {
JingleElement cancel = JingleElement.createSessionTerminateContentCancel(
getPeer(), getSessionId(), jingleContent.getCreator(), jingleContent.getName());
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);
jingleManager.getConnection().createStanzaCollectorAndSend(cancel).nextResultOrThrow();
} catch (SmackException.NotConnectedException | InterruptedException | XMPPException.XMPPErrorException |
SmackException.NoResponseException e) {
LOGGER.log(Level.SEVERE, "Could not send content-cancel.", e);
}
contents.remove(jingleContent.getName());
}
@ -275,10 +268,11 @@ public class JingleSession {
* @param reason reason of termination.
*/
public void terminateSession(JingleReasonElement.Reason reason) {
JingleElement terminate = JingleElement.createSessionTerminate(getPeer(), getSessionId(), reason);
try {
jingleManager.getConnection().createStanzaCollectorAndSend(JingleElement.createSessionTerminate(getPeer(), getSessionId(), reason));
jingleManager.getConnection().sendStanza(terminate);
} 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;
jingleManager.removeSession(this);
@ -360,10 +354,13 @@ public class JingleSession {
if (descriptionManager == null) {
LOGGER.log(Level.WARNING, "Unsupported description type: " + description.getNamespace());
JingleElement terminate = JingleElement.createSessionTerminate(getPeer(), getSessionId(),
JingleReasonElement.Reason.unsupported_applications);
try {
jingleManager.getConnection().createStanzaCollectorAndSend(JingleElement.createSessionTerminate(getPeer(), getSessionId(), JingleReasonElement.Reason.unsupported_applications));
} catch (SmackException.NotConnectedException | InterruptedException e) {
LOGGER.log(Level.SEVERE, "Could not send session-terminate: " + e, e);
jingleManager.getConnection().createStanzaCollectorAndSend(terminate).nextResultOrThrow();
} catch (SmackException.NotConnectedException | InterruptedException | XMPPException.XMPPErrorException |
SmackException.NoResponseException e) {
LOGGER.log(Level.SEVERE, "Could not send session-terminate.", e);
}
} else {
@ -440,7 +437,8 @@ public class JingleSession {
private IQ handleContentAdd(JingleElement 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) {
throw new AssertionError("DescriptionManager is null: " + proposed.getDescription().getNamespace());
@ -493,26 +491,6 @@ public class JingleSession {
*/
private IQ handleContentRemove(final JingleElement request) {
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);
*/
}
/**

View file

@ -20,6 +20,8 @@ import org.jivesoftware.smack.packet.NamedElement;
/**
* An element found usually in 'description' elements.
* <pre> {@code
*
* <jingle>
* <content>
* <description>
@ -29,7 +31,6 @@ import org.jivesoftware.smack.packet.NamedElement;
* <security/>
* </content>
* </jingle>
*
*/
public abstract class JingleContentDescriptionChildElement implements NamedElement {

View file

@ -26,6 +26,8 @@ import org.jivesoftware.smackx.jingle.component.JingleDescription;
/**
* {@link ExtensionElement} representing a {@link JingleDescription}.
* <pre> {@code
*
* <jingle>
* <content>
* <description/> <- This element is us.
@ -34,6 +36,7 @@ import org.jivesoftware.smackx.jingle.component.JingleDescription;
* </content>
* </jingle>
*
* } </pre>
*/
public abstract class JingleContentDescriptionElement implements ExtensionElement {

View file

@ -24,11 +24,15 @@ import org.jivesoftware.smackx.jingle.component.JingleContent;
/**
* {@link NamedElement} representing a {@link JingleContent}.
* <pre> {@code
*
* <jingle>
* <content> <- Me.
* ...
* </content>
* </jingle>
*
* } </pre>
*/
public final class JingleContentElement implements NamedElement {

View file

@ -21,6 +21,8 @@ import org.jivesoftware.smackx.jingle.component.JingleSecurity;
/**
* {@link ExtensionElement} representing a {@link JingleSecurity}.
* <pre> {@code
*
* <jingle>
* <content>
* <description/>
@ -28,6 +30,9 @@ import org.jivesoftware.smackx.jingle.component.JingleSecurity;
* <security/> <- That's me :)
* </content>
* </jingle>
*
* } </pre>
*
*/
public abstract class JingleContentSecurityElement implements ExtensionElement {

View file

@ -21,6 +21,8 @@ import org.jivesoftware.smackx.jingle.component.JingleTransportCandidate;
/**
* {@link NamedElement} representing a {@link JingleTransportCandidate}
*
* <pre> {@code
* <jingle>
* <content>
* <description/>
@ -30,6 +32,7 @@ import org.jivesoftware.smackx.jingle.component.JingleTransportCandidate;
* </transport>
* </content>
* </jingle>
* } </pre>
*
*/
public abstract class JingleContentTransportCandidateElement implements NamedElement {

View file

@ -25,6 +25,8 @@ import org.jivesoftware.smackx.jingle.component.JingleTransport;
/**
* {@link ExtensionElement} representing a {@link JingleTransport}.
*
* <pre> {@code
* <jingle>
* <content>
* <description/>
@ -32,6 +34,7 @@ import org.jivesoftware.smackx.jingle.component.JingleTransport;
* <security/>
* </content>
* </jingle>
* } </pre>
*
*/
public abstract class JingleContentTransportElement implements ExtensionElement {

View file

@ -22,6 +22,8 @@ import org.jivesoftware.smack.packet.NamedElement;
* Abstract JingleContentTransportInfo element.
* 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.
*
* <pre> {@code
* <jingle>
* <content>
* <description/>
@ -31,6 +33,7 @@ import org.jivesoftware.smack.packet.NamedElement;
* <security/>
* </content>
* </jingle>
* } </pre>
*/
public abstract class JingleContentTransportInfoElement implements NamedElement {

View file

@ -88,11 +88,11 @@ public class JingleIBBTransport extends JingleTransport<JingleIBBTransportElemen
@Override
public void establishIncomingBytestreamSession(final XMPPConnection connection, final JingleTransportCallback callback, final JingleSession session) {
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() {
@Override
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())
&& request.getSessionID().equals(getStreamId())) {

View file

@ -219,7 +219,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
@Override
public void establishIncomingBytestreamSession(XMPPConnection connection, JingleTransportCallback callback, JingleSession session)
throws SmackException.NotConnectedException, InterruptedException {
LOGGER.log(Level.INFO, "Establishing incoming bytestream.");
LOGGER.log(Level.FINE, "Establishing incoming bytestream.");
this.callback = callback;
establishBytestreamSession(connection);
}
@ -227,7 +227,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
@Override
public void establishOutgoingBytestreamSession(XMPPConnection connection, JingleTransportCallback callback, JingleSession session)
throws SmackException.NotConnectedException, InterruptedException {
LOGGER.log(Level.INFO, "Establishing outgoing bytestream.");
LOGGER.log(Level.FINE, "Establishing outgoing bytestream.");
this.callback = callback;
establishBytestreamSession(connection);
}
@ -255,7 +255,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
private JingleS5BTransportCandidate connectToCandidates(int timeout) {
if (getTheirCandidates().size() == 0) {
LOGGER.log(Level.INFO, "They provided 0 candidates.");
LOGGER.log(Level.FINE, "They provided 0 candidates.");
return CANDIDATE_FAILURE;
}
@ -265,7 +265,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
try {
return candidate.connect(_timeout, true);
} 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) {
// 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;
}
if (ourSelectedCandidate == CANDIDATE_FAILURE && theirSelectedCandidate == CANDIDATE_FAILURE) {
LOGGER.log(Level.INFO, "Failure.");
LOGGER.log(Level.FINE, "Failure.");
callback.onTransportFailed(new FailedTransportException(null));
return;
}
LOGGER.log(Level.INFO, (session.isInitiator() ? "Initiator" : "Responder") + " is ready.");
LOGGER.log(Level.FINE, (session.isInitiator() ? "Initiator" : "Responder") + " is ready.");
//Determine nominated candidate.
JingleS5BTransportCandidate nominated;
@ -318,7 +318,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
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 {
nominated = nominated.connect(MAX_TIMEOUT, false);
@ -331,7 +331,7 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
try {
session.getJingleManager().getConnection().createStanzaCollectorAndSend(JingleS5BTransportManager.createProxyError(JingleS5BTransport.this));
} 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) {
LOGGER.log(Level.INFO, "Send candidate-activate.");
LOGGER.log(Level.FINE, "Send candidate-activate.");
JingleElement candidateActivate = JingleS5BTransportManager.createCandidateActivated((JingleS5BTransport) nominated.getParent(), nominated);
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);
callback.onTransportReady(this.bytestreamSession);
}
//Our choice
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) {
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);
callback.onTransportReady(this.bytestreamSession);
} 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().createStanzaCollectorAndSend(JingleElement.createJingleErrorOutOfOrder(wrapping));
} 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;
}
@ -432,8 +432,9 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
}
if (theirSelectedCandidate == null) {
LOGGER.log(Level.SEVERE, "ILLEGAL CANDIDATE ID!!!");
LOGGER.log(Level.SEVERE, "Unknown candidateID.");
//TODO: Alert! Illegal candidateId!
return;
}
connectIfReady();

View file

@ -103,12 +103,12 @@ public class JingleS5BTransportCandidate extends JingleTransportCandidate<Jingle
if (dstAddr == null) {
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.INFO, getStreamHost().getAddress() + ":" + getStreamHost().getPort() + " " + getStreamHost().getJID().toString() + " " + getType());
LOGGER.log(Level.FINE, "Connect to foreign candidate " + getCandidateId() + " using " + dstAddr);
LOGGER.log(Level.FINE, getStreamHost().getAddress() + ":" + getStreamHost().getPort() + " " + getStreamHost().getJID().toString() + " " + getType());
client = new Socks5Client(getStreamHost(), dstAddr);
} else {
LOGGER.log(Level.INFO, "Connect to our candidate " + getCandidateId() + " using " + transport.getOurDstAddr());
LOGGER.log(Level.INFO, getStreamHost().getAddress() + ":" + getStreamHost().getPort() + " " + getStreamHost().getJID().toString() + " " + getType());
LOGGER.log(Level.FINE, "Connect to our candidate " + getCandidateId() + " using " + transport.getOurDstAddr());
LOGGER.log(Level.FINE, getStreamHost().getAddress() + ":" + getStreamHost().getPort() + " " + getStreamHost().getJID().toString() + " " + getType());
JingleContent content = transport.getParent();
JingleSession session = content.getParent();
client = new Socks5ClientForInitiator(getStreamHost(), transport.getOurDstAddr(), session.getJingleManager().getConnection(), transport.getStreamId(), session.getPeer());
@ -117,7 +117,7 @@ public class JingleS5BTransportCandidate extends JingleTransportCandidate<Jingle
break;
default:
LOGGER.log(Level.INFO, "Unsupported candidate type: " + getType());
LOGGER.log(Level.FINE, "Unsupported candidate type: " + getType());
break;
}

View file

@ -276,7 +276,7 @@ public final class JingleS5BTransportManager extends Manager implements JingleTr
localStreamHosts = queryLocalStreamHosts();
availableStreamHosts = queryServersStreamHosts();
} 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);
}
}
}

View file

@ -111,7 +111,6 @@ public class JingleTransportIntegrationTest extends AbstractSmackIntegrationTest
rTransport.establishIncomingBytestreamSession(rSession.getJingleManager().getConnection(), new JingleTransportCallback() {
@Override
public void onTransportReady(final BytestreamSession bytestreamSession) {
LOGGER.log(Level.INFO, "Receiving!");
Async.go(new Runnable() {
@Override
public void run() {
@ -128,11 +127,7 @@ public class JingleTransportIntegrationTest extends AbstractSmackIntegrationTest
} else {
break;
}
LOGGER.log(Level.INFO, "Read " + r + " bytes (" + read + " of " + size + ")");
}
LOGGER.log(Level.INFO, "Success!");
bytestreamSession.getInputStream().close();
recvPoint.signal();
} catch (IOException e) {
@ -144,15 +139,13 @@ public class JingleTransportIntegrationTest extends AbstractSmackIntegrationTest
@Override
public void onTransportFailed(Exception e) {
LOGGER.log(Level.SEVERE, e.toString());
recvPoint.signal();
recvPoint.signalFailure(e.toString());
}
}, rSession);
sTransport.establishOutgoingBytestreamSession(sSession.getJingleManager().getConnection(), new JingleTransportCallback() {
@Override
public void onTransportReady(final BytestreamSession bytestreamSession) {
LOGGER.log(Level.INFO, "Sending!");
Async.go(new Runnable() {
@Override
public void run() {
@ -164,7 +157,6 @@ public class JingleTransportIntegrationTest extends AbstractSmackIntegrationTest
} catch (IOException e) {
fail(e.toString());
}
LOGGER.log(Level.INFO, "Sending finished!");
}
});
}

View file

@ -23,9 +23,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
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.XMPPException;
@ -83,12 +80,9 @@ public class JingleFileTransferIntegrationTest extends AbstractSmackIntegrationT
JingleFileTransferManager aftm = JingleFileTransferManager.getInstanceFor(conOne);
JingleFileTransferManager bftm = JingleFileTransferManager.getInstanceFor(conTwo);
final ArrayList<Future<Void>> receiveFuture = new ArrayList<>(); //Uglaay
bftm.addIncomingFileOfferListener(new IncomingFileOfferListener() {
@Override
public void onIncomingFileOffer(IncomingFileOfferController offer) {
LOGGER.log(Level.INFO, "INCOMING FILE TRANSFER!");
offer.addProgressListener(new ProgressListener() {
@Override
@ -140,12 +134,10 @@ public class JingleFileTransferIntegrationTest extends AbstractSmackIntegrationT
fi = new FileInputStream(target);
fi.read(tBytes);
} catch (IOException e) {
LOGGER.log(Level.SEVERE, "Could not read files.");
fail();
fail("Could not read files: " + e.toString() + " " + e.getMessage());
}
assertArrayEquals(sBytes, tBytes);
LOGGER.log(Level.INFO, "SUCCESSFULLY SENT AND RECEIVED");
}

View file

@ -23,7 +23,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.logging.Level;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
@ -97,8 +96,6 @@ public class JingleFileTransferTransportFallbackIntegrationTest extends Abstract
bftm.addIncomingFileOfferListener(new IncomingFileOfferListener() {
@Override
public void onIncomingFileOffer(IncomingFileOfferController offer) {
LOGGER.log(Level.INFO, "INCOMING FILE TRANSFER!");
offer.addProgressListener(new ProgressListener() {
@Override
public void started() {
@ -149,12 +146,10 @@ public class JingleFileTransferTransportFallbackIntegrationTest extends Abstract
fi = new FileInputStream(target);
fi.read(tBytes);
} catch (IOException e) {
LOGGER.log(Level.SEVERE, "Could not read files.");
fail();
fail("Could not read files: " + e.toString() + " " + e.getMessage());
}
assertArrayEquals(sBytes, tBytes);
LOGGER.log(Level.INFO, "SUCCESSFULLY SENT AND RECEIVED");
}
@After