Plugins don't need their own copies of configs and properties.

This commit is contained in:
akwizgran
2011-10-12 16:52:39 +01:00
parent 631f4e74b5
commit 3a07d1b882
14 changed files with 226 additions and 311 deletions

View File

@@ -3,7 +3,6 @@ package net.sf.briar.api.plugins;
import net.sf.briar.api.ContactId;
import net.sf.briar.api.transport.BatchTransportReader;
import net.sf.briar.api.transport.BatchTransportWriter;
import net.sf.briar.api.transport.TransportCallback;
/**
* An interface for receiving readers and writers created by a batch-mode

View File

@@ -2,7 +2,6 @@ package net.sf.briar.api.plugins;
import net.sf.briar.api.ContactId;
import net.sf.briar.api.transport.StreamTransportConnection;
import net.sf.briar.api.transport.TransportCallback;
/**
* An interface for receiving connections created by a stream-mode transport

View File

@@ -0,0 +1,50 @@
package net.sf.briar.api.plugins;
import java.util.Map;
import net.sf.briar.api.ContactId;
import net.sf.briar.api.TransportConfig;
import net.sf.briar.api.TransportProperties;
/**
* An interface through which a transport plugin interacts with the rest of
* the application.
*/
public interface TransportCallback {
/** 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();
/** Stores the plugin's configuration. */
void setConfig(TransportConfig c);
/** Stores the plugin's local transport properties. */
void setLocalProperties(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

@@ -1,12 +1,8 @@
package net.sf.briar.api.plugins;
import java.io.IOException;
import java.util.Map;
import net.sf.briar.api.ContactId;
import net.sf.briar.api.TransportConfig;
import net.sf.briar.api.TransportId;
import net.sf.briar.api.TransportProperties;
public interface TransportPlugin {
@@ -14,22 +10,11 @@ public interface TransportPlugin {
TransportId getId();
/** Starts the plugin. */
void start(TransportProperties localProperties,
Map<ContactId, TransportProperties> remoteProperties,
TransportConfig config) throws IOException;
void start() throws IOException;
/** Stops the plugin. */
void stop() throws IOException;
/** Updates the plugin's local transport properties. */
void setLocalProperties(TransportProperties p);
/** Updates the plugin's transport properties for the given contact. */
void setRemoteProperties(ContactId c, TransportProperties p);
/** Updates the plugin's configuration properties. */
void setConfig(TransportConfig c);
/**
* Returns true if the plugin's poll() method should be called
* periodically to attempt to establish connections.

View File

@@ -1,17 +0,0 @@
package net.sf.briar.api.transport;
import net.sf.briar.api.TransportConfig;
import net.sf.briar.api.TransportProperties;
public interface TransportCallback {
void setLocalProperties(TransportProperties p);
void setConfig(TransportConfig c);
void showMessage(String... message);
boolean showConfirmationMessage(String... message);
int showChoice(String[] choices, String... message);
}