mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 11:49:04 +01:00
Use ConversationManager for timestamps and unread counts
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
package org.briarproject.api.clients;
|
||||
|
||||
public interface ReadableMessageConstants {
|
||||
|
||||
/* Readable Message Local State Metadata */
|
||||
String LOCAL = "local";
|
||||
String READ = "read";
|
||||
String TIMESTAMP = "timestamp";
|
||||
String UNREAD = "unread";
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.briarproject.api.clients;
|
||||
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
|
||||
public interface ReadableMessageManager {
|
||||
|
||||
/**
|
||||
* Returns the timestamp of the latest message in the group with the given
|
||||
* contact, or -1 if the group is empty.
|
||||
*/
|
||||
long getTimestamp(ContactId c) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns the number of unread messages in the group with the given
|
||||
* contact.
|
||||
*/
|
||||
int getUnreadCount(ContactId c) throws DbException;
|
||||
|
||||
/**
|
||||
* Marks a message as read or unread.
|
||||
*/
|
||||
void setReadFlag(ContactId c, MessageId m, boolean local, boolean read)
|
||||
throws DbException;
|
||||
}
|
||||
@@ -17,6 +17,11 @@ public interface ConversationManager {
|
||||
*/
|
||||
ClientId getClientId();
|
||||
|
||||
/**
|
||||
* Returns true if this is the id of a wrapped client.
|
||||
*/
|
||||
boolean isWrappedClient(ClientId clientId);
|
||||
|
||||
/**
|
||||
* Stores a local private message, and returns the corresponding item.
|
||||
*/
|
||||
@@ -38,10 +43,15 @@ public interface ConversationManager {
|
||||
List<ConversationItem> getMessages(ContactId c) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns all messages in the given private conversation.
|
||||
* Returns the timestamp of the latest message in the given private
|
||||
* conversation, or -1 if the conversation is empty.
|
||||
*/
|
||||
List<ConversationItem> getMessages(ContactId c, boolean content)
|
||||
throws DbException;
|
||||
long getTimestamp(ContactId c) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns the number of unread messages in the given private conversation.
|
||||
*/
|
||||
int getUnreadCount(ContactId c) throws DbException;
|
||||
|
||||
/**
|
||||
* Starts a background task to load the content of the given message.
|
||||
@@ -57,5 +67,5 @@ public interface ConversationManager {
|
||||
/**
|
||||
* Marks a conversation item as read or unread.
|
||||
*/
|
||||
void setReadFlag(ConversationItem item, boolean read) throws DbException;
|
||||
void setReadFlag(ContactId c, ConversationItem item, boolean read) throws DbException;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,4 @@ public interface ForumSharingManager extends SharingManager<Forum, ForumInvitati
|
||||
/** Returns true if the forum not already shared and no invitation is open */
|
||||
boolean canBeShared(GroupId g, Contact c) throws DbException;
|
||||
|
||||
/** Marks a forum sharing message as read or unread. */
|
||||
void setReadFlag(MessageId m, boolean read) throws DbException;
|
||||
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ public interface IntroductionConstants {
|
||||
String CONTACT_ID_2 = "contactId2";
|
||||
String RESPONSE_1 = "response1";
|
||||
String RESPONSE_2 = "response2";
|
||||
String READ = "read";
|
||||
|
||||
/* Introduction Request Action */
|
||||
String PUBLIC_KEY1 = "publicKey1";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.briarproject.api.introduction;
|
||||
|
||||
import org.briarproject.api.FormatException;
|
||||
import org.briarproject.api.clients.ReadableMessageManager;
|
||||
import org.briarproject.api.clients.SessionId;
|
||||
import org.briarproject.api.contact.Contact;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
@@ -10,7 +11,7 @@ import org.briarproject.api.sync.MessageId;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface IntroductionManager {
|
||||
public interface IntroductionManager extends ReadableMessageManager {
|
||||
|
||||
/** Returns the unique ID of the introduction client. */
|
||||
ClientId getClientId();
|
||||
@@ -42,7 +43,4 @@ public interface IntroductionManager {
|
||||
Collection<IntroductionMessage> getIntroductionMessages(ContactId contactId)
|
||||
throws DbException;
|
||||
|
||||
/** Marks an introduction message as read or unread. */
|
||||
void setReadFlag(MessageId m, boolean read) throws DbException;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.briarproject.api.messaging;
|
||||
|
||||
import org.briarproject.api.clients.ReadableMessageManager;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.sync.ClientId;
|
||||
@@ -8,7 +9,7 @@ import org.briarproject.api.sync.MessageId;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface MessagingManager {
|
||||
public interface MessagingManager extends ReadableMessageManager {
|
||||
|
||||
/** Returns the unique ID of the messaging client. */
|
||||
ClientId getClientId();
|
||||
@@ -30,7 +31,4 @@ public interface MessagingManager {
|
||||
|
||||
/** Returns the body of the private message with the given ID. */
|
||||
byte[] getMessageBody(MessageId m) throws DbException;
|
||||
|
||||
/** Marks a private message as read or unread. */
|
||||
void setReadFlag(MessageId m, boolean read) throws DbException;
|
||||
}
|
||||
|
||||
@@ -14,9 +14,6 @@ public interface SharingConstants {
|
||||
String SESSION_ID = "sessionId";
|
||||
String STORAGE_ID = "storageId";
|
||||
String STATE = "state";
|
||||
String LOCAL = "local";
|
||||
String TIME = "time";
|
||||
String READ = "read";
|
||||
String IS_SHARER = "isSharer";
|
||||
String SHAREABLE_ID = "shareableId";
|
||||
String INVITATION_MSG = "invitationMsg";
|
||||
|
||||
@@ -46,7 +46,19 @@ public interface SharingManager<S extends Shareable, IM extends InvitationMessag
|
||||
/** Returns true if the group not already shared and no invitation is open */
|
||||
boolean canBeShared(GroupId g, Contact c) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns the timestamp of the latest sharing message sent by the given
|
||||
* contact, or -1 if there are none.
|
||||
*/
|
||||
long getTimestamp(ContactId c) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns the number of unread sharing messages sent by the given contact.
|
||||
*/
|
||||
int getUnreadCount(ContactId c) throws DbException;
|
||||
|
||||
/** Marks a sharing message as read or unread. */
|
||||
void setReadFlag(MessageId m, boolean read) throws DbException;
|
||||
void setReadFlag(ContactId c, MessageId m, boolean local, boolean read)
|
||||
throws DbException;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user