Updated transport plugin API.

This commit is contained in:
akwizgran
2011-10-04 17:49:18 +01:00
parent 2d62b0ad67
commit 11a6858c46
5 changed files with 32 additions and 15 deletions

View File

@@ -0,0 +1,16 @@
package net.sf.briar.api.transport;
import java.util.Map;
public interface TransportCallback {
void setLocalTransports(Map<String, String> transports);
void setConfig(Map<String, String> config);
void showMessage(String message);
boolean showConfirmationMessage(String message);
int showChoice(String message, String[] choices);
}

View File

@@ -1,18 +1,14 @@
package net.sf.briar.api.transport.batch; package net.sf.briar.api.transport.batch;
import java.util.Map; import net.sf.briar.api.transport.TransportCallback;
/** /**
* An interface for receiving readers and writers created by a batch-mode * An interface for receiving readers and writers created by a batch-mode
* transport plugin. * transport plugin.
*/ */
public interface BatchTransportCallback { public interface BatchTransportCallback extends TransportCallback {
void readerCreated(BatchTransportReader r); void readerCreated(BatchTransportReader r);
void writerCreated(BatchTransportWriter w); void writerCreated(BatchTransportWriter w);
void setLocalTransports(Map<String, String> transports);
void setConfig(Map<String, String> config);
} }

View File

@@ -16,9 +16,14 @@ public interface BatchTransportWriter {
OutputStream getOutputStream(); OutputStream getOutputStream();
/** /**
* Closes the writer and disposes of any associated state. This method must * Finishes writing to the transport. This method should be called after
* be called even if the writer is not used, or if an exception is thrown * flushing and closing the output stream.
* while using the writer. */
void finish() throws IOException;
/**
* Disposes of any associated state. This method must be called even if the
* writer is not used, or if an exception is thrown while using the writer.
*/ */
void dispose() throws IOException; void dispose() throws IOException;
} }

View File

@@ -1,16 +1,12 @@
package net.sf.briar.api.transport.stream; package net.sf.briar.api.transport.stream;
import java.util.Map; import net.sf.briar.api.transport.TransportCallback;
/** /**
* An interface for receiving connections created by a stream-mode transport * An interface for receiving connections created by a stream-mode transport
* plugin. * plugin.
*/ */
public interface StreamTransportCallback { public interface StreamTransportCallback extends TransportCallback {
void connectionCreated(StreamTransportConnection c); void connectionCreated(StreamTransportConnection c);
void setLocalTransports(Map<String, String> transports);
void setConfig(Map<String, String> config);
} }

View File

@@ -23,6 +23,10 @@ class TestBatchTransportWriter implements BatchTransportWriter {
return out; return out;
} }
public void finish() throws IOException {
// Nothing to do
}
public void dispose() throws IOException { public void dispose() throws IOException {
// The output stream may have been left open // The output stream may have been left open
out.close(); out.close();