mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 11:49:04 +01:00
Nudge the database API in the direction of sanity.
This commit is contained in:
@@ -8,7 +8,7 @@ import net.sf.briar.api.serial.Writer;
|
||||
/**
|
||||
* Type-safe wrapper for an integer that uniquely identifies a transport plugin.
|
||||
*/
|
||||
public class TransportId implements Writable, Comparable<TransportId> {
|
||||
public class TransportId implements Writable {
|
||||
|
||||
public static final int MIN_ID = 0;
|
||||
public static final int MAX_ID = 65535;
|
||||
@@ -38,10 +38,4 @@ public class TransportId implements Writable, Comparable<TransportId> {
|
||||
public int hashCode() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int compareTo(TransportId t) {
|
||||
if(id < t.id) return -1;
|
||||
if(id > t.id) return 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,6 +101,9 @@ public interface DatabaseComponent {
|
||||
void generateTransportUpdate(ContactId c, TransportWriter t) throws
|
||||
DbException, IOException;
|
||||
|
||||
/** Returns the configuration for the given transport. */
|
||||
TransportConfig getConfig(TransportId t) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns an outgoing connection number for the given contact and
|
||||
* transport.
|
||||
@@ -124,8 +127,8 @@ public interface DatabaseComponent {
|
||||
/** Returns the user's rating for the given author. */
|
||||
Rating getRating(AuthorId a) throws DbException;
|
||||
|
||||
/** Returns all remote transport properties. */
|
||||
Map<TransportId, Map<ContactId, TransportProperties>> getRemoteTransports()
|
||||
/** Returns all remote transport properties for the given transport. */
|
||||
Map<ContactId, TransportProperties> getRemoteProperties(TransportId t)
|
||||
throws DbException;
|
||||
|
||||
/** Returns the secret shared with the given contact. */
|
||||
@@ -134,9 +137,6 @@ public interface DatabaseComponent {
|
||||
/** Returns the set of groups to which the user subscribes. */
|
||||
Collection<Group> getSubscriptions() throws DbException;
|
||||
|
||||
/** Returns the configuration for the given transport. */
|
||||
TransportConfig getTransportConfig(TransportId t) throws DbException;
|
||||
|
||||
/** Returns the contacts to which the given group is visible. */
|
||||
Collection<ContactId> getVisibility(GroupId g) throws DbException;
|
||||
|
||||
@@ -171,6 +171,12 @@ public interface DatabaseComponent {
|
||||
/** Removes a contact (and all associated state) from the database. */
|
||||
void removeContact(ContactId c) throws DbException;
|
||||
|
||||
/**
|
||||
* Sets the configuration for the given transport, replacing any existing
|
||||
* configuration for that transport.
|
||||
*/
|
||||
void setConfig(TransportId t, TransportConfig c) throws DbException;
|
||||
|
||||
/**
|
||||
* Sets the connection reordering window for the given contact and
|
||||
* transport.
|
||||
@@ -178,26 +184,19 @@ public interface DatabaseComponent {
|
||||
void setConnectionWindow(ContactId c, TransportId t, ConnectionWindow w)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Sets the local transport properties for the given transport, replacing
|
||||
* any existing properties for that transport.
|
||||
*/
|
||||
void setLocalProperties(TransportId t, TransportProperties p)
|
||||
throws DbException;
|
||||
|
||||
/** Records the user's rating for the given author. */
|
||||
void setRating(AuthorId a, Rating r) throws DbException;
|
||||
|
||||
/** Records the given messages as having been seen by the given contact. */
|
||||
void setSeen(ContactId c, Collection<MessageId> seen) throws DbException;
|
||||
|
||||
/**
|
||||
* Sets the configuration for the given transport, replacing any existing
|
||||
* configuration for that transport.
|
||||
*/
|
||||
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, TransportProperties properties)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Makes the given group visible to the given set of contacts and invisible
|
||||
* to any other contacts.
|
||||
|
||||
Reference in New Issue
Block a user