Added a lock for the connectionWindows table and exposed

getConnectionWindow() and setConnectionWindow() through the
DatabaseComponent interface.
This commit is contained in:
akwizgran
2011-08-11 15:19:32 +01:00
parent 0e6638bad6
commit 07b34cfbab
9 changed files with 159 additions and 18 deletions

View File

@@ -22,6 +22,7 @@ import net.sf.briar.api.protocol.writers.OfferWriter;
import net.sf.briar.api.protocol.writers.RequestWriter;
import net.sf.briar.api.protocol.writers.SubscriptionWriter;
import net.sf.briar.api.protocol.writers.TransportWriter;
import net.sf.briar.api.transport.ConnectionWindow;
/**
* Encapsulates the database implementation and exposes high-level operations
@@ -103,6 +104,13 @@ public interface DatabaseComponent {
void generateTransportUpdate(ContactId c, TransportWriter t) throws
DbException, IOException;
/**
* Returns the connection reordering window for the given contact and
* transport.
*/
ConnectionWindow getConnectionWindow(ContactId c, int transportId)
throws DbException;
/** Returns the IDs of all contacts. */
Collection<ContactId> getContacts() throws DbException;
@@ -156,6 +164,13 @@ public interface DatabaseComponent {
/** Removes a contact (and all associated state) from the database. */
void removeContact(ContactId c) throws DbException;
/**
* Sets the connection reordering window for the given contact and
* transport.
*/
void setConnectionWindow(ContactId c, int transportId, ConnectionWindow w)
throws DbException;
/** Records the user's rating for the given author. */
void setRating(AuthorId a, Rating r) throws DbException;

View File

@@ -1,6 +1,7 @@
package net.sf.briar.api.transport;
import net.sf.briar.api.ContactId;
import net.sf.briar.api.db.DbException;
/**
* Maintains a transport plugin's connection reordering window and decides
@@ -12,5 +13,5 @@ public interface ConnectionRecogniser {
* Returns the ID of the contact who created the tag if the connection
* should be accepted, or null if the connection should be rejected.
*/
ContactId acceptConnection(byte[] tag);
ContactId acceptConnection(byte[] tag) throws DbException;
}