mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 03:39:05 +01:00
Added support for registering listeners with the database that are
called when new messages are available, and a new method hasSendableMessages(ContactId) that listeners can call to see whether it's worth trying to create a batch.
This commit is contained in:
@@ -48,6 +48,12 @@ public interface DatabaseComponent {
|
||||
/** Waits for any open transactions to finish and closes the database. */
|
||||
void close() throws DbException;
|
||||
|
||||
/** Adds a listener to be notified when new messages are available. */
|
||||
void addListener(MessageListener m);
|
||||
|
||||
/** Removes a listener. */
|
||||
void removeListener(MessageListener m);
|
||||
|
||||
/**
|
||||
* Adds a new contact to the database with the given transport details and
|
||||
* returns an ID for the contact.
|
||||
@@ -112,6 +118,9 @@ public interface DatabaseComponent {
|
||||
/** Returns the contacts to which the given group is visible. */
|
||||
Collection<ContactId> getVisibility(GroupId g) throws DbException;
|
||||
|
||||
/** Returns true if any messages are sendable to the given contact. */
|
||||
boolean hasSendableMessages(ContactId c) throws DbException;
|
||||
|
||||
/** Processes an acknowledgement from the given contact. */
|
||||
void receiveAck(ContactId c, Ack a) throws DbException;
|
||||
|
||||
|
||||
10
api/net/sf/briar/api/db/MessageListener.java
Normal file
10
api/net/sf/briar/api/db/MessageListener.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package net.sf.briar.api.db;
|
||||
|
||||
/**
|
||||
* An interface for receiving notifications when the database may have new
|
||||
* messages available.
|
||||
*/
|
||||
public interface MessageListener {
|
||||
|
||||
void messagesAdded();
|
||||
}
|
||||
Reference in New Issue
Block a user