Changed the root package from net.sf.briar to org.briarproject.

This commit is contained in:
akwizgran
2014-01-08 16:18:30 +00:00
parent dce70f487c
commit 832476412c
427 changed files with 2507 additions and 2507 deletions

View File

@@ -0,0 +1,47 @@
package org.briarproject.api.plugins;
import java.io.IOException;
import java.util.Collection;
import org.briarproject.api.ContactId;
import org.briarproject.api.TransportId;
public interface Plugin {
/** Returns the plugin's transport identifier. */
TransportId getId();
/** Returns a label for looking up the plugin's translated name. */
String getName();
/** Returns the transport's maximum frame length in bytes. */
int getMaxFrameLength();
/** Returns the transport's maximum latency in milliseconds. */
long getMaxLatency();
/** Starts the plugin and returns true if it started successfully. */
boolean start() throws IOException;
/** Stops the plugin. */
void stop() throws IOException;
/**
* Returns true if the plugin's {@link #poll(Collection)} method should be
* called periodically to attempt to establish connections.
*/
boolean shouldPoll();
/**
* Returns the desired interval in milliseconds between calls to the
* plugin's {@link #poll(Collection)} method.
*/
long getPollingInterval();
/**
* Attempts to establish connections to contacts, passing any created
* connections to the callback. To avoid creating redundant connections,
* the plugin may exclude the given contacts from polling.
*/
void poll(Collection<ContactId> connected);
}

View File

@@ -0,0 +1,52 @@
package org.briarproject.api.plugins;
import java.util.Map;
import org.briarproject.api.ContactId;
import org.briarproject.api.TransportConfig;
import org.briarproject.api.TransportProperties;
/**
* An interface through which a transport plugin interacts with the rest of
* the application.
*/
public interface PluginCallback {
/** Returns the plugin's configuration. */
TransportConfig getConfig();
/** Returns the plugin's local transport properties. */
TransportProperties getLocalProperties();
/** Returns the plugin's remote transport properties. */
Map<ContactId, TransportProperties> getRemoteProperties();
/** Merges the given configuration with the plugin's configuration. */
void mergeConfig(TransportConfig c);
/**
* Merges the given properties with the plugin's local transport properties.
*/
void mergeLocalProperties(TransportProperties p);
/**
* Presents the user with a choice among two or more named options and
* returns the user's response. The message may consist of a translatable
* format string and arguments.
* @return an index into the array of options indicating the user's choice,
* or -1 if the user cancelled the choice.
*/
int showChoice(String[] options, String... message);
/**
* Asks the user to confirm an action and returns the user's response. The
* message may consist of a translatable format string and arguments.
*/
boolean showConfirmationMessage(String... message);
/**
* Shows a message to the user. The message may consist of a translatable
* format string and arguments.
*/
void showMessage(String... message);
}

View File

@@ -0,0 +1,17 @@
package org.briarproject.api.plugins;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import com.google.inject.BindingAnnotation;
/** Annotation for injecting the executor used by transport plugins. */
@BindingAnnotation
@Target({ FIELD, METHOD, PARAMETER })
@Retention(RUNTIME)
public @interface PluginExecutor {}

View File

@@ -0,0 +1,16 @@
package org.briarproject.api.plugins;
import java.util.Collection;
import org.briarproject.api.lifecycle.Service;
import org.briarproject.api.plugins.duplex.DuplexPlugin;
/**
* Responsible for starting transport plugins at startup, stopping them at
* shutdown, and providing access to plugins for exchanging invitations.
*/
public interface PluginManager extends Service {
/** Returns any running duplex plugins that support invitations. */
Collection<DuplexPlugin> getInvitationPlugins();
}

View File

@@ -0,0 +1,27 @@
package org.briarproject.api.plugins.duplex;
import org.briarproject.api.ContactId;
import org.briarproject.api.crypto.PseudoRandom;
import org.briarproject.api.plugins.Plugin;
/** An interface for transport plugins that support duplex communication. */
public interface DuplexPlugin extends Plugin {
/**
* Attempts to create and return a connection to the given contact using
* the current transport and configuration properties. Returns null if a
* connection could not be created.
*/
DuplexTransportConnection createConnection(ContactId c);
/** Returns true if the plugin supports exchanging invitations. */
boolean supportsInvitations();
/**
* Attempts to create and return an invitation connection to the remote
* peer. Returns null if no connection can be established within the given
* time.
*/
DuplexTransportConnection createInvitationConnection(PseudoRandom r,
long timeout);
}

View File

@@ -0,0 +1,14 @@
package org.briarproject.api.plugins.duplex;
import org.briarproject.api.ContactId;
import org.briarproject.api.plugins.PluginCallback;
/**
* An interface for handling connections created by a duplex transport plugin.
*/
public interface DuplexPluginCallback extends PluginCallback {
void incomingConnectionCreated(DuplexTransportConnection d);
void outgoingConnectionCreated(ContactId c, DuplexTransportConnection d);
}

View File

@@ -0,0 +1,8 @@
package org.briarproject.api.plugins.duplex;
import java.util.Collection;
public interface DuplexPluginConfig {
Collection<DuplexPluginFactory> getFactories();
}

View File

@@ -0,0 +1,10 @@
package org.briarproject.api.plugins.duplex;
import org.briarproject.api.TransportId;
public interface DuplexPluginFactory {
TransportId getId();
DuplexPlugin createPlugin(DuplexPluginCallback callback);
}

View File

@@ -0,0 +1,38 @@
package org.briarproject.api.plugins.duplex;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* An interface for reading and writing data over a duplex transport. The
* connection is not responsible for encrypting/decrypting or authenticating
* the data.
*/
public interface DuplexTransportConnection {
/** Returns the maximum frame length of the transport in bytes. */
int getMaxFrameLength();
/** Returns the maximum latency of the transport in milliseconds. */
long getMaxLatency();
/** Returns an input stream for reading from the connection. */
InputStream getInputStream() throws IOException;
/** Returns an output stream for writing to the connection. */
OutputStream getOutputStream() throws IOException;
/**
* Returns true if the output stream should be flushed after each packet.
*/
boolean shouldFlush();
/**
* Closes the connection and disposes of any associated resources. The
* first argument indicates whether the connection is being closed because
* of an exception and the second argument indicates whether the connection
* was recognised, which may affect how resources are disposed of.
*/
void dispose(boolean exception, boolean recognised) throws IOException;
}

View File

@@ -0,0 +1,22 @@
package org.briarproject.api.plugins.simplex;
import org.briarproject.api.ContactId;
import org.briarproject.api.plugins.Plugin;
/** An interface for transport plugins that support simplex communication. */
public interface SimplexPlugin extends Plugin {
/**
* Attempts to create and return a reader for the given contact using the
* current transport and configuration properties. Returns null if a reader
* could not be created.
*/
SimplexTransportReader createReader(ContactId c);
/**
* Attempts to create and return a writer for the given contact using the
* current transport and configuration properties. Returns null if a writer
* could not be created.
*/
SimplexTransportWriter createWriter(ContactId c);
}

View File

@@ -0,0 +1,15 @@
package org.briarproject.api.plugins.simplex;
import org.briarproject.api.ContactId;
import org.briarproject.api.plugins.PluginCallback;
/**
* An interface for handling readers and writers created by a simplex transport
* plugin.
*/
public interface SimplexPluginCallback extends PluginCallback {
void readerCreated(SimplexTransportReader r);
void writerCreated(ContactId c, SimplexTransportWriter w);
}

View File

@@ -0,0 +1,8 @@
package org.briarproject.api.plugins.simplex;
import java.util.Collection;
public interface SimplexPluginConfig {
Collection<SimplexPluginFactory> getFactories();
}

View File

@@ -0,0 +1,10 @@
package org.briarproject.api.plugins.simplex;
import org.briarproject.api.TransportId;
public interface SimplexPluginFactory {
TransportId getId();
SimplexPlugin createPlugin(SimplexPluginCallback callback);
}

View File

@@ -0,0 +1,25 @@
package org.briarproject.api.plugins.simplex;
import java.io.IOException;
import java.io.InputStream;
/**
* An interface for reading data from a simplex transport. The reader is not
* responsible for decrypting or authenticating the data before returning it.
*/
public interface SimplexTransportReader {
/** Returns the maximum frame length of the transport in bytes. */
int getMaxFrameLength();
/** Returns an input stream for reading from the transport. */
InputStream getInputStream() throws IOException;
/**
* Closes the reader and disposes of any associated resources. The first
* argument indicates whether the reader is being closed because of an
* exception and the second argument indicates whether the connection was
* recognised, which may affect how resources are disposed of.
*/
void dispose(boolean exception, boolean recognised) throws IOException;
}

View File

@@ -0,0 +1,35 @@
package org.briarproject.api.plugins.simplex;
import java.io.IOException;
import java.io.OutputStream;
/**
* An interface for writing data to a simplex transport. The writer is not
* responsible for authenticating or encrypting the data before writing it.
*/
public interface SimplexTransportWriter {
/** Returns the capacity of the transport in bytes. */
long getCapacity();
/** Returns the maximum frame length of the transport in bytes. */
int getMaxFrameLength();
/** Returns the maximum latency of the transport in milliseconds. */
long getMaxLatency();
/** Returns an output stream for writing to the transport. */
OutputStream getOutputStream() throws IOException;
/**
* Returns true if the output stream should be flushed after each packet.
*/
boolean shouldFlush();
/**
* Closes the writer and disposes of any associated resources. The
* argument indicates whether the writer is being closed because of an
* exception, which may affect how resources are disposed of.
*/
void dispose(boolean exception) throws IOException;
}