Provide more information about plugin states.

This commit is contained in:
akwizgran
2020-01-14 12:18:24 +00:00
parent fcc26c093b
commit b2a1ea84f8
13 changed files with 386 additions and 151 deletions

View File

@@ -9,6 +9,34 @@ import java.util.Collection;
@NotNullByDefault
public interface Plugin {
enum State {
/**
* The plugin has not been started, has been stopped, or is disabled by
* settings.
*/
DISABLED,
/**
* The plugin has been started, has not been stopped, is enabled by
* settings, but can't yet tell whether it can make or receive
* connections.
*/
ENABLING,
/**
* The plugin has been started, has not been stopped, is enabled by
* settings, and can make or receive connections.
*/
AVAILABLE,
/**
* The plugin has been started, has not been stopped, is enabled by
* settings, but can't make or receive connections
*/
UNAVAILABLE
}
/**
* Returns the plugin's transport identifier.
*/
@@ -35,9 +63,9 @@ public interface Plugin {
void stop() throws PluginException;
/**
* Returns true if the plugin is running.
* Returns the current state of the plugin.
*/
boolean isRunning();
State getState();
/**
* Returns true if the plugin should be polled periodically to attempt to

View File

@@ -1,6 +1,7 @@
package org.briarproject.bramble.api.plugin;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import org.briarproject.bramble.api.plugin.Plugin.State;
import org.briarproject.bramble.api.properties.TransportProperties;
import org.briarproject.bramble.api.settings.Settings;
@@ -32,12 +33,7 @@ public interface PluginCallback extends ConnectionHandler {
void mergeLocalProperties(TransportProperties p);
/**
* Signals that the transport is enabled.
* Signals that the transport's state may have changed.
*/
void transportEnabled();
/**
* Signals that the transport is disabled.
*/
void transportDisabled();
void pluginStateChanged(State state);
}