mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 04:39:54 +01:00
Wrap messages, introductions and forum invites in a ConversationManager
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
package org.briarproject.api.conversation;
|
||||
|
||||
import org.briarproject.api.forum.ForumInvitationMessage;
|
||||
|
||||
public interface ConversationForumInvitationItem extends ConversationItem {
|
||||
|
||||
ForumInvitationMessage getForumInvitationMessage();
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.briarproject.api.conversation;
|
||||
|
||||
import org.briarproject.api.introduction.IntroductionRequest;
|
||||
|
||||
public interface ConversationIntroductionRequestItem extends ConversationItem {
|
||||
|
||||
IntroductionRequest getIntroductionRequest();
|
||||
|
||||
boolean wasAnswered();
|
||||
|
||||
void setAnswered(boolean answered);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package org.briarproject.api.conversation;
|
||||
|
||||
import org.briarproject.api.introduction.IntroductionResponse;
|
||||
|
||||
public interface ConversationIntroductionResponseItem extends ConversationItem {
|
||||
|
||||
IntroductionResponse getIntroductionResponse();
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.briarproject.api.conversation;
|
||||
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
|
||||
public interface ConversationItem {
|
||||
|
||||
MessageId getId();
|
||||
|
||||
long getTime();
|
||||
|
||||
interface ContentListener {
|
||||
|
||||
void contentReady();
|
||||
}
|
||||
|
||||
interface Partial extends ConversationItem {
|
||||
|
||||
void setContent(byte[] content);
|
||||
|
||||
void setContentListener(ContentListener listener);
|
||||
}
|
||||
|
||||
interface IncomingItem extends ConversationItem {
|
||||
|
||||
boolean isRead();
|
||||
|
||||
void setRead(boolean read);
|
||||
}
|
||||
|
||||
interface OutgoingItem extends ConversationItem {
|
||||
|
||||
boolean isSent();
|
||||
|
||||
void setSent(boolean sent);
|
||||
|
||||
boolean isSeen();
|
||||
|
||||
void setSeen(boolean seen);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package org.briarproject.api.conversation;
|
||||
|
||||
import org.briarproject.api.FormatException;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.messaging.PrivateMessage;
|
||||
import org.briarproject.api.sync.ClientId;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ConversationManager {
|
||||
|
||||
/**
|
||||
* Returns the unique ID of the conversation client.
|
||||
*/
|
||||
ClientId getClientId();
|
||||
|
||||
/**
|
||||
* Stores a local private message, and returns the corresponding item.
|
||||
*/
|
||||
ConversationItem addLocalMessage(PrivateMessage m, byte[] body) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns the ID of the contact with the given private conversation.
|
||||
*/
|
||||
ContactId getContactId(GroupId g) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns the ID of the private conversation with the given contact.
|
||||
*/
|
||||
GroupId getConversationId(ContactId c) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns all messages in the given private conversation.
|
||||
*/
|
||||
List<ConversationItem> getMessages(ContactId c) throws DbException;
|
||||
|
||||
/**
|
||||
* Returns all messages in the given private conversation.
|
||||
*/
|
||||
List<ConversationItem> getMessages(ContactId c, boolean content)
|
||||
throws DbException;
|
||||
|
||||
/**
|
||||
* Starts a background task to load the content of the given message.
|
||||
*/
|
||||
void loadMessageContent(ConversationItem.Partial m);
|
||||
|
||||
/**
|
||||
* Respond to a conversation item with accept/decline.
|
||||
*/
|
||||
void respondToItem(ContactId c, ConversationItem item, boolean accept,
|
||||
long timestamp) throws DbException, FormatException;
|
||||
|
||||
/**
|
||||
* Marks a conversation item as read or unread.
|
||||
*/
|
||||
void setReadFlag(ConversationItem item, boolean read) throws DbException;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.briarproject.api.conversation;
|
||||
|
||||
import org.briarproject.api.conversation.ConversationItem.Partial;
|
||||
import org.briarproject.api.messaging.PrivateMessageHeader;
|
||||
|
||||
public interface ConversationMessageItem extends Partial {
|
||||
|
||||
PrivateMessageHeader getHeader();
|
||||
|
||||
byte[] getBody();
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.sharing.SharingManager;
|
||||
import org.briarproject.api.sync.ClientId;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -46,4 +47,7 @@ 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;
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.briarproject.api.contact.Contact;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.sync.ClientId;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -41,4 +42,7 @@ 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;
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.sync.ClientId;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -45,4 +46,7 @@ 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;
|
||||
|
||||
/** Marks a sharing message as read or unread. */
|
||||
void setReadFlag(MessageId m, boolean read) throws DbException;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user