Use numeric IDs rather than names to identify transports.

This commit is contained in:
akwizgran
2011-09-29 15:40:09 +01:00
parent c77b4e5b91
commit 7190509ede
20 changed files with 164 additions and 169 deletions

View File

@@ -50,7 +50,7 @@ public interface DatabaseComponent {
* Adds a new contact to the database with the given transport properties
* and shared secret, returns an ID for the contact.
*/
ContactId addContact(Map<String, Map<String, String>> transports,
ContactId addContact(Map<Integer, Map<String, String>> transports,
byte[] secret) throws DbException;
/** Adds a locally generated group message to the database. */
@@ -123,14 +123,14 @@ public interface DatabaseComponent {
/** Returns the set of groups to which the user subscribes. */
Collection<Group> getSubscriptions() throws DbException;
/** Returns the configuration for the transport with the given name. */
Map<String, String> getTransportConfig(String name) throws DbException;
/** Returns the configuration for the given transport. */
Map<String, String> getTransportConfig(int transportId) throws DbException;
/** Returns all local transport properties. */
Map<String, Map<String, String>> getTransports() throws DbException;
Map<Integer, Map<String, String>> getTransports() throws DbException;
/** Returns all transport properties for the given contact. */
Map<String, Map<String, String>> getTransports(ContactId c)
Map<Integer, Map<String, String>> getTransports(ContactId c)
throws DbException;
/** Returns the contacts to which the given group is visible. */
@@ -181,17 +181,17 @@ public interface DatabaseComponent {
void setSeen(ContactId c, Collection<MessageId> seen) throws DbException;
/**
* Sets the configuration for the transport with the given name, replacing
* any existing configuration for that transport.
* Sets the configuration for the given transport, replacing any existing
* configuration for that transport.
*/
void setTransportConfig(String name, Map<String, String> config)
void setTransportConfig(int transportId, Map<String, String> config)
throws DbException;
/**
* Sets the transport properties for the transport with the given name,
* replacing any existing properties for that transport.
* Sets the transport properties for the given transport, replacing any
* existing properties for that transport.
*/
void setTransportProperties(String name, Map<String, String> properties)
void setTransportProperties(int transportId, Map<String, String> properties)
throws DbException;
/**

View File

@@ -5,9 +5,6 @@ import java.util.Map;
/** A packet updating the sender's transport properties. */
public interface TransportUpdate {
/** The maximum length of a plugin's name in UTF-8 bytes. */
static final int MAX_NAME_LENGTH = 50;
/** The maximum length of a property's key or value in UTF-8 bytes. */
static final int MAX_KEY_OR_VALUE_LENGTH = 100;
@@ -18,7 +15,7 @@ public interface TransportUpdate {
static final int MAX_PLUGINS_PER_UPDATE = 50;
/** Returns the transport properties contained in the update. */
Map<String, Map<String, String>> getTransports();
Map<Integer, Map<String, String>> getTransports();
/**
* Returns the update's timestamp. Updates that are older than the newest

View File

@@ -7,6 +7,6 @@ import java.util.Map;
public interface TransportWriter {
/** Writes the contents of the update. */
void writeTransports(Map<String, Map<String, String>> transports,
void writeTransports(Map<Integer, Map<String, String>> transports,
long timestamp) throws IOException;
}

View File

@@ -12,11 +12,8 @@ import net.sf.briar.api.transport.InvalidTransportException;
*/
public interface BatchTransportPlugin {
/**
* Returns the plugin's name, which is used to distinguish its transport
* and configuration properties from those of other plugins.
*/
String getName();
/** Returns the plugin's transport identifier. */
int getTransportId();
/**
* Starts the plugin. Any connections that are later initiated by contacts

View File

@@ -12,11 +12,8 @@ import net.sf.briar.api.transport.InvalidTransportException;
*/
public interface StreamTransportPlugin {
/**
* Returns the plugin's name, which is used to distinguish its transport
* and configuration properties from those of other plugins.
*/
String getName();
/** Returns the plugin's transport identifier. */
int getTransportId();
/**
* Starts the plugin. Any connections that are later initiated by contacts