mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29:06 +01:00
Converted database events from an enum to classes to allow them to
carry data.
This commit is contained in:
@@ -9,6 +9,7 @@ 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.db.event.DatabaseListener;
|
||||
import net.sf.briar.api.protocol.Ack;
|
||||
import net.sf.briar.api.protocol.AuthorId;
|
||||
import net.sf.briar.api.protocol.Batch;
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package net.sf.briar.api.db;
|
||||
|
||||
/** An interface for receiving notifications when database events occur. */
|
||||
public interface DatabaseListener {
|
||||
|
||||
static enum Event {
|
||||
BATCH_RECEIVED,
|
||||
CONTACTS_UPDATED,
|
||||
MESSAGES_ADDED,
|
||||
SUBSCRIPTIONS_UPDATED,
|
||||
TRANSPORTS_UPDATED
|
||||
};
|
||||
|
||||
void eventOccurred(Event e);
|
||||
}
|
||||
5
api/net/sf/briar/api/db/event/BatchReceivedEvent.java
Normal file
5
api/net/sf/briar/api/db/event/BatchReceivedEvent.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package net.sf.briar.api.db.event;
|
||||
|
||||
public class BatchReceivedEvent extends DatabaseEvent {
|
||||
|
||||
}
|
||||
16
api/net/sf/briar/api/db/event/ContactAddedEvent.java
Normal file
16
api/net/sf/briar/api/db/event/ContactAddedEvent.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package net.sf.briar.api.db.event;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
|
||||
public class ContactAddedEvent extends DatabaseEvent {
|
||||
|
||||
private final ContactId contactId;
|
||||
|
||||
public ContactAddedEvent(ContactId contactId) {
|
||||
this.contactId = contactId;
|
||||
}
|
||||
|
||||
public ContactId getContactId() {
|
||||
return contactId;
|
||||
}
|
||||
}
|
||||
10
api/net/sf/briar/api/db/event/ContactRemovedEvent.java
Normal file
10
api/net/sf/briar/api/db/event/ContactRemovedEvent.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package net.sf.briar.api.db.event;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
|
||||
public class ContactRemovedEvent extends ContactAddedEvent {
|
||||
|
||||
public ContactRemovedEvent(ContactId contactId) {
|
||||
super(contactId);
|
||||
}
|
||||
}
|
||||
5
api/net/sf/briar/api/db/event/DatabaseEvent.java
Normal file
5
api/net/sf/briar/api/db/event/DatabaseEvent.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package net.sf.briar.api.db.event;
|
||||
|
||||
public abstract class DatabaseEvent {
|
||||
|
||||
}
|
||||
8
api/net/sf/briar/api/db/event/DatabaseListener.java
Normal file
8
api/net/sf/briar/api/db/event/DatabaseListener.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package net.sf.briar.api.db.event;
|
||||
|
||||
|
||||
/** An interface for receiving notifications when database events occur. */
|
||||
public interface DatabaseListener {
|
||||
|
||||
void eventOccurred(DatabaseEvent e);
|
||||
}
|
||||
5
api/net/sf/briar/api/db/event/MessagesAddedEvent.java
Normal file
5
api/net/sf/briar/api/db/event/MessagesAddedEvent.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package net.sf.briar.api.db.event;
|
||||
|
||||
public class MessagesAddedEvent extends DatabaseEvent {
|
||||
|
||||
}
|
||||
19
api/net/sf/briar/api/db/event/SubscriptionsUpdatedEvent.java
Normal file
19
api/net/sf/briar/api/db/event/SubscriptionsUpdatedEvent.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package net.sf.briar.api.db.event;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
|
||||
public class SubscriptionsUpdatedEvent extends DatabaseEvent {
|
||||
|
||||
private final Collection<ContactId> affectedContacts;
|
||||
|
||||
// FIXME: Replace this constructor
|
||||
public SubscriptionsUpdatedEvent() {
|
||||
affectedContacts = null;
|
||||
}
|
||||
|
||||
public Collection<ContactId> getAffectedContacts() {
|
||||
return affectedContacts;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package net.sf.briar.api.db.event;
|
||||
|
||||
public class TransportsUpdatedEvent extends DatabaseEvent {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user