mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 03:09:04 +01:00
Added null safety annotations to plugin interfaces.
This commit is contained in:
@@ -2,28 +2,42 @@ package org.briarproject.api.plugins;
|
||||
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.nullsafety.NotNullByDefault;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
@NotNullByDefault
|
||||
public interface Plugin {
|
||||
|
||||
/** Returns the plugin's transport identifier. */
|
||||
/**
|
||||
* Returns the plugin's transport identifier.
|
||||
*/
|
||||
TransportId getId();
|
||||
|
||||
/** Returns the transport's maximum latency in milliseconds. */
|
||||
/**
|
||||
* Returns the transport's maximum latency in milliseconds.
|
||||
*/
|
||||
int getMaxLatency();
|
||||
|
||||
/** Returns the transport's maximum idle time in milliseconds. */
|
||||
/**
|
||||
* Returns the transport's maximum idle time in milliseconds.
|
||||
*/
|
||||
int getMaxIdleTime();
|
||||
|
||||
/** Starts the plugin and returns true if it started successfully. */
|
||||
/**
|
||||
* Starts the plugin and returns true if it started successfully.
|
||||
*/
|
||||
boolean start() throws IOException;
|
||||
|
||||
/** Stops the plugin. */
|
||||
/**
|
||||
* Stops the plugin.
|
||||
*/
|
||||
void stop() throws IOException;
|
||||
|
||||
/** Returns true if the plugin is running. */
|
||||
/**
|
||||
* Returns true if the plugin is running.
|
||||
*/
|
||||
boolean isRunning();
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,19 +4,28 @@ import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.crypto.PseudoRandom;
|
||||
import org.briarproject.api.data.BdfList;
|
||||
import org.briarproject.api.keyagreement.KeyAgreementListener;
|
||||
import org.briarproject.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.api.plugins.Plugin;
|
||||
|
||||
/** An interface for transport plugins that support duplex communication. */
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* An interface for transport plugins that support duplex communication.
|
||||
*/
|
||||
@NotNullByDefault
|
||||
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.
|
||||
* connection cannot be created.
|
||||
*/
|
||||
@Nullable
|
||||
DuplexTransportConnection createConnection(ContactId c);
|
||||
|
||||
/** Returns true if the plugin supports exchanging invitations. */
|
||||
/**
|
||||
* Returns true if the plugin supports exchanging invitations.
|
||||
*/
|
||||
boolean supportsInvitations();
|
||||
|
||||
/**
|
||||
@@ -24,21 +33,27 @@ public interface DuplexPlugin extends Plugin {
|
||||
* peer. Returns null if no connection can be established within the given
|
||||
* time.
|
||||
*/
|
||||
@Nullable
|
||||
DuplexTransportConnection createInvitationConnection(PseudoRandom r,
|
||||
long timeout, boolean alice);
|
||||
|
||||
/** Returns true if the plugin supports short-range key agreement. */
|
||||
/**
|
||||
* Returns true if the plugin supports short-range key agreement.
|
||||
*/
|
||||
boolean supportsKeyAgreement();
|
||||
|
||||
/**
|
||||
* Returns a listener that can be used to perform key agreement.
|
||||
* Attempts to create and return a listener that can be used to perform key
|
||||
* agreement. Returns null if a listener cannot be created.
|
||||
*/
|
||||
@Nullable
|
||||
KeyAgreementListener createKeyAgreementListener(byte[] localCommitment);
|
||||
|
||||
/**
|
||||
* Attempts to connect to the remote peer specified in the given descriptor.
|
||||
* Returns null if no connection can be established within the given time.
|
||||
*/
|
||||
@Nullable
|
||||
DuplexTransportConnection createKeyAgreementConnection(
|
||||
byte[] remoteCommitment, BdfList descriptor, long timeout);
|
||||
}
|
||||
|
||||
@@ -1,24 +1,32 @@
|
||||
package org.briarproject.api.plugins.simplex;
|
||||
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.api.plugins.Plugin;
|
||||
import org.briarproject.api.plugins.TransportConnectionReader;
|
||||
import org.briarproject.api.plugins.TransportConnectionWriter;
|
||||
|
||||
/** An interface for transport plugins that support simplex communication. */
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* An interface for transport plugins that support simplex communication.
|
||||
*/
|
||||
@NotNullByDefault
|
||||
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.
|
||||
* cannot be created.
|
||||
*/
|
||||
@Nullable
|
||||
TransportConnectionReader 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.
|
||||
* cannot be created.
|
||||
*/
|
||||
@Nullable
|
||||
TransportConnectionWriter createWriter(ContactId c);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user