mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
broadcast event when a conversation message is tracked
This commit is contained in:
@@ -6,6 +6,7 @@ import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.Message;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.briar.api.conversation.ConversationManager;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -32,16 +33,28 @@ public interface MessageTracker {
|
||||
|
||||
/**
|
||||
* Updates the group count for the given incoming message.
|
||||
* <p>
|
||||
* For messages that are part of a conversation (private chat),
|
||||
* use the corresponding function inside
|
||||
* {@link ConversationManager} instead.
|
||||
*/
|
||||
void trackIncomingMessage(Transaction txn, Message m) throws DbException;
|
||||
|
||||
/**
|
||||
* Updates the group count for the given outgoing message.
|
||||
* <p>
|
||||
* For messages that are part of a conversation (private chat),
|
||||
* use the corresponding function inside
|
||||
* {@link ConversationManager} instead.
|
||||
*/
|
||||
void trackOutgoingMessage(Transaction txn, Message m) throws DbException;
|
||||
|
||||
/**
|
||||
* Updates the group count for the given message.
|
||||
* <p>
|
||||
* For messages that are part of a conversation (private chat),
|
||||
* use the corresponding function inside
|
||||
* {@link ConversationManager} instead.
|
||||
*/
|
||||
void trackMessage(Transaction txn, GroupId g, long timestamp, boolean read)
|
||||
throws DbException;
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.briarproject.bramble.api.db.Transaction;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.Group;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.Message;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.briar.api.client.MessageTracker.GroupCount;
|
||||
import org.briarproject.briar.api.messaging.MessagingManager;
|
||||
@@ -47,6 +48,27 @@ public interface ConversationManager {
|
||||
*/
|
||||
GroupCount getGroupCount(Transaction txn, ContactId c) throws DbException;
|
||||
|
||||
/**
|
||||
* Updates the group count for the given incoming private conversation message
|
||||
* and broadcasts a corresponding event.
|
||||
*/
|
||||
void trackIncomingMessage(Transaction txn, Message m)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Updates the group count for the given outgoing private conversation message
|
||||
* and broadcasts a corresponding event.
|
||||
*/
|
||||
void trackOutgoingMessage(Transaction txn, Message m)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Updates the group count for the given private conversation message
|
||||
* and broadcasts a corresponding event.
|
||||
*/
|
||||
void trackMessage(Transaction txn, GroupId g, long timestamp, boolean read)
|
||||
throws DbException;
|
||||
|
||||
void setReadFlag(GroupId g, MessageId m, boolean read)
|
||||
throws DbException;
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.briarproject.briar.api.conversation.event;
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.event.Event;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.Message;
|
||||
import org.briarproject.briar.api.conversation.ConversationMessageHeader;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
/**
|
||||
* An event that is broadcast when a new conversation message is tracked.
|
||||
* Allows the UI to update the conversation's group count.
|
||||
*/
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class ConversationMessageTrackedEvent extends Event {
|
||||
|
||||
private final long timestamp;
|
||||
private final boolean read;
|
||||
private final ContactId contactId;
|
||||
|
||||
public ConversationMessageTrackedEvent(long timestamp,
|
||||
boolean read, ContactId contactId) {
|
||||
this.timestamp = timestamp;
|
||||
this.read = read;
|
||||
this.contactId = contactId;
|
||||
}
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public boolean getRead() {
|
||||
return read;
|
||||
}
|
||||
|
||||
public ContactId getContactId() {
|
||||
return contactId;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user