From 2a0022faeefc38a987e3ad55087f3dd45c35a9fb Mon Sep 17 00:00:00 2001 From: Alex Clayton Date: Fri, 5 Feb 2016 12:29:28 +0000 Subject: Finish porting S5BTransportSession Finish porting S5BTransportSession to Stroke (previously a lot of it had been commented out). To do so had to introduce a heirachy to the SOCKS5BytestreamSession classes (which were being used as type parameters for the Transport Session) and refactor some of the onByteSent signals to insure they were all of the same type (Integer). Also update PortingProgress.txt to update to give status of some of the porting files. Test-information: Ran unit tests they all still pass. Change-Id: I4295b3a8829c208e65f5a46d19c35090f8c55865 diff --git a/PortingProgress.txt b/PortingProgress.txt index 9b22cc6..97c4ac9 100644 --- a/PortingProgress.txt +++ b/PortingProgress.txt @@ -82,8 +82,9 @@ Entity: All files ported to 6ca201d0b48f4273e24dd7bff17c4a46eeaddf39 except for: -PayloadPersister -- Not Yet Ported! -GenericPayloadPersister -- Not Yet Ported! +Individual Comments: +PayloadPersister and GenericPayloadPersister implemented as +GenericPayloadPersister and GenericPayloadLoader. ----- EventLoop: @@ -96,8 +97,10 @@ FileTransfer: All files ported to 6ca201d0b48f4273e24dd7bff17c4a46eeaddf39 except for: Tests not yet ported. -Incoming and Outgoing Jingle File Transfer unimplemented due to multiple inheritance. -S5BTransportSession -- Incomplete. + +Individual Comments: +Incoming and Outgoing Jingle File Transfer have been implemented +slightly differently to swiften due to multipe inheritance. ----- IDN 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 extends TransportSession { +/** + * S5BTransportSession + * + * @param Type of {@link SOCKS5AbstractBytestreamSession} to use. + */ +public class S5BTransportSession 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 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 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 onFinished = new Signal1(); + public final Signal1 onBytesSent = new Signal1(); + // boost::signal 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 onSessionReady = new Signal1(); - public Signal1 onFinished = new Signal1(); - public Signal1 onBytesSent = new Signal1(); - //public boost::signal 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 onFinished = new Signal1(); - public Signal1 onBytesSent = new Signal1(); - // boost::signal 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 onBytesSent = new Signal1(); public final Signal1 onFinished = new Signal1(); } -- cgit v0.10.2-6-g49f6