diff options
Diffstat (limited to 'src/com')
5 files changed, 67 insertions, 22 deletions
diff --git a/src/com/isode/stroke/filetransfer/S5BTransportSession.java b/src/com/isode/stroke/filetransfer/S5BTransportSession.java index 768354f..4cb2a02 100644 --- a/src/com/isode/stroke/filetransfer/S5BTransportSession.java +++ b/src/com/isode/stroke/filetransfer/S5BTransportSession.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Isode Limited. + * Copyright (c) 2015-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -11,11 +11,20 @@ package com.isode.stroke.filetransfer; -import com.isode.stroke.signals.Signal1; import com.isode.stroke.signals.SignalConnection; -public class S5BTransportSession<T> extends TransportSession { +/** + * S5BTransportSession + * + * @param <T> Type of {@link SOCKS5AbstractBytestreamSession} to use. + */ +public class S5BTransportSession<T extends SOCKS5AbstractBytestreamSession> extends TransportSession { + /** + * Constructor for a read byte stream + * @param session byte stream session. Should not be {@code null}. + * @param readStream read byte stream. Should not be {@code null}. + */ public S5BTransportSession( T session, ReadBytestream readStream) { @@ -24,6 +33,11 @@ public class S5BTransportSession<T> extends TransportSession { initialize(); } + /** + * Constructor for a write byte stream + * @param session byte stream session. Should not be {@code null}. + * @param writeStream write byte stream. Should not be {@code null} + */ public S5BTransportSession( T session, WriteBytestream writeStream) { @@ -34,20 +48,20 @@ public class S5BTransportSession<T> extends TransportSession { public void start() { if (readStream != null) { - //session.startSending(readStream); + session.startSending(readStream); } else { - //session.startReceiving(writeStream); + session.startReceiving(writeStream); } } public void stop() { - //session.stop(); + session.stop(); } private void initialize() { - //finishedConnection = session.onFinished.connect(onFinished); - //bytesSentConnection = session.onBytesSent.connect(onBytesSent); + finishedConnection = session.onFinished.connect(onFinished); + bytesSentConnection = session.onBytesSent.connect(onBytesSent); } private T session; diff --git a/src/com/isode/stroke/filetransfer/SOCKS5AbstractBytestreamSession.java b/src/com/isode/stroke/filetransfer/SOCKS5AbstractBytestreamSession.java new file mode 100644 index 0000000..2f64857 --- /dev/null +++ b/src/com/isode/stroke/filetransfer/SOCKS5AbstractBytestreamSession.java @@ -0,0 +1,36 @@ +/* Copyright (c) 2016, Isode Limited, London, England. + * All rights reserved. + * + * Acquisition and use of this software and related materials for any + * purpose requires a written license agreement from Isode Limited, + * or a written license from an organisation licensed by Isode Limited + * to grant such a license. + * + */ +package com.isode.stroke.filetransfer; + +import com.isode.stroke.signals.Signal1; + +/** + * + */ +public abstract class SOCKS5AbstractBytestreamSession { + + /** + * Constructor + */ + public SOCKS5AbstractBytestreamSession() { + // Empty Constructor + } + + abstract public void startReceiving(WriteBytestream writeStream); + + abstract public void startSending(ReadBytestream stream); + + abstract public void stop(); + + public final Signal1<FileTransferError> onFinished = new Signal1<FileTransferError>(); + public final Signal1<Integer> onBytesSent = new Signal1<Integer>(); + // boost::signal<void (unsigned long long)> onBytesReceived; + +} diff --git a/src/com/isode/stroke/filetransfer/SOCKS5BytestreamClientSession.java b/src/com/isode/stroke/filetransfer/SOCKS5BytestreamClientSession.java index 0144bcb..3e51b5f 100644 --- a/src/com/isode/stroke/filetransfer/SOCKS5BytestreamClientSession.java +++ b/src/com/isode/stroke/filetransfer/SOCKS5BytestreamClientSession.java @@ -4,7 +4,7 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ /* - * Copyright (c) 2015 Isode Limited. + * Copyright (c) 2015 - 2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -33,7 +33,7 @@ import java.util.logging.Logger; * A session which has been connected to a SOCKS5 server (requester). * */ -public class SOCKS5BytestreamClientSession { +public class SOCKS5BytestreamClientSession extends SOCKS5AbstractBytestreamSession { public enum State { Initial(0), @@ -145,10 +145,6 @@ public class SOCKS5BytestreamClientSession { public Signal1<Boolean /*error*/> onSessionReady = new Signal1<Boolean>(); - public Signal1<FileTransferError> onFinished = new Signal1<FileTransferError>(); - public Signal1<Integer> onBytesSent = new Signal1<Integer>(); - //public boost::signal<void (size_t)> onBytesReceived; - private void process() { logger_.fine("unprocessedData.size(): " + unprocessedData.getSize() + "\n"); ByteArray bndAddress = new ByteArray(); diff --git a/src/com/isode/stroke/filetransfer/SOCKS5BytestreamServerSession.java b/src/com/isode/stroke/filetransfer/SOCKS5BytestreamServerSession.java index cb09ad9..8452e36 100644 --- a/src/com/isode/stroke/filetransfer/SOCKS5BytestreamServerSession.java +++ b/src/com/isode/stroke/filetransfer/SOCKS5BytestreamServerSession.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -20,9 +20,10 @@ import com.isode.stroke.signals.Signal1; import com.isode.stroke.signals.Signal; import com.isode.stroke.signals.Slot; import com.isode.stroke.signals.Slot1; + import java.util.logging.Logger; -public class SOCKS5BytestreamServerSession { +public class SOCKS5BytestreamServerSession extends SOCKS5AbstractBytestreamSession { private Connection connection; private SOCKS5BytestreamRegistry bytestreams; @@ -116,9 +117,7 @@ public class SOCKS5BytestreamServerSession { return connection.getLocalAddress(); } - public Signal1<FileTransferError> onFinished = new Signal1<FileTransferError>(); - public Signal1<Long> onBytesSent = new Signal1<Long>(); - // boost::signal<void (unsigned long long)> onBytesReceived; + public String getStreamID() { return streamID; @@ -228,7 +227,7 @@ public class SOCKS5BytestreamServerSession { SafeByteArray dataToSend = new SafeByteArray(readBytestream.read((chunkSize))); if (!dataToSend.isEmpty()) { connection.write(dataToSend); - onBytesSent.emit((long)dataToSend.getSize()); + onBytesSent.emit(dataToSend.getSize()); waitingForData = false; } else { diff --git a/src/com/isode/stroke/filetransfer/TransportSession.java b/src/com/isode/stroke/filetransfer/TransportSession.java index b0e101d..5d07a1b 100644 --- a/src/com/isode/stroke/filetransfer/TransportSession.java +++ b/src/com/isode/stroke/filetransfer/TransportSession.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Isode Limited. + * Copyright (c) 2013-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -17,7 +17,7 @@ public abstract class TransportSession { public abstract void start(); public abstract void stop(); - + public final Signal1<Integer> onBytesSent = new Signal1<Integer>(); public final Signal1<FileTransferError> onFinished = new Signal1<FileTransferError>(); } |