mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 19:59:05 +01:00
Use dedicated classes for transport properties and configs.
This commit is contained in:
17
api/net/sf/briar/api/TransportConfig.java
Normal file
17
api/net/sf/briar/api/TransportConfig.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package net.sf.briar.api;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class TransportConfig extends TreeMap<String, String> {
|
||||
|
||||
private static final long serialVersionUID = 2330384620787778596L;
|
||||
|
||||
public TransportConfig(Map<String, String> c) {
|
||||
super(c);
|
||||
}
|
||||
|
||||
public TransportConfig() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
17
api/net/sf/briar/api/TransportProperties.java
Normal file
17
api/net/sf/briar/api/TransportProperties.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package net.sf.briar.api;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class TransportProperties extends TreeMap<String, String> {
|
||||
|
||||
private static final long serialVersionUID = 7533739534204953625L;
|
||||
|
||||
public TransportProperties(Map<String, String> p) {
|
||||
super(p);
|
||||
}
|
||||
|
||||
public TransportProperties() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,9 @@ import java.util.Map;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.Rating;
|
||||
import net.sf.briar.api.TransportConfig;
|
||||
import net.sf.briar.api.TransportId;
|
||||
import net.sf.briar.api.TransportProperties;
|
||||
import net.sf.briar.api.protocol.Ack;
|
||||
import net.sf.briar.api.protocol.AuthorId;
|
||||
import net.sf.briar.api.protocol.Batch;
|
||||
@@ -51,7 +53,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<TransportId, Map<String, String>> transports,
|
||||
ContactId addContact(Map<TransportId, TransportProperties> transports,
|
||||
byte[] secret) throws DbException;
|
||||
|
||||
/** Adds a locally generated group message to the database. */
|
||||
@@ -116,14 +118,14 @@ public interface DatabaseComponent {
|
||||
Collection<ContactId> getContacts() throws DbException;
|
||||
|
||||
/** Returns all local transport properties. */
|
||||
Map<TransportId, Map<String, String>> getLocalTransports()
|
||||
Map<TransportId, TransportProperties> getLocalTransports()
|
||||
throws DbException;
|
||||
|
||||
/** Returns the user's rating for the given author. */
|
||||
Rating getRating(AuthorId a) throws DbException;
|
||||
|
||||
/** Returns all remote transport properties. */
|
||||
Map<TransportId, Map<ContactId, Map<String, String>>> getRemoteTransports()
|
||||
Map<TransportId, Map<ContactId, TransportProperties>> getRemoteTransports()
|
||||
throws DbException;
|
||||
|
||||
/** Returns the secret shared with the given contact. */
|
||||
@@ -133,7 +135,7 @@ public interface DatabaseComponent {
|
||||
Collection<Group> getSubscriptions() throws DbException;
|
||||
|
||||
/** Returns the configuration for the given transport. */
|
||||
Map<String, String> getTransportConfig(TransportId t) throws DbException;
|
||||
TransportConfig getTransportConfig(TransportId t) throws DbException;
|
||||
|
||||
/** Returns the contacts to which the given group is visible. */
|
||||
Collection<ContactId> getVisibility(GroupId g) throws DbException;
|
||||
@@ -186,14 +188,14 @@ public interface DatabaseComponent {
|
||||
* Sets the configuration for the given transport, replacing any existing
|
||||
* configuration for that transport.
|
||||
*/
|
||||
void setTransportConfig(TransportId t, Map<String, String> config)
|
||||
void setTransportConfig(TransportId t, TransportConfig config)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Sets the transport properties for the given transport, replacing any
|
||||
* existing properties for that transport.
|
||||
*/
|
||||
void setTransportProperties(TransportId t, Map<String, String> properties)
|
||||
void setTransportProperties(TransportId t, TransportProperties properties)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,9 @@ 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 {
|
||||
|
||||
@@ -12,21 +14,21 @@ public interface TransportPlugin {
|
||||
TransportId getId();
|
||||
|
||||
/** Starts the plugin. */
|
||||
void start(Map<String, String> localProperties,
|
||||
Map<ContactId, Map<String, String>> remoteProperties,
|
||||
Map<String, String> config) throws IOException;
|
||||
void start(TransportProperties localProperties,
|
||||
Map<ContactId, TransportProperties> remoteProperties,
|
||||
TransportConfig config) throws IOException;
|
||||
|
||||
/** Stops the plugin. */
|
||||
void stop() throws IOException;
|
||||
|
||||
/** Updates the plugin's local transport properties. */
|
||||
void setLocalProperties(Map<String, String> properties);
|
||||
void setLocalProperties(TransportProperties p);
|
||||
|
||||
/** Updates the plugin's transport properties for the given contact. */
|
||||
void setRemoteProperties(ContactId c, Map<String, String> properties);
|
||||
void setRemoteProperties(ContactId c, TransportProperties p);
|
||||
|
||||
/** Updates the plugin's configuration properties. */
|
||||
void setConfig(Map<String, String> config);
|
||||
void setConfig(TransportConfig c);
|
||||
|
||||
/**
|
||||
* Returns true if the plugin's poll() method should be called
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.sf.briar.api.protocol;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sf.briar.api.TransportId;
|
||||
import net.sf.briar.api.TransportProperties;
|
||||
|
||||
/** A packet updating the sender's transport properties. */
|
||||
public interface TransportUpdate {
|
||||
@@ -17,7 +18,7 @@ public interface TransportUpdate {
|
||||
static final int MAX_PLUGINS_PER_UPDATE = 50;
|
||||
|
||||
/** Returns the transport properties contained in the update. */
|
||||
Map<TransportId, Map<String, String>> getTransports();
|
||||
Map<TransportId, TransportProperties> getTransports();
|
||||
|
||||
/**
|
||||
* Returns the update's timestamp. Updates that are older than the newest
|
||||
|
||||
@@ -4,11 +4,12 @@ import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sf.briar.api.TransportId;
|
||||
import net.sf.briar.api.TransportProperties;
|
||||
|
||||
/** An interface for creating a transport update. */
|
||||
public interface TransportWriter {
|
||||
|
||||
/** Writes the contents of the update. */
|
||||
void writeTransports(Map<TransportId, Map<String, String>> transports,
|
||||
void writeTransports(Map<TransportId, TransportProperties> transports,
|
||||
long timestamp) throws IOException;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package net.sf.briar.api.transport;
|
||||
|
||||
import java.util.Map;
|
||||
import net.sf.briar.api.TransportConfig;
|
||||
import net.sf.briar.api.TransportProperties;
|
||||
|
||||
public interface TransportCallback {
|
||||
|
||||
void setLocalProperties(Map<String, String> properties);
|
||||
void setLocalProperties(TransportProperties p);
|
||||
|
||||
void setConfig(Map<String, String> config);
|
||||
void setConfig(TransportConfig c);
|
||||
|
||||
void showMessage(String... message);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user